Source
# mkCubieCard.sh v0.1:
# 2013, Carlo Caione <carlo.caione@gmail.com>
# heavely based on :
# mkA10card.sh v0.1
# 2012, Jason Plum <jplum@archlinuxarm.org>
# loosely based on :
# mkcard.sh v0.5
# (c) Copyright 2009 Graeme Gregory <dp@xora.org.uk>
# Licensed under terms of GPLv2
#
# Parts of the procudure base on the work of Denys Dmytriyenko
# http://wiki.omap.com/index.php/MMC_Boot_Format
IMAGES_DIR=$1
SPL_IMG=$IMAGES_DIR/sunxi-spl.bin
SPL_UBOOT=$IMAGES_DIR/u-boot-sunxi-with-spl.bin
UBOOT_IMG=$IMAGES_DIR/u-boot.bin
UIMAGE=$IMAGES_DIR/uImage
BIN_BOARD_FILE=$IMAGES_DIR/script.bin
ROOTFS=$IMAGES_DIR/rootfs.tar
BOOT_CMD_H=$IMAGES_DIR/boot.scr
export LC_ALL=C
if [ $# -ne 2 ]; then
echo "Usage: $0 <images_dir> <drive>"
exit 1;
fi
if [ `id -u` -ne 0 ]; then
echo "This script must be run as root" 1>&2
exit 1
fi
if [ ! -f $SPL_IMG -a ! -f $SPL_UBOOT ] ||
[ ! -f $UBOOT_IMG ] ||
[ ! -f $UIMAGE ] ||
[ ! -f $BIN_BOARD_FILE ] ||
[ ! -f $ROOTFS ] ||
[ ! -f $BOOT_CMD_H ]; then
echo "File(s) missing."
exit 1
fi
DRIVE=$2
P1=`mktemp -d`
P2=`mktemp -d`
dd if=/dev/zero of=$DRIVE bs=1M count=3
SIZE=`fdisk -l $DRIVE | grep Disk | grep bytes | awk '{print $5}'`
echo DISK SIZE - $SIZE bytes
# ~2048, 16MB, FAT, bootable
# ~rest of drive, Ext4
{
echo 32,512,0x0C,*
echo 544,,,-
} | sfdisk -D $DRIVE