I am new to this forum. Actually I am facing an issue while simulating spike for bare metal or pk (proxy kernel). A simple C program hello.c is not running its throwing me the errors I have attached in the scrnshot. Can anyone please help me to solve this Issue.
pk is effectively an interpreter. Not a command line option to spike. Spike runs the interpreter pk, and the interpreter pk runs your program hello. So the correct command line is “spike pk hello”. That assumes all three programs are on your PATH, you might need to give full pathnames if one isn’t on your path.
The command “spike --help” will show you spike command line options. -pN sets the number of cpus to emulate. Spike isn’t verifying that N is a number, it just passes it to atoi, Atoi doesn’t do error checking. The implementation I have just returns 0, Emulating 0 processors probably won’t work very well. Would you like to file a bug report against spike?
Thanks Jim, I understand what you mean. Now the problem is when I run with absolute path for spike, pk and also hello it gives an error “elf.c:40: assertion failed:IS_ELF64(eh)”
What should I do now?
Apparently you built a rv64 spike and pk, but have a rv32 hello world program. That won’t work. They must all be rv64 or rv32. spike and pk build rv64 by default I believe. If you want rv32 versions of them, then I think you need to add --with-isa=rv32imac (or whatever your correct ISA is) to the riscv-isa-sim configure options, and add --host=riscv32-unknown-elf to the riscv-pk configure options. I’m not a spike or pk expert, so I’m not sure about the exact details.
Your suggestions help me a lot and also successfully run “hello world” program. Now my ultimate target is to run spike 32 bit but when I use flag - -isa=rv32im its stuck.
I used following commands:
riscv64-unknown-elf-gcc median_main.c median.c -O2 -o median -std=gnu99 -march=rv32im -mabi=ilp32 -Wa,-march=rv32im
spike --isa=rv32im /home/prince/project_work/toolchain/sc-riscv64-unknown-elf-gcc-20180126-linux64/riscv-unknown-elf-gcc/bin/riscv64-unknown-elf/bin/pk median
I have also tried instead of no. 2 step
- spike --isa=rv32im /home/prince/project_work/toolchain/sc-riscv64-unknown-elf-gcc-20180126-linux64/riscv-unknown-elf-gcc/bin/riscv32-unknown-elf/bin/pk median
I’m not a spike expert and “stuck” isn’t a very useful description of the problem.
Note that spike plus pk only supports a limited number of system calls, sufficient to run a few popular benchmarks like coremark. It isn’t intended to support all linux programs. If you are trying to run a non-trivial program, it might not be supported. If you need better linux program support, then you want to use qemu instead of spike. user mode qemu supports all linux system calls (in theory).
You can try debugging the problem. spike can emit instruction traces. I think this is the -l option. You could generate an instruction trace and then analyze it to see if spike is stuck on one instruction, or if maybe your program is stuck in a loop. You could try running spike under gdb to see where it is getting stuck.
Maybe spike is waiting for input? Try hitting return a few times to see if that does anything.
Thanks a lot Jim for your suggestions.