3 asrock_bootconfig_mangle
() {
4 local mtdnum
="$(find_mtd_index 0:bootconfig)"
5 # XXX: drop upper case after kernel v5.4 is gone (qcom-smem)
6 [ -n "$mtdnum" ] || mtdnum
="$(find_mtd_index 0:BOOTCONFIG)"
8 if [ -z "$mtdnum" ]; then
9 echo "cannot find bootconfig mtd partition"
12 dd if=/dev
/mtd
$mtdnum of
=/tmp
/mtd
$mtdnum bs
=1k
14 local partition_byte
="$(dd if=/tmp/mtd$mtdnum bs=1 skip=52 count=1)"
15 local upgrade_byte
="$(dd if=/tmp/mtd$mtdnum bs=1 skip=4 count=1)"
17 if [ $1 = "bootcheck" ]; then
18 if [ ! -s $upgrade_byte ]; then
19 dd if=/dev
/mtd
$mtdnum of
=/tmp
/mtd
$mtdnum bs
=1k
20 printf '\x00' |
dd of
=/tmp
/mtd
$mtdnum conv
=notrunc bs
=1 seek
=4
21 printf '\x00' |
dd of
=/tmp
/mtd
$mtdnum conv
=notrunc bs
=1 seek
=56
25 elif [ $1 = "sysupgrade" ]; then
26 printf '\x01' |
dd of
=/tmp
/mtd
$mtdnum conv
=notrunc bs
=1 seek
=4
27 printf '\x01' |
dd of
=/tmp
/mtd
$mtdnum conv
=notrunc bs
=1 seek
=56
30 if [ -s $partition_byte ]; then
31 printf '\x01' |
dd of
=/tmp
/mtd
$mtdnum conv
=notrunc bs
=1 seek
=52
33 printf '\x00' |
dd of
=/tmp
/mtd
$mtdnum conv
=notrunc bs
=1 seek
=52
36 mtd
write /tmp
/mtd
$mtdnum /dev
/mtd
$mtdnum
40 asrock_upgrade_prepare
() {
41 local ubidev
="$( nand_find_ubi ubi )"
43 #Set upgrade flag. If something goes wrong, router will boot with
45 asrock_bootconfig_mangle
'sysupgrade'
48 echo "cannot find bootconfig mtd partition"
52 # Just delete these partitions if present and use
53 # OpenWrt's standard names for those.
54 ubirmvol
/dev
/$ubidev -N ubi_rootfs
&> /dev
/null || true
55 ubirmvol
/dev
/$ubidev -N ubi_rootfs_data
&> /dev
/null || true