blob: 5e5c356ed6946ab98c5a2a39b037aeef96bcc30f (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
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
}
|