1 linksys_get_target_firmware
() {
2 local cur_boot_part mtd_ubi0
4 cur_boot_part
="$(/usr/sbin/fw_printenv -n boot_part)"
5 if [ -z "${cur_boot_part}" ]; then
6 mtd_ubi0
=$
(cat /sys
/devices
/virtual
/ubi
/ubi
0/mtd_num
)
7 case "$(grep -E "^mtd
${mtd_ubi0}:" /proc/mtd | cut -d '"' -f 2)" in
11 alt_kernel|alt_rootfs)
15 >&2 printf "Current boot_part='%s
' selected from ubi0/mtd_num='%s
'" \
16 "${cur_boot_part}" "${mtd_ubi0}"
19 # OEM U-Boot for EA6350v3, EA8300 and MR8300; bootcmd=
20 # if test $auto_recovery = no;
22 # elif test $boot_part = 1;
27 case "$cur_boot_part" in
50 platform_do_upgrade_linksys() {
51 local magic_long="$(get_magic_long "$1")"
53 local rm_oem_fw_vols="squashfs ubifs" # from OEM [alt_]rootfs UBI
57 local part_label="$(linksys_get_target_firmware)"
58 touch /var/lock/fw_printenv.lock
60 if [ -z "$part_label" ]; then
61 echo "cannot find target partition"
65 local target_mtd=$(find_mtd_part "$part_label")
67 [ "$magic_long" = "73797375" ] && {
68 CI_KERNPART="$part_label"
69 if [ "$part_label" = "kernel" ]; then
72 CI_UBIPART="alt_rootfs"
75 local mtdnum="$(find_mtd_index "$CI_UBIPART")"
76 if [ ! "$mtdnum" ]; then
77 echo "cannot find ubi mtd partition $CI_UBIPART"
81 local ubidev="$(nand_find_ubi "$CI_UBIPART")"
82 if [ ! "$ubidev" ]; then
83 ubiattach -m "$mtdnum"
85 ubidev="$(nand_find_ubi "$CI_UBIPART")"
88 if [ "$ubidev" ]; then
89 for vol in $rm_oem_fw_vols; do
90 ubirmvol "/dev/$ubidev" -N "$vol" 2>/dev/null
94 # complete std upgrade
98 [ "$magic_long" = "27051956" ] && {
99 echo "writing \"$1\" image to \"$part_label\""
100 get_image "$1" | mtd write - "$part_label"