ultraembedded / biriscv

32-bit Superscalar RISC-V CPU
Apache License 2.0
838 stars 146 forks source link

Using own ELF results in an infinite loop #4

Open MakisChristou opened 4 years ago

MakisChristou commented 4 years ago

So as the title suggests, I am trying to simulate the CPU with my own ELF files. When doing so the simulator hangs in an infinite loop. I used riscv32-unknown-elf-gcc to compile the *.c code with no other flags or arguments. I've also tried using the example provided but it had the same result. Any ideas why that is?

ultraembedded commented 4 years ago

Can you attach the ELF and I’ll take a look.

MakisChristou commented 4 years ago

Sure here is it. I've used the objdump command and I've realized that a difference between your provided binary and mine is the boot vector section at the begging. Yours starts from 0X80000000 and mine doesn't have that section at all. But I don't seem to be able to replicate that with the options that I use in my compile.sh script. Any help (or direction) would be appreciated!

ultraembedded commented 4 years ago

Ok. Your ELF is compiled and linked against newlib. This means that the entry point and memory layout are different, and it will also take quite a long time to run on simulation.

If you want to run a cutdown test elf, you could try starting from this project; https://github.com/ultraembedded/minispartan6-audio/tree/master/src_c

It has a makefile, linker script (which starts from 0x80000000) and a tiny libc library which is more simulation friendly.

MakisChristou commented 4 years ago

Thanks for the response! I tried using the project that you provided, but I've been unsuccessful at using the generated binary in biriscv. For the record, I just cloned the repository, run make and used the generated binary in the biriscv icarus simulation (but still with the same infinite loop result). Here is the generated binary and corresponding make output if that helps. What am I doing wrong? Again thanks for your time!

Marytv commented 3 years ago

Same issue for me also. Working with the given elf and not with my own. https://github.com/ultraembedded/minispartan6-audio/tree/master/src_c Tried the elf from above, but issue not solved.