litex-hub / linux-on-litex-rocket

Run 64-bit Linux on LiteX + RocketChip
BSD 2-Clause "Simplified" License
181 stars 18 forks source link

toolchains selection issue when building BBL #22

Closed tongchen126 closed 2 years ago

tongchen126 commented 2 years ago

In the fourth step of this section, the toolchains is configured to use 'riscv64-unknown-linux-gnu'. However, this toolchains is for compiling Linux executable files(i.e., for compiling application on top of Linux with libraries support and not for executing on the bare machine, like bootloader). And the use of this toolchains will trigger errors when compiling bbl.
On the other hand, 'riscv64-unknown-elf' toolchains should be the right choice to compile bbl(for the bare machine), which can be found on this comment by @developandplay.

Encountered error when using 'riscv64-unknown-linux-gnu': bbl_error

'riscv64-unknown-elf' is fine with this: bbl

gsomlo commented 2 years ago

In my experience, riscv64-unknown-elf is a subset of riscv64-unknown-linux-gnu. If the former works for you but the latter does not, it's probably because the latter is somehow misconfigured or missing part of its installation. The prebuilt toolchain linked in the README (at http://www.contrib.andrew.cmu.edu/~somlo/BTCP/RISCV-toolchain.tar.xz) has both *-elf and *-linux-gnu, and both work just fine for me. Of course, *-elf is sufficient to build self-contained blobs (e.g., firmware, kernel), and *-linux-gnu is required to build programs linked against glibc, so definitely feel free to restrict yourself to using *-elf whenever that's suitable!

Hope this helps!