2 # Copyright (C) 2014-2015 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 # re-enable recovery so we get back if the new firmware is broken
23 fw_setenv auto_recovery
yes
25 echo "$target_firmware"
28 linksys_get_root_magic
() {
29 (get_image
"$@" |
dd skip
=786432 bs
=4 count
=1 |
hexdump -v -n 4 -e '1/1 "%02x"') 2>/dev
/null
32 platform_do_upgrade_linksys
() {
33 local magic_long
="$(get_magic_long "$1")"
36 local part_label
="$(linksys_get_target_firmware)"
37 touch /var
/lock
/fw_printenv.lock
39 if [ ! -n "$part_label" ]
41 echo "cannot find target partition"
45 local target_mtd
=$
(find_mtd_part
$part_label)
47 [ "$magic_long" = "73797375" ] && {
48 CI_KERNPART
="$part_label"
49 if [ "$part_label" = "kernel1" ]
58 [ "$magic_long" = "27051956" ] && {
59 # check firmwares' rootfs types
60 local target_mtd
=$
(find_mtd_part
$part_label)
61 local oldroot
="$(linksys_get_root_magic $target_mtd)"
62 local newroot
="$(linksys_get_root_magic "$1")"
64 if [ "$newroot" = "55424923" -a "$oldroot" = "55424923" ]
65 # we're upgrading from a firmware with UBI to one with UBI
67 # erase everything to be safe
69 get_image
"$1" | mtd
-n write - $part_label
71 get_image
"$1" | mtd
write - $part_label
76 platform_copy_config_linksys
() {
77 cp -f /tmp
/sysupgrade.tgz
/tmp
/syscfg
/sysupgrade.tgz