Closed Zielasko closed 6 years ago
32-bit linux support is known to be broken. There is no schedule for fixing it.
There are a number of problems here. One is the fact that the 32-bit glibc support has not been upstreamed, so 32-bit linux support is only available in the old and obsolete glibc version in riscv-gnu-toolchain. This old glibc version does not work with current qemu. It only works with the old qemu in riscv-gnu-toolchain. It is believed that there was a struct stat change somewhere along the way which isn't reflected in this old glibc tree. Building a 32-bit linux toolchain and running programs on old user-mode qemu mostly works, but there was a glibc ABI change for instruction cache flushing that is missing, and it is believed that the signal handler frame changed (probably a ucontext_t struct change) which is also missing. Any programs that needs either of these two features will fail. Another problem is that the kernel is apparently broken and/or qemu support is broken. The core linux kernel port was upstreamed last fall, but only the 64-bit support has been tested upstream.
There has been some discussion of issues in a thread on the riscv.org sw-dev mailing list. You could try asking there. This thread for instance https://groups.google.com/a/groups.riscv.org/forum/#!searchin/sw-dev/Qemu%7Csort:date/sw-dev/9mZDHPEiqds/Vs52Zb6yAAAJ has info about 32-bit linux builds, and has a proposed 32-bit kernel patch near the bottom.
In general, I can't recommend riscv-tools. It is hard to build and poorly maintained. I would suggest riscv-gnu-toolchain if you just want a toolchain, and freedom-u-sdk if you want to build kernel/buildroot and boot it on a simulator. riscv-tools might be useful if you want to learn how to build a system from scratch, and it requires doing a lot of stuff by hand.
Thanks.
I tried building the freedom-u-sdk with make sim
, but this fails for me, while trying to build vmlinux.
Everything else compiles without any error, but for linux it can find freedom-u-sdk/linux/scripts/extract-cert.c:21:25: fatal error: openssl/bio.h File or directory not found
.
I hope its okay to ask this here since riscv-tools is not exactly freedom-u-sdk.
Also about the riscv-tools 64bit linux i tried to build. Im not exactly sure what output to expect for bbl + tinyconfig + busybox. As i posted above, i get some basic output printed on the early0 bootconsole, which tells me at least something seems to work, but after that it stops printing anything. So if everything would be working as it should, i would be getting a login ash ?
The kernel build failed while building a utility for the host. You need to install the missing package on the host, probably something like libssl-dev.
The default serial driver no longer works with spike, the simulator used with "make sim". "make qemu" should work, it gives you qemu instead of spike, qemu has more features than spike. If you really want to use spike, then you have to modify the kernel config file to enable the old serial driver. This has been mentioned in freedom-u-sdk issues. See for instance https://github.com/sifive/freedom-u-sdk/issues/48
Thanks again.
Since i needed libssl-dev before, i was pretty sure i had it installed.
Installing this and switching to the branch hifive-unleashed, as suggested in the issue you linked, lets me successfully boot 64bit Linux on spike.
Hi Im was trying to get a 32bit version of Linux running on spike for quite some time now.
Its quite hard to find much documentation on RISCV 32bit that works for the current version. In many cases available flags for configuration have changed (eg. --enable-32bit), so i got spike working for normal newlib programs, but not for any Linux kernel or the bbl.
I also tried building the 64bit toolchain and running 64bit Linux on spike, which worked to some extend.
Im using the master branch of all repositories, but i also tried other branches for some tools (and most available branches for riscv-linux).
I listed most of my build configurations below and what problems i have/had with them. It would be nice to get some help for what mistakes i might have made or some info if it is at all possible to get 32bit Linux running on spike with a current version of spike+toolchain.
32bit toolchain
first try using the build-rv32ima.sh script
(i modified with-arch(ima->g) and with-abi(ilp32->ilp32d)
all projects build successfully. compiling a simple "hello world" program with riscv32-unknown-elf-gcc and executing it on spike results in:
but running bbl on spike doesnt print anything and gets stuck in a loop after some time (probably while trying to execute the dummy payload)
i tried to recompile spike and especially pk/bbl several times, but for rv32 it always gets stuck in a loop.
building without the default buildscript
toolchain
../configure --prefix=$RISCV --with-arch=rv32g --with-abi=ilp32d
(same as build script)make linux
for linux-gnu-gccriscv-fesvr
../configure --prefix=$RISCV --target=riscv32-unknown-linux-gnu
spike
../configure --prefix=$RISCV --with-fesvr=$RISCV
riscv-pk
../configure --prefix=$RISCV --host=riscv32-unknown-linux-gnu
and the same for newlib
../configure --prefix=$RISCV --host=riscv32-unknown-elf
testing spike with pk
running bbl
same loop/error:
for spike32bit bbl32bitnewlib with no payload (so it should run dummypayload):
spike bbl
:no output, spike hangs
../configure --prefix=$RISCV --host=riscv32-unknown-linux-gnu --with-payload=RISCV/kernel/vmlinux32defwBB
results in the same loop with no output.64bit toolchain
using the build script builds a working toolchain able to run pk and bbl (with dummy payload)
configuration for riscv64-pk
../configure --prefix=$RISCV --host=riscv64-unknown-linux-gnu
../configure --prefix=$RISCV --host=riscv64-unknown-elf(build with default buildscript config)
both have same output(successful executing dummypayload):./riscv64-tools/bin/spike bbl
../configure --prefix=$RISCV --host=riscv32-unknown-linux-gnu --with-payload=RISCV/kernel/vmlinux64defwBB
spike64 bbl64gnulinux --withpayload=linux64-kernel-defconfig+busybox64gnulinux
executing
spike bbl
:(this one might have been caused by some leftover files from building the rv32 versions, though i tried to reset all source dirs to a clean state each time and rebuilding had the same result) built again on my laptop, but using tinyconfig for the linuxkernel (also running Ubuntu):
executing
spike bbl
:this time it prints some output, but after disabling
early0
, its just running the same code repeatedly:Compiling a Kernel
Following the guide from riscv-tools
make mrproper
make ARCH=riscv defconfig
and
make ARCH=riscv tinyconfig
setting crosscompiler to riscv-unknown-linux-gnu
(for both 32 and 64 version)
make ARCH=riscv -j8
this works for 64bit and 32bit, but for 32bit i had to remove all graphics DRM options from the (def).config file for some (non master) branches (i tested several), else it cant find some function:
__ucmpdi2
with busybox
make allnoconfig
set additional flags with menuconfig (cant find Support --install so i set it manually) this builds for 32 and 64bitfurther creating directories as in the guide create inittabfile (link is broken)
(first path seems slightly wrong in the guide)
add initframfs source file to kernel config building kernel succeeds witht he same config as above for 32 and 64
rebuilding riscv-pk and executing bbl gives the output listed above.