Using Reference Boards

You can create builds for Nexus and Pixel devices using Android Open Source Project (AOSP) builds and the relevant hardware-specific binaries. For available Android builds and targeted devices, see Source code tags and builds.

You can also create builds for HiKey Android reference boards, which are designed to help non-mobile component vendors develop and port drivers to Android releases. Using a reference board can ease upgrade efforts, reduce time to market for new Android devices, lower device costs by enabling ODM/OEMs to choose from a wider range of compatible components, and increase the speed of innovation among component suppliers.

Google supports HiKey960 and 96Boards-certified HiKey boards as Android reference boards. AOSP provides kernel source and board support for HiKey, so developers can easily create and debug peripheral drivers, do kernel development, and perform other tasks with fewer OEM encumbrances. To develop new ContextHub features that use new sensors or LEDs, you can also use a NeonKey sensor hub connected to a HiKey or HiKey960 development board.

HiKey960 boards

The HiKey960 board is available from Amazon and Lenovator.

HiKey960 board image
Figure 1. HiKey960 board by Lenovator

Compiling userspace

Use the following commands to download and build Android on the HiKey960 board.

  1. Download the Android source tree:
    repo init -u https://android.googlesource.com/platform/manifest -b master
    repo sync -j24
    
  2. Build:
    . ./build/envsetup.sh
    lunch hikey960-userdebug
    make -j32
    

Installing initial images

  1. Select fastboot mode by turning ON switch 3 (for details, refer to the HiKey960 Getting Started guide).
  2. Power the board.
  3. Flash initial images:
    cd device/linaro/hikey/installer/hikey960
    ./flash-all.sh
    
  4. Turn OFF switch 3 and power cycle the board.

Flashing images

  1. Enter fastboot mode by turning ON switch 3.
  2. Flash images by running the following commands:
    fastboot flash boot out/target/product/hikey960/boot.img
    fastboot flash dts out/target/product/hikey960/dt.img
    fastboot flash system out/target/product/hikey960/system.img
    fastboot flash vendor out/target/product/hikey960/vendor.img
    fastboot flash cache out/target/product/hikey960/cache.img
    fastboot flash userdata out/target/product/hikey960/userdata.img
    
  3. Turn OFF switch 3 and power cycle the board.

Building the kernel

  1. Run the following commands:
    git clone https://android.googlesource.com/kernel/hikey-linaro
    cd hikey-linaro
    git checkout -b android-hikey-linaro-4.9 origin/android-hikey-linaro-4.9
    make ARCH=arm64 hikey960_defconfig
    make ARCH=arm64 CROSS_COMPILE=aarch64-linux-android- -j24
    
  2. Update the kernel in the boot image.
    • Copy hi3660-hikey960.dtb (arch/arm64/boot/dts/hisilicon/hi3660-hikey960.dtb) to the hikey-kernel directory as file: hi3660-hikey960.dtb-4.9
    • Copy the Image file (arch/arm64/boot/Image.gz-dtb) to the hikey-kernel directory as file: Image.gz-dtb-hikey960-4.9
  3. Make the boot image:
    make bootimage -j24
    

Setting the serial number

To set the random serial number, run:

fastboot getvar nve:SN@16_DIGIT_NUMBER

Bootloader exports the generated serial number to the kernel via androidboot.serialno=.

Setting monitor resolution

Edit the device/linaro/hikey/hikey960/BoardConfig.mk parameter BOARD_KERNEL_CMDLINE and configure the video setting. For example, the setting for a 24-inch monitor is video=HDMI-A-1:1280x800@60.

HiKey boards

The HiKey board (also known as HiKey620) is available in 1 GB RAM and 2 GB RAM configurations from Lenovator.

HiKey620 board image
Figure 2. HiKey board by Lenovator

Compiling userspace

Use the following commands to download and build Android on the HiKey board.

  1. Download the Android source tree:
    repo init -u https://android.googlesource.com/platform/manifest -b master
    repo sync -j24
    
  2. Install mcopy utility:
    apt-get install mtools
    
  3. Build:
    . ./build/envsetup.sh
    lunch hikey-userdebug
    make -j32
    

Note: For 4 GB eMMC use $ make -j32 TARGET_USERDATAIMAGE_4GB=true instead of $ make -j32.

