riscv-software-src / riscv-isa-sim

Spike, a RISC-V ISA Simulator
Other
2.36k stars 825 forks source link

"spike --isa=RV32IMAFDC pk hello" can't output hello world ! #453

Open rockcarry opened 4 years ago

rockcarry commented 4 years ago

I buillt a toolchain for RV32IMC from riscv-gnu-toolchain project ./configure --prefix=/opt/riscv32 --with-arch=rv32imc --with-abi=ilp32

wrote a hello.c

include

include

int main(void) { printf("hello world !\n"); return 0; }

using riscv32-unknown-elf-gcc toolchain compile hello.c riscv32-unknown-elf-gcc -Wall hello.c -o hello

run it: spike --isa=RV32IMAFDC pk hello

there is no output.

if using riscv64-unknown-elf-gcc to compile it and run, it works fine: riscv64-unknown-elf-gcc hello.c spike --isa=RV64IMAFDC pk a.out bbl loader hello world !

spike does not support RV32 ?

hyf6661669 commented 4 years ago

Spike does support rv32, because I successfully use it to run elf file compiled by rv32 compiler.

hyf6661669 commented 4 years ago

I think maybe your riscv-proxy-kernel is not set to 32-bit, have a look at: https://github.com/riscv/riscv-pk

We assume that the RISCV environment variable is set to the RISC-V tools install path, and that the riscv-gnu-toolchain package is installed. Please note that building the binaries directly inside the source directory is not supported; you need to use a separate build directory.

$ mkdir build
$ cd build
$ ../configure --prefix=$RISCV --host=riscv64-unknown-elf
$ make
$ make install
Alternatively, the GNU/Linux toolchain may be used to build this package, by setting --host=riscv64-unknown-linux-gnu.

By default, 64-bit (RV64) versions of pk and bbl are built. To built 32-bit (RV32) versions, supply a --with-arch=rv32i flag to the configure command.

The install step installs 64-bit build products into a directory matching your host (e.g. $RISCV/riscv64-unknown-elf). 32-bit versions are installed into a directory matching a 32-bit version of your host (e.g. $RISCV/riscv32-unknown-elf).
sahooora commented 2 years ago

The same issue! Did you find a way to solve it?

rockcarry commented 2 years ago

using 64bit is OK. the way to solove it, is using riscv 64bit. another is I written a riscv VM to run my code.

jundijiujieke commented 1 year ago

I use the riscv64-unknown-elf-gcc to compile the hello.c But i can't find pk version. image

And when i run "spike pk hello", its result is strange. image Does anyone know how to solve this problem?

riscv1111 commented 10 months ago

I compiled hello.c with riscv64-unknown-elf-gcc but I can't find the pk version. 图像

When I run "spike pk hello", it turns out strangely. 图像Does anyone know how to fix this?

How should this problem be solved?