21ad3075bd8cac324270d9479d6c8dc3b867164f
[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 "$CONF_TAR" -a "$SAVE_CONFIG" -eq 1 ] && append="-j $CONF_TAR"
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 "$CONF_TAR" -a "$SAVE_CONFIG" -eq 1 ] && append="-j $CONF_TAR"
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 c-55|\
222 carambola2|\
223 cf-e316n-v2|\
224 cf-e320n-v2|\
225 cf-e355ac-v1|\
226 cf-e355ac-v2|\
227 cf-e375ac|\
228 cf-e380ac-v1|\
229 cf-e380ac-v2|\
230 cf-e385ac|\
231 cf-e520n|\
232 cf-e530n|\
233 cpe505n|\
234 cpe830|\
235 cpe870|\
236 dap-1330-a1|\
237 dgl-5500-a1|\
238 dhp-1565-a1|\
239 dir-505-a1|\
240 dir-600-a1|\
241 dir-615-c1|\
242 dir-615-e1|\
243 dir-615-e4|\
244 dir-615-i1|\
245 dir-825-c1|\
246 dir-835-a1|\
247 dlan-hotspot|\
248 dlan-pro-1200-ac|\
249 dlan-pro-500-wp|\
250 dr342|\
251 dr531|\
252 dragino2|\
253 e1700ac-v2|\
254 e558-v2|\
255 e600g-v2|\
256 e600gac-v2|\
257 e750a-v4|\
258 e750g-v8|\
259 ebr-2310-c1|\
260 ens202ext|\
261 epg5000|\
262 esr1750|\
263 esr900|\
264 ew-balin|\
265 ew-dorin|\
266 ew-dorin-router|\
267 gl-ar150|\
268 gl-ar300m|\
269 gl-ar300|\
270 gl-ar750|\
271 gl-ar750s|\
272 gl-domino|\
273 gl-mifi|\
274 gl-usb150|\
275 hiwifi-hc6361|\
276 hornet-ub-x2|\
277 jwap230|\
278 lbe-m5|\
279 lima|\
280 loco-m-xw|\
281 mzk-w04nu|\
282 mzk-w300nh|\
283 n5q|\
284 nanostation-m|\
285 nanostation-m-xw|\
286 nbg460n_550n_550nh|\
287 pqi-air-pen|\
288 r36a|\
289 r602n|\
290 rme-eg200|\
291 rocket-m|\
292 rocket-m-ti|\
293 rocket-m-xw|\
294 rw2458n|\
295 sc1750|\
296 sc300m|\
297 sc450|\
298 sr3200|\
299 t830|\
300 tew-632brp|\
301 tew-712br|\
302 tew-732br|\
303 tew-823dru|\
304 tl-wr1043n-v5|\
305 tl-wr942n-v1|\
306 unifi|\
307 unifi-outdoor|\
308 unifiac-lite|\
309 unifiac-pro|\
310 wam250|\
311 weio|\
312 whr-g301n|\
313 whr-hp-g300n|\
314 whr-hp-gn|\
315 wlae-ag300n|\
316 wndap360|\
317 wpj342|\
318 wpj344|\
319 wpj531|\
320 wpj558|\
321 wpj563|\
322 wrt400n|\
323 wrtnode2q|\
324 wzr-450hp2|\
325 wzr-hp-ag300h|\
326 wzr-hp-g300nh|\
327 wzr-hp-g300nh2|\
328 wzr-hp-g450h|\
329 xd3200)
330 [ "$magic" != "2705" ] && {
331 echo "Invalid image type."
332 return 1
333 }
334
335 return 0
336 ;;
337 alfa-ap96|\
338 alfa-nx|\
339 ap121|\
340 ap121-mini|\
341 ap135-020|\
342 ap136-010|\
343 ap136-020|\
344 ap147-010|\
345 ap152|\
346 ap91-5g|\
347 ap96|\
348 arduino-yun|\
349 bhr-4grv2|\
350 bxu2000n-2-a1|\
351 db120|\
352 dr344|\
353 dw33d|\
354 f9k1115v2|\
355 hornet-ub|\
356 mr12|\
357 mr16|\
358 zbt-we1526|\
359 zcn-1523h-2|\
360 zcn-1523h-5)
361 [ "$magic_long" != "68737173" -a "$magic_long" != "19852003" ] && {
362 echo "Invalid image type."
363 return 1
364 }
365
366 return 0
367 ;;
368 all0258n|\
369 all0315n|\
370 cap324|\
371 cap4200ag|\
372 cr3000|\
373 cr5000)
374 platform_check_image_allnet "$1" && return 0
375 return 1
376 ;;
377 all0305|\
378 eap300v2|\
379 eap7660d|\
380 ja76pf|\
381 ja76pf2|\
382 jwap003|\
383 ls-sr71|\
384 pb42|\
385 pb44|\
386 routerstation|\
387 routerstation-pro|\
388 wp543|\
389 wpe72)
390 [ "$magic" != "4349" ] && {
391 echo "Invalid image. Use *-sysupgrade.bin files on this board"
392 return 1
393 }
394
395 local md5_img=$(dd if="$1" bs=2 skip=9 count=16 2>/dev/null)
396 local md5_chk=$(dd if="$1" bs=$CI_BLKSZ skip=1 2>/dev/null | md5sum -); md5_chk="${md5_chk%% *}"
397
398 if [ -n "$md5_img" -a -n "$md5_chk" ] && [ "$md5_img" = "$md5_chk" ]; then
399 return 0
400 else
401 echo "Invalid image. Contents do not match checksum (image:$md5_img calculated:$md5_chk)"
402 return 1
403 fi
404
405 return 0
406 ;;
407 antminer-s1|\
408 antminer-s3|\
409 antrouter-r1|\
410 archer-c5|\
411 archer-c7|\
412 el-m150|\
413 el-mini|\
414 gl-inet|\
415 lan-turtle|\
416 mc-mac1200r|\
417 minibox-v1|\
418 minibox-v3.2|\
419 omy-g1|\
420 omy-x1|\
421 onion-omega|\
422 oolite-v1|\
423 oolite-v5.2|\
424 oolite-v5.2-dev|\
425 packet-squirrel|\
426 re355|\
427 re450|\
428 rut900|\
429 smart-300|\
430 som9331|\
431 tellstick-znet-lite|\
432 tl-mr10u|\
433 tl-mr11u|\
434 tl-mr12u|\
435 tl-mr13u|\
436 tl-mr3020|\
437 tl-mr3040|\
438 tl-mr3040-v2|\
439 tl-mr3220|\
440 tl-mr3220-v2|\
441 tl-mr3420|\
442 tl-mr3420-v2|\
443 tl-mr6400|\
444 tl-wa701nd-v2|\
445 tl-wa7210n-v2|\
446 tl-wa750re|\
447 tl-wa7510n|\
448 tl-wa801nd-v2|\
449 tl-wa801nd-v3|\
450 tl-wa830re-v2|\
451 tl-wa850re|\
452 tl-wa850re-v2|\
453 tl-wa855re-v1|\
454 tl-wa860re|\
455 tl-wa901nd|\
456 tl-wa901nd-v2|\
457 tl-wa901nd-v3|\
458 tl-wa901nd-v4|\
459 tl-wa901nd-v5|\
460 tl-wdr3320-v2|\
461 tl-wdr3500|\
462 tl-wdr4300|\
463 tl-wdr4900-v2|\
464 tl-wdr6500-v2|\
465 tl-wpa8630|\
466 tl-wr1041n-v2|\
467 tl-wr1043nd|\
468 tl-wr1043nd-v2|\
469 tl-wr1043nd-v4|\
470 tl-wr2543n|\
471 tl-wr703n|\
472 tl-wr710n|\
473 tl-wr720n-v3|\
474 tl-wr740n-v6|\
475 tl-wr741nd|\
476 tl-wr741nd-v4|\
477 tl-wr802n-v1|\
478 tl-wr802n-v2|\
479 tl-wr810n|\
480 tl-wr810n-v2|\
481 tl-wr840n-v2|\
482 tl-wr840n-v3|\
483 tl-wr841n-v1|\
484 tl-wr841n-v7|\
485 tl-wr841n-v8|\
486 tl-wr841n-v9|\
487 tl-wr841n-v11|\
488 tl-wr842n-v2|\
489 tl-wr842n-v3|\
490 tl-wr902ac-v1|\
491 tl-wr940n-v4|\
492 tl-wr940n-v6|\
493 tl-wr941nd|\
494 tl-wr941nd-v5|\
495 tl-wr941nd-v6|\
496 ts-d084|\
497 wifi-pineapple-nano)
498 local magic_ver="0100"
499
500 case "$board" in
501 tl-wdr6500-v2)
502 magic_ver="0200"
503 ;;
504 esac
505
506 [ "$magic" != "$magic_ver" ] && {
507 echo "Invalid image type."
508 return 1
509 }
510
511 local hwid
512 local mid
513 local imagehwid
514 local imagemid
515
516 hwid=$(tplink_get_hwid)
517 mid=$(tplink_get_mid)
518 imagehwid=$(tplink_get_image_hwid "$1")
519 imagemid=$(tplink_get_image_mid "$1")
520
521 [ "$hwid" != "$imagehwid" -o "$mid" != "$imagemid" ] && {
522 echo "Invalid image, hardware ID mismatch, hw:$hwid $mid image:$imagehwid $imagemid."
523 return 1
524 }
525
526 local boot_size
527
528 boot_size=$(tplink_get_image_boot_size "$1")
529 [ "$boot_size" != "00000000" ] && {
530 echo "Invalid image, it contains a bootloader."
531 return 1
532 }
533
534 return 0
535 ;;
536 bsb|\
537 dir-825-b1|\
538 tew-673gru)
539 dir825b_check_image "$1" && return 0
540 ;;
541 rb-411|\
542 rb-411u|\
543 rb-433|\
544 rb-433u|\
545 rb-435g|\
546 rb-450|\
547 rb-450g|\
548 rb-493|\
549 rb-493g|\
550 rb-750|\
551 rb-750gl|\
552 rb-751|\
553 rb-751g|\
554 rb-911g-2hpnd|\
555 rb-911g-5hpnd|\
556 rb-911g-5hpacd|\
557 rb-912uag-2hpnd|\
558 rb-912uag-5hpnd|\
559 rb-921gs-5hpacd-r2|\
560 rb-951g-2hnd|\
561 rb-951ui-2hnd|\
562 rb-2011l|\
563 rb-2011il|\
564 rb-2011ils|\
565 rb-2011uas|\
566 rb-2011uas-2hnd|\
567 rb-2011uias|\
568 rb-2011uias-2hnd|\
569 rb-sxt2n|\
570 rb-sxt5n)
571 nand_do_platform_check routerboard $1
572 return $?
573 ;;
574 c-60|\
575 hiveap-121|\
576 nbg6716|\
577 r6100|\
578 rambutan|\
579 wi2a-ac200i|\
580 wndr3700v4|\
581 wndr4300)
582 nand_do_platform_check $board $1
583 return $?
584 ;;
585 cpe210|\
586 eap120|\
587 wbs210|\
588 wbs510)
589 tplink_pharos_check_image "$1" "7f454c46" "$(tplink_pharos_get_model_string)" '' && return 0
590 return 1
591 ;;
592 cpe210-v2)
593 tplink_pharos_check_image "$1" "01000000" "$(tplink_pharos_v2_get_model_string)" '\0\xff\r' && return 0
594 return 1
595 ;;
596 cpe510)
597 local modelstr="$(tplink_pharos_v2_get_model_string)"
598 tplink_pharos_board_detect $modelstr
599 case $AR71XX_MODEL in
600 'TP-Link CPE510 v2.0')
601 tplink_pharos_check_image "$1" "7f454c46" "$modelstr" '\0\xff\r' && return 0
602 return 1
603 ;;
604 *)
605 tplink_pharos_check_image "$1" "7f454c46" "$(tplink_pharos_get_model_string)" '' && return 0
606 return 1
607 ;;
608 esac
609 ;;
610 a40|\
611 a60|\
612 mr1750|\
613 mr1750v2|\
614 mr600|\
615 mr600v2|\
616 mr900|\
617 mr900v2|\
618 om2p|\
619 om2p-hs|\
620 om2p-hsv2|\
621 om2p-hsv3|\
622 om2p-hsv4|\
623 om2p-lc|\
624 om2pv2|\
625 om2pv4|\
626 om5p|\
627 om5p-ac|\
628 om5p-acv2|\
629 om5p-an)
630 platform_check_image_openmesh "$magic_long" "$1" && return 0
631 return 1
632 ;;
633 mr18|\
634 z1)
635 merakinand_do_platform_check $board $1
636 return $?
637 ;;
638 dir-869-a1|\
639 mynet-n600|\
640 mynet-n750|\
641 qihoo-c301)
642 [ "$magic_long" != "5ea3a417" ] && {
643 echo "Invalid image, bad magic: $magic_long"
644 return 1
645 }
646
647 local typemagic=$(seama_get_type_magic "$1")
648 [ "$typemagic" != "6669726d" ] && {
649 echo "Invalid image, bad type: $typemagic"
650 return 1
651 }
652
653 return 0
654 ;;
655 e2100l|\
656 mynet-rext|\
657 wrt160nl)
658 cybertan_check_image "$1" && return 0
659 return 1
660 ;;
661 nbg6616|\
662 uap-pro|\
663 unifi-outdoor-plus)
664 [ "$magic_long" != "19852003" ] && {
665 echo "Invalid image type."
666 return 1
667 }
668
669 return 0
670 ;;
671 tube2h)
672 alfa_check_image "$1" && return 0
673 return 1
674 ;;
675 wndr3700|\
676 wnr1000-v2|\
677 wnr2000-v3|\
678 wnr612-v2|\
679 wpn824n)
680 local hw_magic
681
682 hw_magic="$(ar71xx_get_mtd_part_magic firmware)"
683 [ "$magic_long" != "$hw_magic" ] && {
684 echo "Invalid image, hardware ID mismatch, hw:$hw_magic image:$magic_long."
685 return 1
686 }
687
688 return 0
689 ;;
690 wnr2000-v4)
691 [ "$magic_long" != "32303034" ] && {
692 echo "Invalid image type."
693 return 1
694 }
695
696 return 0
697 ;;
698 wnr2200)
699 [ "$magic_long" != "32323030" ] && {
700 echo "Invalid image type."
701 return 1
702 }
703
704 return 0
705 ;;
706 dap-2695-a1)
707 local magic=$(wrgg_get_image_magic "$1")
708 [ "$magic" != "21030820" ] && {
709 echo "Invalid image, bad type: $magic"
710 return 1
711 }
712
713 return 0;
714 ;;
715 # these boards use metadata images
716 fritz300e|\
717 fritz4020|\
718 fritz450e|\
719 koala|\
720 rb-750-r2|\
721 rb-750p-pbr2|\
722 rb-750up-r2|\
723 rb-911-2hn|\
724 rb-911-5hn|\
725 rb-931-2nd|\
726 rb-941-2nd|\
727 rb-951ui-2nd|\
728 rb-952ui-5ac2nd|\
729 rb-962uigs-5hact2hnt|\
730 rb-lhg-5nd|\
731 rb-map-2nd|\
732 rb-mapl-2nd|\
733 rb-wap-2nd|\
734 rb-wapg-5hact2hnd|\
735 rb-wapr-2nd)
736 return 0
737 ;;
738 esac
739
740 echo "Sysupgrade is not yet supported on $board."
741 return 1
742 }
743
744 platform_pre_upgrade() {
745 local board=$(board_name)
746
747 case "$board" in
748 rb-750-r2|\
749 rb-750p-pbr2|\
750 rb-750up-r2|\
751 rb-911-2hn|\
752 rb-911-5hn|\
753 rb-931-2nd|\
754 rb-941-2nd|\
755 rb-951ui-2nd|\
756 rb-952ui-5ac2nd|\
757 rb-962uigs-5hact2hnt|\
758 rb-lhg-5nd|\
759 rb-map-2nd|\
760 rb-mapl-2nd|\
761 rb-wap-2nd|\
762 rb-wapg-5hact2hnd|\
763 rb-wapr-2nd)
764 # erase firmware if booted from initramfs
765 [ -z "$(rootfs_type)" ] && mtd erase firmware
766 ;;
767 esac
768 }
769
770 platform_nand_pre_upgrade() {
771 local board=$(board_name)
772
773 case "$board" in
774 rb*)
775 CI_KERNPART=none
776 local fw_mtd=$(find_mtd_part kernel)
777 fw_mtd="${fw_mtd/block/}"
778 [ -n "$fw_mtd" ] || return
779 mtd erase kernel
780 tar xf "$1" sysupgrade-routerboard/kernel -O | nandwrite -o "$fw_mtd" -
781 ;;
782 wi2a-ac200i)
783 case "$(fw_printenv -n dualPartition)" in
784 imgA)
785 fw_setenv dualPartition imgB
786 fw_setenv ActImg NokiaImageB
787 ;;
788 imgB)
789 fw_setenv dualPartition imgA
790 fw_setenv ActImg NokiaImageA
791 ;;
792 esac
793 ubiblock -r /dev/ubiblock0_0 2>/dev/null >/dev/null
794 rm -f /dev/ubiblock0_0
795 ubidetach -d 0 2>/dev/null >/dev/null
796 CI_UBIPART=ubi_alt
797 CI_KERNPART=kernel_alt
798 ;;
799 esac
800 }
801
802 platform_do_upgrade() {
803 local board=$(board_name)
804
805 case "$board" in
806 all0258n)
807 platform_do_upgrade_allnet "0x9f050000" "$ARGV"
808 ;;
809 all0305|\
810 eap7660d|\
811 ja76pf|\
812 ja76pf2|\
813 jwap003|\
814 ls-sr71|\
815 pb42|\
816 pb44|\
817 routerstation|\
818 routerstation-pro)
819 platform_do_upgrade_combined "$ARGV"
820 ;;
821 all0315n)
822 platform_do_upgrade_allnet "0x9f080000" "$ARGV"
823 ;;
824 cap4200ag|\
825 eap300v2|\
826 ens202ext)
827 platform_do_upgrade_allnet "0xbf0a0000" "$ARGV"
828 ;;
829 dir-825-b1|\
830 tew-673gru)
831 platform_do_upgrade_dir825b "$ARGV"
832 ;;
833 a40|\
834 a60|\
835 mr1750|\
836 mr1750v2|\
837 mr600|\
838 mr600v2|\
839 mr900|\
840 mr900v2|\
841 om2p|\
842 om2p-hs|\
843 om2p-hsv2|\
844 om2p-hsv3|\
845 om2p-hsv4|\
846 om2p-lc|\
847 om2pv2|\
848 om2pv4|\
849 om5p|\
850 om5p-ac|\
851 om5p-acv2|\
852 om5p-an)
853 platform_do_upgrade_openmesh "$ARGV"
854 ;;
855 c-60|\
856 hiveap-121|\
857 nbg6716|\
858 r6100|\
859 rambutan|\
860 rb-411|\
861 rb-411u|\
862 rb-433|\
863 rb-433u|\
864 rb-435g|\
865 rb-450|\
866 rb-450g|\
867 rb-493|\
868 rb-493g|\
869 rb-750|\
870 rb-750gl|\
871 rb-751|\
872 rb-751g|\
873 rb-911g-2hpnd|\
874 rb-911g-5hpacd|\
875 rb-911g-5hpnd|\
876 rb-912uag-2hpnd|\
877 rb-912uag-5hpnd|\
878 rb-921gs-5hpacd-r2|\
879 rb-951g-2hnd|\
880 rb-951ui-2hnd|\
881 rb-2011il|\
882 rb-2011ils|\
883 rb-2011l|\
884 rb-2011uas|\
885 rb-2011uas-2hnd|\
886 rb-2011uias|\
887 rb-2011uias-2hnd|\
888 rb-sxt2n|\
889 rb-sxt5n|\
890 wi2a-ac200i|\
891 wndr3700v4|\
892 wndr4300)
893 nand_do_upgrade "$1"
894 ;;
895 mr18|\
896 z1)
897 merakinand_do_upgrade "$1"
898 ;;
899 uap-pro|\
900 unifi-outdoor-plus)
901 MTD_CONFIG_ARGS="-s 0x180000"
902 default_do_upgrade "$ARGV"
903 ;;
904 wp543|\
905 wpe72)
906 platform_do_upgrade_compex "$ARGV"
907 ;;
908 *)
909 default_do_upgrade "$ARGV"
910 ;;
911 esac
912 }