OSDN Git Service

c818c7e7cce479a71503555528832fd498c94d83
[immortalwrt/immortalwrt.git] / target / linux / ramips / mt7621 / base-files / lib / upgrade / platform.sh
1 #
2 # Copyright (C) 2010 OpenWrt.org
3 #
4
5 PART_NAME=firmware
6 REQUIRE_IMAGE_METADATA=1
7
8 RAMFS_COPY_BIN='fw_printenv fw_setenv'
9 RAMFS_COPY_DATA='/etc/fw_env.config /var/lock/fw_printenv.lock'
10
11 platform_check_image() {
12         return 0
13 }
14
15 platform_do_upgrade() {
16         local board=$(board_name)
17
18         case "$board" in
19         alfa-network,quad-e4g)
20                 [ "$(fw_printenv -n dual_image 2>/dev/null)" = "1" ] &&\
21                 [ -n "$(find_mtd_part backup)" ] && {
22                         PART_NAME=backup
23                         if [ "$(fw_printenv -n bootactive 2>/dev/null)" = "1" ]; then
24                                 fw_setenv bootactive 2 || exit 1
25                         else
26                                 fw_setenv bootactive 1 || exit 1
27                         fi
28                 }
29                 ;;
30         ampedwireless,ally-00x19k|\
31         ampedwireless,ally-r1900k)
32                 if [ "$(fw_printenv --lock / -n bootImage 2>/dev/null)" != "0" ]; then
33                         fw_setenv --lock / bootImage 0 || exit 1
34                 fi
35                 ;;
36         mikrotik,routerboard-750gr3|\
37         mikrotik,routerboard-760igs|\
38         mikrotik,routerboard-m11g|\
39         mikrotik,routerboard-m33g)
40                 [ "$(rootfs_type)" = "tmpfs" ] && mtd erase firmware
41                 ;;
42         asus,rt-ac65p|\
43         asus,rt-ac85p)
44                 echo "Backing up firmware"
45                 dd if=/dev/mtd4 bs=1024 count=4096  > /tmp/backup_firmware.bin
46                 dd if=/dev/mtd5 bs=1024 count=52224 >> /tmp/backup_firmware.bin
47                 mtd -e firmware2 write /tmp/backup_firmware.bin firmware2
48                 ;;
49         esac
50
51         case "$board" in
52         ampedwireless,ally-00x19k|\
53         ampedwireless,ally-r1900k|\
54         asus,rt-ac65p|\
55         asus,rt-ac85p|\
56         beeline,smartbox-flash|\
57         dlink,dir-1960-a1|\
58         dlink,dir-2640-a1|\
59         dlink,dir-2660-a1|\
60         dlink,dir-853-a3|\
61         hiwifi,hc5962|\
62         iptime,a3004t|\
63         iptime,ax2004m|\
64         iptime,t5004|\
65         jcg,q20|\
66         linksys,e5600|\
67         linksys,ea6350-v4|\
68         linksys,ea7300-v1|\
69         linksys,ea7300-v2|\
70         linksys,ea7500-v2|\
71         linksys,ea8100-v1|\
72         linksys,ea8100-v2|\
73         netgear,r6220|\
74         netgear,r6260|\
75         netgear,r6350|\
76         netgear,r6700-v2|\
77         netgear,r6800|\
78         netgear,r6850|\
79         netgear,r6900-v2|\
80         netgear,r7200|\
81         netgear,r7450|\
82         netgear,wac104|\
83         netgear,wac124|\
84         netis,wf2881|\
85         raisecom,msg1500-x-00|\
86         sercomm,na502|\
87         xiaomi,mi-router-3g|\
88         xiaomi,mi-router-3-pro|\
89         xiaomi,mi-router-4|\
90         xiaomi,mi-router-ac2100|\
91         xiaomi,mi-router-cr6606|\
92         xiaomi,mi-router-cr6608|\
93         xiaomi,mi-router-cr6609|\
94         xiaomi,redmi-router-ac2100)
95                 nand_do_upgrade "$1"
96                 ;;
97         iodata,wn-ax1167gr2|\
98         iodata,wn-ax2033gr|\
99         iodata,wn-dx1167r|\
100         iodata,wn-dx2033gr)
101                 iodata_mstc_upgrade_prepare "0xfe75"
102                 nand_do_upgrade "$1"
103                 ;;
104         iodata,wn-dx1200gr)
105                 iodata_mstc_upgrade_prepare "0x1fe75"
106                 nand_do_upgrade "$1"
107                 ;;
108         ubnt,edgerouter-x|\
109         ubnt,edgerouter-x-sfp)
110                 platform_upgrade_ubnt_erx "$1"
111                 ;;
112         zyxel,nr7101)
113                 fw_setenv CheckBypass 0
114                 fw_setenv Image1Stable 0
115                 CI_KERNPART="Kernel"
116                 nand_do_upgrade "$1"
117                 ;;
118         zyxel,wap6805)
119                 local kernel2_mtd="$(find_mtd_part Kernel2)"
120                 [ "$(hexdump -n 4 -e '"%x"' $kernel2_mtd)" = "56190527" ] &&\
121                 [ "$(hexdump -n 4 -s 104 -e '"%x"' $kernel2_mtd)" != "0" ] &&\
122                 dd bs=4 count=1 seek=26 conv=notrunc if=/dev/zero of=$kernel2_mtd 2>/dev/null &&\
123                 echo "Kernel2 sequence number was reset to 0"
124                 CI_KERNPART="Kernel"
125                 nand_do_upgrade "$1"
126                 ;;
127         *)
128                 default_do_upgrade "$1"
129                 ;;
130         esac
131 }