User:RemDogKap/SandBox/Build U-Boot and OpenSBI From Source
Placeholder intro and explanation, I'm tired don't want to write now, contributions welcome
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
- Must use linux, can use wsl
Preparing the Build Environment
Fist, install the cross-compiler and if not already installed, git.
$ sudo apt update && sudo apt install gcc-riscv64-linux-gnu git
[Optional] Check the version of the riscv64-linux-gnu-gcc
compiler.
$ riscv64-linux-gnu-gcc -v
The output should looks something like:
Using built-in specs. COLLECT_GCC=riscv64-linux-gnu-gcc COLLECT_LTO_WRAPPER=/usr/lib/gcc-cross/riscv64-linux-gnu/10/lto-wrapper Target: riscv64-linux-gnu Configured with: ../src/configure -v --with-pkgversion='Debian 10.2.1-6' --with-bugurl=file:///usr/share/doc/gcc-10/README.Bugs --enable-languages=c,ada,c++,go,d,fortran,objc,obj-c++,m2 --prefix=/usr --with-gcc-major-version-only --program-suffix=-10 --enable-shared --enable-linker-build-id --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --libdir=/usr/lib --enable-nls --with-sysroot=/ --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --with-default-libstdcxx-abi=new --enable-gnu-unique-object --disable-libitm --disable-libsanitizer --disable-libquadmath --disable-libquadmath-support --enable-plugin --enable-default-pie --with-system-zlib --enable-libphobos-checking=release --without-target-system-zlib --enable-multiarch --disable-werror --disable-multilib --with-arch=rv64imafdc --with-abi=lp64d --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=riscv64-linux-gnu --program-prefix=riscv64-linux-gnu- --includedir=/usr/riscv64-linux-gnu/include --with-build-config=bootstrap-lto-lean --enable-link-mutex Thread model: posix Supported LTO compression algorithms: zlib gcc version 10.2.1 20210110 (Debian 10.2.1-6)
Create or enter the directory where the files used in this guide will be stored. This tutorial will be using the Linux home directory.
Home Directory Example
$ cd ~
New Directory Example
$ mkdir ~/Star64-Firmware $ cd ~/Star64-Firmware
U-Boot
Clone the U-Boot GitHub repository. The entire history is not needed (--depth 1
) and we want the Star64 branch (-b Star64
).
$ git clone --depth 1 -b Star64 https://github.com/Fishwaldo/u-boot.git
Enter the U-Boot directory.
$ cd u-boot
Select the U-Boot configuration for the Star64, marking the architecture as RISC-V and using the cross-compiler installed earlier.
$ make pine64_star64_defconfig ARCH=riscv CROSS_COMPILE=riscv64-linux-gnu-
Finally, compile U-Boot.
$ make ARCH=riscv CROSS_COMPILE=riscv64-linux-gnu-
This should create three files.
- The U-Boot binary, later packaged as an OpenSBI payload, located at
/u-boot/u-boot.bin
. - The device tree blob (binary), which contains information on the characteristics of the device and is passed to the operating system instead of hard-coding device configurations into the operating system, and is located at
/u-boot/arch/riscv/dts/pine64_star64.dtb
. - The U-Boot secondary program loader which will later be packaged into the
u-boot-spl.bin.normal.out
file and is located at/u-boot/spl/u-boot-spl.bin
.
==