This document describes how to build ATF, UEFI for HiKey960 from source.
Note: at the time of this writing, ATF and UEFI for HiKey960 are not officially released yet. Please use with caution.
- Code Locations
-
ARM Trusted Firmware: link
-
edk2: link
-
OpenPlatformPkg: link
-
l-loader: link
-
atf-fastboot: (only for HiKey) link
- Build Procedure
-
Fetch all the above repositories into local host. Make all the repositories in the same ${BUILD_PATH}.
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://github.com/96boards-hikey/atf-fastboot
-
Create the symbol link to OpenPlatformPkg in edk2.
$cd ${BUILD_PATH}/edk2
$ln -sf ../OpenPlatformPkg
-
Prepare AARCH64 toolchain from Linaro. link
-
If your hikey960 hardware is v1, update uefi-tools/platform.config first. (optional)
Uncomment the below sentence. Otherwise, UEFI can't output messages on serial console on hikey960 v1.
BUILDFLAGS=-DSERIAL_BASE=0xFDF05000
If your hikey960 hardware is v2 or newer, nothing to do. -
Build it as debug/release mode with l-loader.sh script file. Setup your choice on debug or release mode in the script. Set your toolchain path in the script.
export LOADER_DIR=${BUILD_PATH}/l-loader
cd ${LOADER_DIR}
# Build UEFI & ARM Trust Firmware
bash ./l-loader.sh hikey960
All images including partition table are generated in l-loader directory.
- Setup Console
-
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
-
Open the console.
$telnet localhost 2004
And you could open the console remotely, too.
- Boot UEFI in recovery mode
-
Fetch that are used in recovery mode. They're generated in l-loader directory according to the steps above.
-
Prepare config file.
$vi config
# The content of config file
./hisi-sec_usb_xloader.img 0x00020000
./hisi-sec_uce_boot.img 0x6A908000
./recovery.bin 0x1AC00000
-
Remove the modemmanager package. This package may causes hikey_idt tool failure.
$sudo apt-get purge modemmanager
-
Run the command to download l-loader.bin into HiKey960.
$sudo ./hikey_idt -c config -p /dev/ttyUSB1
-
UEFI running in recovery mode.
When prompt '.' is displayed on console, press hotkey 'f' in keyboard. Then Android fastboot app is running.
The timeout of prompt '.' is 10 seconds. -
Update images.
$sudo fastboot flash ptable prm_ptable.img
$sudo fastboot flash xloader hisi-sec_xloader.img
$sudo fastboot flash fastboot l-loader.bin
$sudo fastboot flash fip fip.bin
$sudo fastboot flash boot boot.img
$sudo fastboot flash cache cache.img
$sudo fastboot flash system system.img
$sudo fastboot flash userdata userdata.img
-
Notice: UEFI could also boot kernel in recovery mode, but BL31 isn't loaded in recovery mode.
- Boot UEFI in normal mode
-
Hotkey in UEFI
When prompt '.' is displayed on console, user could input hotkey from keyboard.
If hotkey 'f' is pressed, run AndroidFastbootApp.
If hotkey Enter is pressed, load abootimg (android kernel) from UFS by AndroidBootApp.
If hotkey Esc is pressed, load boot manager menu. The menu can't display well on minicom. So recommend to use telnet instead. -
Exit from AndroidFastbootApp.
If hotkey Space or Enter is pressed, exit AndroidFastbootApp and load abootimg (android kernel) from UFS by AndroidBootApp. -
Operation in boot manager menu. (optional)
A window is displayed in console.
- Select "Android Fastboot" entry to run fastboot protocol.
- Select "Android Boot" entry to boot android kernel from UFS device. If it's flushed already.
- Build Android kernel image
- Both raw kernel and gzipped kernel are supported now. But DTB must be appended on kernel image to generate abootimg.
The script file cc in l-loader git repository describes how to build an abootimg on HiKey960 for UEFI.
- Miscellaneous
-
Generate new random serial number.
$fastboot oem serialno -
HiKey Support.
The build process of HiKey platform isn't listed in this document. Please refer the reference build script file build_uefi.sh in l-loader git repository. This reference build file could build ATF/UEFI for both HiKey and HiKey960 platform.
atf-fastboot git repository is only for HiKey platform. It derives from old ATF on HiKey. It only contains the feature of downloading images and flushing to eMMC. -
Partition table.
The image format of partition table is simplified. The old hisi-ptable.img is discarded. Now both HiKey and HiKey960 use primary partition table image (prm_ptable.img).
The instructions of generating partition table is different between HiKey and HiKey960. Please refer to build_uefi.sh.
- Known Issues
- Fail to run sgdisk when generate partition table.
The patch is also provided in l-loader git repository.
sudo apt-get source gdisk
cd gdisk-1.0.1
patch -p1 < ${l-loader}/0001-sgdisk-force-blocksize-as-4096.patch
make
cp sgdisk ${l-loader}/sgdisk