6 PROGNAME=$(basename $0)
10 echo "Create an SD card that boots on an i.MX53/6 board."
12 echo "Note: all data on the the card will be completely deleted!"
14 echo "Superuser permissions may be required to write to the device."
16 echo "Usage: ${PROGNAME} <sd_block_device>"
18 echo " <sd_block_device> The device to be written to"
20 echo "Example: ${PROGNAME} /dev/mmcblk0"
29 if [ $(id -u) -ne 0 ]; then
30 echo "${PROGNAME} must be run as root"
36 # The partition name prefix depends on the device name:
37 # - /dev/sde -> /dev/sde1
38 # - /dev/mmcblk0 -> /dev/mmcblk0p1
39 if echo ${DEV}|grep -q mmcblk ; then
48 # Unmount the partitions if mounted
49 umount ${PART1} || true
50 umount ${PART2} || true
52 # First, clear the card
53 dd if=/dev/zero of=${DEV} bs=1M count=20
58 # SD layout for i.MX6 boot:
59 # - Bootloader at offset 1024
60 # - FAT partition starting at 1MB offset, containing uImage and *.dtb
61 # - ext2/3 partition formatted as ext2 or ext3, containing the root filesystem.
69 # Copy the bootloader at offset 1024
70 dd if=output/images/u-boot.imx of=${DEV} obs=512 seek=2
72 # Prepare a temp dir for mounting partitions
75 # FAT partition: kernel and DTBs
77 mount ${PART1} ${TMPDIR}
78 cp output/images/*Image ${TMPDIR}/
79 cp output/images/*.dtb ${TMPDIR}/ || true
83 # ext2 partition: root filesystem
85 mount ${PART2} ${TMPDIR}
86 tar -C ${TMPDIR}/ -xf output/images/rootfs.tar