platform.sh 1.42 KB
Newer Older
Gabor Juhos's avatar
Gabor Juhos committed
1
2
3
4
5
#
# Copyright (C) 2010 OpenWrt.org
#

PART_NAME=firmware
6
REQUIRE_IMAGE_METADATA=1
Gabor Juhos's avatar
Gabor Juhos committed
7

8
9
10
RAMFS_COPY_BIN='fw_printenv fw_setenv'
RAMFS_COPY_DATA='/etc/fw_env.config /var/lock/fw_printenv.lock'

Gabor Juhos's avatar
Gabor Juhos committed
11
platform_check_image() {
12
	return 0
Gabor Juhos's avatar
Gabor Juhos committed
13
14
}

15
platform_do_upgrade() {
16
	local board=$(board_name)
17

18
	case "$board" in
19
20
21
22
23
24
25
26
27
28
29
	alfa-network,quad-e4g)
		[ "$(fw_printenv -n dual_image 2>/dev/null)" = "1" ] &&\
		[ -n "$(find_mtd_part backup)" ] && {
			PART_NAME=backup
			if [ "$(fw_printenv -n bootactive 2>/dev/null)" = "1" ]; then
				fw_setenv bootactive 2 || exit 1
			else
				fw_setenv bootactive 1 || exit 1
			fi
		}
		;;
30
31
32
33
34
	mikrotik,rb750gr3|\
	mikrotik,rbm11g|\
	mikrotik,rbm33g)
		[ -z "$(rootfs_type)" ] && mtd erase firmware
		;;
35
	asus,rt-ac65p|\
36
37
38
39
40
41
	asus,rt-ac85p)
		echo "Backing up firmware"
		dd if=/dev/mtd4 bs=1024 count=4096  > /tmp/backup_firmware.bin
		dd if=/dev/mtd5 bs=1024 count=52224 >> /tmp/backup_firmware.bin
		mtd -e firmware2 write /tmp/backup_firmware.bin firmware2
		;;
42
43
	esac

44
	case "$board" in
45
	asus,rt-ac65p|\
46
	asus,rt-ac85p|\
47
48
	hiwifi,hc5962|\
	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
61
62
63
	iodata,wn-dx1167r)
		iodata_mstc_upgrade_prepare
		nand_do_upgrade "$1"
		;;
64
65
66
67
	ubiquiti,edgerouterx|\
	ubiquiti,edgerouterx-sfp)
		platform_upgrade_ubnt_erx "$1"
		;;
Gabor Juhos's avatar
Gabor Juhos committed
68
	*)
69
		default_do_upgrade "$1"
Gabor Juhos's avatar
Gabor Juhos committed
70
71
72
		;;
	esac
}