b1feea7ae60ebf8b9cd81b83a53c85bd0e4a2a40
[openwrt/openwrt.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 mikrotik,routerboard-750gr3|\
31 mikrotik,routerboard-760igs|\
32 mikrotik,routerboard-m11g|\
33 mikrotik,routerboard-m33g)
34 [ -z "$(rootfs_type)" ] && mtd erase firmware
35 ;;
36 asus,rt-ac65p|\
37 asus,rt-ac85p)
38 echo "Backing up firmware"
39 dd if=/dev/mtd4 bs=1024 count=4096 > /tmp/backup_firmware.bin
40 dd if=/dev/mtd5 bs=1024 count=52224 >> /tmp/backup_firmware.bin
41 mtd -e firmware2 write /tmp/backup_firmware.bin firmware2
42 ;;
43 esac
44
45 case "$board" in
46 asus,rt-ac65p|\
47 asus,rt-ac85p|\
48 dlink,dir-1960-a1|\
49 dlink,dir-2660-a1|\
50 hiwifi,hc5962|\
51 linksys,ea7300-v1|\
52 linksys,ea7500-v2|\
53 netgear,r6220|\
54 netgear,r6260|\
55 netgear,r6350|\
56 netgear,r6700-v2|\
57 netgear,r6800|\
58 netgear,r6850|\
59 netgear,wac104|\
60 netgear,wac124|\
61 netis,wf2881|\
62 xiaomi,mi-router-ac2100|\
63 xiaomi,mir3g|\
64 xiaomi,mir3p|\
65 xiaomi,redmi-router-ac2100)
66 nand_do_upgrade "$1"
67 ;;
68 iodata,wn-ax1167gr2|\
69 iodata,wn-ax2033gr|\
70 iodata,wn-dx1167r)
71 iodata_mstc_upgrade_prepare
72 nand_do_upgrade "$1"
73 ;;
74 ubnt,edgerouter-x|\
75 ubnt,edgerouter-x-sfp)
76 platform_upgrade_ubnt_erx "$1"
77 ;;
78 zyxel,wap6805)
79 local kernel2_mtd="$(find_mtd_part Kernel2)"
80 [ "$(hexdump -n 4 -e '"%x"' $kernel2_mtd)" = "56190527" ] &&\
81 [ "$(hexdump -n 4 -s 104 -e '"%x"' $kernel2_mtd)" != "0" ] &&\
82 dd bs=4 count=1 seek=26 conv=notrunc if=/dev/zero of=$kernel2_mtd 2>/dev/null &&\
83 echo "Kernel2 sequence number was reset to 0"
84 CI_KERNPART="Kernel"
85 nand_do_upgrade "$1"
86 ;;
87 *)
88 default_do_upgrade "$1"
89 ;;
90 esac
91 }