2 # Copyright (C) 2014 OpenWrt.org
5 linksys_get_target_firmware
() {
7 local cur_boot_part mtd_ubi0
9 cur_boot_part
=$
(/usr
/sbin
/fw_printenv
-n boot_part
)
10 if [ -z "${cur_boot_part}" ] ; then
11 mtd_ubi0
=$
(cat /sys
/devices
/virtual
/ubi
/ubi
0/mtd_num
)
12 case $
(grep -E ^mtd
${mtd_ubi0}: /proc
/mtd | cut
-d '"' -f 2) in
16 alt_kernel|alt_rootfs
)
20 >&2 printf "Current boot_part='%s' selected from ubi0/mtd_num='%s'" \
21 "${cur_boot_part}" "${mtd_ubi0}"
24 case $cur_boot_part in
28 bootcmd "run altnandboot"
36 bootcmd "run nandboot"
47 platform_do_upgrade_linksys
() {
48 local magic_long
="$(get_magic_long "$1")"
51 local part_label
="$(linksys_get_target_firmware)"
52 touch /var
/lock
/fw_printenv.lock
54 if [ ! -n "$part_label" ]
56 echo "cannot find target partition"
60 local target_mtd
=$
(find_mtd_part
$part_label)
62 [ "$magic_long" = "73797375" ] && {
63 CI_KERNPART
="$part_label"
64 if [ "$part_label" = "kernel1" ]
73 [ "$magic_long" = "27051956" ] && {
74 get_image
"$1" | mtd
write - $part_label