c3c icon indicating copy to clipboard operation
c3c copied to clipboard

Add support for RiscV (ESP) llvm embedded target

Open xfcasio opened this issue 1 year ago • 6 comments

request to add support for the riscv llvm embedded target

xfcasio avatar Aug 03 '24 00:08 xfcasio

Right now we already have elf-riscv32 available, can you experiment a bit with it to see what's missing from the toolchain? Presumably there are other things needed for esp to run, so maybe we could include more out of the box, or at least a tutorial.

lerno avatar Aug 03 '24 01:08 lerno

I have a few boards on order to try this out on real hardware. There is a video on how I got an example to work under qemu. The compiler required no modifications, but there were a few tricks. I am also working on adding block asm support for RISC-V. I'll submit a PR for consideration when done.

Video: https://youtu.be/0iAJxx6Ok4E

chuckb avatar Aug 04 '24 15:08 chuckb

That's really cool. I wonder what the problem was with the linker. Did you use C3's built in linker or an external one? And I guess also that --no-entry should probably be default on targets without an OS provided, e.g. elf-riscv?

Anything else to improve the quality of life?

lerno avatar Aug 04 '24 22:08 lerno

I was using the external risc-v toolchain linker since I already had a linker file that worked (well, with the minor mod mentioned in the video.) I used no-entry as I was trying to strip everything to bare bones to make sure my own startup and main entry point was followed. It would be cool to not have to use make and use C3's facility, but I had stuff working from other projects I borrowed, so I used what I had. It may indeed work with the right flags.

chuckb avatar Aug 08 '24 02:08 chuckb

It would be interesting to see what's needed to fix if you just do --no-entry and --use-libc=no.

lerno avatar Aug 08 '24 14:08 lerno

What else do we need to support this well? (And close this issue!)

lerno avatar Aug 23 '24 17:08 lerno