]> git.sesse.net Git - debian-xu4/commitdiff
Support building boot images for eMMC devices.
authorSteinar H. Gunderson <sgunderson@bigfoot.com>
Sun, 15 May 2016 22:47:40 +0000 (00:47 +0200)
committerSteinar H. Gunderson <sgunderson@bigfoot.com>
Sun, 15 May 2016 22:47:40 +0000 (00:47 +0200)
README
mkimage.sh

diff --git a/README b/README
index ef3febb274e96bab18691a647a9a74b24d86227e..0349694a8683b1e0485ea0b3128efe77a6869af7 100644 (file)
--- a/README
+++ b/README
@@ -5,7 +5,20 @@ The image is signed with my GnuPG key; you can find the key in the
 Debian keyring.
 
 The prebuilt images are made for 1GB cards, so they should fit onto
 Debian keyring.
 
 The prebuilt images are made for 1GB cards, so they should fit onto
-pretty much any modern SD card.
+pretty much any modern SD or MMC card. Root images built for SD cards
+will fit work on MMC devices but not the other way round (the prebuilt
+root images are for SD).
+
+If you want to update the boot partition of an eMMC device (where
+U-Boot lives), you will need to unlock it before Linux lets you
+write to it, e.g.:
+
+  echo 0 > /sys/block/mmcblk0boot0/force_ro
+
+SD cards do not have hardware partitions (U-Boot is stored on the same
+block device as everything else), so all you need to do is to decompress
+the image and dd it to the card.
+
 
 Prebuilt images: https://storage.sesse.net/debian-xu4/
 ODROID forum thread: http://forum.odroid.com/viewtopic.php?f=96&t=21256
 
 Prebuilt images: https://storage.sesse.net/debian-xu4/
 ODROID forum thread: http://forum.odroid.com/viewtopic.php?f=96&t=21256
index 88b964d65c7736abe02b79dd6bd5072cd593d85c..bf78888d80a4d10b8ab022547915f1b014fc0071 100755 (executable)
@@ -1,15 +1,13 @@
 #! /bin/bash
 
 # Install a bog-standard Debian bootable for ODROID XU3/XU4.
 #! /bin/bash
 
 # Install a bog-standard Debian bootable for ODROID XU3/XU4.
-# Note that this will only work for SD cards; MMC devices
-# have a different layout. See
-# /usr/share/doc/u-boot-exynos/README.odroid.gz for more details.
 #
 # Note: You will need u-boot-exynos >= 2016.05~rc3+dfsg1-1,
 # which at the time of writing is in experimental (it will
 # probably eventually hit stretch).
 #
 #
 # Note: You will need u-boot-exynos >= 2016.05~rc3+dfsg1-1,
 # which at the time of writing is in experimental (it will
 # probably eventually hit stretch).
 #
-# Beware: This will ERASE ALL DATA on the target SD card.
+# Beware: This will ERASE ALL DATA on the target SD card
+# or MMC partition.
 #
 #
 # Copyright 2016 Steinar H. Gunderson <steinar+odroid@gunderson.no>.
 #
 #
 # Copyright 2016 Steinar H. Gunderson <steinar+odroid@gunderson.no>.
@@ -20,8 +18,9 @@ set -e
 DEVICE=
 BOOTPART_MB=256
 SUITE=stretch
 DEVICE=
 BOOTPART_MB=256
 SUITE=stretch
+TYPE=sd
 
 
-while getopts "b:s:" opt; do
+while getopts "b:s:t:" opt; do
        case $opt in
                b)
                        BOOTPART_MB=$OPTARG
        case $opt in
                b)
                        BOOTPART_MB=$OPTARG
@@ -30,6 +29,9 @@ while getopts "b:s:" opt; do
                        # Sorry, jessie won't work; the kernel doesn't support XU3/XU4.
                        SUITE=$OPTARG
                        ;;
                        # Sorry, jessie won't work; the kernel doesn't support XU3/XU4.
                        SUITE=$OPTARG
                        ;;
+               t)
+                       TYPE=$OPTARG
+                       ;;
                :)
                        echo "Option -$OPTARG requires an argument."
                        exit 1
                :)
                        echo "Option -$OPTARG requires an argument."
                        exit 1
@@ -40,12 +42,17 @@ shift $((OPTIND - 1))
 
 DEVICE=$1
 if [ ! -b "$DEVICE" ]; then
 
 DEVICE=$1
 if [ ! -b "$DEVICE" ]; then
-       echo "Usage: $0 [-b BOOTPARTITION_SIZE] [-s SUITE] DEVICE [OTHER_DEBOOTSTRAP_ARGS...]"
+       echo "Usage: $0 [-b BOOTPARTITION_SIZE] [-s SUITE] [-t sd|mmc] DEVICE [OTHER_DEBOOTSTRAP_ARGS...]"
        echo "DEVICE is an SD card device, e.g. /dev/sdb."
        exit 1
 fi
 shift
 
        echo "DEVICE is an SD card device, e.g. /dev/sdb."
        exit 1
 fi
 shift
 
+if [ "$TYPE" != "sd" ] && [ "$TYPE" != "mmc" ]; then
+       echo "Card type must be 'sd' or 'mmc'."
+       exit 1
+fi
+
 set -x
 
 # Prerequisites.
 set -x
 
 # Prerequisites.
@@ -77,11 +84,18 @@ else
 fi
 
 # Put the different stages of U-Boot into the right place.
 fi
 
 # Put the different stages of U-Boot into the right place.
-# The offsets come from README.odroid.gz.
-dd if=u-boot/sd_fuse/hardkernel_1mb_uboot/bl1.bin.hardkernel of=${DEVICE} seek=1 conv=sync
-dd if=u-boot/sd_fuse/hardkernel_1mb_uboot/bl2.bin.hardkernel.1mb_uboot of=${DEVICE} seek=31 conv=sync
-dd if=/usr/lib/u-boot/odroid-xu3/u-boot-dtb.bin of=${DEVICE} seek=63 conv=sync
-dd if=u-boot/sd_fuse/hardkernel_1mb_uboot/tzsw.bin.hardkernel of=${DEVICE} seek=2111 conv=sync
+# The offsets come from /usr/share/doc/u-boot-exynos/README.odroid.gz.
+if [ "$TYPE" = "sd" ]; then
+       UBOOT_DEVICE=${DEVICE}
+       UBOOT_OFFSET=1
+else
+       UBOOT_DEVICE=${DEVICE}boot0
+       UBOOT_OFFSET=0
+fi
+dd if=u-boot/sd_fuse/hardkernel_1mb_uboot/bl1.bin.hardkernel of=${UBOOT_DEVICE} seek=${UBOOT_OFFSET} conv=sync
+dd if=u-boot/sd_fuse/hardkernel_1mb_uboot/bl2.bin.hardkernel.1mb_uboot of=${UBOOT_DEVICE} seek=$((UBOOT_OFFSET + 30)) conv=sync
+dd if=/usr/lib/u-boot/odroid-xu3/u-boot-dtb.bin of=${UBOOT_DEVICE} seek=$((UBOOT_OFFSET + 62)) conv=sync
+dd if=u-boot/sd_fuse/hardkernel_1mb_uboot/tzsw.bin.hardkernel of=${UBOOT_DEVICE} seek=$((UBOOT_OFFSET + 2110)) conv=sync
 
 # Clear out the environment.
 dd if=/dev/zero of=${DEVICE} seek=2560 count=32 bs=512 conv=sync
 
 # Clear out the environment.
 dd if=/dev/zero of=${DEVICE} seek=2560 count=32 bs=512 conv=sync