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
(Created page with "{{zero_header}} {{Languages|zero/dev/u-boot}} Radxa Zero > Development > U-Boot === Build U-Boot and run it on Radxa Zero...")
 
(Run U-boot)
Line 65: Line 65:
 
* Download and run in RAM from USB
 
* Download and run in RAM from USB
  
 +
Install the maskrom usb download tool with pip
 +
 +
  sudo apt install pip3
 
   pip3 install git+https://github.com/superna9999/pyamlboot
 
   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
 
* Write the u-boot to Micro SD card and run
  
   bin='''u-boot.bin.sd.bin'''
+
   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=1 count=444
 
   sudo dd if=$bin of=/dev/sdx conv=fsync,notrunc bs=512 skip=1 seek=1
 
   sudo dd if=$bin of=/dev/sdx conv=fsync,notrunc bs=512 skip=1 seek=1
  
* Write the u-boot to eMMC and run
+
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.
 +
 
 +
  wget https://dl.radxa.com/zero/images/loader/rz-fastboot-loader.bin
 +
  boot-g12.py rz-fastboot-loader.bin
 +
  fastboot flash 0x200 /path/to/fip/radxa-zero/u-boot.bin
 +
  fastboot reboot
  
  /path/to/fip/radxa-zero/u-boot.bin
+
unplug and plug USB C cable and new u-boot will boot from eMMC.

Revision as of 07:17, 9 September 2021

    Radxa Zero >  Development >  U-Boot

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

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
 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.

 wget https://dl.radxa.com/zero/images/loader/rz-fastboot-loader.bin
 boot-g12.py rz-fastboot-loader.bin
 fastboot flash 0x200 /path/to/fip/radxa-zero/u-boot.bin
 fastboot reboot

unplug and plug USB C cable and new u-boot will boot from eMMC.