864c59c8e5a4cbc0583760dbb900b222f000e5b9
[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-m11g|\
32 mikrotik,routerboard-m33g)
33 [ -z "$(rootfs_type)" ] && mtd erase firmware
34 ;;
35 asus,rt-ac65p|\
36 asus,rt-ac85p)
37 echo "Backing up firmware"
38 dd if=/dev/mtd4 bs=1024 count=4096 > /tmp/backup_firmware.bin
39 dd if=/dev/mtd5 bs=1024 count=52224 >> /tmp/backup_firmware.bin
40 mtd -e firmware2 write /tmp/backup_firmware.bin firmware2
41 ;;
42 esac
43
44 case "$board" in
45 asus,rt-ac65p|\
46 asus,rt-ac85p|\
47 hiwifi,hc5962|\
48 netgear,r6220|\
49 netgear,r6260|\
50 netgear,r6350|\
51 netgear,r6700-v2|\
52 netgear,r6800|\
53 netgear,r6850|\
54 netis,wf2881|\
55 xiaomi,mir3g|\
56 xiaomi,mir3p)
57 nand_do_upgrade "$1"
58 ;;
59 iodata,wn-ax1167gr2|\
60 iodata,wn-ax2033gr|\
61 iodata,wn-dx1167r)
62 iodata_mstc_upgrade_prepare
63 nand_do_upgrade "$1"
64 ;;
65 ubnt,edgerouter-x|\
66 ubnt,edgerouter-x-sfp)
67 platform_upgrade_ubnt_erx "$1"
68 ;;
69 *)
70 default_do_upgrade "$1"
71 ;;
72 esac
73 }