3 # 2013, Carlo Caione <carlo.caione@gmail.com>
6 # 2012, Jason Plum <jplum@archlinuxarm.org>
9 # (c) Copyright 2009 Graeme Gregory <dp@xora.org.uk>
10 # Licensed under terms of GPLv2
12 # Parts of the procudure base on the work of Denys Dmytriyenko
13 # http://wiki.omap.com/index.php/MMC_Boot_Format
16 SPL_IMG
=$IMAGES_DIR/sunxi-spl.bin
17 SPL_UBOOT
=$IMAGES_DIR/u-boot-sunxi-with-spl.bin
18 UBOOT_IMG
=$IMAGES_DIR/u-boot.bin
19 UIMAGE
=$IMAGES_DIR/uImage
20 BIN_BOARD_FILE
=$IMAGES_DIR/script.bin
21 ROOTFS
=$IMAGES_DIR/rootfs.
tar
22 BOOT_CMD_H
=$IMAGES_DIR/boot.scr
27 echo "Usage: $0 <images_dir> <drive>"
31 if [ `id -u` -ne 0 ]; then
32 echo "This script must be run as root" 1>&2
36 if [ ! -f $SPL_IMG -a ! -f $SPL_UBOOT ] ||
37 [ ! -f $UBOOT_IMG ] ||
39 [ ! -f $BIN_BOARD_FILE ] ||
41 [ ! -f $BOOT_CMD_H ]; then
42 echo "File(s) missing."
50 dd if=/dev
/zero of
=$DRIVE bs
=1M count
=3
52 SIZE
=`fdisk -l $DRIVE | grep Disk | grep bytes | awk '{print $5}'`
54 echo DISK SIZE
- $SIZE bytes
57 # ~2048, 16MB, FAT, bootable
58 # ~rest of drive, Ext4
66 if [ -b ${DRIVE}1 ]; then
69 mkfs.vfat
-n "boot" ${DRIVE}1
71 if [ -b ${DRIVE}p1
]; then
74 mkfs.vfat
-n "boot" ${DRIVE}p1
76 echo "Cant find boot partition in /dev"
82 if [ -b ${DRIVE}2 ]; then
85 mkfs.ext4
-L "Cubie" ${DRIVE}2
87 if [ -b ${DRIVE}p2
]; then
90 mkfs.ext4
-L "Cubie" ${DRIVE}p2
92 echo "Cant find rootfs partition in /dev"
103 cp $BIN_BOARD_FILE $P1
104 # write u-boot script
107 tar -C $P2 -xvf $ROOTFS
117 if [ -e $SPL_UBOOT ]; then
118 dd if=$SPL_UBOOT of
=$DRIVE bs
=1024 seek
=8
121 dd if=$SPL_IMG of
=$DRIVE bs
=1024 seek
=8
123 dd if=$UBOOT_IMG of
=$DRIVE bs
=1024 seek
=32