Connect to the uart, e.g. with picocom:
$ picocom -b 115200 /dev/cuaU0
New HiKey boards should already have a UEFI environment. These instructions are only needed if you have an older board, or if a firmware upgrade fails.
This is only used to flash the board, a separate UART is used by UEFI and FreeBSD.
To use the HiKey you will need access to the debug UART. This is located near U11 as can be seen below.
There is no connector on the board so one will need to be soldered to it. Unfortunately it is at 1.8v where most USB to serial adapters operate at 3.3v or 5v.
The pinout is as follows. The RX and TX pins are relative to the board, i.e. TX is where the board transmits.
FTDI adapters will work with a 1.8v input on the TX, however will need a level shifter to shift from 3.3v to 1.8v. The following schematic will allow a 3.3v adapter work with the 1.8v input. It uses a 2N7000 MOSFET and 1k ohm resistor. The drain is connected to the 1.8v output from the UART, the gate is connected to the 3.3v signal from the FDTI, and the source is corrected to the RX pin on the board, with a pulldown resistor to ground.
The following shows it connected. Note below the MOSFET the track is cut so the source and drain are not shorted together. The red wire on the left provides the 1.8v to the drain.
You will need the android fastboot utility, this is available in the android-tools-fastboot package.
pkg install android-tools-fastboot
You will also need the serial loader.
And the files to load onto the board.
fetch https://builds.96boards.org/snapshots/hikey/linaro/uefi/64/l-loader.bin fetch https://builds.96boards.org/snapshots/hikey/linaro/uefi/64/fip.bin fetch https://builds.96boards.org/snapshots/hikey/linaro/uefi/64/ptable-linux.img fetch https://builds.96boards.org/snapshots/hikey/linaro/uefi/64/nvme.img fetch https://builds.96boards.org/snapshots/hikey/linaro/debian/345/boot-fat.uefi.img.gz gunzip boot-fat.uefi.img.gz
Attach pins 2-3 of J15 to boot to the serial loader mode. This lets us flash the board with hisi-idt.py. To use this mode ensure the USB device is not connected, otherwise it won't enter the correct mode.
After powering the board on run the following. Replace /dev/cuaU0 with the name of the serial device used.
python hisi-idt.py -d /dev/cuaU0 --img1=l-loader.bin
This will output something like:
+----------------------+ Serial: /dev/cuaU0 Image1: l-loader.bin Image2: +----------------------+ Sending l-loader.bin ... Done
Attach a USB cable to the USB OTG connector and flash the firmware (the order matters) using android fastboot. Caution: fastboot is a FreeBSD alias for the reboot command, make sure to use the correct binary.
/usr/local/bin/fastboot flash ptable ptable-linux.img /usr/local/bin/fastboot flash fastboot fip.bin /usr/local/bin/fastboot flash nvme nvme.img /usr/local/bin/fastboot flash boot boot-fat.uefi.img
Power off the board and move the jumper on J15 from pins 3-4 to pins 5-6. This will tell UEFI to boot to boot to the fastboot mode, allowing us to exit to the UEFI menu.