1 platform_do_upgrade
() {
2 local board
=$
(board_name
)
6 local diskdev partdev
diff
8 export_bootdevice
&& export_partdevice diskdev
0 ||
{
9 echo "Unable to determine upgrade device"
13 #Keep the persistent random mac address (if it exists)
14 mkdir
-p /tmp
/recovery
15 export_partdevice recoverydev
2
16 if mount
-o rw
,noatime
"/dev/$recoverydev" -tvfat /tmp
/recovery
; then
17 [ -f "/tmp/recovery/mac_addr" ] && cp /tmp
/recovery
/mac_addr
/tmp
/
22 if [ "$SAVE_PARTITIONS" = "1" ]; then
23 get_partitions
"/dev/$diskdev" bootdisk
25 #extract the boot sector from the image
26 get_image
"$@" |
dd of
=/tmp
/image.bs count
=1 bs
=512b
28 get_partitions
/tmp
/image.bs image
31 diff="$(grep -F -x -v -f /tmp/partmap.bootdisk /tmp/partmap.image)"
36 if [ -n "$diff" ]; then
37 get_image
"$@" |
dd of
="/dev/$diskdev" bs
=4096 conv
=fsync
39 # Separate removal and addtion is necessary; otherwise, partition 1
40 # will be missing if it overlaps with the old partition 2
41 partx
-d - "/dev/$diskdev"
42 partx
-a - "/dev/$diskdev"
44 #iterate over each partition from the image and write it to the boot disk
45 while read part start size
; do
47 if export_partdevice partdev
$part; then
48 echo "Writing image to /dev/$partdev..."
49 get_image
"$@" |
dd of
="/dev/$partdev" ibs
="512" obs
=1M skip
="$start" count
="$size" conv
=fsync
51 echo "Unable to find partition $part device, skipped."
53 done < /tmp
/partmap.image
56 echo "Writing new UUID to /dev/$diskdev..."
57 get_image
"$@" |
dd of
="/dev/$diskdev" bs
=1 skip
=440 count
=4 seek
=440 conv
=fsync
60 if mount
-o rw
,noatime
"/dev/$recoverydev" -t vfat
/tmp
/recovery
; then
61 [ -f "/tmp/mac_addr" ] && cp /tmp
/mac_addr
/tmp
/recovery
63 if [ "$diskdev" = "mmcblk0" -a -r /tmp
/recovery
/eMMCboot.bin
]; then
64 echo 0 > /sys
/block
/mmcblk0boot
0/force_ro
65 dd if=/tmp
/recovery
/eMMCboot.bin of
=/dev
/mmcblk0boot0 conv
=fsync
67 echo 1 > /sys
/block
/mmcblk0boot
0/force_ro
74 unielec
,u7623-02-emmc-512m
)
75 #Keep the persisten random mac address (if it exists)
76 mkdir
-p /tmp
/recovery
77 mount
-o rw
,noatime
/dev
/mmcblk0p1
/tmp
/recovery
78 [ -f "/tmp/recovery/mac_addr" ] && \
79 mv -f /tmp
/recovery
/mac_addr
/tmp
/
82 #1310720 is the offset in bytes from the start of eMMC and to
83 #the location of the kernel (2560 512 byte sectors)
84 get_image
"$1" |
dd of
=/dev
/mmcblk0 bs
=1310720 seek
=1 conv
=fsync
86 mount
-o rw
,noatime
/dev
/mmcblk0p1
/tmp
/recovery
87 [ -f "/tmp/mac_addr" ] && mv -f /tmp
/mac_addr
/tmp
/recovery
92 default_do_upgrade
"$1"
99 platform_check_image
() {
100 local board
=$
(board_name
)
101 local magic
="$(get_magic_long "$1")"
102 local diskdev partdev
diff
104 [ "$#" -gt 1 ] && return 1
108 [ "$magic" != "53444d4d" ] && {
109 echo "Invalid image type."
112 export_bootdevice
&& export_partdevice diskdev
0 ||
{
113 echo "Unable to determine upgrade device"
117 get_partitions
"/dev/$diskdev" bootdisk
119 #extract the boot sector from the image
120 get_image
"$@" |
dd of
=/tmp
/image.bs count
=1 bs
=512b
2>/dev
/null
122 get_partitions
/tmp
/image.bs image
125 diff="$(grep -F -x -v -f /tmp/partmap.bootdisk /tmp/partmap.image)"
127 rm -f /tmp
/image.bs
/tmp
/partmap.bootdisk
/tmp
/partmap.image
129 if [ -n "$diff" ]; then
130 echo "Partition layout has changed. Full image will be written."
131 ask_bool
0 "Abort" && exit 1
135 unielec
,u7623-02-emmc-512m
)
136 [ "$magic" != "27051956" ] && {
137 echo "Invalid image type."
143 echo "Sysupgrade is not supported on your board yet."
151 platform_copy_config_emmc
() {
154 if export_bootdevice
&& export_partdevice partdev
$1; then
156 mount
-o rw
,noatime
"/dev/$partdev" -t vfat
/recovery
157 cp -af "$UPGRADE_BACKUP" "/recovery/$BACKUP_FILE"
163 platform_copy_config
() {
164 case "$(board_name)" in
166 platform_copy_config_emmc
2
168 unielec
,u7623-02-emmc-512m
)
169 platform_copy_config_emmc
1