cnrv / fpga-rocket-chip

Wrapper for Rocket-Chip on FPGAs
Other
120 stars 26 forks source link

Program of riscv had running incorrectly #7

Closed dreamflyings closed 4 years ago

dreamflyings commented 4 years ago

Loading the elf file is correct at power-on.But when I run the program I get an error.

./hello.riscv

[ 204.720000] hello.riscv[63]: unhandled signal 4 code 0x1 at 0x0000000080000040 in hello.riscv[80000000+1000] [ 204.724000] CPU: 0 PID: 63 Comm: hello.riscv Not tainted 4.20.0-44631-g8fe28cb58bcb-dirty #4 [ 204.724000] sepc: 0000000080000040 ra : 0000000000000000 sp : 0000000000000000 [ 204.728000] gp : 0000000000000000 tp : 0000000000000000 t0 : 000000000001e000 [ 204.732000] t1 : 0000000000000000 t2 : 0000000000000000 s0 : 0000000000000000 [ 204.732000] s1 : 0000000000000000 a0 : 0000000000000000 a1 : 0000000000000000 [ 204.736000] a2 : 0000000000000000 a3 : 0000000000000000 a4 : 0000000000000000 [ 204.736000] a5 : 0000000000000000 a6 : 0000000000000000 a7 : 0000000000000000 [ 204.740000] s2 : 0000000000000000 s3 : 0000000000000000 s4 : 0000000000000000 [ 204.740000] s5 : 0000000000000000 s6 : 0000000000000000 s7 : 0000000000000000 [ 204.744000] s8 : 0000000000000000 s9 : 0000000000000000 s10: 0000000000000000 [ 204.748000] s11: 0000000000000000 t3 : 0000000000000000 t4 : 0000000000000000 [ 204.748000] t5 : 0000000000000000 t6 : 0000000000000000 [ 204.752000] sstatus: 8000000200006020 sbadaddr: 000000003002a073 scause: 0000000000000002 Illegal instruction

wsong83 commented 4 years ago

Normally when the error is illegal instruction, it is very likely you are running an executable compiled using a version of GCC mismatching with the processor. In the readme, the riscv-gnu-toolchain tested is the version around May 17 2019. Can you check your gcc?

If you are using the relatively correct gcc, you can debug further by looking at the scause, sbadaddr, sepc and sstatus register.

dreamflyings commented 4 years ago

@wsong83 Thank you very much, and the problem has been solved.