HiKey(LeMaker version):UART

From BananaPro/Pi
Jump to: navigation, search

Description

In order to debug the HiKey board when we are developing the low-level driver, we need use a UART port on the HiKey. The HiKey board has different UART port, so we need confirm which one we need to use for debugging.
Note: the expansion port I/O pins on the HiKey, including the UART signals, are at 1.8V levels, so please select a 1.8V debug cable for HiKey.
And also do not connect VCC in any situation when you use UART debugging.

Default debug UART port in built HiKey Linux distribution

By default, all the Linaro built HiKey Linux distribution will use the UART3 on the HiKey board as the debug UART for UEFI and kernel.
The UART3 port is on the Low Speed connector of HiKey. In Debian, UART3 will appear as /dev/ttyAMA3 and are configured at 115200 baud by default.
HiKey UART3.png

J1802-01 DGND
J1802-13 UART3_RX
J1802-11 UART3_TX

You have no need to use VCC.

How to change the debug UART from UART3 to other UART port

HiKey also has UART0 on a separate header, and UART2 on the Low Speed Expansion connector. So if we want to use UART0 or UART2 as the debug UART port, we need do some change in the source code. Below we will use UART2 as example to teach how to change the debug UART.
UART0 UART2

J801-01 1.8V
J801-02 UART0_RX
J803-03 GND
J804-04 UART0_TX

Note: If you want to use UART0, please carefully read the sheet above to know every pin function on the UART0. Especially when you want to connect a USB-TO-SERIAL adapter, please do not connect the VCC to the "J801-01 1.8V" pin, this wrong connection will damage your PMU so that the board will not be powered on any more.

Use UART2 as console in kernel

# Update kernel command line in /EFI/BOOT/grub.cfg (linux boot line)
linux ($root)/boot/Image console=tty0 console=ttyAMA2,115200 root=/dev/disk/by-partlabel/system rootwait rw quiet efi=noruntime

Use UART2 as console in ARM Trust Firmware

  1. 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_UART2_BASE CRASH_CONSOLE_BASE=PL011_UART2_BASE
# Rebuild ARM Trust Firmware

For the steps to build UEFI for HiKey, please refer to HiKey(LeMaker_version):Building_Debian_from_Source_Code#Build_UEFI_for_HiKey for the details.

Use UART2 as console in UEFI

# Update SERIAL_BASE in HisiPkg/HiKeyPkg/HiKey.dsc file.
# The base address for UART0 registers is 0xF801_5000.
# The base address for UART2 registers is 0xF711_2000.
# The base address for UART3 registers is 0xF711_3000.
DEFINE SERIAL_BASE = 0xF711_2000
# Rebuild UEFI

For the steps to build UEFI for HiKey, please refer to HiKey(LeMaker_version):Building_Debian_from_Source_Code#Build_UEFI_for_HiKey for the details.

Where to buy the UART debug cable or expansion board

We can now select one from here .