Open an image file on a RV32 simulation

115 views
Skip to first unread message

Steven

unread,
Feb 10, 2021, 6:05:39 AM2/10/21
to Chipyard
Hi,

I am trying to test an image dectction program on a RV32 simulation. When I run this program on a PC, I can put the image on the PC and use fopen to open the image:

FILE* fpBMP;
if ((fpBMP = fopen("1.bmp", "rb")) == NULL) {
printf("file open failed");
exit(0);
}

when I run this program on the simulation, where can I put the image? On the Host PC or on the RV32 simulation?  

If on the host PC, how can I open and read the image from the RV32 simulation?
if on the RV32 simulation, how can I load the image to the simulation?

I have checked this conversation. But I am not sure what the magic_mem means and what will the open function return and what the handle means in the other three functions?

And does RV32 compiler support malloc and free functions?

Thanks in advance.



Jerry Zhao

unread,
Feb 15, 2021, 12:30:23 AM2/15/21
to chip...@googlegroups.com
It sounds like you want to use the proxy-kernel (pk), which will allow your simulated RISC-V system to execute syscalls by proxy on the host (x86) system. 

echo "void main() { int* i = malloc(4); printf(\"Hello world\n\"); }" | riscv64-unknown-elf-gcc -xc -
spike pk hello.riscv

Binaries compiled this way can be executed on Chipyard simulators with `BINARY="pk binary.riscv"`
make run-binary BINARY="pk hello.riscv"
You should be able to use malloc/free in binaries compiled this way.

The examples above are for RV64 simulated systems. To do the same for a RV32 system, you must install RV32 versions of pk and the toolchains.
Is there a reason in particular you want to use a RV32 system? The advantages of RV64 over RV32 for SW compatibility and support are numerous.

-Jerry

--
You received this message because you are subscribed to the Google Groups "Chipyard" group.
To unsubscribe from this group and stop receiving emails from it, send an email to chipyard+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/chipyard/0081aab6-f1a8-496d-988e-f0cdf30a7948n%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages