Bootable SD card

Identify the card
First identify the device of the card and export it as $card.

 export card=/dev/sdX

Cleaning
To be on safe side erase the first part of your SD Card.  dd if=/dev/zero of=$card bs=1M count=1

Bootloader
 dd if=spl/sunxi-spl.bin of=$card bs=1024 seek=8 dd if=u-boot.img of=$card bs=1024 seek=40

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

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

Partitioning
With recent u-boot it's fine to use ext2/ext3 as boot partition, and other filesystems in the root partition too.

With separate boot partition
Traditional layout  sfdisk -R $card cat < mkfs.vfat ${card}1 mkfs.ext4 ${card}2

 cardroot=${card}2

Boot Partition
 mount ${card}1 /mnt/ cp linux-sunxi/arch/arm/boot/uImage /mnt/ cp sunxi-boards/sys_config/a10/script.bin /mnt/ umount /mnt/

Single partition
(experimental)  sfdisk -R $card cat < mkfs.ext4 ${card}1

 cardroot=${card}1

Boot Partition
 mount ${card}1 /mnt/ mkdir /mnt/boot cp linux-sunxi/arch/arm/boot/uImage /mnt/boot cp sunxi-boards/sys_config/a10/script.bin /mnt/boot umount /mnt/

Rootfs
Here this depends on what distribution you want to install. Which partition layout you use does not matter much since the root device is passed to the kernel as argument. You might need tweaks to fstab or other files if your layout does not match what the rootfs expects. As of this writing most available images use two partitions with separate /boot.

Using rootfs tarball
 mount ${cardroot} /mnt/ tar -C /mnt/ -xjpf my-chosen-rootfs.tar.bz2 umount /mnt

The recommended rootfs is ubuntu-alip.

Linaro rootfs
Linaro offers a set of different root filesystems. A retention policy of 30 days applies to Linaro rootfs on snapshot servers. New snapshots can be generated on request. Latest snapshots can be made from sources such as Ubuntu Build Service

In any case, you can get the actual rootfs tarballs here. ALIP is a minimal LXDE based desktop environment which might me useful to most allwinner users.

Using debootstrap - Debian/Ubuntu based distributions
debootstrap>/tt> is an alternative to rootfs tarball as described in the previous section

distro=precise mount ${cardroot} /mnt/ debootstrap --arch=armhf --foreign $distro /mnt/ cp /usr/bin/qemu-arm-static /mnt/usr/bin/ chroot /mnt /debootstrap/debootstrap --second-stage exit
 * 1) feel free to change distro to raring/saucy/.. as appropriate for later Ubuntu version or wheezy for Debian
 * 1) you can add --variant=buildd to install a compiler in your chroot at debootstrap time but using apt is probably faster

cat <<EOT > etc/apt/sources.list deb http://ports.ubuntu.com/ $distro main universe deb-src http://ports.ubuntu.com/ $distro main universe deb http://ports.ubuntu.com/ $distro-security main universe deb-src http://ports.ubuntu.com/ $distro-security main universe deb http://ports.ubuntu.com/ $distro-updates main universe deb-src http://ports.ubuntu.com/ $distro-updates main universe EOT
 * 1) for Ubuntu

cat <<EOT > etc/apt/sources.list deb http://http.debian.net/debian $distro main contrib non-free deb-src http://http.debian.net/debian $distro main contrib non-free deb http://http.debian.net/debian $distro-updates main contrib non-free deb-src http://http.debian.net/debian $distro-updates main contrib non-free deb http://security.debian.org/debian-security $distro/updates main contrib non-free deb-src http://security.debian.org/debian-security $distro/updates main contrib non-free EOT
 * 1) for Debian

cat <<EOT >> etc/fstab none	/tmp	tmpfs	defaults,noatime,mode=1777 0 0 /dev/mmcblk0p1	/boot	vfat defaults 0 0 EOT cp /etc/resolv.conf /mnt/etc chroot /mnt export LANG=C apt-get update cat <<END > /etc/apt/apt.conf.d/71-no-recommends APT::Install-Recommends "0"; APT::Install-Suggests "0"; END apt-get install locales dpkg-reconfigure locales export LANG=en_US.UTF-8 apt-get install nvi ; apt-get remove nano passwd exit rm /mnt/usr/bin/qemu-arm-static /mnt/etc/resolv.conf echo something > /mnt/etc/hostname echo T0:2345:respawn:/sbin/getty -L ttyS0 115200 vt100 >> etc/inittab umount /mnt
 * 1) if you have a separate boot partition
 * 1) set up 'apt
 * 1) set up locales (Debian) - dpkg scripts tend to complain otherwise
 * 1) Choose en_US.UTF-8 for both prompts, or whatever you want.
 * 1) install your favourite packages here
 * 1) set root password - otherwise you won't be able to log in
 * 1) cleanup
 * 1) ensure hostname has not carried over from your build host
 * 1) enable serial console (Debian/sysvinit way)
 * 1) enable serial console (Ubuntu/upstart way - TBD)

Kernel modules
When you have copied rootfs to your card you might want to copy the kernel modules as well.

=Troubleshooting=


 * re-check that you have written the image correctly Check image checksum if provided. Re-read writing instructions carefully. Try another writing method if available - dd/phoenixsuit/win32-diskimage. Especially writing on Windows tends to cause trouble. If your board is new you can try an image for similar board with the same CPU. Use console cable if you have one to check the boot messages.


 * power off the board completely before booting If you are using a console cable the board may not power off completely. There is a possiblility that self-powered USB peripherials or USB hubs may cause sililar issue. The red power light would get dimmer when the board is off but does not turn off completely. In this case the mmc controller may not get reset properly and the board boots from nand. Power off the board, disconnect all peripherials, and disconnect the serial console cable. Try booting again. You can re-connect your peripherials before booting. This issue does not seem to happen when the kernel powers down the mmc controller properly but is common when the kernel crashes.


 * check for bad micro-SD card contact This is common issue on boards that use micro-SD socket. Try removing and re-inserting the card, cleaning the contacs on the card and dusting off the SD card socket. Some people report that inserting the card together with a piece of paper improves contact and allows booting cards which are too loose in the socket.

= See also =

U-Boot

 * U-Boot

External

 * Additional info on sunxi's flavor of U-Boot