Open Rahul-Kande opened 3 years ago
Probably a Spike memory map conflict with your binary (Spike has hard coded ROMs and other simulator specific memory ranges that probably interferes), try something like the following for bare metal. (Spike expects binaries to conform to a certain memory map, the PK should normally take care of this for hosted applications, but if you want to run generic binaries on bare metal a few changes are needed)
What you need to do to get things running bare metal is probably to modify the memory map in spike to relocate the hard coded regions or modify your linker script for the opentitan binary. (Spike has debug reserved memory from 0x0-0xFFF, Boot rom at 0x1000-0x1FFF, and DRAM by default at 0x8000_0000 (IIRC)- There are some more defined regions in the spike source, but I don't remember these on the top of my head. The boot rom is disabled altogether by using the --disable-dtb flag)
Furthermore you'll probably need to define the memory ranges in your binary on the spike command line as well, example below should get you started.
spike --isa=rv32imc --disable-dtb -l -m
How to decide these ranges of memory addresses? It causes access exceptions
spike --isa=rv32imc --disable-dtb -l -m hello spike: argument required for option -m Try 'spike --help' for more information. akeana@akeana-Latitude-3520:~/proj/tools/spike-demo$ spike --isa=rv32imc --disable-dtb -l -m2048 hello Access exception occurred while loading payload hello: Memory address 0x135b0 is invalid akeana@akeana-Latitude-3520:~/proj/tools/spike-demo$ spike --isa=rv32imc --disable-dtb -l -m0x00000000 hello spike: ../riscv/cfg.h:44: mem_cfg_t::mem_cfg_t(reg_t, reg_t): Assertion `(size % PGSIZE == 0) && (base % PGSIZE == 0) && (base + size > base)' failed. Aborted (core dumped) akeana@akeana-Latitude-3520:~/proj/tools/spike-demo$ spike --isa=rv32imc --disable-dtb -l -m0x00000000:0xFFF hello Warning: the memory at [0x0, 0xFFE] has been realigned to the 4 KiB page size: [0x0, 0xFFF] Access exception occurred while loading payload hello: Memory address 0x135b0 is invalid akeana@akeana-Latitude-3520:~/proj/tools/spike-demo$ spike --isa=rv32imc --disable-dtb -l -m0x00000000:0xFFE hello Warning: the memory at [0x0, 0xFFD] has been realigned to the 4 KiB page size: [0x0, 0xFFF] Access exception occurred while loading payload hello: Memory address 0x135b0 is invalid
We don't know how your ELF file was compiled, so we have no way to know where all the target program is expecting memories. Based on the error messages above, it apparently expects memory at 0x135b0, so you could try something like -m0x10000:0x10000
to put memory at addresses 0x10000-0x1ffff.
Likely you will need several more besides that one.
Hello,
I am trying to simulate the spike with elf files generated from the Opentitan SoC software (https://github.com/lowRISC/opentitan/tree/master/sw/device/examples/hello_world). I have tried to run it in both baremetal and pk methods. Unfortunately, neither of them work.
Here are how I run them:
Please help me solve this issue. Thank you
Note: Here are the details about my setup: