Skip to content
Daniel Griscom edited this page Oct 11, 2018 · 71 revisions

u-boot for Allwinner sunxi series of SoCs (A10, A13, A10s, and A20)

linux-sunxi u-boot is fully SPL enabled which means it supports booting directly on the bare metal with no help from the Allwinner bootloaders. U-Boot SPL fully replaces Allwinner boot0 & boot1.

Branch information:

sunxi Main branch, tracks upstream u-boot master. Supports A10, A13, A10s and A20.

lichee-dev NAND capable replacement for Allwinner A10 u-boot

lichee-dev-a20 NAND capable replacement for Allwinner A20 u-boot

lichee/ Unmodified mirrors of original Allwinner sources

Tags/Releases

v2013.07-sunxi.4 Current release. Functionally equivalent to v2013.07-sunxi, only adding u-boot-sunxi-with-spl.bin build output by default.

v2013.07-sunxi.3 Broken release. See v2013.07-sunxi.4.

v2013.07-sunxi.2 Old release. Functionally equivalent to v2013.07-sunxi, only adding u-boot.img build output by default.

v2013.07-sunxi Old release.

v2013.04-sunxi Old release.

v2013.01-sunxi Old release

v2013.01.01-sunxi Old release

v2012.10-sunxi Old stable release. Board specific SPL to set correct DRAM parameters for the board.

v2011.09-sun4i Old release. SPL support för some 512MB systems, based on original Mele A1000 DRAM settings. Do not properly power the CPU core which may cause system instabilities.

How to compile u-boot

You need a suitable gcc ARM Linux GNUEABI toolchain installed and added to your PATH.

Then compile u-boot for A10 by running

make 'boardtype' CROSS_COMPILE=arm-linux-gnueabihf-

(v2014 release: make 'boardtype'_config CROSS_COMPILE=arm-linux-gnueabihf- )

See boards.cfg for a list of known board types.

As of 2013-10-10 the list contains (in the alphabetic order):

A10_MID_1GB
A10-OLinuXino-Lime
A10s-OLinuXino-M
A10s-OLinuXino-M_FEL
A13-OLinuXino
A13-OLinuXino_FEL
A13-OLinuXino_FEL_sdcon
A13-OLinuXinoM
A13-OLinuXinoM_FEL
A13_MID
A20-OLinuXino_MICRO
A20-OLinuXino_MICRO_FEL
Auxtek-T003
Auxtek-T004
Bananapi
ba10_tv_box
Coby_MID7042
Coby_MID8042
Coby_MID9742
Iteaduino_Plus_A10
Iteaduino_Plus_A20
Colombus
Ippo_q8h
Cubieboard
Cubieboard2
Cubieboard2_FEL
Cubietruck
Cubietruck_FEL
Cubieboard_FEL
DNS_M82
EOMA68_A10
EOMA68_A10_FEL
EOMA68_A20
EOMA68_A20_FEL
EU3000
Gooseberry_A721
H6
Hackberry
HCore_HC860
Hyundai_A7HD
i12-tvbox
Interra-3
INet_86VZ
INet_86VZ_FEL
INet97F-II
INet_K70HC
Jesurun-Q5
K1001L1C
Linksprite_pcDuino3
Marsboard_A10
Marsboard_A20
Marsboard_A20_debug
Megafeis_A08
Mele_A1000
Mele_A1000_FEL
Mele_A1000G
Mele_A3700
Merrii_Hummingbird_A20
merrii_m2
Mini-X
Mini-X-1Gb
Mini-X_A10s
mk802
mk802-1gb
mk802_a10s
mk802ii_A20
mk802ii
mk808c_A20
pcDuino
pengpod1000
pengpod700
PoV_ProTab2_IPS9
PoV_ProTab2_IPS_3g
PoV_ProTab2_XXL
r7-tv-dongle
Sanei_N90
sun4i
sun4i_sdcon
sun5i
sun5i_sdcon
sun5i_uart1
uhost_u1a
Wexler_TAB_7200
wobo-i5
xzpad700
zatab

If your board is not listed then see "Adding a new board" below

Board names ending with _FEL are configured for USB-Booting.

To build natively on ARM hard-float systems you may need to install soft-float GCC libraries. On Ubuntu ARM and the like install gcc-multilib package to get these. This is due to an u-boot upstream decision to always build u-boot soft-float on ARM.

How to make a bootable sunxi SD-card

A10 & A13 boots the SPL loader from block 8. This then loads actual u-boot from block 40 onwards, counted in 1KB blocks. Replace /dev/sdX with the device name of your media

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

or if you prefer to install the components separately

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

If using v2013.07 or earlier then the procedure is slightly different

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

Remember to leave sufficient space for all u-boot files when partitioning the card. Recommended to have first partition start at sector 2048 (1MB), or much higher if using Falcon boot mode. See Storage Map section below for details.

