1 platform_do_upgrade_emmc
() {
2 local board
=$
(board_name
)
5 export_bootdevice
&& export_partdevice diskdev
0 ||
{
6 v
"Unable to determine upgrade device"
10 if [ "$UPGRADE_OPT_SAVE_PARTITIONS" = "1" ]; then
11 get_partitions
"/dev/$diskdev" bootdisk
12 v
"Extract boot sector from the image"
13 get_image_dd
"$1" of
=/tmp
/image.bs count
=1 bs
=512b
14 get_partitions
/tmp
/image.bs image
17 #iterate over each partition from the image and write it to the boot disk
18 while read part start size
; do
19 if export_partdevice partdev
$part; then
20 if [ "$partdev" = "mmcblk0p2" ]; then
21 v
"Writing image mmcblk0p3 for /dev/$partdev $start $size"
22 get_image_dd
"$1" of
="/dev/mmcblk0p3" ibs
="512" obs
=1M skip
="$start" count
="$size" conv
=fsync
23 elif [ "$partdev" = "mmcblk0p1" ]; then
24 v
"Writing image mmcblk0p1 for /dev/$partdev $start $size"
25 get_image_dd
"$1" of
="/dev/$partdev" ibs
="512" obs
=1M skip
="$start" count
="$size" conv
=fsync
28 v
"Unable to find partition $part device, skipped."
30 done < /tmp
/partmap.image
32 v
"Writing new UUID to /dev/$diskdev..."
33 get_image_dd
"$1" of
="/dev/$diskdev" bs
=1 skip
=440 count
=4 seek
=440 conv
=fsync
35 dd if=/dev
/zero of
=$
(find_mmc_part rootfs_data
) bs
=512 count
=8