ipq40xx: add support for EnGenius EAP2200
[oweals/openwrt.git] / target / linux / ipq40xx / base-files / lib / upgrade / platform.sh
1 PART_NAME=firmware
2 REQUIRE_IMAGE_METADATA=1
3
4 RAMFS_COPY_BIN='fw_printenv fw_setenv'
5 RAMFS_COPY_DATA='/etc/fw_env.config /var/lock/fw_printenv.lock'
6
7 platform_check_image() {
8         case "$(board_name)" in
9         asus,rt-ac58u)
10                 CI_UBIPART="UBI_DEV"
11                 local ubidev=$(nand_find_ubi $CI_UBIPART)
12                 local asus_root=$(nand_find_volume $ubidev jffs2)
13
14                 [ -n "$asus_root" ] || return 0
15
16                 cat << EOF
17 jffs2 partition is still present.
18 There's probably no space left
19 to install the filesystem.
20
21 You need to delete the jffs2 partition first:
22 # ubirmvol /dev/ubi0 --name=jffs2
23
24 Once this is done. Retry.
25 EOF
26                 return 1
27                 ;;
28         esac
29         return 0;
30 }
31
32 zyxel_do_upgrade() {
33         local tar_file="$1"
34
35         local board_dir=$(tar tf $tar_file | grep -m 1 '^sysupgrade-.*/$')
36         board_dir=${board_dir%/}
37
38         tar Oxf $tar_file ${board_dir}/kernel | mtd write - kernel
39
40         if [ -n "$UPGRADE_BACKUP" ]; then
41                 tar Oxf $tar_file ${board_dir}/root | mtd -j "$UPGRADE_BACKUP" write - rootfs
42         else
43                 tar Oxf $tar_file ${board_dir}/root | mtd write - rootfs
44         fi
45 }
46
47 platform_do_upgrade() {
48         case "$(board_name)" in
49         8dev,jalapeno |\
50         aruba,ap-303 |\
51         aruba,ap-303h |\
52         avm,fritzbox-7530 |\
53         avm,fritzrepeater-1200 |\
54         avm,fritzrepeater-3000 |\
55         cilab,meshpoint-one |\
56         engenius,eap2200 |\
57         qxwlan,e2600ac-c2)
58                 nand_do_upgrade "$1"
59                 ;;
60         alfa-network,ap120c-ac)
61                 part="$(awk -F 'ubi.mtd=' '{printf $2}' /proc/cmdline | sed -e 's/ .*$//')"
62                 if [ "$part" = "rootfs1" ]; then
63                         fw_setenv active 2 || exit 1
64                         CI_UBIPART="rootfs2"
65                 else
66                         fw_setenv active 1 || exit 1
67                         CI_UBIPART="rootfs1"
68                 fi
69                 nand_do_upgrade "$1"
70                 ;;
71         asus,map-ac2200)
72                 CI_KERNPART="linux"
73                 nand_do_upgrade "$1"
74                 ;;
75         asus,rt-ac58u)
76                 CI_UBIPART="UBI_DEV"
77                 CI_KERNPART="linux"
78                 nand_do_upgrade "$1"
79                 ;;
80         compex,wpj419)
81                 nand_do_upgrade "$1"
82                 ;;
83         linksys,ea6350v3 |\
84         linksys,ea8300)
85                 platform_do_upgrade_linksys "$1"
86                 ;;
87         meraki,mr33)
88                 CI_KERNPART="part.safe"
89                 nand_do_upgrade "$1"
90                 ;;
91         openmesh,a42 |\
92         openmesh,a62)
93                 PART_NAME="inactive"
94                 platform_do_upgrade_openmesh "$1"
95                 ;;
96         zyxel,nbg6617)
97                 zyxel_do_upgrade "$1"
98                 ;;
99         *)
100                 default_do_upgrade "$1"
101                 ;;
102         esac
103 }