a6f52cd1432fcee3b0b7c51a2422de2ff86549da
[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         3g-6200nl | \
19         3g300m | \
20         air3gii | \
21         all0239-3g | \
22         all0256n | \
23         all5002 | \
24         bc2 | \
25         broadway | \
26         carambola | \
27         dir-300-b1 | \
28         dir-600-b1 | \
29         dir-600-b2 | \
30         dir-615-h1 | \
31         dir-615-d | \
32         dir-620-a1 | \
33         dap-1350 | \
34         esr-9753 | \
35         fonera20n | \
36         rt-n13u | \
37         freestation5 | \
38         hw550-3g | \
39         mofi3500-3gn | \
40         mzk-w300nh2 | \
41         nbg-419n | \
42         nw718 | \
43         omni-emb | \
44         omni-emb-hpm | \
45         psr-680w | \
46         rt-g32-b1 | \
47         rt-n10-plus | \
48         rt-n15 | \
49         rt-n56u | \
50         sl-r7205 | \
51         tew-691gr | \
52         tew-692gr | \
53         w306r-v20 |\
54         w502u |\
55         wr6202 |\
56         v22rw-2x2 | \
57         wl341v3 | \
58         wl-330n | \
59         wl-351 | \
60         wli-tx4-ag300n | \
61         whr-g300n |\
62         ur-326n4g |\
63         ur-336un |\
64         wr512-3gn)
65                 [ "$magic" != "27051956" ] && {
66                         echo "Invalid image type."
67                         return 1
68                 }
69                 return 0
70                 ;;
71         dir-645)
72                 [ "$magic" != "5ea3a417" ] && {
73                         echo "Invalid image type."
74                         return 1
75                 }
76                 return 0
77                 ;;
78         esac
79
80         echo "Sysupgrade is not yet supported on $board."
81         return 1
82 }
83
84 platform_do_upgrade() {
85         local board=$(ramips_board_name)
86
87         case "$board" in
88         *)
89                 default_do_upgrade "$ARGV"
90                 ;;
91         esac
92 }
93
94 disable_watchdog() {
95         killall watchdog
96         ( ps | grep -v 'grep' | grep '/dev/watchdog' ) && {
97                 echo 'Could not disable watchdog'
98                 return 1
99         }
100 }
101
102 append sysupgrade_pre_upgrade disable_watchdog