ar71xx: fix tl-wdr3320-v2 upgrade
[openwrt/openwrt.git] / target / linux / ar71xx / base-files / lib / upgrade / platform.sh
1 #
2 # Copyright (C) 2011 OpenWrt.org
3 #
4
5 . /lib/functions/system.sh
6 . /lib/ar71xx.sh
7
8 PART_NAME=firmware
9 RAMFS_COPY_DATA='/lib/ar71xx.sh /etc/fw_env.config /var/lock/fw_printenv.lock'
10 RAMFS_COPY_BIN='nandwrite fw_printenv fw_setenv'
11
12 CI_BLKSZ=65536
13 CI_LDADR=0x80060000
14
15 PLATFORM_DO_UPGRADE_COMBINED_SEPARATE_MTD=0
16
17 platform_find_partitions() {
18 local first dev size erasesize name
19 while read dev size erasesize name; do
20 name=${name#'"'}; name=${name%'"'}
21 case "$name" in
22 vmlinux.bin.l7|vmlinux|kernel|linux|linux.bin|rootfs|filesystem)
23 if [ -z "$first" ]; then
24 first="$name"
25 else
26 echo "$erasesize:$first:$name"
27 break
28 fi
29 ;;
30 esac
31 done < /proc/mtd
32 }
33
34 platform_find_kernelpart() {
35 local part
36 for part in "${1%:*}" "${1#*:}"; do
37 case "$part" in
38 vmlinux.bin.l7|vmlinux|kernel|linux|linux.bin)
39 echo "$part"
40 break
41 ;;
42 esac
43 done
44 }
45
46 platform_find_rootfspart() {
47 local part
48 for part in "${1%:*}" "${1#*:}"; do
49 [ "$part" != "$2" ] && echo "$part" && break
50 done
51 }
52
53 platform_do_upgrade_combined() {
54 local partitions=$(platform_find_partitions)
55 local kernelpart=$(platform_find_kernelpart "${partitions#*:}")
56 local erase_size=$((0x${partitions%%:*})); partitions="${partitions#*:}"
57 local kern_length=0x$(dd if="$1" bs=2 skip=1 count=4 2>/dev/null)
58 local kern_blocks=$(($kern_length / $CI_BLKSZ))
59 local root_blocks=$((0x$(dd if="$1" bs=2 skip=5 count=4 2>/dev/null) / $CI_BLKSZ))
60
61 if [ -n "$partitions" ] && [ -n "$kernelpart" ] && \
62 [ ${kern_blocks:-0} -gt 0 ] && \
63 [ ${root_blocks:-0} -gt 0 ] && \
64 [ ${erase_size:-0} -gt 0 ];
65 then
66 local rootfspart=$(platform_find_rootfspart "$partitions" "$kernelpart")
67 local append=""
68 [ -f "$UPGRADE_BACKUP" ] && append="-j $UPGRADE_BACKUP"
69
70 if [ "$PLATFORM_DO_UPGRADE_COMBINED_SEPARATE_MTD" -ne 1 ]; then
71 ( dd if="$1" bs=$CI_BLKSZ skip=1 count=$kern_blocks 2>/dev/null; \
72 dd if="$1" bs=$CI_BLKSZ skip=$((1+$kern_blocks)) count=$root_blocks 2>/dev/null ) | \
73 mtd -r $append -F$kernelpart:$kern_length:$CI_LDADR,rootfs write - $partitions
74 elif [ -n "$rootfspart" ]; then
75 dd if="$1" bs=$CI_BLKSZ skip=1 count=$kern_blocks 2>/dev/null | \
76 mtd write - $kernelpart
77 dd if="$1" bs=$CI_BLKSZ skip=$((1+$kern_blocks)) count=$root_blocks 2>/dev/null | \
78 mtd -r $append write - $rootfspart
79 fi
80 fi
81 PLATFORM_DO_UPGRADE_COMBINED_SEPARATE_MTD=0
82 }
83
84 tplink_get_image_hwid() {
85 get_image "$@" | dd bs=4 count=1 skip=16 2>/dev/null | hexdump -v -n 4 -e '1/1 "%02x"'
86 }
87
88 tplink_get_image_mid() {
89 get_image "$@" | dd bs=4 count=1 skip=17 2>/dev/null | hexdump -v -n 4 -e '1/1 "%02x"'
90 }
91
92 tplink_get_image_boot_size() {
93 get_image "$@" | dd bs=4 count=1 skip=37 2>/dev/null | hexdump -v -n 4 -e '1/1 "%02x"'
94 }
95
96 tplink_pharos_check_support_list() {
97 local image="$1"
98 local offset="$2"
99 local model="$3"
100 local trargs="$4"
101
102 # Here $image is given to dd directly instead of using get_image;
103 # otherwise the skip will take almost a second (as dd can't seek)
104 dd if="$image" bs=1 skip=$offset count=1024 2>/dev/null | tr -d "$trargs" | (
105 while IFS= read -r line; do
106 [ "$line" = "$model" ] && exit 0
107 done
108
109 exit 1
110 )
111 }
112
113 tplink_pharos_check_image() {
114 local image_magic="$(get_magic_long "$1")"
115 local board_magic="$2"
116 [ "$image_magic" != "$board_magic" ] && {
117 echo "Invalid image magic '$image_magic'. Expected '$board_magic'."
118 return 1
119 }
120
121 local model_string="$3"
122 local trargs="$4"
123
124 # New images have the support list at 7802888, old ones at 1511432
125 tplink_pharos_check_support_list "$1" 7802888 "$model_string" "$trargs" || \
126 tplink_pharos_check_support_list "$1" 1511432 "$model_string" "$trargs" || {
127 echo "Unsupported image (model not in support-list)"
128 return 1
129 }
130
131 return 0
132 }
133
134 seama_get_type_magic() {
135 get_image "$@" | dd bs=1 count=4 skip=53 2>/dev/null | hexdump -v -n 4 -e '1/1 "%02x"'
136 }
137
138 wrgg_get_image_magic() {
139 get_image "$@" | dd bs=4 count=1 skip=8 2>/dev/null | hexdump -v -n 4 -e '1/1 "%02x"'
140 }
141
142 cybertan_get_image_magic() {
143 get_image "$@" | dd bs=8 count=1 skip=0 2>/dev/null | hexdump -v -n 8 -e '1/1 "%02x"'
144 }
145
146 cybertan_check_image() {
147 local magic="$(cybertan_get_image_magic "$1")"
148 local fw_magic="$(cybertan_get_hw_magic)"
149
150 [ "$fw_magic" != "$magic" ] && {
151 echo "Invalid image, ID mismatch, got:$magic, but need:$fw_magic"
152 return 1
153 }
154
155 return 0
156 }
157
158 platform_do_upgrade_compex() {
159 local fw_file=$1
160 local fw_part=$PART_NAME
161 local fw_mtd=$(find_mtd_part $fw_part)
162 local fw_length=0x$(dd if="$fw_file" bs=2 skip=1 count=4 2>/dev/null)
163 local fw_blocks=$(($fw_length / 65536))
164
165 if [ -n "$fw_mtd" ] && [ ${fw_blocks:-0} -gt 0 ]; then
166 local append=""
167 [ -f "$UPGRADE_BACKUP" ] && append="-j $UPGRADE_BACKUP"
168
169 sync
170 dd if="$fw_file" bs=64k skip=1 count=$fw_blocks 2>/dev/null | \
171 mtd $append write - "$fw_part"
172 fi
173 }
174
175 alfa_check_image() {
176 local magic_long="$(get_magic_long "$1")"
177 local fw_part_size=$(mtd_get_part_size firmware)
178
179 case "$magic_long" in
180 "27051956")
181 [ "$fw_part_size" != "16318464" ] && {
182 echo "Invalid image magic \"$magic_long\" for $fw_part_size bytes"
183 return 1
184 }
185 ;;
186 "68737173")
187 [ "$fw_part_size" != "7929856" ] && {
188 echo "Invalid image magic \"$magic_long\" for $fw_part_size bytes"
189 return 1
190 }
191 ;;
192 esac
193
194 return 0
195 }
196
197 platform_check_image() {
198 local board=$(board_name)
199 local magic="$(get_magic_word "$1")"
200 local magic_long="$(get_magic_long "$1")"
201
202 [ "$#" -gt 1 ] && return 1
203
204 case "$board" in
205 airgateway|\
206 airgatewaypro|\
207 airrouter|\
208 ap121f|\
209 ap132|\
210 ap531b0|\
211 ap90q|\
212 archer-c25-v1|\
213 archer-c58-v1|\
214 archer-c59-v1|\
215 archer-c59-v2|\
216 archer-c60-v1|\
217 archer-c60-v2|\
218 archer-c7-v4|\
219 archer-c7-v5|\
220 bullet-m|\
221 bullet-m-xw|\
222 c-55|\
223 carambola2|\
224 cf-e316n-v2|\
225 cf-e320n-v2|\
226 cf-e355ac-v1|\
227 cf-e355ac-v2|\
228 cf-e375ac|\
229 cf-e380ac-v1|\
230 cf-e380ac-v2|\
231 cf-e385ac|\
232 cf-e520n|\
233 cf-e530n|\
234 cpe505n|\
235 cpe830|\
236 cpe870|\
237 dap-1330-a1|\
238 dgl-5500-a1|\
239 dhp-1565-a1|\
240 dir-505-a1|\
241 dir-600-a1|\
242 dir-615-c1|\
243 dir-615-e1|\
244 dir-615-e4|\
245 dir-615-i1|\
246 dir-825-c1|\
247 dir-835-a1|\
248 dlan-hotspot|\
249 dlan-pro-1200-ac|\
250 dlan-pro-500-wp|\
251 dr342|\
252 dr531|\
253 dragino2|\
254 e1700ac-v2|\
255 e558-v2|\
256 e600g-v2|\
257 e600gac-v2|\
258 e750a-v4|\
259 e750g-v8|\
260 ebr-2310-c1|\
261 ens202ext|\
262 epg5000|\
263 esr1750|\
264 esr900|\
265 ew-balin|\
266 ew-dorin|\
267 ew-dorin-router|\
268 gl-ar150|\
269 gl-ar300m|\
270 gl-ar300|\
271 gl-ar750|\
272 gl-ar750s|\
273 gl-domino|\
274 gl-mifi|\
275 gl-usb150|\
276 hiwifi-hc6361|\
277 hornet-ub-x2|\
278 jwap230|\
279 lbe-m5|\
280 lima|\
281 loco-m-xw|\
282 mzk-w04nu|\
283 mzk-w300nh|\
284 n5q|\
285 nanostation-m|\
286 nanostation-m-xw|\
287 nbg460n_550n_550nh|\
288 pqi-air-pen|\
289 r36a|\
290 r602n|\
291 rme-eg200|\
292 rocket-m|\
293 rocket-m-ti|\
294 rocket-m-xw|\
295 rw2458n|\
296 sc1750|\
297 sc300m|\
298 sc450|\
299 sr3200|\
300 t830|\
301 tew-632brp|\
302 tew-712br|\
303 tew-732br|\
304 tew-823dru|\
305 tl-wr1043n-v5|\
306 tl-wr942n-v1|\
307 unifi|\
308 unifi-outdoor|\
309 unifiac-lite|\
310 unifiac-pro|\
311 wam250|\
312 weio|\
313 whr-g301n|\
314 whr-hp-g300n|\
315 whr-hp-gn|\
316 wlae-ag300n|\
317 wndap360|\
318 wpj342|\
319 wpj344|\
320 wpj531|\
321 wpj558|\
322 wpj563|\
323 wrt400n|\
324 wrtnode2q|\
325 wzr-450hp2|\
326 wzr-hp-ag300h|\
327 wzr-hp-g300nh|\
328 wzr-hp-g300nh2|\
329 wzr-hp-g450h|\
330 xd3200)
331 [ "$magic" != "2705" ] && {
332 echo "Invalid image type."
333 return 1
334 }
335
336 return 0
337 ;;
338 alfa-ap96|\
339 alfa-nx|\
340 ap121|\
341 ap121-mini|\
342 ap135-020|\
343 ap136-010|\
344 ap136-020|\
345 ap147-010|\
346 ap152|\
347 ap91-5g|\
348 ap96|\
349 arduino-yun|\
350 bhr-4grv2|\
351 bxu2000n-2-a1|\
352 db120|\
353 dr344|\
354 dw33d|\
355 f9k1115v2|\
356 hornet-ub|\
357 mr12|\
358 mr16|\
359 zbt-we1526|\
360 zcn-1523h-2|\
361 zcn-1523h-5)
362 [ "$magic_long" != "68737173" -a "$magic_long" != "19852003" ] && {
363 echo "Invalid image type."
364 return 1
365 }
366
367 return 0
368 ;;
369 all0258n|\
370 all0315n|\
371 cap324|\
372 cap4200ag|\
373 cr3000|\
374 cr5000)
375 platform_check_image_allnet "$1" && return 0
376 return 1
377 ;;
378 all0305|\
379 eap300v2|\
380 eap7660d|\
381 ja76pf|\
382 ja76pf2|\
383 jwap003|\
384 ls-sr71|\
385 pb42|\
386 pb44|\
387 routerstation|\
388 routerstation-pro|\
389 wp543|\
390 wpe72)
391 [ "$magic" != "4349" ] && {
392 echo "Invalid image. Use *-sysupgrade.bin files on this board"
393 return 1
394 }
395
396 local md5_img=$(dd if="$1" bs=2 skip=9 count=16 2>/dev/null)
397 local md5_chk=$(fwtool -q -t -i /dev/null "$1"; dd if="$1" bs=$CI_BLKSZ skip=1 2>/dev/null | md5sum -); md5_chk="${md5_chk%% *}"
398
399 if [ -n "$md5_img" -a -n "$md5_chk" ] && [ "$md5_img" = "$md5_chk" ]; then
400 return 0
401 else
402 echo "Invalid image. Contents do not match checksum (image:$md5_img calculated:$md5_chk)"
403 return 1
404 fi
405
406 return 0
407 ;;
408 antminer-s1|\
409 antminer-s3|\
410 antrouter-r1|\
411 archer-c5|\
412 archer-c7|\
413 el-m150|\
414 el-mini|\
415 gl-inet|\
416 lan-turtle|\
417 mc-mac1200r|\
418 minibox-v1|\
419 minibox-v3.2|\
420 omy-g1|\
421 omy-x1|\
422 onion-omega|\
423 oolite-v1|\
424 oolite-v5.2|\
425 oolite-v5.2-dev|\
426 packet-squirrel|\
427 re355|\
428 re450|\
429 rut900|\
430 smart-300|\
431 som9331|\
432 tellstick-znet-lite|\
433 tl-mr10u|\
434 tl-mr11u|\
435 tl-mr12u|\
436 tl-mr13u|\
437 tl-mr3020|\
438 tl-mr3040|\
439 tl-mr3040-v2|\
440 tl-mr3220|\
441 tl-mr3220-v2|\
442 tl-mr3420|\
443 tl-mr3420-v2|\
444 tl-mr6400|\
445 tl-wa701nd-v2|\
446 tl-wa7210n-v2|\
447 tl-wa750re|\
448 tl-wa7510n|\
449 tl-wa801nd-v2|\
450 tl-wa801nd-v3|\
451 tl-wa830re-v2|\
452 tl-wa850re|\
453 tl-wa850re-v2|\
454 tl-wa855re-v1|\
455 tl-wa860re|\
456 tl-wa901nd|\
457 tl-wa901nd-v2|\
458 tl-wa901nd-v3|\
459 tl-wa901nd-v4|\
460 tl-wa901nd-v5|\
461 tl-wdr3320-v2|\
462 tl-wdr3500|\
463 tl-wdr4300|\
464 tl-wdr4900-v2|\
465 tl-wdr6500-v2|\
466 tl-wpa8630|\
467 tl-wr1041n-v2|\
468 tl-wr1043nd|\
469 tl-wr1043nd-v2|\
470 tl-wr1043nd-v4|\
471 tl-wr2543n|\
472 tl-wr703n|\
473 tl-wr710n|\
474 tl-wr720n-v3|\
475 tl-wr740n-v6|\
476 tl-wr741nd|\
477 tl-wr741nd-v4|\
478 tl-wr802n-v1|\
479 tl-wr802n-v2|\
480 tl-wr810n|\
481 tl-wr810n-v2|\
482 tl-wr840n-v2|\
483 tl-wr840n-v3|\
484 tl-wr841n-v1|\
485 tl-wr841n-v7|\
486 tl-wr841n-v8|\
487 tl-wr841n-v9|\
488 tl-wr841n-v11|\
489 tl-wr842n-v2|\
490 tl-wr842n-v3|\
491 tl-wr902ac-v1|\
492 tl-wr940n-v4|\
493 tl-wr940n-v6|\
494 tl-wr941nd|\
495 tl-wr941nd-v5|\
496 tl-wr941nd-v6|\
497 ts-d084|\
498 wifi-pineapple-nano)
499 local magic_ver="0100"
500
501 case "$board" in
502 tl-wdr3320-v2|tl-wdr6500-v2)
503 magic_ver="0200"
504 ;;
505 esac
506
507 [ "$magic" != "$magic_ver" ] && {
508 echo "Invalid image type."
509 return 1
510 }
511
512 local hwid
513 local mid
514 local imagehwid
515 local imagemid
516
517 hwid=$(tplink_get_hwid)
518 mid=$(tplink_get_mid)
519 imagehwid=$(tplink_get_image_hwid "$1")
520 imagemid=$(tplink_get_image_mid "$1")
521
522 [ "$hwid" != "$imagehwid" -o "$mid" != "$imagemid" ] && {
523 echo "Invalid image, hardware ID mismatch, hw:$hwid $mid image:$imagehwid $imagemid."
524 return 1
525 }
526
527 local boot_size
528
529 boot_size=$(tplink_get_image_boot_size "$1")
530 [ "$boot_size" != "00000000" ] && {
531 echo "Invalid image, it contains a bootloader."
532 return 1
533 }
534
535 return 0
536 ;;
537 bsb|\
538 dir-825-b1|\
539 tew-673gru)
540 dir825b_check_image "$1" && return 0
541 ;;
542 rb-411|\
543 rb-411u|\
544 rb-433|\
545 rb-433u|\
546 rb-435g|\
547 rb-450|\
548 rb-450g|\
549 rb-493|\
550 rb-493g|\
551 rb-750|\
552 rb-750gl|\
553 rb-751|\
554 rb-751g|\
555 rb-911g-2hpnd|\
556 rb-911g-5hpnd|\
557 rb-911g-5hpacd|\
558 rb-912uag-2hpnd|\
559 rb-912uag-5hpnd|\
560 rb-921gs-5hpacd-r2|\
561 rb-922uags-5hpacd|\
562 rb-951g-2hnd|\
563 rb-951ui-2hnd|\
564 rb-2011l|\
565 rb-2011il|\
566 rb-2011ils|\
567 rb-2011uas|\
568 rb-2011uas-2hnd|\
569 rb-2011uias|\
570 rb-2011uias-2hnd|\
571 rb-2011uias-2hnd-r2|\
572 rb-sxt2n|\
573 rb-sxt5n)
574 nand_do_platform_check routerboard $1
575 return $?
576 ;;
577 c-60|\
578 hiveap-121|\
579 nbg6716|\
580 r6100|\
581 rambutan|\
582 wi2a-ac200i|\
583 wndr3700v4|\
584 wndr4300)
585 nand_do_platform_check $board $1
586 return $?
587 ;;
588 cpe210|\
589 cpe510|\
590 eap120|\
591 wbs210|\
592 wbs510)
593 tplink_pharos_check_image "$1" "7f454c46" "$(tplink_pharos_get_model_string)" '' && return 0
594 return 1
595 ;;
596 cpe210-v2|\
597 cpe210-v3)
598 tplink_pharos_check_image "$1" "01000000" "$(tplink_pharos_v2_get_model_string)" '\0\xff\r' && return 0
599 return 1
600 ;;
601 cpe510-v2)
602 tplink_pharos_check_image "$1" "7f454c46" "$(tplink_pharos_v2_get_model_string)" '\0\xff\r' && return 0
603 return 1
604 ;;
605 a40|\
606 a60|\
607 mr1750|\
608 mr1750v2|\
609 mr600|\
610 mr600v2|\
611 mr900|\
612 mr900v2|\
613 om2p|\
614 om2p-hs|\
615 om2p-hsv2|\
616 om2p-hsv3|\
617 om2p-hsv4|\
618 om2p-lc|\
619 om2pv2|\
620 om2pv4|\
621 om5p|\
622 om5p-ac|\
623 om5p-acv2|\
624 om5p-an)
625 platform_check_image_openmesh "$magic_long" "$1" && return 0
626 return 1
627 ;;
628 mr18|\
629 z1)
630 merakinand_do_platform_check $board $1
631 return $?
632 ;;
633 dir-869-a1|\
634 mynet-n600|\
635 mynet-n750|\
636 qihoo-c301)
637 [ "$magic_long" != "5ea3a417" ] && {
638 echo "Invalid image, bad magic: $magic_long"
639 return 1
640 }
641
642 local typemagic=$(seama_get_type_magic "$1")
643 [ "$typemagic" != "6669726d" ] && {
644 echo "Invalid image, bad type: $typemagic"
645 return 1
646 }
647
648 return 0
649 ;;
650 e2100l|\
651 mynet-rext|\
652 wrt160nl)
653 cybertan_check_image "$1" && return 0
654 return 1
655 ;;
656 nbg6616|\
657 uap-pro|\
658 unifi-outdoor-plus)
659 [ "$magic_long" != "19852003" ] && {
660 echo "Invalid image type."
661 return 1
662 }
663
664 return 0
665 ;;
666 tube2h)
667 alfa_check_image "$1" && return 0
668 return 1
669 ;;
670 wndr3700|\
671 wnr1000-v2|\
672 wnr2000-v3|\
673 wnr612-v2|\
674 wpn824n)
675 local hw_magic
676
677 hw_magic="$(ar71xx_get_mtd_part_magic firmware)"
678 [ "$magic_long" != "$hw_magic" ] && {
679 echo "Invalid image, hardware ID mismatch, hw:$hw_magic image:$magic_long."
680 return 1
681 }
682
683 return 0
684 ;;
685 wnr2000-v4)
686 [ "$magic_long" != "32303034" ] && {
687 echo "Invalid image type."
688 return 1
689 }
690
691 return 0
692 ;;
693 wnr2200)
694 [ "$magic_long" != "32323030" ] && {
695 echo "Invalid image type."
696 return 1
697 }
698
699 return 0
700 ;;
701 dap-2695-a1)
702 local magic=$(wrgg_get_image_magic "$1")
703 [ "$magic" != "21030820" ] && {
704 echo "Invalid image, bad type: $magic"
705 return 1
706 }
707
708 return 0;
709 ;;
710 # these boards use metadata images
711 fritz300e|\
712 fritz4020|\
713 fritz450e|\
714 koala|\
715 rb-750-r2|\
716 rb-750p-pbr2|\
717 rb-750up-r2|\
718 rb-911-2hn|\
719 rb-911-5hn|\
720 rb-931-2nd|\
721 rb-941-2nd|\
722 rb-951ui-2nd|\
723 rb-952ui-5ac2nd|\
724 rb-962uigs-5hact2hnt|\
725 rb-lhg-5nd|\
726 rb-map-2nd|\
727 rb-mapl-2nd|\
728 rb-sxt-2nd-r3|\
729 rb-wap-2nd|\
730 rb-wapg-5hact2hnd|\
731 rb-wapr-2nd)
732 return 0
733 ;;
734 esac
735
736 echo "Sysupgrade is not yet supported on $board."
737 return 1
738 }
739
740 platform_pre_upgrade() {
741 local board=$(board_name)
742
743 case "$board" in
744 rb-750-r2|\
745 rb-750p-pbr2|\
746 rb-750up-r2|\
747 rb-911-2hn|\
748 rb-911-5hn|\
749 rb-931-2nd|\
750 rb-941-2nd|\
751 rb-951ui-2nd|\
752 rb-952ui-5ac2nd|\
753 rb-962uigs-5hact2hnt|\
754 rb-lhg-5nd|\
755 rb-map-2nd|\
756 rb-mapl-2nd|\
757 rb-sxt-2nd-r3|\
758 rb-wap-2nd|\
759 rb-wapg-5hact2hnd|\
760 rb-wapr-2nd)
761 # erase firmware if booted from initramfs
762 [ -z "$(rootfs_type)" ] && mtd erase firmware
763 ;;
764 esac
765 }
766
767 platform_nand_pre_upgrade() {
768 local board=$(board_name)
769
770 case "$board" in
771 rb*)
772 CI_KERNPART=none
773 local fw_mtd=$(find_mtd_part kernel)
774 fw_mtd="${fw_mtd/block/}"
775 [ -n "$fw_mtd" ] || return
776 mtd erase kernel
777 tar xf "$1" sysupgrade-routerboard/kernel -O | nandwrite -o "$fw_mtd" -
778 ;;
779 wi2a-ac200i)
780 case "$(fw_printenv -n dualPartition)" in
781 imgA)
782 fw_setenv dualPartition imgB
783 fw_setenv ActImg NokiaImageB
784 ;;
785 imgB)
786 fw_setenv dualPartition imgA
787 fw_setenv ActImg NokiaImageA
788 ;;
789 esac
790 ubiblock -r /dev/ubiblock0_0 2>/dev/null >/dev/null
791 rm -f /dev/ubiblock0_0
792 ubidetach -d 0 2>/dev/null >/dev/null
793 CI_UBIPART=ubi_alt
794 CI_KERNPART=kernel_alt
795 ;;
796 esac
797 }
798
799 platform_do_upgrade() {
800 local board=$(board_name)
801
802 case "$board" in
803 all0258n)
804 platform_do_upgrade_allnet "0x9f050000" "$1"
805 ;;
806 all0305|\
807 eap7660d|\
808 ja76pf|\
809 ja76pf2|\
810 jwap003|\
811 ls-sr71|\
812 pb42|\
813 pb44|\
814 routerstation|\
815 routerstation-pro)
816 platform_do_upgrade_combined "$1"
817 ;;
818 all0315n)
819 platform_do_upgrade_allnet "0x9f080000" "$1"
820 ;;
821 cap4200ag|\
822 eap300v2|\
823 ens202ext)
824 platform_do_upgrade_allnet "0xbf0a0000" "$1"
825 ;;
826 dir-825-b1|\
827 tew-673gru)
828 platform_do_upgrade_dir825b "$1"
829 ;;
830 a40|\
831 a60|\
832 mr1750|\
833 mr1750v2|\
834 mr600|\
835 mr600v2|\
836 mr900|\
837 mr900v2|\
838 om2p|\
839 om2p-hs|\
840 om2p-hsv2|\
841 om2p-hsv3|\
842 om2p-hsv4|\
843 om2p-lc|\
844 om2pv2|\
845 om2pv4|\
846 om5p|\
847 om5p-ac|\
848 om5p-acv2|\
849 om5p-an)
850 platform_do_upgrade_openmesh "$1"
851 ;;
852 c-60|\
853 hiveap-121|\
854 nbg6716|\
855 r6100|\
856 rambutan|\
857 rb-411|\
858 rb-411u|\
859 rb-433|\
860 rb-433u|\
861 rb-435g|\
862 rb-450|\
863 rb-450g|\
864 rb-493|\
865 rb-493g|\
866 rb-750|\
867 rb-750gl|\
868 rb-751|\
869 rb-751g|\
870 rb-911g-2hpnd|\
871 rb-911g-5hpacd|\
872 rb-911g-5hpnd|\
873 rb-912uag-2hpnd|\
874 rb-912uag-5hpnd|\
875 rb-921gs-5hpacd-r2|\
876 rb-922uags-5hpacd|\
877 rb-951g-2hnd|\
878 rb-951ui-2hnd|\
879 rb-2011il|\
880 rb-2011ils|\
881 rb-2011l|\
882 rb-2011uas|\
883 rb-2011uas-2hnd|\
884 rb-2011uias|\
885 rb-2011uias-2hnd|\
886 rb-2011uias-2hnd-r2|\
887 rb-sxt2n|\
888 rb-sxt5n|\
889 wi2a-ac200i|\
890 wndr3700v4|\
891 wndr4300)
892 nand_do_upgrade "$1"
893 ;;
894 mr18|\
895 z1)
896 merakinand_do_upgrade "$1"
897 ;;
898 uap-pro|\
899 unifi-outdoor-plus)
900 MTD_CONFIG_ARGS="-s 0x180000"
901 default_do_upgrade "$1"
902 ;;
903 wp543|\
904 wpe72)
905 platform_do_upgrade_compex "$1"
906 ;;
907 *)
908 default_do_upgrade "$1"
909 ;;
910 esac
911 }