Zero/dev/u-boot
Radxa Zero > Development > U-Boot
Contents
Build U-Boot and run it on Radxa Zero
This guide describes how to build U-Boot and run it on Radxa Zero. U-Boot images could be installed into eMMC or Micro SD Card or USB boot.
Requirement
- Radxa Zero
- USB A to C cable
- A PC/laptop running Linux(Ubuntu 18.04 or higher)
Build U-Boot
Step 1: Get the source code
You need Git to get multiple git repositories to build the image.
Install Git if you don't have it.
sudo apt-get update && sudo apt-get install -y git
Install other required packages:
sudo apt install bc nano mc build-essential autoconf libtool cmake pkg-config git python-dev swig libpcre3-dev libnode-dev gawk wget diffstat bison flex device-tree-compiler libncurses5-dev gcc-aarch64-linux-gnu g+±aarch64-linux-gnu binfmt-support qemu-user-static
Clone the source code
git clone -b radxa-zero-v2021.07 https://github.com/radxa/u-boot.git
FIP(Firmware in Package) is a bunch of scripts and prebuilt binaries(first stage loader etc) for Radxa Zero u-boot.
git clone https://github.com/radxa/fip.git
Step 2: Install necessary tools
sudo apt-get install -y gcc-aarch64-linux-gnu device-tree-compiler libncurses5 libncurses5-dev sudo apt-get install -y bc python dosfstools flex build-essential libssl-dev mtools
Get the toolchain
wget https://developer.arm.com/-/media/Files/downloads/gnu-a/10.3-2021.07/binrel/gcc-arm-10.3-2021.07-x86_64-aarch64-none-elf.tar.xz sudo tar xvf gcc-arm-10.3-2021.07-x86_64-aarch64-none-elf.tar.xz -C /opt
Step 3: Build U-boot
export CROSS_COMPILE=/opt/gcc-arm-10.2-2020.11-x86_64-aarch64-none-elf/bin/aarch64-none-elf- export ARCH=arm cd u-boot make radxa-zero_defconfig make
You will have u-boot.bin built.
Step 4: Pack U-boot
cp u-boot.bin ../fip/radxa-zero/bl33.bin cd ../fip/radxa-zero make
This will generate
u-boot.bin u-boot.bin.sd.bin u-boot.bin.usb.bl2 u-boot.bin.usb.tpl
Run U-boot
- Download and run in RAM from USB
Install the maskrom usb download tool with pip
sudo apt install pip3 sudo pip3 install git+https://github.com/superna9999/pyamlboot
Press and hold the USB boot button on the back of Radxa Zero, plug the Zero to PC
$ lsusb Bus 002 Device 030: ID 1b8e:c003 Amlogic, Inc. GX-CHIP
Download and run u-boot.bin
boot-g12.py /path/to/fip/radxa-zero/u-boot.bin
On serial console, you will see the just built u-boot is booting.
- Write the u-boot to Micro SD card and run
bin=/path/to/fip/radxa-zero/u-boot.bin.sd.bin sudo dd if=$bin of=/dev/sdx conv=fsync,notrunc bs=1 count=444 sudo dd if=$bin of=/dev/sdx conv=fsync,notrunc bs=512 skip=1 seek=1
Plug the micro SD card to Zero and boot. If your Zero has eMMC, you can erase it first to make sure it boots from micro SD card.
- Write the u-boot to eMMC
We use fastboot to flash u-boot to eMMC. Unplug the micro SD card of Zero and press&hold the usb boot button, plug the power cable to PC.
sudo apt install fastboot wget https://dl.radxa.com/zero/images/loader/rz-fastboot-loader.bin boot-g12.py rz-fastboot-loader.bin sudo fastboot flash 0x200 /path/to/fip/radxa-zero/u-boot.bin sudo fastboot reboot
unplug and plug USB C cable and new u-boot will boot from eMMC.