Create a bootable SD for a Cubietruck

Assuming you have followed the last post you should now have a directory with a Debian armhf root filesystem in. The next stage is to build a bootable SD card image to actually boot your Cubietruck from.

The Allwinner SoC doesn’t have a bios in the way a x86 computer does and the boot process is made up of a number of stages, for full details see the Rhombus Tech website. The parts that we care about are the SPL and u-boot which are written to the SD card 8 blocks in, u-boot then loads a kernel called uImage from the first partition.

I extracted the kernel, modules and firmware from a Linaro image, which is part of the Cubietruck lubuntu tutorial. I did this because Debian doesn’t currently have a working Allwinner kernel and I intended to build a main line kernel anyway. The files I used are listed below.

Name Desc URL
u-boot u-boot with spl download
bootfs uImage, uEnv.txt, script.bin download
rootfs rootfs download

Once you have got the files downloaded you need to put the bootloader on the SD card and transfer the rootfs.

First of all set the directory that the rootfs you have made previously or downloaded.


This is the tar command to exact the modules and firmware, to the correct places in the rootfs directory. This assumes you have downloaded the Linaro rootfs file or my file.

sudo tar xvfz rootfs-part2.tar.gz -C $targetdir lib/modules lib/firmware

Setup modules to autoload at boottime, these modules are for the GPIO pins, the graphics and the wireless+bluetooth adapter. These modules are for the 3.4 sunxi kernel.

cat <<EOT > $targetdir/etc/modules

Now we need to actually put things on the SD card, be careful with dd it can and will wipe your harddisk if you make a mistake. In my case I had an SD card reader so I set things to point at that slot only by using the by-id links from udev. These by-id links which include the serial number which helped to avoid mistakes. The following commands assume you have done the same and are using by-id links.


Blank the first 1MB of the card

dd if=/dev/zero of=${card} bs=1M count=1

Write u-boot and spl to the correct spot on the SD card.

dd if=u-boot-sunxi-with-spl-ct-20131102.bin of=$card bs=1024 seek=8

Build a partition table with 256M of boot space and the rest in a single large partition.

cat <<EOT | sfdisk --force --in-order -uS $card

Format and mount the first partition of the SD card

mkfs.ext2 ${card}-part1
mkdir -p /run/cubietruck-part1
mount  ${card}-part1 /run/cubietruck-part1

Extract the kernel and support files from the Linaro bootfs download

tar -C /run/cubietruck-part1 -xvf bootfs-part1.tar.gz
umount /run/cubietruck-part1
rmdir /run/cubietruck-part1

Finally format the second partition of the SD card and copy over the rootfs you have built

mkfs.ext4 ${card}-part2
mkdir -p /run/cubietruck-part2
mount  ${card}-part2 /run/cubietruck-part2
rsync -avxPHS $targetdir/ /run/cubietruck-part2/

And un-mount the card before ejecting it

umount /run/cubietruck-part1
rmdir /run/cubietruck-part1
eject $card

5 thoughts on “Create a bootable SD for a Cubietruck”

  1. Thanks for this guide, but pleease rewrite this when you are sober again. It’s completely confusing. Can’t make heads or tails of it. Where is the sunxi bootloader, what should I do with your dropbox link. Its completely unecessary with the bootfs/rootfs links you posted.

    echo < $targetdir/etc/modules

    ..this doesn’t work. Only works with cat not echo.
    This is all really confusing.

    1. I’ve re-edited the post, hopefully making it easier to follow. The Dropbox link was to a slightly newer kernel if you wanted it.

      1. Wow, that was fast. Didn’t expect that. Got it working anyway. Except, I can’t get to chroot into the rootfs inside my arch linux system. Always this dreaded, /bin/bash no such file or directory error. Only got it working on my other debian box :/.

        1. Try using: chroot /bin/sh

          Debian uses /bin/sh as the default shell not /bin/bash that arch does.

Comments are closed.