Skip to main content

U-boot Development

Using bsp

bsp is a set of tools provided by Radxa to quickly build U-Boot Kernels. It is very easy to build your own U-Boot and Kernel using bsp.

The following shows you how to build a kernel with bsp using Radxa ROCK 5B as an example.

bsp environment configuration

The following is the recommended environment for bsp.
Hardware: x86_64 PC recommended
System: Ubuntu or Debian

installs dependencies

sudo apt update
sudo apt install -y git qemu-user-static binfmt-support

# Podman (recommended)

sudo apt install -y podman podman-docker
sudo touch /etc/containers/nodocker

# Docker

# sudo apt install docker.io

# Optional dependencies for minor features

sudo apt install -y systemd-container

Getting the code

bsp uses the git submodule. Therefore, use the following command to get the code:

git clone --recurse-submodules https://github.com/radxa-repo/bsp.git

Understanding bsp usage

Once you have the bsp code on your machine, you can run bsp to see the built-in help:

cd bsp
. /bsp

Build U-Boot

Running ./bsp will show you all the parameters and their explanations, and you can see the command bsp [options] <linux|u-boot> <profile> [product] from the prompt.
Taking Radxa ROCK 5B as an example, the U-Boot profile is "rk2410". The following are profiles for other products:

productprofileproductprofileproductprofileproductprofile
rock-2rk2410radxa-e54crk2410radxa-zerolatestrock-pi-elatest
radxa-e24c-spirk2410radxa-nx5-iork2410radxa-zero-2prolatestrock-4selatest
rock-5-itxrk2410radxa-cm4-rpi-cm4-iork2410radxa-cm3-iolatestrock-pi-4a-pluslatest
rock-5ark2410radxa-cm5-iork2410radxa-cm3-rpi-cm4-iolatestrock-pi-4b-pluslatest
rock-5brk2410radxa-cm5-rpi-cm4-iork2410radxa-cm3-sodimm-iolatestrock-4c-pluslatest
rock-5b-plusrk2410radxa-cm3j-rpi-cm4-iork2410radxa-e23latestrock-pi-4alatest
rock-5crk2410radxa-e25rknextradxa-zero3latestrock-pi-4blatest
rock-5drk2410radxa-cm3i-iorknextrock-3alatestrock-pi-4clatest
rock-5trk2410rock-3blatestrock-4-core-iolatest
rock-5a-spirk2410rock-3clatest
rock-5c-spirk2410rock-pi-n10latest
rock-5d-spirk2410rock-s0latest
radxa-e52crk2410rock-pi-slatest

Then fill in the profile parameter of the bsp command with the product's corresponding profile: rk2410 to pull and configure the code, for example:

./bsp u-boot rk2410 rock-5b --no-build
# `--no-build` only configure the code without compile

The path to the U-Boot source code is located in .src/u-boot in the bsp directory, and the U-Boot can be built again after modifying the kernel source code:

cd bsp
./bsp --no-prepare-source u-boot rk2410 rock-5b -r 999
# Parameter description:
# `--no-prepare-source` # This parameter is not needed for first time compilation, it is added to compile with local modifications, if this parameter is not added, the latest code will be synchronized from the Radxa kernel repository and overwrite the local modifications.
# `-r 999` # Specify the kernel version as 999 for priority use.

After compilation, many deb packages will be generated in the current directory, you just need to install the following deb packages.

u-boot-rk2410_2017.09-999_arm64.deb

Copy the above one deb packages to the board and install them with the dpkg command to complete the U-Boot installation.

sudo dpkg -i u-boot-rk2410_2017.09-999_arm64.deb

After the installation is complete, you need to flash U-Boot to the boot media

cd /usr/lib/u-boot/rock-5b/                     # rock-5b 为你当前使用的型号,需要根据实际使用的设备来选择
sudo ./setup.sh update_bootloader /dev/mmcblk1 # /dev/mmcblk1 为你当前使用的启动介质,需要根据实际使用的设备来选择
sudo reboot

After reboot, you can observe the U-Boot boot log to see if U-Boot has been updated successfully.

Compile manually

tip

bsp is the only compilation method currently being maintained, and it makes additional changes to the source code when compiling. If you want to build on our official releases, you should at least use bsp to download and configure the code.

If you want to build with a custom make command, please refer to the Prepare working tree section to configure the code.

Refer to