ipq807x: add Edimax CAX1800
[openwrt/staging/jow.git] / target / linux / 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'
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_initramfs_prepare
39 ;;
40 esac
41 }
42
43 platform_do_upgrade() {
44 case "$(board_name)" in
45 edimax,cax1800)
46 nand_do_upgrade "$1"
47 ;;
48 redmi,ax6|\
49 xiaomi,ax3600)
50 # Make sure that UART is enabled
51 fw_setenv boot_wait on
52 fw_setenv uart_en 1
53
54 # Enforce single partition.
55 fw_setenv flag_boot_rootfs 0
56 fw_setenv flag_last_success 0
57 fw_setenv flag_boot_success 1
58 fw_setenv flag_try_sys1_failed 8
59 fw_setenv flag_try_sys2_failed 8
60
61 # Kernel and rootfs are placed in 2 different UBI
62 CI_KERN_UBIPART="ubi_kernel"
63 CI_ROOT_UBIPART="rootfs"
64 nand_do_upgrade "$1"
65 ;;
66 *)
67 default_do_upgrade "$1"
68 ;;
69 esac
70 }