SDK build howto

Allwinner usually provides device manufacturers with a complete SDK that includes the matching u-boot and kernel sources (with some odd binaries), Android packages, buildroot, build scripts and a matching Linaro toolchain.

Development board vendors share the SDK with hardware owners to customize. This howto assumes you have such an SDK. This document is based on the A23 and A80 SDKs. If you have one for an earlier SoC, some names may vary.

= Warning = This howto is not complete.

= Contents of the SDK = The SDK is split into several parts, but the build scripts requires them to be complete.


 * android-4.4
 * lichee
 * build.sh -- main build script
 * buildroot -- rootfs, toolchain, and build scripts
 * linux-3.4 -- linux kernel
 * brandy -- boot related stuff
 * build.sh -- simple build script for u-boot
 * u-boot-2011.09 -- Allwinner's port of u-Boot
 * out</tt> -- build intermediaries and results. toolchain is also in here
 * tools</tt>
 * tools_win</tt> -- LiveSuit/PhoenixSuit tools and drivers
 * pack</tt> -- tools and configuration related to firmware packing
 * chips</tt> -- chip specific files (boot0/u-boot binaries, fex files)
 * common</tt> -- common config files and tools
 * out</tt> -- work directory for firmware packing
 * pack</tt> -- firmware packing script

= Basic Full Build =

Once you have unpacked the SDK (the lichee directory in particular), you can go in a do a straight full build, which results in a LiveSuite image.

Configuring the Build
The SDK can build android or linux flavor images, and may target different boards.

lichee$ ./build.sh config

Welcome to mkscript setup progress All available chips: 0. sun9iw1p1 Choice: 0 All available platforms: 0. android 1. dragonboard 2. linux Choice: 0 All available kernel: 0. linux-3.4 Choice: 0 All available boards: 0. optimus 1. p1  2. perf 3. perf5 4. perf-lpddr3 Choice: 0

Running the Build
Running build.sh will produce binaries and images under out/ /{linux,android}. These will be used to generate the firmware image in the next step.

lichee$ ./build.sh

This will prepare the toolchain (or build buildroot if you're building for Linux), the kernel, and the rootfs (if not Android).

Linux Build Specifics
Building the Linux platform will build the whole buildroot tree. As the buildroot version bundled in the SDK is rather old, errors are bound to happen. Please use an older host toolchain.

Android Build Specifics
(This section requires additional work.) The Android image is built from the android directory in the SDK.

Packing the Image
Run the following command to pack the final LiveSuit image.

lichee$ ./build.sh pack

= Manual Build of Separate Components = The following section explains how to build the various components from the SDK, so you can use them on your system.

boot0
Most SDKs only ship a binary version of boot0. This is a pristine version, and needs to be seeded with information such as the debug UART, DRAM clock rates, NAND/MMC ports. Normally this is done during the packing process. This section goes through the process manually.

The boot0 binary can be found under lichee/tools/pack/chips/CHIP/bin/ Replace CHIP with whatever chip you have.

There are 2 flavors of boot0: 1 for NAND, and 1 for SD/MMC. One will not work with the other, as boot0 loads the next stage bootloader (U-Boot) from the respective supported storage. Also, there is a special boot0 for FEL mode.

The following is a series of commands to properly prepare boot0 for usage.


 * 1) Using sun9iw1p1 A80 Optimus Board as an example
 * 2) Under lichee/tools/pack

cp -fv chips/sun9iw1p1/configs/optimus/sys_config.fex out/sys_config.fex
 * 1) Copy fex file

cp -fv chips/sun9iw1p1/bin/boot0_nand_sun9iw1p1.bin out/boot0_nand.fex cp -fv chips/sun9iw1p1/bin/boot0_sdcard_sun9iw1p1.bin out/boot0_sdcard.fex cp -fv chips/sun9iw1p1/bin/fes1_sun9iw1p1.bin out/fes1.fex
 * 1) Copy boot0

dos2unix out/sys_config.fex
 * 1) Fex file compiler requires fex file in CRLF format

pctools/linux/mod_update/script out/sys_config.fex
 * 1) Compile fex file

pctools/linux/mod_update/update_boot0 out/boot0_sdcard.fex out/sys_config.bin SDMMC_CARD
 * 1) Patch sdcard boot0

pctools/linux/mod_update/update_boot0 out/boot0_nand.fex out/sys_config.bin NAND
 * 1) Patch nand boot0

pctools/linux/mod_update/update_fes1 out/fes1.fex out/sys_config.bin
 * 1) Patch FEL boot0

You can then dd the boot0 image onto an SD card, or load the FEL mode boot0 over usb.

U-Boot
Building U-Boot is fairly straightforward.

First build the U-Boot binary: lichee$ cd brandy/u-boot-2011.09

u-boot-2011.09$ make sun9iw1p1_config # replace sun9iw1p1 with whatever platform you have

u-boot-2011.09$ make [...] arm-linux-gnueabi-objcopy --gap-fill=0xff -O binary u-boot u-boot.bin 'u-boot-sun9iw1p1.bin' -> '../../tools/pack/chips/sun9iw1p1/bin/u-boot-sun9iw1p1.bin'

The last line shows the U-Boot binary being copied to the packing directory. This is because the binary still needs to be seeded with information from the fex file.

The following is an example to manually patch u-boot:


 * 1) Using sun9iw1p1 A80 Optimus Board as an example
 * 2) Under lichee/tools/pack

cp -fv chips/sun9iw1p1/configs/optimus/sys_config.fex out/sys_config.fex
 * 1) Copy fex file

cp -fv chips/sun9iw1p1/bin/u-boot-sun9iw1p1.bin out/u-boot.fex
 * 1) Copy U-Boot

dos2unix out/sys_config.fex
 * 1) Fex file compiler requires fex file in CRLF format

pctools/linux/mod_update/script out/sys_config.fex
 * 1) Compile fex file

pctools/linux/mod_update/update_uboot out/u-boot.fex out/sys_config.bin
 * 1) Patch U-Boot