riscv-software-src / riscv-tests

Other
906 stars 463 forks source link

Couldn't open ELF program error #207

Open luoxinjie1146 opened 5 years ago

luoxinjie1146 commented 5 years ago

When I run spike pk rv64ui-p-add, it reported

bbl loader
couldn't open ELF program: rv64ui-p-add!

I can't make sense how to use the riscv-test.

aswaterman commented 5 years ago

Don't use pk, just run them directly on spike.

On Sun, Sep 22, 2019 at 9:27 AM luoxinjie1146 notifications@github.com wrote:

When I run spike pk rv64ui-p-add, it reported

bbl loader couldn't open ELF program: vvadd.riscv!

I can't make sense how to use the riscv-test.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/riscv/riscv-tests/issues/207?email_source=notifications&email_token=AAH3XQQHJZRASZVZ7CJATCDQK6MFNA5CNFSM4IZDPMM2YY3PNVWWK3TUL52HS4DFUVEXG43VMWVGG33NNVSW45C7NFSM4HM4SY3A, or mute the thread https://github.com/notifications/unsubscribe-auth/AAH3XQURZOVYQRAIWPDDHIDQK6MFNANCNFSM4IZDPMMQ .

luoxinjie1146 commented 5 years ago

@aswaterman Thanks, it works. But how can I run it on my host? It didn't print PASS or FAIL. Otherwise, what's the difference between spike and pk?

aswaterman commented 5 years ago

Spike will exit with a nonzero exit code if the test program fails.

pk is used for running applications compiled for the Linux ABI.

SaltedFishLZ commented 3 years ago

I wonder how the non-pk version executes some functions like "print"? Will it use HTIF and emulated JTAG in Rocket Chip to send data to the host?

aswaterman commented 3 years ago

That's right - which is that same thing that pk would do.

SaltedFishLZ commented 3 years ago

That's right - which is that same thing that pk would do.

Update: It seems the emulated JTAG isn't the matter here. It seems the only thing we need to load ELF and print messages is the tohost and fromhost registers. Is my understanding right? I also wonder how do different emulators recognize these 2 special memory addresses. I searched in the source codes of Rocket Chips but cannot find any clue about how the Rocket emulator achieves this goal. Moreover, are these 2 addresses hard-coded? If not, how can we change them? Thanks a lot!

aswaterman commented 3 years ago

The host system knows about the ELF that's running on the target, and so it knows the addresses of tohost/fromhost by reading the ELF symbol table. (The addresses are not hardcoded.) Then, as long as the host has some mechanism to read the target machine's memory, it all works out. For the rocket-chip emulator, the host uses the debug interface to read target memory.

SaltedFishLZ commented 3 years ago

The host system knows about the ELF that's running on the target, and so it knows the addresses of tohost/fromhost by reading the ELF symbol table. (The addresses are not hardcoded.) Then, as long as the host has some mechanism to read the target machine's memory, it all works out. For the rocket-chip emulator, the host uses the debug interface to read target memory.

So, it means that different emulators may have different implementations to recognize these 2 registers?

Is there any specification on how to load ELF into Verilator generated emulators? Verilated designs are hard to understand and I cannot find any documentation on modifying the internal states of Verilated designs (e.g., directly modifying the content of the emulated AXI main memory).

BTW, is the debug interface the same thing as the Scala source codes in https://github.com/chipsalliance/rocket-chip/tree/master/src/main/scala/devices/debug ? So for Rocket Chip, it does have a real hardware RTL design to load ELF into DRAM? If we tape out the Rocket Chip, we don't need some ROM to store the binary and program the ROM with a ROM programmer like what we usually do for many embedded systems?

SaltedFishLZ commented 3 years ago

Also, Verilog supports $readmemh and $writememh. It seems we can directly manipulate memory contents in Verilog test benches (e.g., https://gitee.com/liangkangnan/tinyriscv/blob/master/tb/tinyriscv_soc_tb.v). I wonder whether we have something similar (or simple enough like the example above) to load ELF into the CPU memory in RTL-generated emulators.

pavitrar20 commented 2 years ago

I also got this error while trying to compile a simple hello program riscv64-unknown-elf-gcc -march=rv64gcv hello.c -o hello andspike pk $RISC/riscv64-unknown-elf/bin/pk hello bbl loader couldn't open ELF program: /home/ubuntu/Spike/riscv64-unknown-elf/bin/pk!

I tried with 32 bit variant, although I believe spike works with riscv64 riscv32-unknown-elf-gcc -march=rv32gcv hello.c -o hello ubuntu@ip-172-31-17-9:~/Spike$ spike pk $RISC/riscv32-unknown-elf/bin/pk hello bbl loader ../pk/elf.c:40: assertion failed: IS_ELF64(eh). (Expected result?)

How to run simple programs on spike? How would the code get loaded on the simulator.

All help is appreciated @aswaterman

pavitrar20 commented 2 years ago

I encountered the same error. How does one run the program without using spike?