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.

Below is an example of how to build a U-Boot with bsp, using the Radxa CM3 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


    After configuring the bsp environment, you need to compile U-Boot once before pulling U-Boot code from the repository.  
    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 CM3 as an example, the U-Boot profile is **latest**. The following are profiles for other products:
    |       Model      | profile |
    | :--------------: | :-----: |
    |  Radxa ROCK 5A   | rknext  |
    |  Radxa ROCK 5B   | rknext  |
    |  Radxa ROCK 5C   | rknext  |
    | Radxa ROCK 5 ITX | rknext  |
    |  Radxa ROCK 3A   | latest  |
    |  Radxa ROCK 3B   | latest  |
    |  Radxa ROCK 3C   | latest  |
    |  Radxa CM3 Series| latest  |
    | Radxa CM3I Series| latest  |
    | Radxa ROCK PI S  | latest  |
    Then fill in the profile parameter of the bsp command with the corresponding product profile **latest** e.g. ". /bsp u-boot latest radxa-cm3-io" to build U-Boot.  
    The path to the U-Boot source code is located in ".src/u-boot" in the bsp directory. After modifying the U-Boot source code, you can build U-Boot again:
  

    cd bsp
    . /bsp --no-prepare-source u-boot latest radxa-cm3-io
    Parameter description:
    --no-prepare-source # You don't need to add this parameter for the first time, it is added to compile with local changes, if you don't add this parameter it will synchronize the latest code from the Radxa U-Boot repository and overwrite the local changes.
  

For more information on how to use the bsp parameter, you can run . /bsp.

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


    u-boot-latest_2023.10-1_arm64.deb
  

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


    sudo dpkg -i u-boot-latest_2023.10-1_arm64.deb
  

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


    cd /usr/lib/u-boot/radxa-cm3-io/
    sudo . /setup.sh update_bootloader /dev/mmcblk1 #/dev/mmcblk1 is your current boot media, you need to select it according to the actual device you are using.
    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