ipq806x: switch to full dual-boot for the nbg6817 sysupgrade support
Instead of writing to the currently booted partition set, this implements full dual-boot support for sysupgrade by always writing to the other, currently inactive, partition set and toggling the dualflag after a successful flash. The currently active/ booted partition set is determined by parsing /proc/cmdline for its rootfs parameter (supplied by the DTS), instead of reading from the 0:DUAL_FLAG mtd, in order to prevent (potentially) bricking both partition sets. Signed-off-by: Stefan Lippers-Hollmann <s.l-h@gmx.de>
This commit is contained in:
parent
42fe7b3bbe
commit
4baffa02ce
1 changed files with 23 additions and 3 deletions
|
@ -21,6 +21,7 @@ zyxel_do_flash() {
|
||||||
local tar_file=$1
|
local tar_file=$1
|
||||||
local kernel=$2
|
local kernel=$2
|
||||||
local rootfs=$3
|
local rootfs=$3
|
||||||
|
local dualflagmtd=$4
|
||||||
|
|
||||||
# keep sure its unbound
|
# keep sure its unbound
|
||||||
losetup --detach-all || {
|
losetup --detach-all || {
|
||||||
|
@ -63,6 +64,16 @@ zyxel_do_flash() {
|
||||||
umount /tmp/new_root
|
umount /tmp/new_root
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# flashing successful, toggle the dualflag
|
||||||
|
case "$rootfs" in
|
||||||
|
"/dev/mmcblk0p5")
|
||||||
|
printf "\xff" >$dualflagmtd
|
||||||
|
;;
|
||||||
|
"/dev/mmcblk0p8")
|
||||||
|
printf "\x01" >$dualflagmtd
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
# Cleanup
|
# Cleanup
|
||||||
losetup -d $loopdev >/dev/null 2>&1
|
losetup -d $loopdev >/dev/null 2>&1
|
||||||
sync
|
sync
|
||||||
|
@ -79,12 +90,21 @@ zyxel_do_upgrade() {
|
||||||
[ -b "${rootfs}" ] || return 1
|
[ -b "${rootfs}" ] || return 1
|
||||||
case "$board" in
|
case "$board" in
|
||||||
zyxel,nbg6817)
|
zyxel,nbg6817)
|
||||||
|
local dualflagmtd="$(find_mtd_part 0:DUAL_FLAG)"
|
||||||
|
[ -b $dualflagmtd ] || return 1
|
||||||
|
|
||||||
case "$rootfs" in
|
case "$rootfs" in
|
||||||
"/dev/mmcblk0p5")
|
"/dev/mmcblk0p5")
|
||||||
kernel="/dev/mmcblk0p4"
|
# booted from the primary partition set
|
||||||
|
# write to the alternative set
|
||||||
|
kernel="/dev/mmcblk0p7"
|
||||||
|
rootfs="/dev/mmcblk0p8"
|
||||||
;;
|
;;
|
||||||
"/dev/mmcblk0p8")
|
"/dev/mmcblk0p8")
|
||||||
kernel="/dev/mmcblk0p7"
|
# booted from the alternative partition set
|
||||||
|
# write to the primary set
|
||||||
|
kernel="/dev/mmcblk0p4"
|
||||||
|
rootfs="/dev/mmcblk0p5"
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
return 1
|
return 1
|
||||||
|
@ -96,7 +116,7 @@ zyxel_do_upgrade() {
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
zyxel_do_flash $tar_file $kernel $rootfs
|
zyxel_do_flash $tar_file $kernel $rootfs $dualflagmtd
|
||||||
|
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue