-
Notifications
You must be signed in to change notification settings - Fork 286
Reference Bootloader Hikey
Used to switch from aarch32 to aarch64 and boot. First image to be flashed when in recovery mode.
Tool specific to HiKey, and can be found at https://github.com/96boards/l-loader
As part of the build process, l-loader incorporates bl1.bin
, and binary is named as l-loader.bin
.
Reference implementation of the ARM Trusted Firmware, based on the open source ARM Trusted Firmware project.
Since the changes required for HiKey are not yet upstream, a specific git tree is provided as part of the 96Boards github project, and can be found at https://github.com/96boards/arm-trusted-firmware.
The ARM TF tree is meant to be built together with EDK2, and the binary containing the ARM TF code is bl1.bin
.
EDK2 is a modern, feature-rich, cross-platform firmware development environment for the UEFI and PI specifications.
Since the changes required for HiKey are not yet upstream, a specific git tree is provided as part of the 96Boards github project, and can be found at https://github.com/96boards/edk2.
The binary containing EDK2 is fip.bin
, and flashed with the fastboot identifier.
GRUB is a portable, powerful bootloader, commonly used by desktop and servers.
Since no extra change is required for GRUB2, the Debian package is used as reference.
GRUB2 is provided as an UEFI application, with binary named as grubaa64.efi
(for ARM 64).
Reference implementation of the Fastboot protocol, available as an UEFI application.
Binary file AndroidFastbootApp.efi
.
Latest UEFI snapshot build is published at http://builds.96boards.org/snapshots/reference-platform/uefi/latest/release/hikey/
In order to flash from scratch (recovery mode), download the following files:
- l-loader.bin
- fip.bin
- ptable-linux.img for Debian/CentOS/Fedora
- ptable-aosp.img for Android AOSP
- hisi-idt.py for the HiKey recovery tool
The main difference between Debian and AOSP is the partition table that gets used, so you need to pick the right partition table (ptable*.img) and the right boot image for the distribution you want to use.
For the boot files (from the reference builds):
- boot-fat.uefi.img.gz for Debian
- boot_fat.uefi.img.tar.xz for AOSP
For example, to download the latest UEFI build and Debian boot file:
wget http://builds.96boards.org/snapshots/reference-platform/uefi/latest/release/hikey/l-loader.bin
wget http://builds.96boards.org/snapshots/reference-platform/uefi/latest/release/hikey/fip.bin
wget http://builds.96boards.org/snapshots/reference-platform/uefi/latest/release/hikey/ptable-linux.img
wget https://raw.githubusercontent.com/96boards/burn-boot/master/hisi-idt.py
wget http://builds.96boards.org/snapshots/reference-platform/debian/latest/hikey/boot-fat.uefi.img.gz
gunzip boot-fat.uefi.img.gz
In order to be able to flash all the files listed above, it’s required to boot HiKey in a special mode, called recovery mode.
Steps to booting into recovery mode:
- Turn off the HiKey board
- Make sure pin1-pin2 and pin3-pin4 on J15 are linked (recovery mode)
- Connect HiKey micro-USB to PC with USB cable
- Power the HiKey board
Once powered on in recovery mode, for 90 seconds, a new USB serial interface should show up at your host machine. If you are running Linux as your host, you should see the following at your kernel log:
usb 1-2.1: new full-speed USB device number 46 using xhci_hcd
usb 1-2.1: New USB device found, idVendor=12d1, idProduct=3609
usb 1-2.1: New USB device strings: Mfr=1, Product=4, SerialNumber=0
usb 1-2.1: Product: ㌲㔴㜶㤸
usb 1-2.1: Manufacturer: 䕇䕎䥎
option 1-2.1:1.0: GSM modem (1-port) converter detected
usb 1-2.1: GSM modem (1-port) converter now attached to ttyUSB0
Now the board is ready to be flashed with the HiKey recovery tool (hisi-idt.py). You have 90 seconds to flash l-loader in the next step.
The only binary that is required to be flashed with the HiKey recovery tool is l-loader.bin
. Since l-loader.bin
also implements the fastboot protocol, the remaining components can be easily flashed with fastboot
instead.
In order to flash l-loader, run the following:
sudo python hisi-idt.py --img1=l-loader.bin -d /dev/ttyUSB1
You should get the following output:
+----------------------+
Serial: /dev/ttyUSB0
Image1: l-loader.bin
Image2:
+----------------------+
Sending l-loader.bin ...
Done
Once the flashing is completed, the board will automatically boot into fastboot mode. Once again, in case you are running Linux at your host, you should see the following:
usb 1-2.1: new high-speed USB device number 48 using xhci_hcd
usb 1-2.1: New USB device found, idVendor=18d1, idProduct=d00d
usb 1-2.1: New USB device strings: Mfr=1, Product=2, SerialNumber=3
usb 1-2.1: Product: Android 2.0
usb 1-2.1: Manufacturer: Androi
usb 1-2.1: SerialNumber: 0123456789ABCDEF
Since fastboot is supported by l-loader, to flash the remaining files just use fastboot directly:
sudo fastboot flash ptable ptable-linux.img
sudo fastboot flash fastboot fip.bin
sudo fastboot flash boot boot-fat.uefi.img
Remember to always flash the partition first, unless you already know the partition table that was flashed last.
- Turn off HiKey board
- Remove the jumper of pin3-pin4 on J15
- Turn on HiKey board
In case you want to force UEFI to always load the fastboot application first, make sure that jumper of pin5-pin6 on J15 are connected.
To access the UEFI shell, simply interrupt the boot process after powering up your board (make sure you have UART access), and select the Shell option.
[2] Shell
And to load fastboot from the shell:
bc. Shell> fastboot
Android Fastboot mode – version 0.4. Press any key to quit
If auto boot feature is enabled, a predefined boot entry will be selected by default.
Boot entries:
- Android Fastboot App
- Grub on eMMC
- Grub on SD
By default, the predefined boot entry is 2. If jumper on pin5-6 of J15 is connect, the predefined boot entry is 1.
To change boot order for the case jumper not on pin5-6:
bc. sudo fastboot oem bootdevice [emmc|sd]
By default, auto boot feature is enabled.
To disable auto boot:
sudo fastboot oem autoboot 0
To enable auto boot:
sudo fastboot oem autoboot 1
Generate new serial number:
sudo fastboot oem serialno
By default, random serial number is generated in recovery mode. If user wants to generate new serial number, run the above command when hikey is in recovery mode. Then power off. In the next boot, fastboot will use the new generated serial number for transmission.
- Flashing l-loader.bin to the pseudopartitions is not enabled
- Explaining how to manually create the boot partition, and showing that the device tree file is critical for the boot process
- Describing how to build everything from sources