Installing initial fastboot and PTable

  1. Select special bootloader mode by linking the J15 1-2 and 3-4 pins.
  2. Connect USB to PC to get ttyUSB device (for example, /dev/ttyUSB1).
  3. Power the board:
    cd device/linaro/hikey/installer/hikey
    ./flash-all.sh /dev/ttyUSB1 [4g]
    
  4. Remove jumper 3-4 and power the board.

Flashing images

  1. Enter fastboot mode by linking the J15 1-2 and 5-6 pins.
  2. Run the following commands:
    fastboot flash ptable device/linaro/hikey/installer/hikey/ptable-aosp-8g.img
    fastboot reboot-bootloader
    fastboot flash boot out/target/product/hikey/boot.img
    fastboot flash vendor out/target/product/hikey/vendor.img
    fastboot flash -w system out/target/product/hikey/system.img
    
  3. Remove jumper 5-6 and power the board.

Building the kernel

  1. Run the following commands:
    git clone https://android.googlesource.com/kernel/hikey-linaro
    cd hikey-linaro
    git checkout -b android-hikey-linaro-4.9 origin/android-hikey-linaro-4.9
    make ARCH=arm64 hikey_defconfig
    make ARCH=arm64 CROSS_COMPILE=aarch64-linux-android- -j24
    
  2. Copy the output to the HiKey kernel directory (/kernel/hikey-linaro):
    • Copy hi6220-hikey.dtb (arch/arm64/boot/dts/hisilicon/hi6220-hikey.dtb) to the hikey-kernel directory as file hi6220-hikey.dtb-4.9.
    • Copy the Image file (arch/arm64/boot/Image.gz-dtb) to the hikey-kernel directory as file Image.gz-dtb-4.9.
  3. Make the boot image:
    make bootimage -j24
    

Setting monitor resolution

Edit the device/linaro/hikey/hikey/BoardConfig.mk parameter BOARD_KERNEL_CMDLINE and configure the video setting. For example, the setting for a 24-inch monitor is video=HDMI-A-1:1280x800@60.

Configuring kernel serial output (UART3)

Set the J2 low-speed expansion connector to 1 - Gnd, 11 - Rx, 13 - Tx.

NeonKey sensor hub

To develop new ContextHub features that use new sensors or LEDs, you can use a NeonKey sensor hub connected to a HiKey or HiKey960 development board.

NeonKey sensor hub image
Figure 3. NeonKey sensor hub

NeonKey is a certified 96Boards mezzanine base on STM32F411CE with the following components:

  • Pressure sensor: BMP280
  • ALS/proximity sensor: RPR-0521RS
  • ARM hall sensor: MRMS501A
  • LED driver with 15 LEDs: LP3943
  • Accel/gyro and geomagnetic sensors: BMI160 and BMM150
  • Temp/humidity sensor: SI7034-A10
  • 4 GPIO-driven LEDs, I2C expansion, GPIO (2 lines) expansion, JTAG connector
  • NOR flash: 512 KB
  • SRAM: 128 KB, 96boards LS expansion connector

Kernel source and ContextHub board support is available in AOSP to decrease OEM encumbrances to help developers do things like create and debug new sensors and make new HAL and kernel changes.

To build, enable, and upload NeonKey:

  1. Pull AOSP source:
    repo init -u https://android.googlesource.com/platform/manifest -b master & repo sync -j24
    
  2. Build:
    . ./build/envsetup.sh
    lunch hikey-userdebug
    . device/google/contexthub/firmware/toolchain-setup.sh
    make -C device/google/contexthub/firmware/variant/neonkey
    adb push device/google/contexthub/firmware/out/nanohub/neonkey/full.bin /data/local/tmp
    
  3. To enable NeonKey, enter boot mode using the following method:
    1. Connect BOOT0 to 1V8 (link JTAG P4 1-5 pins).
    2. Hold the USR button.
    3. Push the RST button.
  4. To upload the firmware:
    adb root
    adb shell stm32_flash -u -d /dev/ttyAMA2 -e 0xffff -w /data/local/tmp/full.bin
    
  5. To build userspace HAL:
    make TARGET_SENSOR_MEZZANINE=neonkey -j24
    fastboot flashall