-
Notifications
You must be signed in to change notification settings - Fork 286
HiKeyUEFI
NOTE: Throughout this document, when you see Jumper pin1-6 on J15, it refers to original HiKey boards built by CircuitCoR. If the board you have is built by LEMAKERR, then read these as "Jumper pin1-6 on J601"
The following binaries are required:
- l-loader.bin - used to switch from aarch32 to aarch64 and boot
- fip.bin - firmware package
- ptable-aosp-[4g|8g].img or ptable-linux-[4g|8g].img - partition tables for respectively AOSP images or Linux images
- kernel and dtb images - included in the boot partition
Latest UEFI snapshot builds are published here. Download the following files:
Note: Latest UEFI release build is published here, and you can go to this link to get the prebuilt binaries.
Latest Debian snapshot builds are published here. You can pick a boot partition and an eMMC rootfs:
- boot-fat.uefi.img.gz
- hikey-jessie_developer_YYYYMMDD-XXX-4g.emmc.img.gz or hikey-jessie_developer_YYYYMMDD-XXX-8g.emmc.img.gz
Latest Debian release build is published here.
For example, to download the latest UEFI build and Debian build:
wget https://snapshots.linaro.org/96boards/reference-platform/components/uefi-staging/latest/hikey/release/recovery.bin
wget https://snapshots.linaro.org/96boards/reference-platform/components/uefi-staging/latest/hikey/release/l-loader.bin
wget https://snapshots.linaro.org/96boards/reference-platform/components/uefi-staging/latest/hikey/release/fip.bin
wget https://builds.96boards.org/releases/hikey/linaro/uefi-openplatformpkg/latest/ptable-linux.img
wget https://builds.96boards.org/releases/hikey/linaro/debian/latest/boot-fat.uefi.img.gz
wget https://builds.96boards.org/releases/hikey/linaro/debian/latest/hikey-jessie_developer_YYYYMMDD-XXX-4g.emmc.img.gz (or hikey-jessie_developer_YYYYMMDD-XXX-8g.emmc.img.gz)
gunzip *.img.gz
Now skip to the Flash binaries to eMMC section.
The source code is available from:
- l-loader
- ARM Trusted Firmware
- EDK II (UEFI)
- (Optional) [OP-TEE] (https://github.com/OP-TEE/optee_os)
Prerequisites:
- GCC 7.1 - cross-toolchain for Aarch64 available in your PATH. Linaro GCC 7.1-2017.08 is used in the build instructions.
- GCC cross-toolchain for gnueabihf available in your PATH. Linaro GCC 4.9-2015.02 is used in the build instructions.
- GPT fdisk (gdisk package from your favorite distribution).
git clone https://github.com/ARM-software/arm-trusted-firmware -b integration
git clone https://github.com/96boards-hikey/edk2 -b testing/hikey960_v2.5
git clone https://github.com/96boards-hikey/OpenPlatformPkg -b testing/hikey960_v1.3.4
git clone https://github.com/96boards-hikey/l-loader -b testing/hikey960_v1.2
git clone https://git.linaro.org/uefi/uefi-tools
git clone https://github.com/96boards-hikey/atf-fastboot
git clone https://github.com/OP-TEE/optee_os
Refer to build_uefi.sh in l-loader git repository.
The files fip.bin, l-loader.bin, recovery.bin and ptable-linux.img are now built. All the image files are in $BUILD/l-loader directory.
Install ser2net. Use telnet as the console since UEFI will output window that fails to display in minicom.
$sudo apt-get install ser2net
Configure ser2net.
$sudo vi /etc/ser2net.conf
Append one line for serial-over-USB in below.
#ser2net.conf
2004:telnet:0:/dev/ttyUSB0:115200 8DATABITS NONE 1STOPBIT banner
Start ser2net
$sudo killall ser2net
$sudo ser2net -u
Open the console.
$telnet localhost 2004
And you could open the console remotely, too.
The flashing process requires to be in recovery mode if user wants to update firmware.
- turn off HiKey board
- connect debug UART on HiKey to PC (used to monitor debug status)
- make sure pin1-pin2 and pin3-pin4 on J15 are linked (recovery mode)
Name | Link | State |
---|---|---|
Auto Power up | Link 1-2 | closed |
Boot Select | Link 3-4 | closed |
GPIO3-1 | Link 5-6 | open |
- remove the modemmanager package.
$sudo apt-get purge modemmanager
- connect HiKey Micro-USB to PC with USB cable
- turn on HiKey board
- on serial console, you should see some debug message (NULL packet)
- run HiKey recovery tool to flash l-loader.bin (Note: if the serial port recorded in hisi-idt.py isn't available, adjust the command line below by manually setting the serial port with "-d /dev/ttyUSBx" where x is usually the last serial port reported by "dmesg" command)
$ sudo python hisi-idt.py -d /dev/ttyUSB1 --img1 recovery.bin
do not reboot yet
- run fastboot commands to flash the images (order must be respected)
$ sudo fastboot flash ptable ptable-linux.img
$ sudo fastboot flash loader l-loader.bin
$ sudo fastboot flash fastboot fip.bin
$ sudo fastboot flash boot boot.img
$ sudo fastboot flash system hikey-jessie_alip_2015MMDD-nnn.emmc.img
- turn off HiKey board
- remove the jumper of pin3-pin4 on J15
Name | Link | State |
---|---|---|
Auto Power up | Link 1-2 | closed |
Boot Select | Link 3-4 | open |
GPIO3-1 | Link 5-6 | open |
- turn on HiKey board
- When prompt '.' is displayed on console, user could input hotkey from serial console. a. If hotkey 'f' is pressed, run fastboot mode. b. If hotkey 'Enter' is pressed, load kernel or GRUB from storage device. c. If hotkey 'Esc' is pressed, load boot manager menu. The menu can't be displayed well on minicom, So recommend to use telnet instead.
- make sure that jumper of pin5-pin6 on J15 are connected
Name | Link | State |
---|---|---|
Auto Power up | Link 1-2 | closed |
Boot Select | Link 3-4 | open |
GPIO3-1 | Link 5-6 | closed |
- fastboot configuration in host
sudo apt-get install android-tools-fastboot
- host use:
$ sudo fastboot flash ptable ptable-linux.img
$ sudo fastboot flash fastboot fip.bin
$ sudo fastboot flash boot boot-fat.uefi.img
$ sudo fastboot flash system system.img
$ sudo fastboot flash cache cache.img
$ sudo fastboot flash userdata userdata.img
# l-loader.bin should be flashed in recovery mode only
- Run Fastboot automatically:
Connect jumper on pin5-6 of J15. Then UEFI will run Fastboot app directly.
Name | Link | State |
---|---|---|
Auto Power up | Link 1-2 | closed |
Boot Select | Link 3-4 | open |
GPIO3-1 | Link 5-6 | closed |
If user input "enter" key directly, bootmenu will be displayed.
HiKey supports booting from both eMMC and microSD card.
- make sure pin1-pin2 and pin3-pin4 on J15 are linked (recovery mode)
Name | Link | State |
---|---|---|
Auto Power up | Link 1-2 | closed |
Boot Select | Link 3-4 | closed |
GPIO3-1 | Link 5-6 | open |
- Generate new serial number
# In recovery mode, we need to input this command to run initial program with fastboot protocol.
$sudo python hisi-idt.py --img1=recovery.bin
# Change serial number by custom fastboot command.
$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 time, fastboot will use the new generated serial number for transmission.
- Set specified serial number
$sudo fastboot oem serialno set {serialno string, 16 characters long}
- Operate user led
$sudo fastboot oem led1 on
$sudo fastboot oem led1 off
All four leds could be controlled by fastboot command. They are from led1 to led4.
By default, UART3 is used as serial console. There's UART3 port on LS connector on HiKey. If user wants to use UART0 instead, he has to change a few things below.
- Use UART0 as console in ARM Trust Firmware
# Update $CROSS_COMPILE in uefi-tools/atf-build.sh
CROSS_COMPILE="$CROSS_COMPILE" make -j$NUM_THREADS PLAT="$ATF_PLATFORM" $SPD_OPTION DEBUG=$DEBUG CONSOLE=PL011_UART0_BASE CRASH_CONSOLE_BASE=PL011_UART0_BASE
# Rebuild ARM Trust Firmware
- Use UART0 as console in OP-TEE
# Rerun make with CFG_CONSOLE_UART=0 option
- Use UART0 as console in UEFI
# Update SERIAL_BASE in HisiPkg/HiKeyPkg/HiKey.dsc file.
DEFINE SERIAL_BASE = 0xF8015000
# Rebuild UEFI
- Use UART0 as console in kernel
# Update kernel command line in grub.cfg
linux ($root)/boot/Image console=tty0 console=ttyAMA0,115200 console=ttyAMA3,115200 root=/dev/disk/by-partlabel/system rootwait rw quiet efi=noruntime
# Don't need to build kernel again.
- flashing l-loader.bin to the pseudopartitions is not enabled