2 # Copyright (C) 2014 OpenWrt.org
5 linksys_get_target_firmware() {
6 cur_boot_part=`/usr/sbin/fw_printenv -n boot_part`
8 if [ "$cur_boot_part" = "1" ]
10 # current primary boot - update alt boot
11 target_firmware="kernel2"
13 fw_setenv bootcmd "run altnandboot"
14 elif [ "$cur_boot_part" = "2" ]
16 # current alt boot - update primary boot
17 target_firmware="kernel1"
19 fw_setenv bootcmd "run nandboot"
22 echo "$target_firmware"
25 platform_do_upgrade_linksys() {
26 local magic_long="$(get_magic_long "$1")"
29 local part_label="$(linksys_get_target_firmware)"
30 touch /var/lock/fw_printenv.lock
32 if [ ! -n "$part_label" ]
34 echo "cannot find target partition"
38 # we don't know, what filesystem does the other partition use,
41 get_image "$1" | mtd -n write - $part_label
44 linksys_preupgrade() {
45 export RAMFS_COPY_BIN="${RAMFS_COPY_BIN} /usr/sbin/fw_printenv /usr/sbin/fw_setenv"
46 export RAMFS_COPY_BIN="${RAMFS_COPY_BIN} /bin/mkdir /bin/touch"
47 export RAMFS_COPY_DATA="${RAMFS_COPY_DATA} /etc/fw_env.config /var/lock/fw_printenv.lock"
49 [ -f /tmp/sysupgrade.tgz ] && {
50 cp /tmp/sysupgrade.tgz /tmp/syscfg/sysupgrade.tgz
54 append sysupgrade_pre_upgrade linksys_preupgrade