uEnv.txt support

This version of u-boot support uEnv.txt, and will look for it in the first partition FAT /uEnv.txt or extX /uEnv.txt or extX /boot/uEnv.txt. uEnv.txt contains variables on the form variable=value, one per line. If the variable uenvcmd is set then u-boot will run the commands listed in this variable.

boot.scr support

This version of u-boot supports boot.scr, and will look for it in the first partition FAT /boot.scr or extX /boot.scr or extX /boot/boot.scr. boot.scr contains your needed uboot commands for loading script.bin, kernel. initrd (optional), setting kernel parameters and booting.

To create boot.scr first make a u-boot script boot.cmd with the u-boot commands you need for booting your system. An example follows:

setenv bootargs console=ttyS0 root=/dev/mmcblk0p1 rootwait panic=10 ${extra}
ext2load mmc 0 0x43000000 boot/script.bin
ext2load mmc 0 0x48000000 boot/uImage
bootm 0x48000000

Then translate this to a boot.scr by using the mkimage command

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

Default boot action

If no boot.scr is found then it will fall back to load script.bin & kernel uImage from the first partition in FAT format

fatload mmc 0 0x43000000 script.bin && fatload mmc 0 0x48000000 ${kernel} && watchdog 0 && bootm 0x48000000

Adding a new board

To add a new board to u-boot you need to collect some information about your board. The most reliable source of this information is to inspect the boot1 file header. Unfortunately it's not entirely trivial how to reach that.

If you have UART console with access to u-boot loaded from NAND then you can dump the boot1 file header by running

md.b 0x42400000 0x2084

send the resulting output to me ([email protected]) together with a copy of your script.bin and the name of your board.

Usually you can easily extract script.bin by holding down the key '2' on the console while booting and then connect to the device with USB cable. On most A1x devices the boot partition then shows up as a removable USB device.

If you have console access but your u-boot do not allow you to halt the boot procedure then you can try replacing uboot.bin with the generic sun4i(A10) or sun5i(A13) versions to exract the information.

If you don't have console access to u-boot but have a SD breakout board then you can push the generic sun4i_sdcon(A10) or sun5i_sdcon(A13) versions to enable u-boot console on the SD breakout board.

Be warned that you may need to livesuit the device to restore NAND u-boot version to boot the Android from NAND again.

Watchdog support

The watchdog command can be used to set a watchdog timeout. A timeout of 0 disables the watchdog. The watchdog have an upper limit of approximately 20 seconds.

You can enable automatic watchdog support by building with CONFIG_WATCHDOG enabled. This makes the watchdog armed by default. Be warned that If the kernel is not up and running and poking the watchdog within the watchdog timeout (approximately 20 seconds) then the watchdog will automatically reboot the system.

Default environment

baudrate=115200
scriptaddr=0x44000000
bootscr=boot.scr
bootenv=uEnv.txt
loadbootscr=fatload mmc 0 ${scriptaddr} ${bootscr} || ext2load mmc 0 ${scriptaddr} ${bootscr} || ext2load mmc 0 ${scriptaddr} boot/${bootscr}
loadbootenv=fatload mmc 0 ${scriptaddr} ${bootenv} || ext2load mmc 0 ${scriptaddr} ${bootenv} || ext2load mmc 0 ${scriptaddr} boot/${bootenv}
boot_mmc=fatload mmc 0 0x43000000 script.bin && fatload mmc 0 0x48000000 ${kernel} && watchdog 0 && bootm 0x48000000
bootcmd=if run loadbootenv; then \
                echo Loaded environment from ${bootenv}; \
                env import -t ${scriptaddr} ${filesize}; \
        fi; \
        if test -n ${uenvcmd}; then \
                echo Running uenvcmd ...; \
                run uenvcmd; \
        fi; \
        if run loadbootscr; then \
                echo Jumping to ${bootscr}; \
                source ${scriptaddr}; \
        fi; \
        run setargs boot_mmc;
bootdelay=3                                                                           
console=ttyS0,115200                                                                  
kernel=uImage                                                                         
loglevel=8                                                                            
panicarg=panic=10                                                                     
root=/dev/mmcblk0p2
setargs=setenv bootargs console=${console} root=${root} loglevel=${loglevel} ${panicarg} ${extraargs}
stderr=serial                                                                         
stdin=serial                                                                          
stdout=serial 

Storage map

How the SD-Card is used by u-boot-mmc, counted in 512B sectors / 1KB blocks:

sector start size
   0      0   8KB Unused, available for partition table etc.
  16      8  32KB Initial SPL loader
  80     40 504KB u-boot  (sector 64 / 32KB for 2013.07 and earlier)
1088    544 128KB environment
1344    672 128KB Falcon mode boot params
1600    800  ---- Falcon mode kernel start
2048   1024     - Free for partitions (higher if using Falcon boot)