9e1376a5788894ee0a0443bde392e11cca09c5fd
3 asrock_bootconfig_mangle
() {
4 local mtdnum
="$( find_mtd_index 0:BOOTCONFIG )"
6 if [ -z "$mtdnum" ]; then
7 echo "cannot find bootconfig mtd partition"
10 dd if=/dev
/mtd
$mtdnum of
=/tmp
/mtd
$mtdnum bs
=1k
12 local partition_byte
="$(dd if=/tmp/mtd$mtdnum bs=1 skip=52 count=1)"
13 local upgrade_byte
="$(dd if=/tmp/mtd$mtdnum bs=1 skip=4 count=1)"
15 if [ $1 = "bootcheck" ]; then
16 if [ ! -s $upgrade_byte ]; then
17 dd if=/dev
/mtd
$mtdnum of
=/tmp
/mtd
$mtdnum bs
=1k
18 printf '\x00' |
dd of
=/tmp
/mtd
$mtdnum conv
=notrunc bs
=1 seek
=4
19 printf '\x00' |
dd of
=/tmp
/mtd
$mtdnum conv
=notrunc bs
=1 seek
=56
23 elif [ $1 = "sysupgrade" ]; then
24 printf '\x01' |
dd of
=/tmp
/mtd
$mtdnum conv
=notrunc bs
=1 seek
=4
25 printf '\x01' |
dd of
=/tmp
/mtd
$mtdnum conv
=notrunc bs
=1 seek
=56
28 if [ -s $partition_byte ]; then
29 printf '\x01' |
dd of
=/tmp
/mtd
$mtdnum conv
=notrunc bs
=1 seek
=52
31 printf '\x00' |
dd of
=/tmp
/mtd
$mtdnum conv
=notrunc bs
=1 seek
=52
34 mtd
write /tmp
/mtd
$mtdnum /dev
/mtd
$mtdnum
38 asrock_upgrade_prepare
() {
39 local ubidev
="$( nand_find_ubi ubi )"
41 #Set upgrade flag. If something goes wrong, router will boot with
43 asrock_bootconfig_mangle
'sysupgrade'
46 echo "cannot find bootconfig mtd partition"
50 # Just delete these partitions if present and use
51 # OpenWrt's standard names for those.
52 ubirmvol
/dev
/$ubidev -N ubi_rootfs
&> /dev
/null || true
53 ubirmvol
/dev
/$ubidev -N ubi_rootfs_data
&> /dev
/null || true