584e16410a47d0e7c6f1b36cf70877c88e6ff961
[openwrt.git] / target / linux / ramips / base-files / lib / upgrade / platform.sh
1 #
2 # Copyright (C) 2010 OpenWrt.org
3 #
4
5 . /lib/ramips.sh
6
7 PART_NAME=firmware
8 RAMFS_COPY_DATA=/lib/ramips.sh
9
10 platform_check_image() {
11         local board=$(ramips_board_name)
12         local magic="$(get_magic_long "$1")"
13
14         [ "$ARGC" -gt 1 ] && return 1
15
16         case "$board" in
17         3g-6200n | \
18         air3gii | \
19         all0239-3g | \
20         all0256n | \
21         all5002 | \
22         bc2 | \
23         broadway | \
24         carambola | \
25         dir-300-b1 | \
26         dir-600-b1 | \
27         dir-600-b2 | \
28         dir-615-h1 | \
29         dir-615-d | \
30         dir-620-a1 | \
31         dap-1350 | \
32         esr-9753 | \
33         fonera20n | \
34         rt-n13u | \
35         freestation5 | \
36         hw550-3g | \
37         mofi3500-3gn | \
38         mzk-w300nh2 | \
39         nbg-419n | \
40         nw718 | \
41         omni-emb | \
42         psr-680w | \
43         rt-g32-b1 | \
44         rt-n10-plus | \
45         rt-n15 | \
46         rt-n56u | \
47         sl-r7205 | \
48         tew-691gr | \
49         tew-692gr | \
50         w306r-v20 |\
51         w502u |\
52         wr6202 |\
53         v22rw-2x2 | \
54         wl341v3 | \
55         wl-330n | \
56         wl-351 | \
57         wli-tx4-ag300n | \
58         whr-g300n |\
59         ur-336un |\
60         wr512-3gn)
61                 [ "$magic" != "27051956" ] && {
62                         echo "Invalid image type."
63                         return 1
64                 }
65                 return 0
66                 ;;
67         dir-645)
68                 [ "$magic" != "5ea3a417" ] && {
69                         echo "Invalid image type."
70                         return 1
71                 }
72                 return 0
73                 ;;
74         esac
75
76         echo "Sysupgrade is not yet supported on $board."
77         return 1
78 }
79
80 platform_do_upgrade() {
81         local board=$(ramips_board_name)
82
83         case "$board" in
84         *)
85                 default_do_upgrade "$ARGV"
86                 ;;
87         esac
88 }
89
90 disable_watchdog() {
91         killall watchdog
92         ( ps | grep -v 'grep' | grep '/dev/watchdog' ) && {
93                 echo 'Could not disable watchdog'
94                 return 1
95         }
96 }
97
98 append sysupgrade_pre_upgrade disable_watchdog