U-Boot

Support for sunxi devices is increasingly available from upstream U-Boot. This page describes that support. We have a separate page for the sunxi branch of U-Boot.

= Status =

The current u-boot release (v2014.07) only contains basic sunxi support. The next release (v2014.10) will have a much more functionality.

v2014.07
v2014.07 Release branch
 * sun7i (AKA A20) processors
 * MMC
 * GMAC Ethernet
 * Boards:
 * Cubietech Cubietruck

v2014.10 (git)

 * AHCI (SATA)
 * sun4i (AKA A10) and sun5i (AKA A10s and A13) processors
 * EMAC Ethernet
 * AXP152 and AXP209 power controllers
 * EHCI USB
 * SMP support for sun7i via PSCI.

v2015.01 (sunxi/next development)

 * sun6i (A31) processor support
 * P2WI
 * AXP221
 * sun8i (A23) processor support (no SPL)
 * sun6i/sun8i reset support
 * Boards:
 * Mele M3
 * Olimex A20-OLinuXino-Lime2
 * WITS Colombus Board

In Progress

 * sun8i (A23) SPL
 * RSB
 * AXP223
 * Boards:
 * LeMaker Banana Pi
 * Merrii Hummingbird A31
 * CSQ CS908

= Supported Devices = Beware: some of the above might only be supported in the latest development version.

USB 1.x, USB keyboards
Current U-Boot (2015.04-rc4) has a problem supporting both USB 1.x (OHCI) and USB 2.0 (EHCI) at the same time - the latter includes the SUNXI_EHCI for Allwinner boards. Unfortunately, this also affects many USB HID / keyboard devices which would not be detected properly by U-Boot. The typical message in this case is "cannot reset port N!?", where N is whichever USB port those devices were attached to.

A possible workaround is to place an external USB 2.0 hub between your board and these USB devices.

See: http://lists.denx.de/pipermail/u-boot/2015-January/200162.html.

= Compile U-Boot =

Get a toolchain
If you haven't done so before, get a suitable toolchain installed and added to your PATH.

Clone the repository
For u-boot version v2014.10-rc1 and later:

You can clone the u-boot repository by running: git clone git://git.denx.de/u-boot.git

Determine build target
For u-boot version v2014.10-rc1 and later:

Go to your u-boot tree and search in the directory configs/ for your board, the file name looks like _defconfig. So, Cubieboard2_defconfig for the Cubietech Cubieboard2.

Build
For u-boot version v2014.10-rc1 and later:

When you have determined what  you want to build, configure: make CROSS_COMPILE=arm-linux-gnueabihf- _defconfig

Then just build it: make CROSS_COMPILE=arm-linux-gnueabihf-

Boot
When the build has completed, there will be u-boot-sunxi-with-spl.bin available in your u-boot tree.

For getting these bits loaded onto the hardware, please refer to the respective howto:
 * SD Card
 * USB

For booting from sd with mainline u-boot, the recommended way is:


 * create a file boot.cmd on the first partition (also check Kernel arguments for extra 'bootargs' options):

(If you're wondering why setting bootm_boot_mode might be necessary for older 3.4.x kernels, have a look at the details of PSCI.)


 * convert boot.cmd in boot.scr:

mkimage -C none -A arm -T script -d boot.cmd boot.scr


 * install uboot

dd if=u-boot-sunxi-with-spl.bin of=/dev/sdX bs=1024 seek=8


 * copy uImage (linux kernel) and script.bin (binary representation of FEX) to the first partition

Look at Manual build howto for more details.

Troubleshooting
The sunxi-3.4 kernel may fail to boot with one of the following error messages on the serial console (but this message is not visible on a HDMI monitor or a LCD display!): Error: unrecognized/unsupported machine ID (r1 = 0x10001008). Error: unrecognized/unsupported machine ID (r1 = 0x1000102a). Error: unrecognized/unsupported machine ID (r1 = 0x100010bb). In this case either try to "Enable workarounds for booting old kernels" in u-boot menuconfig or upgrade to a recent stage/sunxi-3.4 kernel.

If upgrading to stage/sunxi-3.4 is not an option (using some old and very much diverged sunxi-3.4 fork is really necessary), then the following patches can be cherry-picked: wget https://github.com/linux-sunxi/linux-sunxi/commit/5052b83aa44dc16d6662d8d9d936166c139ad8c5.patch wget https://github.com/linux-sunxi/linux-sunxi/commit/9a1cd034181af628d4145202289e1993c1687db6.patch wget https://github.com/linux-sunxi/linux-sunxi/commit/c4c4664ed1a2f35e54a33ae4e65f517721ff43b5.patch wget https://github.com/linux-sunxi/linux-sunxi/commit/ade08aa6e5249a9e75a97393e86c250b2bcb3ec8.patch wget https://github.com/linux-sunxi/linux-sunxi/commit/16b25a95327f45a995f6efcf3e9d83a414231af9.patch wget https://github.com/linux-sunxi/linux-sunxi/commit/dea62f21deb177053b84b15a519dff6c74d061d9.patch wget https://github.com/linux-sunxi/linux-sunxi/commit/d47d367036be38c5180632ec8a3ad169a4593a88.patch git am 5052b83aa44dc16d6662d8d9d936166c139ad8c5.patch git am 9a1cd034181af628d4145202289e1993c1687db6.patch git am c4c4664ed1a2f35e54a33ae4e65f517721ff43b5.patch git am ade08aa6e5249a9e75a97393e86c250b2bcb3ec8.patch git am 16b25a95327f45a995f6efcf3e9d83a414231af9.patch git am dea62f21deb177053b84b15a519dff6c74d061d9.patch git am d47d367036be38c5180632ec8a3ad169a4593a88.patch

= Configure U-Boot =

Please refer to our configuring U-Boot howto.

= Adding a new device to upstream U-Boot =

http://lists.denx.de/pipermail/u-boot/2014-December/199351.html

Failsafe DRAM settings, based on standard JEDEC timings
Each device has DRAM settings configured in its defconfig file in the U-Boot "configs" directory (here is an example for the Cubietruck board). The slow failsafe DRAM settings for an A10/A13/A20 device may look like:  +S:CONFIG_DRAM_CLK=360 +S:CONFIG_DRAM_ZQ=123 +S:CONFIG_DRAM_EMR1=4 +S:CONFIG_DRAM_TIMINGS_DDR3_800E_1066G_1333J=y

The settings from the Android firmware
Somewhat better settings can be retrieved by the meminfo tool from the stock Android or GNU/Linux system, provided by the device manufacturer. It still makes sense to test the reliability of the resulting DRAM configuration. Because some vendors are providing poor configuration for ZQ or EMR1, but nevertheless trying to optimistically set the DRAM clock speed too high.

Performance optimized DRAM settings
Tuning DRAM setting for each individual board can provide much better performance than the failsafe defaults. This involves trial and error testing of different settings using a tool until an optimal combination is found. The DRAM Controller page provides links to start researching this topic. This approach will be time consuming, so a satisfactory solution using one of the other approaches may be best to start with.

LCD Settings
There is a separate wiki page about configuring LCD in U-Boot.

= External links =


 * Our mainline kernel howto.