-
Notifications
You must be signed in to change notification settings - Fork 631
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How do I compile a c program such that the binary can be run/simulated by an RTL config? #816
Comments
Could you try running |
Just did now. Same thing, except I don't get the "Listening on port", "UART0", and "warning: tohost and fromhost" messages. drak@JBOOK-PRIMARY:~/chipyard/sims/verilator$ make run-binary CONFIG=RocketConfig BINARY=/home/drak/hello-riscv
Running with RISCV=/home/drak/chipyard/esp-tools-install
(set -o pipefail && /home/drak/chipyard/sims/verilator/simulator-chipyard-RocketConfig +permissive +dramsim +dramsim_ini_dir=/home/drak/chipyard/generators/testchipip/src/main/resources/dramsim2_ini +max-cycles=10000000 +verbose +permissive-off /home/drak/hello-riscv </dev/null 2> >(spike-dasm > /home/drak/chipyard/sims/verilator/output/chipyard.TestHarness.RocketConfig/hello-riscv.out) | tee /home/drak/chipyard/sims/verilator/output/chipyard.TestHarness.RocketConfig/hello-riscv.log) The process hangs and continues to utilize 100% of a CPU thread, as before. If I attempt to pass it a file that does not exist, or if I pass it an executable that was compiled for x64, the process terminates with error 255. |
I encountered the same problem. I compile my c program with riscv64-unknown-elf-gcc, and get the ELF file a.out. I run ./simulator-chipyard-MegaBoomConfig pk ~/H/hello-world/Gslexample/a.out, and it just hangs. After some search, I try ./simulator-chipyard-MegaBoomConfig pk ~/H/hello-world/Gslexample/a.out +dramsim. It seems like stuck, but after a long time(about 30 min), it gets the results. So, maybe just be patient. |
Hi, I am getting the below error: [UART] UART0 is here (stdin/stdout). When I try to run tests this way: I get the UART0 print but nothing after that: Am I missing anything here? Please help out. |
@JL102 , I noticed that when you ran your program on Spike, you ran it with pk. Was it able to run on Spike without pk as well? @RaoShri , It would be useful to run the first make command ( |
@alonamid , └─$ ./simulator-chipyard-RocketConfig $RISCV/bin/target/share/riscv-tests/isa/rv64ui-p-add About adding the verbose to the first command, how do I do it? Enabling verbose would help me debug a lot of things faster. Might seem like a trivial question, bear with me, I am new to this. |
You can run |
@alonamid When running with run-make-binary, I was able to see the errors and fix it. └─$ make run-binary-debug BINARY=$RISCV/bin/target/share/riscv-tests/isa/rv64ui-p-add CONFIG=ShrinidhiCustomConfig Again terminal print is blank, but I see the test has passed in the log. └─$ ./simulator-chipyard-ShrinidhiCustomConfig $RISCV/bin/target/share/riscv-tests/isa/rv64ui-p-bltu I see this, but no corresponding log/out file in output/chipyard.TestHarness.ShrinidhiCustomConfig. I am guessing this test also has passed but I have no print in terminal nor any log file for it. |
I got the same question with you , have you saved your problem ? And how ? Thanks! |
Please read the document carefully. https://chipyard.readthedocs.io/en/latest/Software/Baremetal.html #include <stdio.h> int main(void) $ riscv64-unknown-elf-gcc -fno-common -fno-builtin-printf -specs=htif_nano.specs -c hello.c root@51df727fcb26: |
Thanks, I hadn't even seen that page myself. Probably because the title ("Baremetal RISC-V Programs") didn't stick out to me as what I had been looking for. The way I had solved the problem was by copying the contents of the All the command-line arguments that they use is black magic to me, but the resulting executable takes even less time to simulate. Simulating executable with the riscv-tests black magic:
Simulating executable with the suggested command line arguments:
Here's my benchmarks folder with that modified Makefile: https://github.com/JL102/rowan-riscv-tensor/tree/main/benchmarks |
well. Without linux or any other os is Bare Metal. And chipyard doesn't ship with an booting/running linux, it is baremetal. |
Closing as the question has been answered. (Thanks again) |
Hello,
I am attempting to use
riscv64-unknown-elf-gcc
to compile a simple test program, and have it run on an RTL config (from section 2.1 in the docs).This is the test file,
hello.c
. I initially had it print a "hello world" statement, but changed it such that it does not need any imports or libraries:This is what I am doing:
riscv64-unknown-elf-gcc -g hello.c -o hello-riscv
spike pk hello-riscv
runs without errors. (When my "hello world" program had a printf statement, it printed correctly as well.)chipyard/sims/verilator
, I run:./simulator-chipyard-RocketConfig ~/hello-riscv
This is the output I get:
and then it hangs indefinitely. Upon examining
top
, I can see thatsimulator-chipy
continues to utilize 100% of a CPU thread.Is there anything I'm doing wrong? How do I compile the program such that it runs correctly? I could not find any information about tohost and fromhost, aside from chapter 6.12, which talks about booting a Linux kernel. I'm not attempting to boot Linux via the RISC-V cpu; I just want it to run a certain binary like in the default examples.
The text was updated successfully, but these errors were encountered: