riscv-qemu icon indicating copy to clipboard operation
riscv-qemu copied to clipboard

How to skip reset_vec execution before user program?

Open sergeysmolov opened this issue 6 years ago • 2 comments

I run a bare metal RISC-V assembler program on QEMU. I use the following command:

qemu-system-riscv64 -M spike_v1.10 -cpu any -d in_asm -nographic -singlestep -bios program.bin

The simulation starts with the following instructions:

IN: 
0x0000000000001000:  00000297          auipc           t0,0            # 0x1000

IN: 
0x0000000000001004:  02028593          addi            a1,t0,32

IN: 
0x0000000000001008:  f1402573          csrrs           a0,mhartid,zero

IN: 
0x000000000000100c:  0182b283          ld              t0,24(t0)

IN: 
0x0000000000001010:  00028067          jr              t0

IN: 
0x0000000080000000:  0000              mv              s0,sp

As I understand, these instructions (preamble) are stored at 'reset_vec' array (/hw/riscv/spike.c) and they're executed at the very beginning.

Is it possible to avoid their emulation and run my program only? When I've used QEMU for Aarch64 programs simulation, it was possible to skip this preamble by using '-bios' option instead of '-kernel'.

sergeysmolov avatar Apr 12 '18 12:04 sergeysmolov

We could implement the -bios option so that you can specify the firmware that is loaded, rather than use -kernel.

Otherwise you can make your own board for your own use. e.g. copy which ever board you are using and modify the reset vector i.e. add an option to load the firmware from a file. This is essentially similar to implementing the -bios option.

michaeljclark avatar Apr 16 '18 00:04 michaeljclark

We could implement the -bios option so that you can specify the firmware that is loaded, rather than use -kernel.

That would be great.

sergeysmolov avatar Apr 16 '18 14:04 sergeysmolov