During last couple of months I see quite big interest in building products on A20 SoC. This chip can be bought for 6USD in quantity. Most important features are:

  • Dual-Core ARM Cortex-A7 (ARMv7)
  • Mali-400 MP2
  • HDMI, VGA and LCD
  • MMC and NAND
  • OTG and 2 Host ports

Tracking media related to low-end mobile market IMHO the hottest SoCs are Allwinner A20 and Rockchip RK3288.

A20 ship with dozen development boards like Cubieboard or pcDuino series, Banana Pi, MarsBoard or Hummingbird. About a year ago I choose to buy Cubietruck and this led to couple interesting projects from porting USBSniffer to writing bare-metal bootloader based on U-boot code. Below setup is not complicated but contain many pieces and looking for correct procedure for each one is headache. Especially I felt that when I did it once couple months ago and was not able to recover my setup without over a day of googling. Because I of that I decided to write this post and leave notes for me and others who want bootstrap Cubietruck setup.

Some configs and scripts can be found on github repo.

ct-dev

Table of contents

Prerequisites

  • Linux development workstation (I use Debian stretch/sid)
  • USB to TTL serial adapter – best would be with original FT232RL, but Chinese substitutes also works
  • microSD card
  • Ethernet cable – to connect your CT to router
  • good power supply 5V/2.5A – USB should also work when taking care about power budget of whole setup
  • HDMI or VGA monitor – nice to have

General approach

Bootloader (U-Boot) obtain IP address dynamically then using hard coded information about TFTP server it downloads script which contain instruction about next steps. Usually next steps include downloading kernel over TFTP and passing to it parameter indicating that rootfs should be mounted over NFS and pointing to server location.

Because different U-Boot scripts are required for sunxi-3.4 and mainline kernel I toggle config on tftp server.

Below I put together various pieces spread across network to have it in one place.

Quick TFTP setup

To check if TFTP listen:

It would be useful to have separate directory if in future setup will be enhanced for other boards:

Quick NFS setup

Add line like this:

Create direcrtory for root filesystems:

Restart NFS:

Toolchain

I’m using Linaro toolchain based on GCC4.9 you can download package here.

To verify this step you can try:

U-Boot (2015.10-rc2)

To boot sunxi-3.4 setting ARM architecture -> Enable workarounds for booting old kernels is required.

Log like this:

means that you incorrectly set toolchain.

Linux kernel

sunxi-3.4 kernel

Ethernet driver have to be built-in, because when included as module do not start early enough to mount rootfs over NFS.

script.bin

To generate MAC you can use this tool or you can give your Cubietruck MAC if you know it. One way to figure it out is flash only U-boot and run

To generate script.bin:

Mainline kernel (sunxi-next 387a2c191af6 4.2.0-rc4)

Rootfs

Based on Olimex guide.

In this place I prefer to use en_US.UTF-8 as a lingua franca of Linux world. Next we will install couple of tools that are almost always useful.

At this point it is good to make a backup copy. Time consuming but with very small output:

Let’s put it all together

Prepare SD card

Assuming your SD card is on /dev/sdc

Partitioning:

Flash U-Boot image:

Format and mount boot partition:

Below script add flexibility to booting process by allowing user to replace on server boot.scr. This makes Cubietruck able to dual boot sunxi-3.4 and mainline kernel. Please replace <my_tftp_server_ip> with your TFTP address.

Make U-Boot readable image:

Now you can put your SD card into Cubietruck.

Prepare NFS and TFTP content

Copy kernel and files required to boot:

Copy filesystem to NFS server directory:

Copy modules:

Create U-Boot scripts for sunxi and mainline

Sunxi script will look like this:

Make U-Boot readable image:

Mainline script will look like this:

Make U-Boot readable image:

Known issues

TFTP error: ‘Unsupported option(s) requested’ (8)

This problem was discussed here. You can fix it by changing TFTP TIMEOUT:

Recompile U-boot and flash it on SD card again.

Summary

You can boot to sunxi-3.4 kernel by simply:

And switch to mainline kernel using:

Hopefully above shell history drop is readable for you, most of above content can be googled – I just needed place to store notes from scratchpad. If you hit some problems do not bother to ask in comments. If you like this post or think it can be helpful for others please share.

Thanks for reading.