Please enable javascript, or click here to visit my ecommerce web site powered by Shopify.
Jump to: navigation, search

Difference between revisions of "Zero/dev/u-boot"

< Zero‎ | dev
Line 103: Line 103:
 
   sudo fastboot flash 0x200 /path/to/'''fip/radxa-zero/u-boot.bin'''
 
   sudo fastboot flash 0x200 /path/to/'''fip/radxa-zero/u-boot.bin'''
 
   sudo fastboot reboot
 
   sudo fastboot reboot
 +
 +
Some forum user also discover a method to [https://forum.radxa.com/t/install-os-direct-to-emmc-with-ubuntu/7435 flash U-Boot with dd] in USB mass storage mode:
 +
 +
wget https://dl.radxa.com/zero/images/loader/u-boot.bin
 +
sudo dd if=u-boot.bin of=/dev/sdx bs=512 seek=1

Revision as of 02:15, 9 December 2021

    Radxa Zero >  Development >  U-Boot

Build U-Boot and flash it on Radxa Zero

This guide describes how to build U-Boot and flash it on Radxa Zero. U-Boot image can be flashed on eMMC or microSD, and it can be sideload from USB as well.

WARNING! Flash bootloader incorrectly could result in unbootable system and loss of data. Do not replace bundled bootloader unless you understand the risk.

Requirement

  • Radxa Zero
  • USB A to C cable
  • A computer running Ubuntu 18.04 or higher

Build U-Boot

Step 1: Get the source code

We use git to fetch source code from internet. If you do not have git installed, try following commands:

   sudo apt update
   sudo apt install git

Once you have git installed, you can download the source code:

   git clone -b radxa-zero-v2021.07 https://github.com/radxa/u-boot.git

FIP(Firmware in Package) is a collection of scripts and pre-built binaries (such as first stage loader and so on) for Radxa Zero U-Boot. Get them with following command:

   git clone https://github.com/radxa/fip.git
Step 2: Set up build environment

Execute following commands to install build dependencies and the tool chain necessary for building.

 sudo apt install bc nano mc build-essential autoconf libtool cmake pkg-config git python python-dev swig libpcre3-dev libnode-dev gawk wget diffstat bison flex device-tree-compiler libncurses5 libncurses5-dev gcc-aarch64-linux-gnu g++-aarch64-linux-gnu binfmt-support qemu-user-static dosfstools libssl-dev mtools
 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 find u-boot.bin under u-boot folder if everything runs without error.

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

  • Sideloading from USB

When your U-Boot is broken you can sideload a working image to recover an unbootable system. This can also be used to verify the newly generated image is working before flashing it permanently on storage media.

Install the maskrom usb download tool with pip

 sudo apt install pip3
 sudo pip3 install pyamlboot

Press and hold the USB boot button on the back of Radxa Zero, and connect Zero to your PC.

You should see following device connected to your system:

 $ lsusb
 Bus 002 Device 030: ID 1b8e:c003 Amlogic, Inc. GX-CHIP

Sideloadng u-boot.bin:

 boot-g12.py /path/to/fip/radxa-zero/u-boot.bin

If you have serial console attached to Radxa Zero, you will see the boot message from U-Boot.

  • Flash U-Boot to microSD
 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

If your Zero has built-in eMMC, we recommend erase it so the microSD's U-Boot will be used.

  • Flash U-Boot to eMMC

We use fastboot to flash U-Boot to eMMC. Unplug microSD card from Zero and press & hold the usb boot button, then connect Zero to your 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

Some forum user also discover a method to flash U-Boot with dd in USB mass storage mode:

wget https://dl.radxa.com/zero/images/loader/u-boot.bin
sudo dd if=u-boot.bin of=/dev/sdx bs=512 seek=1