aboutsummaryrefslogtreecommitdiffstats
path: root/target/linux/mvebu/cortexa72/base-files/lib/upgrade/emmc-puzzle.sh
diff options
context:
space:
mode:
Diffstat (limited to 'target/linux/mvebu/cortexa72/base-files/lib/upgrade/emmc-puzzle.sh')
-rwxr-xr-xtarget/linux/mvebu/cortexa72/base-files/lib/upgrade/emmc-puzzle.sh36
1 files changed, 36 insertions, 0 deletions
diff --git a/target/linux/mvebu/cortexa72/base-files/lib/upgrade/emmc-puzzle.sh b/target/linux/mvebu/cortexa72/base-files/lib/upgrade/emmc-puzzle.sh
new file mode 100755
index 0000000000..5e5c356ed6
--- /dev/null
+++ b/target/linux/mvebu/cortexa72/base-files/lib/upgrade/emmc-puzzle.sh
@@ -0,0 +1,36 @@
+platform_do_upgrade_emmc() {
+ local board=$(board_name)
+ local diskdev partdev
+
+ export_bootdevice && export_partdevice diskdev 0 || {
+ v "Unable to determine upgrade device"
+ return 1
+ }
+ sync
+ if [ "$UPGRADE_OPT_SAVE_PARTITIONS" = "1" ]; then
+ get_partitions "/dev/$diskdev" bootdisk
+ v "Extract boot sector from the image"
+ get_image_dd "$1" of=/tmp/image.bs count=1 bs=512b
+ get_partitions /tmp/image.bs image
+ fi
+
+ #iterate over each partition from the image and write it to the boot disk
+ while read part start size; do
+ if export_partdevice partdev $part; then
+ if [ "$partdev" = "mmcblk0p2" ]; then
+ v "Writing image mmcblk0p3 for /dev/$partdev $start $size"
+ get_image_dd "$1" of="/dev/mmcblk0p3" ibs="512" obs=1M skip="$start" count="$size" conv=fsync
+ elif [ "$partdev" = "mmcblk0p1" ]; then
+ v "Writing image mmcblk0p1 for /dev/$partdev $start $size"
+ get_image_dd "$1" of="/dev/$partdev" ibs="512" obs=1M skip="$start" count="$size" conv=fsync
+ fi
+ else
+ v "Unable to find partition $part device, skipped."
+ fi
+ done < /tmp/partmap.image
+
+ v "Writing new UUID to /dev/$diskdev..."
+ get_image_dd "$1" of="/dev/$diskdev" bs=1 skip=440 count=4 seek=440 conv=fsync
+
+ sleep 1
+}