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