4 asrock_bootconfig_mangle
() {
5 local mtdnum
="$( find_mtd_index 0:BOOTCONFIG )"
7 if [ -z "$mtdnum" ]; then
8 echo "cannot find bootconfig mtd partition"
11 dd if=/dev
/mtd
$mtdnum of
=/tmp
/mtd
$mtdnum bs
=1k
13 local partition_byte
="$(dd if=/tmp/mtd$mtdnum bs=1 skip=52 count=1)"
14 local upgrade_byte
="$(dd if=/tmp/mtd$mtdnum bs=1 skip=4 count=1)"
16 if [ $1 = "bootcheck" ]; then
17 if [ ! -s $upgrade_byte ]; then
18 dd if=/dev
/mtd
$mtdnum of
=/tmp
/mtd
$mtdnum bs
=1k
19 printf '\x00' |
dd of
=/tmp
/mtd
$mtdnum conv
=notrunc bs
=1 seek
=4
20 printf '\x00' |
dd of
=/tmp
/mtd
$mtdnum conv
=notrunc bs
=1 seek
=56
24 elif [ $1 = "sysupgrade" ]; then
25 printf '\x01' |
dd of
=/tmp
/mtd
$mtdnum conv
=notrunc bs
=1 seek
=4
26 printf '\x01' |
dd of
=/tmp
/mtd
$mtdnum conv
=notrunc bs
=1 seek
=56
29 if [ -s $partition_byte ]; then
30 printf '\x01' |
dd of
=/tmp
/mtd
$mtdnum conv
=notrunc bs
=1 seek
=52
32 printf '\x00' |
dd of
=/tmp
/mtd
$mtdnum conv
=notrunc bs
=1 seek
=52
35 mtd
write /tmp
/mtd
$mtdnum /dev
/mtd
$mtdnum
39 asrock_upgrade_prepare
() {
40 local ubidev
="$( nand_find_ubi ubi )"
42 #Set upgrade flag. If something goes wrong, router will boot with
44 asrock_bootconfig_mangle
'sysupgrade'
47 echo "cannot find bootconfig mtd partition"
51 # Just delete these partitions if present and use
52 # OpenWrt's standard names for those.
53 ubirmvol
/dev
/$ubidev -N ubi_rootfs
&> /dev
/null || true
54 ubirmvol
/dev
/$ubidev -N ubi_rootfs_data
&> /dev
/null || true