qualcommax: cleanup whitespace and sort-order
[openwrt/staging/jow.git] / target / linux / qualcommax / ipq807x / base-files / lib / upgrade / platform.sh
1 PART_NAME=firmware
2 REQUIRE_IMAGE_METADATA=1
3
4 RAMFS_COPY_BIN='fw_printenv fw_setenv head'
5 RAMFS_COPY_DATA='/etc/fw_env.config /var/lock/fw_printenv.lock'
6
7 xiaomi_initramfs_prepare() {
8 # Wipe UBI if running initramfs
9 [ "$(rootfs_type)" = "tmpfs" ] || return 0
10
11 local rootfs_mtdnum="$( find_mtd_index rootfs )"
12 if [ ! "$rootfs_mtdnum" ]; then
13 echo "unable to find mtd partition rootfs"
14 return 1
15 fi
16
17 local kern_mtdnum="$( find_mtd_index ubi_kernel )"
18 if [ ! "$kern_mtdnum" ]; then
19 echo "unable to find mtd partition ubi_kernel"
20 return 1
21 fi
22
23 ubidetach -m "$rootfs_mtdnum"
24 ubiformat /dev/mtd$rootfs_mtdnum -y
25
26 ubidetach -m "$kern_mtdnum"
27 ubiformat /dev/mtd$kern_mtdnum -y
28 }
29
30 platform_check_image() {
31 return 0;
32 }
33
34 platform_pre_upgrade() {
35 case "$(board_name)" in
36 redmi,ax6|\
37 xiaomi,ax3600|\
38 xiaomi,ax9000)
39 xiaomi_initramfs_prepare
40 ;;
41 esac
42 }
43
44 platform_do_upgrade() {
45 case "$(board_name)" in
46 buffalo,wxr-5950ax12)
47 CI_KERN_UBIPART="rootfs"
48 CI_ROOT_UBIPART="user_property"
49 buffalo_upgrade_prepare
50 nand_do_flash_file "$1" || nand_do_upgrade_failed
51 nand_do_restore_config || nand_do_upgrade_failed
52 buffalo_upgrade_optvol
53 ;;
54 compex,wpq873|\
55 dynalink,dl-wrx36|\
56 edimax,cax1800|\
57 netgear,rax120v2|\
58 netgear,wax218|\
59 netgear,wax620|\
60 netgear,wax630)
61 nand_do_upgrade "$1"
62 ;;
63 edgecore,eap102)
64 active="$(fw_printenv -n active)"
65 if [ "$active" -eq "1" ]; then
66 CI_UBIPART="rootfs2"
67 else
68 CI_UBIPART="rootfs1"
69 fi
70 # force altbootcmd which handles partition change in u-boot
71 fw_setenv bootcount 3
72 fw_setenv upgrade_available 1
73 nand_do_upgrade "$1"
74 ;;
75 prpl,haze|\
76 qnap,301w)
77 kernelname="0:HLOS"
78 rootfsname="rootfs"
79 mmc_do_upgrade "$1"
80 ;;
81 redmi,ax6|\
82 xiaomi,ax3600|\
83 xiaomi,ax9000)
84 # Make sure that UART is enabled
85 fw_setenv boot_wait on
86 fw_setenv uart_en 1
87
88 # Enforce single partition.
89 fw_setenv flag_boot_rootfs 0
90 fw_setenv flag_last_success 0
91 fw_setenv flag_boot_success 1
92 fw_setenv flag_try_sys1_failed 8
93 fw_setenv flag_try_sys2_failed 8
94
95 # Kernel and rootfs are placed in 2 different UBI
96 CI_KERN_UBIPART="ubi_kernel"
97 CI_ROOT_UBIPART="rootfs"
98 nand_do_upgrade "$1"
99 ;;
100 yuncore,ax880)
101 active="$(fw_printenv -n active)"
102 if [ "$active" -eq "1" ]; then
103 CI_UBIPART="rootfs_1"
104 else
105 CI_UBIPART="rootfs"
106 fi
107 # force altbootcmd which handles partition change in u-boot
108 fw_setenv bootcount 3
109 fw_setenv upgrade_available 1
110 nand_do_upgrade "$1"
111 ;;
112 zyxel,nbg7815)
113 local config_mtdnum="$(find_mtd_index 0:bootconfig)"
114 [ -z "$config_mtdnum" ] && reboot
115 part_num="$(hexdump -e '1/1 "%01x|"' -n 1 -s 168 -C /dev/mtd$config_mtdnum | cut -f 1 -d "|" | head -n1)"
116 if [ "$part_num" -eq "0" ]; then
117 kernelname="0:HLOS"
118 rootfsname="rootfs"
119 mmc_do_upgrade "$1"
120 else
121 kernelname="0:HLOS_1"
122 rootfsname="rootfs_1"
123 mmc_do_upgrade "$1"
124 fi
125 ;;
126 *)
127 default_do_upgrade "$1"
128 ;;
129 esac
130 }