U-Boot/Legacy U-Boot

Initially u-boot sunxi port developed by Tom Cubie. Now within sunxi community developed and maintained by Henrik Nordström the u-boot support comes in two branches, one with NAND and android stuff(boot.img, fastboot) support and another with MMC-only ( aka SD ) support, which is more the traditional linux style.

For details see the linux-sunxi u-boot wiki.

= Compile U-Boot = First of all you need a suitable toolchain installed and added to your PATH. Then proceed as follows.

git clone https://github.com/linux-sunxi/u-boot-sunxi.git
 * Clone sunxi version of u-boot git repository:


 * Go to the project directory and execute the build commands. Replace the board name in the third command with the one you are working with. Cubieboard is used in this example. The full list of supported boards is included in the 'u-boot-sunxi/boards.cfg' file you just cloned.

cd u-boot-sunxi make distclean CROSS_COMPILE=arm-linux-gnueabihf- make Cubieboard CROSS_COMPILE=arm-linux-gnueabihf-

Here, "CROSS_COMPILE=arm-linux-gnueabihf-" is the architecture designation which should match your toolchain and "Cubieboard" should be replaced by your board model. See the boards.cfg file for possible board configuration variants.

make Cubieboard CROSS_COMPILE=arm-linux-gnueabihf- is shorthand for make Cubiebaord_config CROSS_COMPILE=arm-linux-gnueabihf- make CROSS_COMPILE=arm-linux-gnueabihf-


 * After finishing you'll find the following compiled files, required for booting:

spl/u-boot-spl.bin u-boot.bin

= Configure U-Boot =

u-boot nand environment
Example u-boot environment from a stock android u-boot environment partition

bootdelay=0 bootcmd=run setargs boot_normal console=ttyS0,115200 nand_root=/dev/nandc mmc_root=/dev/mmcblk0p4 init=/init loglevel=8 setargs=setenv bootargs console=${console} root=${nand_root} init=${init} loglevel=${loglevel} boot_normal=nand read 40007800 boot;boota 40007800 boot_recovery=nand read 40007800 recovery;boota 40007800 boot_fastboot=fastboot

set u-boot environment variable
For setting environment variable in uboot interactive shell, you must not place the '=' sign between variable name and value you want to asign.

setenv root /dev/sda1

But, iff you display environment variable in uboot interactive shell, you will see a '='

root=/dev/sda1

mmc environment
If you do this on an already existing SD-card image you may also want to clear the u-boot environment area, to remove any old settings that may have been saved there and return to the (very reasonable) u-boot defaults:

dd if=/dev/zero of=/dev/sdX bs=1024 seek=544 count=128

= Adding a new device to U-Boot =

dram config
With the output from bootinfo or  a10-meminfo, you can now create a dram file for your device in board/sunxi/ The output from either program trivially applies to a u-boot sunxi dram file.

First, try to match your settings with an existing dram file. There are a lot of generic dram files available for a10, perhaps one of those matches your config. If an existing board config for another device matches yours, then please consider turning this into a generic dram file.

If nothing matches, copy an existing file to a filename relevant for your device and edit the entries manually. Do not forget to git add this new file.

Add dram file to build system
Edit board/sunxi/Makefile to add a line which links your device with the right dram_ object.

Add board to boards.cfg
boards.cfg, in the top level of your u-boot tree, holds all board configurations.

Scroll down until you find the sunxi devices, and create an entry for your device.

Build and run the new u-boot
That's it. You should now be able to compile and  test u-boot. It makes sense to also get a kernel and operating system running to more completely test the u-boot dram settings before committing code.

Commit your work to the git tree and send in the patch
You can now commit your changes, and with: git format-patch -M -C HEAD^

You will create a git mbox patch file which you can mail to our mailinglist. If you have set up git correctly, you can just run: git send-email 0001-*.patch