0bae8e16817c45ecf992e9605f584842568f0d2f
[openwrt/staging/chunkeey.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 askey_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}/root | mtd write - rootfs
39
40 nand_do_upgrade "$1"
41 }
42
43 zyxel_do_upgrade() {
44 local tar_file="$1"
45
46 local board_dir=$(tar tf $tar_file | grep -m 1 '^sysupgrade-.*/$')
47 board_dir=${board_dir%/}
48
49 tar Oxf $tar_file ${board_dir}/kernel | mtd write - kernel
50
51 if [ -n "$UPGRADE_BACKUP" ]; then
52 tar Oxf $tar_file ${board_dir}/root | mtd -j "$UPGRADE_BACKUP" write - rootfs
53 else
54 tar Oxf $tar_file ${board_dir}/root | mtd write - rootfs
55 fi
56 }
57
58 platform_do_upgrade() {
59 case "$(board_name)" in
60 8dev,jalapeno |\
61 aruba,ap-303 |\
62 aruba,ap-303h |\
63 aruba,ap-365 |\
64 avm,fritzbox-7530 |\
65 avm,fritzrepeater-1200 |\
66 avm,fritzrepeater-3000 |\
67 buffalo,wtr-m2133hp |\
68 cilab,meshpoint-one |\
69 edgecore,ecw5211 |\
70 edgecore,oap100 |\
71 engenius,eap2200 |\
72 mobipromo,cm520-79f |\
73 qxwlan,e2600ac-c2)
74 nand_do_upgrade "$1"
75 ;;
76 alfa-network,ap120c-ac)
77 part="$(awk -F 'ubi.mtd=' '{printf $2}' /proc/cmdline | sed -e 's/ .*$//')"
78 if [ "$part" = "rootfs1" ]; then
79 fw_setenv active 2 || exit 1
80 CI_UBIPART="rootfs2"
81 else
82 fw_setenv active 1 || exit 1
83 CI_UBIPART="rootfs1"
84 fi
85 nand_do_upgrade "$1"
86 ;;
87 asus,map-ac2200)
88 CI_KERNPART="linux"
89 nand_do_upgrade "$1"
90 ;;
91 asus,rt-ac58u)
92 CI_UBIPART="UBI_DEV"
93 CI_KERNPART="linux"
94 nand_do_upgrade "$1"
95 ;;
96 cellc,rtl30vw)
97 CI_UBIPART="ubifs"
98 askey_do_upgrade "$1"
99 ;;
100 compex,wpj419)
101 nand_do_upgrade "$1"
102 ;;
103 linksys,ea6350v3 |\
104 linksys,ea8300)
105 platform_do_upgrade_linksys "$1"
106 ;;
107 meraki,mr33)
108 CI_KERNPART="part.safe"
109 nand_do_upgrade "$1"
110 ;;
111 openmesh,a42 |\
112 openmesh,a62)
113 PART_NAME="inactive"
114 platform_do_upgrade_openmesh "$1"
115 ;;
116 zyxel,nbg6617)
117 zyxel_do_upgrade "$1"
118 ;;
119 *)
120 default_do_upgrade "$1"
121 ;;
122 esac
123 }