riscvarchive / riscv-linux

RISC-V Linux Port
606 stars 209 forks source link

Unable to boot vmlinux with spike #85

Closed szhou42 closed 6 years ago

szhou42 commented 7 years ago

Hi I have built the 32-bit riscv toolchain and riscv-linux using the following commands cd riscv-tools ./build-rv32ima.sh

cd riscv-gnu-toolchain/build ../configure --prefix=$RISCV --with-arch=rv32gc --with-abi=ilp32d make linux

cd ~/riscv-linux make ARCH=riscv defconfig make -j16 ARCH=riscv CROSS_COMPILE=riscv32-unknown-linux-gnu-

However, when I do "spike bbl vmlinux", spike hangs. spike -l bbl vmlinux shows me this exception: "core 0: exception trap_instruction_access_fault, epc 0x0000000000000000"

Also, compiling and running a hello world program with the riscv32-unknown-linux-gnu-gcc also make spike hangs but does not produce such exception.

What could be the cause of this?

palmer-dabbelt commented 7 years ago

This is probably a version mismatch. The versions in here should match

https://github.com/sifive/freedom-u-sdk/tree/new

If you just run "make sim" it should boot Linux.

szhou42 commented 7 years ago

Hi palmer, this repo seems to build a 64-bit toolchain by default, is it possible to build a 32-bit one? nvm, i'll try to build it manually first without the provided Makefile

szhou42 commented 7 years ago

I have built the riscv32-unknown-linux-gnu toolchain, and trying to build linux with this command

make -j4 ARCH=riscv vmlinux CROSS_COMPILE=riscv32-unknown-

and got lots of incompatible ABI errors for these .o files

/home/osdev/install/riscv/lib/gcc/riscv32-unknown-linux-gnu/7.1.1/../../../../riscv32-unknown-linux-gnu/bin/ld: arch/riscv/kernel/vdso/rt_sigreturn.o: ABI is incompatible with that of the selected emulation: target emulation elf64-littleriscv' does not matchelf32-littleriscv' /home/osdev/install/riscv/lib/gcc/riscv32-unknown-linux-gnu/7.1.1/../../../../riscv32-unknown-linux-gnu/bin/ld: failed to merge target specific data of file arch/riscv/kernel/vdso/rt_sigreturn.o /home/osdev/install/riscv/lib/gcc/riscv32-unknown-linux-gnu/7.1.1/../../../../riscv32-unknown-linux-gnu/bin/ld: arch/riscv/kernel/vdso/rt_sigreturn.o: file class ELFCLASS64 incompatible with ELFCLASS32 /home/osdev/install/riscv/lib/gcc/riscv32-unknown-linux-gnu/7.1.1/../../../../riscv32-unknown-linux-gnu/bin/ld: final link failed: File in wrong format collect2: error: ld returned 1 exit status VDSOLD arch/riscv/kernel/vdso/vdso-dummy.o

palmer-dabbelt commented 6 years ago

Everything should line up now in freedom-u-sdk, and we recently added support for setting the ISA and ABI. YMMV on the 32-bit port actually working, though, as it doesn't get tested as much as it should :).