<< It would be nice if we could get TCC integrated on apps/ to run inside
MCUs
with much memory (like STM32 with external SDRAM), ESP32, BL808, etc. >>

Thanks Alan! We have a couple of issues that might affect TCC Compiler on
NuttX:

(1) RISC-V Registers are mixed up when TCC emits code for NuttX System
Calls:
https://lupyuen.codeberg.page/articles/tcc.html#appendix-nuttx-system-call

(2) TCC won't link with NuttX Libraries compiled with GCC. We'll have to
recompile the NuttX Libraries with TCC:
https://github.com/lupyuen/tcc-riscv32-wasm#fix-missing-printf-in-nuttx-app

(3) TCC for RISC-V hasn't been updated for the past 8 months:
https://github.com/sellicott/tcc-riscv32/commits/main/

Perhaps our article will revive the TCC project? Let's see what happens :-)

Something interesting popped up: Our NuttX ROM FS Driver works well in
WebAssembly. Which means we can run it to host a ROM FS Filesystem inside a
Web Browser!
https://github.com/lupyuen/tcc-riscv32-wasm#rom-fs-filesystem-for-tcc-webassembly

TCC Compiler in WebAssembly needs a filesystem (inside the Web Browser)
that's preloaded with C Header Files and Library Files. Our NuttX ROM FS
Driver is perfect for that. I'll explain more in the next article.

So cool to have our NuttX Drivers running on new unexpected platforms :-)

Lup

On Mon, Feb 5, 2024 at 1:06 AM Alan C. Assis <acas...@gmail.com> wrote:

> Hi Lup,
>
> Congratulations! That was a great achievement!!!
>
> It would be nice if we could get TCC integrated on apps/ to run inside MCUs
> with much memory (like STM32 with external SDRAM), ESP32, BL808, etc.
>
> Best Regards,
>
> Alan
>
> On Sat, Feb 3, 2024 at 8:08 PM Lee, Lup Yuen <lu...@appkaki.com> wrote:
>
> > Today we're running NuttX Emulator inside a Web Browser. What if we could
> > build and test NuttX Apps in the Web Browser? Learning NuttX becomes so
> > cool!
> >
> > Let's explore with TCC (Tiny C Compiler) for 64-bit RISC-V, compiled to
> > WebAssembly with Zig Compiler...
> >
> > (1) Zig Compiler compiles TCC Compiler to WebAssembly (with one tiny fix)
> > (2) But we hit some Missing POSIX Functions
> > (3) So we built minimal File Input and Output
> > (4) Hacked up a simple workaround for fprintf and friends
> > (5) And TCC produces a RISC-V Binary that runs on NuttX Emulator, in the
> > Web Browser!
> > (6) Though it needs Low-Level NuttX System Calls. We might fix this by
> > porting NuttX ROM FS to Zig and WebAssembly.
> >
> > Here's the article: https://lupyuen.codeberg.page/articles/tcc.html
> >
> > Lup
> >
>

Reply via email to