mirror of
https://github.com/openwrt/openwrt.git
synced 2026-06-17 12:40:16 +04:00
mvebu: cortexa53: uDPU/eDPU: update active bootscript as well
Currently, sysupgrade will only upgrade the unused slot, however since the whole dual firmware logic is in the bootscript U-boot will just use the first bootscript it finds. So, in a case that you are running slot A it will upgrade slot B, however that means that slot B will be still booted by the old bootscript that came with the previous firmware version. This is an issue if you need to change anything, so lets add a custom function that upgrades the active bootscript as well after flashing the slot firmware. Signed-off-by: Robert Marko <robert.marko@sartura.hr>
This commit is contained in:
@@ -7,6 +7,40 @@ RAMFS_COPY_BIN='fw_printenv fw_setenv mkfs.f2fs fdisk'
|
|||||||
RAMFS_COPY_DATA='/etc/fw_env.config /var/lock/fw_printenv.lock'
|
RAMFS_COPY_DATA='/etc/fw_env.config /var/lock/fw_printenv.lock'
|
||||||
REQUIRE_IMAGE_METADATA=1
|
REQUIRE_IMAGE_METADATA=1
|
||||||
|
|
||||||
|
# U-Boot loads the first boot.scr it finds, so keep the active slot's script in
|
||||||
|
# sync even when the full upgrade is written to the inactive slot.
|
||||||
|
methode_update_active_bootscript() {
|
||||||
|
local active_part="$1"
|
||||||
|
local updated_part="$2"
|
||||||
|
local active_dev
|
||||||
|
local updated_dev
|
||||||
|
local ret=0
|
||||||
|
|
||||||
|
[ "$active_part" -a "$updated_part" ] || return 0
|
||||||
|
|
||||||
|
active_dev="$(find_mmc_part "$active_part" "$CI_ROOTDEV")"
|
||||||
|
updated_dev="$(find_mmc_part "$updated_part" "$CI_ROOTDEV")"
|
||||||
|
[ "$active_dev" -a "$updated_dev" ] || return 1
|
||||||
|
|
||||||
|
mkdir -p /tmp/bootpart-new
|
||||||
|
mount -o ro "$updated_dev" /tmp/bootpart-new || return 1
|
||||||
|
|
||||||
|
cp /tmp/bootpart-new/boot.scr /tmp/boot.scr
|
||||||
|
ret=$?
|
||||||
|
umount /tmp/bootpart-new
|
||||||
|
[ $ret -eq 0 ] || return 1
|
||||||
|
|
||||||
|
mkdir -p /tmp/bootpart-active
|
||||||
|
mount "$active_dev" /tmp/bootpart-active || return 1
|
||||||
|
|
||||||
|
cp /tmp/boot.scr /tmp/bootpart-active/boot.scr || ret=1
|
||||||
|
sync
|
||||||
|
|
||||||
|
umount /tmp/bootpart-active
|
||||||
|
|
||||||
|
return $ret
|
||||||
|
}
|
||||||
|
|
||||||
platform_check_image() {
|
platform_check_image() {
|
||||||
case "$(board_name)" in
|
case "$(board_name)" in
|
||||||
glinet,gl-mv1000|\
|
glinet,gl-mv1000|\
|
||||||
@@ -35,15 +69,19 @@ platform_do_upgrade() {
|
|||||||
;;
|
;;
|
||||||
methode,udpu|\
|
methode,udpu|\
|
||||||
methode,edpu)
|
methode,edpu)
|
||||||
|
local active_kernpart
|
||||||
|
|
||||||
[ "$(rootfs_type)" = "tmpfs" ] && {
|
[ "$(rootfs_type)" = "tmpfs" ] && {
|
||||||
local firmware_active="$(fw_printenv -n bootactive)"
|
local firmware_active="$(fw_printenv -n bootactive)"
|
||||||
case "$firmware_active" in
|
case "$firmware_active" in
|
||||||
1)
|
1)
|
||||||
|
active_kernpart="kernel_1"
|
||||||
CI_KERNPART="kernel_2"
|
CI_KERNPART="kernel_2"
|
||||||
CI_ROOTPART="rootfs_2"
|
CI_ROOTPART="rootfs_2"
|
||||||
fw_setenv bootactive 2
|
fw_setenv bootactive 2
|
||||||
;;
|
;;
|
||||||
2)
|
2)
|
||||||
|
active_kernpart="kernel_2"
|
||||||
CI_KERNPART="kernel_1"
|
CI_KERNPART="kernel_1"
|
||||||
CI_ROOTPART="rootfs_1"
|
CI_ROOTPART="rootfs_1"
|
||||||
fw_setenv bootactive 1
|
fw_setenv bootactive 1
|
||||||
@@ -54,11 +92,13 @@ platform_do_upgrade() {
|
|||||||
local root="$(cmdline_get_var root)"
|
local root="$(cmdline_get_var root)"
|
||||||
case "$root" in
|
case "$root" in
|
||||||
/dev/mmcblk*p2)
|
/dev/mmcblk*p2)
|
||||||
|
active_kernpart="kernel_1"
|
||||||
CI_KERNPART="kernel_2"
|
CI_KERNPART="kernel_2"
|
||||||
CI_ROOTPART="rootfs_2"
|
CI_ROOTPART="rootfs_2"
|
||||||
fw_setenv bootactive 2
|
fw_setenv bootactive 2
|
||||||
;;
|
;;
|
||||||
/dev/mmcblk*p4)
|
/dev/mmcblk*p4)
|
||||||
|
active_kernpart="kernel_2"
|
||||||
CI_KERNPART="kernel_1"
|
CI_KERNPART="kernel_1"
|
||||||
CI_ROOTPART="rootfs_1"
|
CI_ROOTPART="rootfs_1"
|
||||||
fw_setenv bootactive 1
|
fw_setenv bootactive 1
|
||||||
@@ -66,6 +106,9 @@ platform_do_upgrade() {
|
|||||||
esac
|
esac
|
||||||
|
|
||||||
emmc_do_upgrade "$1"
|
emmc_do_upgrade "$1"
|
||||||
|
|
||||||
|
methode_update_active_bootscript "$active_kernpart" "$CI_KERNPART" || \
|
||||||
|
echo "Failed to update active boot script"
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
default_do_upgrade "$1"
|
default_do_upgrade "$1"
|
||||||
|
|||||||
Reference in New Issue
Block a user