VexRiscv icon indicating copy to clipboard operation
VexRiscv copied to clipboard

[Question] How can I run C code on vexRiscv?

Open adz0612 opened this issue 1 year ago • 3 comments

Hey, I have generated the Full version of vexRiscv using sbt "runMain vexriscv.demo.GenFull"

and then I ran some regression tests which passed. I tried running the uart.elf example using verilator, openOCD and GDB,

riscv32-unknown-elf-gdb src/test/resources/elf/uart.elf load continue This prints the output in the terminal window.

I want to understand how I can run any other C code following the same steps. I tried running a simple Hello world but did not get any output on the terminal window. I compiled the C code with RV64 tool chain with -march="rv32ima" -mabi="ilp32" and then tried debugging the same like the uart example, riscv32-unknown-elf-gdb helloWorld.out load continue

This did not print anything on the screen. I'm assuming I'm compiling the program wrong. Can someone help?

adz0612 avatar Aug 31 '22 16:08 adz0612

Hey, @Dolu1990 any idea how I can do this? Thanks!

adz0612 avatar Sep 01 '22 11:09 adz0612

@adz0612 by any chance are you a user of LiteX? It has a bare-metal demo that was my starting point for C programming on Vex. There is probably the equivalent demo somewhere in the VexRiscv or Murax repos, but I don't know where.

Basically, you need a linker script to put the code and data regions in the correct spots for your system.

tcal-x avatar Sep 01 '22 16:09 tcal-x

Here is a old example for Murax : https://github.com/SpinalHDL/VexRiscvSocSoftware/tree/master/projects/murax/demo

Very old stuff, not very nice XD

Dolu1990 avatar Sep 02 '22 09:09 Dolu1990

I was able to run C code using the Murax files, thanks!

adz0612 avatar Oct 20 '22 18:10 adz0612