about summary refs log tree commit diff
path: root/mkimage.sh.in
diff options
context:
space:
mode:
Diffstat (limited to 'mkimage.sh.in')
-rw-r--r--mkimage.sh.in44
1 files changed, 28 insertions, 16 deletions
diff --git a/mkimage.sh.in b/mkimage.sh.in
index 26007dd..ed6b6e4 100644
--- a/mkimage.sh.in
+++ b/mkimage.sh.in
@@ -1,6 +1,6 @@
 #!/bin/sh
 #-
-# Copyright (c) 2013-2015 Juan Romero Pardines.
+# Copyright (c) 2013-2016 Juan Romero Pardines.
 # All rights reserved.
 #
 # Redistribution and use in source and binary forms, with or without
@@ -56,11 +56,11 @@ Usage: $PROGNAME [options] <rootfs-tarball>
 The <rootfs-tarball> argument expects a tarball generated by void-mkrootfs.
 The platform is guessed automatically by its name.
 
-Accepted sizes suffixes: K, M, G, T, E.
+Accepted sizes suffixes: KiB, MiB, GiB, TiB, EiB.
 
 OPTIONS
  -b <fstype>    Set /boot filesystem type (defaults to FAT)
- -B <bsize>     Set /boot filesystem size (defaults to 64MB)
+ -B <bsize>     Set /boot filesystem size (defaults to 64MiB)
  -r <fstype>    Set / filesystem type (defaults to EXT4)
  -s <totalsize> Set total image size (defaults to 2GB)
  -o <output>    Set image filename (guessed automatically)
@@ -104,7 +104,7 @@ fi
 
 : ${IMGSIZE:=2G}
 : ${BOOT_FSTYPE:=vfat}
-: ${BOOT_FSSIZE:=64M}
+: ${BOOT_FSSIZE:=64MiB}
 : ${ROOT_FSTYPE:=ext4}
 
 if [ -z "$FILENAME" ]; then
@@ -113,11 +113,11 @@ fi
 
 # double check PLATFORM is supported...
 case "$PLATFORM" in
-    bananapi|beaglebone|cubieboard2|cubietruck|odroid-u2|rpi|rpi2|usbarmory|*-musl);;
+    bananapi|beaglebone|cubieboard2|cubietruck|odroid-c2|odroid-u2|rpi|rpi2|usbarmory|*-musl);;
     *) die "The $PLATFORM is not supported, exiting..."
 esac
 
-for f in parted partx losetup mount mkfs.${BOOT_FSTYPE} mkfs.${ROOT_FSTYPE}; do
+for f in sfdisk partx losetup mount mkfs.${BOOT_FSTYPE} mkfs.${ROOT_FSTYPE}; do
     if ! which ${f} >/dev/null; then
         die "Cannot find ${f}, exiting."
     fi
@@ -136,24 +136,27 @@ truncate -s "${IMGSIZE}" $FILENAME >/dev/null 2>&1
 ROOTFSDIR=$(mktemp -d)
 
 info_msg "Creating disk image partitions/filesystems ..."
-parted $FILENAME mktable msdos
 if [ "$BOOT_FSTYPE" = "vfat" ]; then
     _btype="fat32"
     _args="-I -F16"
 fi
 case "$PLATFORM" in
-cubieboard2|cubietruck)
-    parted $FILENAME mkpart primary ext2 2048s ${ROOT_FSSIZE} 100%
-    parted $FILENAME toggle 1 boot
+cubieboard2|cubietruck|ci20*|odroid-c2*)
+    sfdisk ${FILENAME} <<_EOF
+label: dos
+2048,,L
+_EOF
     LOOPDEV=$(losetup --show --find --partscan $FILENAME)
     mkfs.${ROOT_FSTYPE} $disable_journal ${LOOPDEV}p1 >/dev/null 2>&1
     mount ${LOOPDEV}p1 $ROOTFSDIR
     ROOT_UUID=$(blkid -o value -s UUID ${LOOPDEV}p1)
     ;;
 *)
-    parted $FILENAME mkpart primary ${_btype} 2048s ${BOOT_FSSIZE}
-    parted $FILENAME mkpart primary ext2 ${BOOT_FSSIZE} 100%
-    parted $FILENAME toggle 1 boot
+    sfdisk ${FILENAME} <<_EOF
+label: dos
+2048,${BOOT_FSSIZE},b
+${BOOT_SIZE},+,L,*
+_EOF
     LOOPDEV=$(losetup --show --find --partscan $FILENAME)
     mkfs.${BOOT_FSTYPE} $_args ${LOOPDEV}p1 >/dev/null
     case "$ROOT_FSTYPE" in
@@ -188,18 +191,27 @@ if [ -n "$BOOT_UUID" ]; then
 fi
 
 case "$PLATFORM" in
-bananapi|cubieboard2|cubietruck)
+bananapi*|cubieboard2*|cubietruck*)
     dd if=${ROOTFSDIR}/boot/u-boot-sunxi-with-spl.bin of=${LOOPDEV} bs=1024 seek=8 >/dev/null 2>&1
     ;;
-odroid-u2)
+odroid-c2*)
+    dd if=${ROOTFSDIR}/boot/bl1.bin.hardkernel of=${LOOPDEV} bs=1 count=442 >/dev/null 2>&1
+    dd if=${ROOTFSDIR}/boot/bl1.bin.hardkernel of=${LOOPDEV} bs=512 skip=1 seek=1 >/dev/null 2>&1
+    dd if=${ROOTFSDIR}/boot/u-boot.bin of=${LOOPDEV} bs=512 seek=97 >/dev/null 2>&1
+    ;;
+odroid-u2*)
     dd if=${ROOTFSDIR}/boot/E4412_S.bl1.HardKernel.bin of=${LOOPDEV} seek=1 >/dev/null 2>&1
     dd if=${ROOTFSDIR}/boot/bl2.signed.bin of=${LOOPDEV} seek=31 >/dev/null 2>&1
     dd if=${ROOTFSDIR}/boot/u-boot.bin of=${LOOPDEV} seek=63 >/dev/null 2>&1
     dd if=${ROOTFSDIR}/boot/E4412_S.tzsw.signed.bin of=${LOOPDEV} seek=2111 >/dev/null 2>&1
     ;;
-usbarmory)
+usbarmory*)
     dd if=${ROOTFSDIR}/boot/u-boot.imx of=${LOOPDEV} bs=512 seek=2 conv=fsync >/dev/null 2>&1
     ;;
+ci20*)
+    dd if=${ROOTFSDIR}/boot/u-boot-spl.bin of=${LOOPDEV} obs=512 seek=1 >/dev/null 2>&1
+    dd if=${ROOTFSDIR}/boot/u-boot.img of=${LOOPDEV} obs=1K seek=14 >/dev/null 2>&1
+    ;;
 esac
 
 mountpoint -q ${ROOTFSDIR}/boot && umount ${ROOTFSDIR}/boot