This page describes how to make a A10 bootable SD/MMC CARD under linux/unix.

Build

First you need a spare sd card, backup important data first. Assume your sd card is /dev/sdb in your computer. You can back up all the data on sd card with the following command:

sudo dd if=/dev/sdb of=~/sd_card.backup

To restore it with the fowlling command:

sudo dd if=~/sd_card.backup of=/dev/sdb

Now get all the source code we need and build them.

If you don't have toolchain install first:

sudo apt-get install gcc-4.5-arm-linux-gnueabi #(or 4.4, 4.3)

sudo apt-get install build-essential git

  • u-boot

git clone git://github.com/linux-sunxi/u-boot-sunxi.git u-boot

cd u-boot

The build u-boot for sun4i

make sun4i CROSS_COMPILE=arm-linux-gnueabi-

The file we needed is u-boot.bin and spl/sun4i-spl.bin in u-boot diretory.

  • kernel

beaware that you need mkimage on your system

sudo apt-get install uboot-mkimage

git clone git://github.com/allwinner/linux-2.6.36.git

cd linux-2.6.36

cp arch/arm/configs/sun4i_defconfig .config

make ARCH=arm CROSS_COMPILE=arm-linux-gnueabi- uImage

The uImage is in arch/arm/boot/uImage

Format

Now we need to build a new partition table on this sd card with two partitions, the first one is for the linux kernel, and the second one is for the rootfs. What about u-boot? U-boot is write to the sdcard as raw data before the two partitions.

  • Wipe sdcard partition table.(this will erase everything!!)

sudo dd if=/dev/zero of=/dev/sdb bs=1M count=1

  • Re-format the sdcard.

sudo fdisk /dev/sdb

Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel Building a new DOS disklabel with disk identifier 0x8bf7da7b. Changes will remain in memory only, until you decide to write them. After that, of course, the previous content won't be recoverable.

Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)

Command (m for help):n

Command action e extended p primary partition (1-4)

p

Partition number (1-4, default 1):(press ENTER)

First sector (2048-3948543, default 2048):(press ENTER)

Last sector, +sectors or +size{K,M,G} (2048-3948543, default 3948543): +16M

Command (m for help):n

Command action e extended p primary partition (1-4)

p

Partition number (1-4, default 2):(press ENTER)

Using default value 2

First sector (34816-3948543, default 34816):(press ENTER)

Using default value 34816

Last sector, +sectors or +size{K,M,G} (34816-3948543, default 3948543):(press ENTER)

Using default value 3948543

Command (m for help): w

The partition table has been altered!

Calling ioctl() to re-read partition table.

WARNING: Re-reading the partition table failed with error 16: Device or resource busy.
The kernel still uses the old table. The new table will be used at
the next reboot or after you run partprobe(8) or kpartx(8)
Syncing disks.

  • make file system on the sd card

sudo mkfs.vfat /dev/sdb1

sudo mkfs.ext4 /dev/sdb2

  • write the u-boot.bin and sun4i-spl.bin to the sdcard

sudo dd if=spl/sun4i-spl.bin of=/dev/sdb bs=1024 seek=8

sudo dd if=u-boot.bin of=/dev/sdb bs=1024 seek=32

Done

  • copy the uImage to the sdb1 fat file system and plug the sdcard to A10 sd card slot, u-boot will load the kernel and boots.

Not really done

script.bin also needs to be loaded at 0x43000000 for the kernel to work.

From u-boot console run

setenv kernel uImage
setenv boot_mmc 'fatload mmc 0 0x43000000 script.bin; fatload mmc 0 0x48000000 ${kernel}; bootm 0x48000000'
saveenv

and copy a suitable script.bin to the fat boot partition.

If using the version from hno then the default environment already loads script.bin. In addition it can also loat a boot.scr script from the first partition in either ext2 or fat format. This can be created using mkimage from a plaintext list of commands; see http://www.denx.de/wiki/view/DULG/UBootScripts for details.