Good day!
I have a problem with running the RISC-V rocket-chip cycle-accurate emulator for the
dummy_rocc_test.c program that I compile, located in the rocket-chip repository (
riscv-tools/riscv-isa-sim/dummy_rocc).
I will explain my steps below and place the problem afterwards. The steps I'm taking:
1.
git clone https://github.com/ucb-bar/rocket-chip.git2.
git submodule update --init --recursive` in the rocket-chip, rocket-chip/riscv-tools directories3.
export RISCV=[a folder called riscv-toolchain]4.
export PATH=[...]/riscv-toolchain/bin:$PATH5.
. rocket-chip/riscv-tools/build.sh (without running
build-rv32im.sh afterwards)
6.
make CONFIG=RoccConfigExample in the
rocket-chip/emulator directory
7.
cd rocket-chip/riscv-tools/riscv-isa-sim/dummy-rocc8.
riscv64-unknown-elf-gcc dummy_rocc_test.c -o dummy_rocc_test.out9. (while in the
dummy_rocc folder)
rocket-chip/emulator/emulator-TestHarness-RoccExampleConfig +dramsim +max-cycles=10000 +verbose pk dummy_rocc_test.out 3>&1 1>&2 2>&3 | spike-dasm > dummy_rocc_test.log10.
riscv64-unknown-elf-objdump --disassemble-all dummy_rocc_test.out > dummy_rocc_test.dumpThe output of `dummy_rocc_test.log` file (first 25 lines, full text
here):
C0: 0 [0] pc=[b90caeae11] W[r 0=0000000000000000][0] R[r19=0000000000000000] R[r 4=918250ce690efa03] inst=[024983dc] unknown
C0: 1 [0] pc=[b90caeae11] W[r 0=0000000000000000][0] R[r19=0000000000000000] R[r 4=918250ce690efa03] inst=[024983dc] unknown
C0: 2 [0] pc=[b90caeae11] W[r 0=0000000000000000][0] R[r19=0000000000000000] R[r 4=918250ce690efa03] inst=[024983dc] unknown
C0: 3 [0] pc=[b90caeae11] W[r 0=0000000000000000][0] R[r19=0000000000000000] R[r 4=918250ce690efa03] inst=[024983dc] unknown
C0: 4 [0] pc=[b90caeae11] W[r 0=0000000000000000][0] R[r19=0000000000000000] R[r 4=918250ce690efa03] inst=[024983dc] unknown
C0: 5 [0] pc=[b90caeae11] W[r 0=0000000000000000][0] R[r19=0000000000000000] R[r 4=918250ce690efa03] inst=[024983dc] unknown
C0: 6 [0] pc=[b90caeae11] W[r 0=0000000000000000][0] R[r19=0000000000000000] R[r 4=918250ce690efa03] inst=[024983dc] unknown
C0: 7 [0] pc=[b90caeae11] W[r 0=0000000000000000][0] R[r19=0000000000000000] R[r 4=918250ce690efa03] inst=[024983dc] unknown
C0: 8 [0] pc=[b90caeae11] W[r 0=0000000000000000][0] R[r19=0000000000000000] R[r 4=918250ce690efa03] inst=[024983dc] unknown
C0: 9 [0] pc=[b90caeae11] W[r 0=0000000000000000][0] R[r19=0000000000000000] R[r 4=918250ce690efa03] inst=[024983dc] unknown
C0: 10 [0] pc=[b90caeae11] W[r 0=0000000000000000][0] R[r19=0000000000000000] R[r 4=918250ce690efa03] inst=[024983dc] unknown
C0: 11 [0] pc=[b90caeae11] W[r 0=0000000000000000][0] R[r19=0000000000000000] R[r 4=918250ce690efa03] inst=[024983dc] unknown
C0: 12 [0] pc=[b90caeae11] W[r 0=0000000000000000][0] R[r19=0000000000000000] R[r 4=918250ce690efa03] inst=[024983dc] unknown
C0: 13 [0] pc=[b90caeae11] W[r 0=0000000000000000][0] R[r19=0000000000000000] R[r 4=918250ce690efa03] inst=[024983dc] unknown
C0: 14 [0] pc=[b90caeae11] W[r 0=0000000000000000][0] R[r19=0000000000000000] R[r 4=918250ce690efa03] inst=[024983dc] unknown
C0: 15 [0] pc=[b90caeae11] W[r 0=0000000000000000][0] R[r19=0000000000000000] R[r 4=918250ce690efa03] inst=[024983dc] unknown
C0: 16 [0] pc=[b90caeae11] W[r 0=0000000000000000][0] R[r19=0000000000000000] R[r 4=918250ce690efa03] inst=[024983dc] unknown
C0: 17 [0] pc=[b90caeae11] W[r 0=0000000000000000][0] R[r19=0000000000000000] R[r 4=918250ce690efa03] inst=[024983dc] unknown
C0: 18 [0] pc=[b90caeae11] W[r 0=0000000000000000][0] R[r19=0000000000000000] R[r 4=918250ce690efa03] inst=[024983dc] unknown
C0: 19 [0] pc=[0000001000] W[r 0=0000000000000000][0] R[r13=0000000000000000] R[r 0=918250ce690efa03] inst=[0e06b783] ld a5, 224(a3)
C0: 20 [0] pc=[0000001002] W[r 0=0000000000000000][0] R[r 0=0000000000000000] R[r 0=918250ce690efa03] inst=[00006db7] lui s11, 0x6
C0: 21 [0] pc=[0000001002] W[r 0=0000000000000000][0] R[r 0=0000000000000000] R[r 0=918250ce690efa03] inst=[00006db7] lui s11, 0x6
C0: 22 [0] pc=[0000001002] W[r 0=0000000000000000][0] R[r 0=0000000000000000] R[r 0=918250ce690efa03] inst=[00006db7] lui s11, 0x6
C0: 23 [0] pc=[0000001002] W[r 0=0000000000000000][0] R[r 0=0000000000000000] R[r 0=918250ce690efa03] inst=[00006db7] lui s11, 0x6
C0: 24 [0] pc=[0000001002] W[r 0=0000000000000000][0] R[r 0=0000000000000000] R[r 0=918250ce690efa03] inst=[00006db7] lui s11, 0x6
C0: 25 [0] pc=[0000001002] W[r 0=0000000000000000][0] R[r 0=0000000000000000] R[r 0=918250ce690efa03] inst=[00006db7] lui s11, 0x6
...
The output of `dummy_rocc_test.dump` (first 35 lines, full text
here):
dummy_rocc_test.out: file format elf64-littleriscv
Disassembly of section .text:
0000000000010000 <_ftext>:
10000: 00008197 auipc gp,0x8
10004: d8018193 addi gp,gp,-640 # 17d80 <_gp>
10008: 00007297 auipc t0,0x7
1000c: 5d028293 addi t0,t0,1488 # 175d8 <_PathLocale>
10010: 00007317 auipc t1,0x7
10014: 67030313 addi t1,t1,1648 # 17680 <_end>
10018: 0002b023 sd zero,0(t0)
1001c: 00828293 addi t0,t0,8
10020: fe62ece3 bltu t0,t1,10018 <_ftext+0x18>
10024: 00000517 auipc a0,0x0
10028: 2f050513 addi a0,a0,752 # 10314 <__libc_fini_array>
1002c: 2a4000ef jal 102d0 <atexit>
10030: 3c0000ef jal 103f0 <__libc_init_array>
10034: 00012503 lw a0,0(sp)
10038: 00810593 addi a1,sp,8
1003c: 00000613 li a2,0
10040: 124000ef jal 10164 <main>
10044: 2a00006f j 102e4 <exit>
0000000000010048 <_fini>:
10048: 00008067 ret
000000000001004c <deregister_tm_clones>:
1004c: 00017537 lui a0,0x17
10050: 000177b7 lui a5,0x17
10054: 57850713 addi a4,a0,1400 # 17578 <__TMC_END__>
10058: 57f78793 addi a5,a5,1407 # 1757f <__TMC_END__+0x7>
1005c: 40e787b3 sub a5,a5,a4
My main problem is that I cannot make the emulator output me a
SUCCESS! with a correct number of cycles for the compiled program
dummy_rocc_test.c. The same program runs fine with
spike pk. The output from the emulator
dummy_rocc_test.log shows that there's no instruction from the disassembled program file
dummy_rocc_test.dump is being executed; so the program itself isn't being executed by the emulator.
I understand the emulator starts with randomized values in its registers, that's explains the first value in
pc. Afterwards, it sets at
[0000001000] which, correct me if I'm wrong, but I think it's the same
0x10000 address from where programs start to execute if run with a proxy kernel (where the first instruction in
dummy_rocc_test.dump should be).
I do believe that
pc should start first with a value of
0x200 /
pc=[0000000200] first though, to start the proxy kernel (
0x200 being the address of choice for starting bare-metal programs by RISC-V). Even if I give a bigger number for
+maxcycles in step 9,
pc just loops through the same addresses, never going through
[0000001000] again or though
[0000000200] and outputting the same
FAILED! in the end because the program apparently didn't execute in time.
I would like to understand where am I wrong in the thinking I'm doing or in the steps I'm taking. Thank you for your time!
I've also posted this question on StackOverflow
here. I'm sorry beforehand if this isn't the place to post this kind of question, but I'm just looking to understand and learn about the architecture and its tools.