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