diff --git a/iopsys-brcm63xx-arm/image/bundled-migrator-script/script.sh b/iopsys-brcm63xx-arm/image/bundled-migrator-script/script.sh index 38d30afbe7de91eccc761e732201cecec1aa2443..069256dae0e2fc6ce6754466b050eb1e59dc3b2c 100755 --- a/iopsys-brcm63xx-arm/image/bundled-migrator-script/script.sh +++ b/iopsys-brcm63xx-arm/image/bundled-migrator-script/script.sh @@ -47,7 +47,25 @@ upgrade_ubi_volume() { fsync /dev/ubi0_$id } -local img="$1" size +# Save nvram values in migrator raw ubi partition. +# These values are picked up by uboot on first boot +# and stored in uboot environment. +save_nvram() { + names=$(ls /proc/nvram | sort) + + for name in $names; do + # Skip the bootline + [ $name == bootline ] || [ $name == Bootline ] && continue + + value=$(cat /proc/nvram/$name) + echo "$name=$value" >> /tmp/nvram + done + + size=$(ls -l /tmp/nvram | awk '{ print $5 }') + echo $size +} + +img="$1" echo "Running iop5 to iop6 migration script" @@ -58,6 +76,7 @@ size=$(extract_section $img loader) if [ $size -gt 0 ]; then mtd -e /dev/mtd1 write /tmp/loader /dev/mtd1 else + echo "Bad boot loader size; exiting." return 1 fi @@ -83,12 +102,15 @@ echo "Extracting rootfs" size=$(extract_section $img rootfs) upgrade_ubi_volume rootfs $size rootfs1 4 -# Create the overlay. Save id 6 for rootfs2. +echo "Saving nvram" +size=$(save_nvram) +upgrade_ubi_volume nvram $size migrator 10 + echo "Creating overlay partition" -ubimkvol "/dev/ubi0" -n 10 -N overlay1 -t dynamic -s 38092800 +ubimkvol "/dev/ubi0" -n 11 -N overlay1 -t dynamic -s 38092800 echo "Upgrade completed; rebooting." -#reboot +reboot # Halt execution of sysupgrade, both when sourced and execuded as a task. return 1 || exit 1