X-Git-Url: http://git.openwrt.org/?a=blobdiff_plain;f=target%2Flinux%2Fmvebu%2Fbase-files%2Flib%2Fupgrade%2Flinksys.sh;h=3f45d6cac5e879f050442b76cf7b4270dc177207;hb=b3770eaca39f223faecfcc0d169a1bb2f6f9464a;hp=d06a1b8ed0534364b595618f24b65f9f3a3e275d;hpb=62e4c915ee867b5c3610fcc150d3a6bf90cbb130;p=openwrt%2Fopenwrt.git diff --git a/target/linux/mvebu/base-files/lib/upgrade/linksys.sh b/target/linux/mvebu/base-files/lib/upgrade/linksys.sh index d06a1b8ed0..3f45d6cac5 100644 --- a/target/linux/mvebu/base-files/lib/upgrade/linksys.sh +++ b/target/linux/mvebu/base-files/lib/upgrade/linksys.sh @@ -3,26 +3,45 @@ # linksys_get_target_firmware() { + + local cur_boot_part mtd_ubi0 + cur_boot_part=`/usr/sbin/fw_printenv -n boot_part` - target_firmware="" - if [ "$cur_boot_part" = "1" ] - then - # current primary boot - update alt boot - target_firmware="kernel2" - fw_setenv boot_part 2 - fw_setenv bootcmd "run altnandboot" - elif [ "$cur_boot_part" = "2" ] - then - # current alt boot - update primary boot - target_firmware="kernel1" - fw_setenv boot_part 1 - fw_setenv bootcmd "run nandboot" + if [ -z "${cur_boot_part}" ] ; then + mtd_ubi0=$(cat /sys/devices/virtual/ubi/ubi0/mtd_num) + case $(egrep ^mtd${mtd_ubi0}: /proc/mtd | cut -d '"' -f 2) in + kernel1|rootfs1) + cur_boot_part=1 + ;; + kernel2|rootfs2) + cur_boot_part=2 + ;; + esac + >&2 printf "Current boot_part='%s' selected from ubi0/mtd_num='%s'" \ + "${cur_boot_part}" "${mtd_ubi0}" fi - # re-enable recovery so we get back if the new firmware is broken - fw_setenv auto_recovery yes - - echo "$target_firmware" + case $cur_boot_part in + 1) + fw_setenv -s - <<-EOF + boot_part 2 + bootcmd "run altnandboot" + EOF + printf "kernel2" + return + ;; + 2) + fw_setenv -s - <<-EOF + boot_part 1 + bootcmd "run nandboot" + EOF + printf "kernel1" + return + ;; + *) + return + ;; + esac } linksys_get_root_magic() { @@ -55,7 +74,7 @@ platform_do_upgrade_linksys() { nand_upgrade_tar "$1" } - [ "$magic_long" = "27051956" ] && { + [ "$magic_long" = "27051956" -o "$magic_long" = "0000a0e1" ] && { # check firmwares' rootfs types local target_mtd=$(find_mtd_part $part_label) local oldroot="$(linksys_get_root_magic $target_mtd)" @@ -73,21 +92,7 @@ platform_do_upgrade_linksys() { } } -linksys_preupgrade() { - local board=$(mvebu_board_name) - - case "$board" in - armada-385-linksys-caiman|armada-385-linksys-cobra|armada-385-linksys-shelby|armada-xp-linksys-mamba|armada-385-linksys-rango) - export RAMFS_COPY_BIN="${RAMFS_COPY_BIN} /usr/sbin/fw_printenv /usr/sbin/fw_setenv" - export RAMFS_COPY_BIN="${RAMFS_COPY_BIN} /bin/mkdir /bin/touch" - export RAMFS_COPY_DATA="${RAMFS_COPY_DATA} /etc/fw_env.config /var/lock/fw_printenv.lock" - - [ -f /tmp/sysupgrade.tgz ] && { - cp /tmp/sysupgrade.tgz /tmp/syscfg/sysupgrade.tgz - } - ;; - esac +platform_copy_config_linksys() { + cp -f /tmp/sysupgrade.tgz /tmp/syscfg/sysupgrade.tgz + sync } - -append sysupgrade_pre_upgrade linksys_preupgrade -