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