ipq807x: add Xiaomi AX3600
[openwrt/openwrt.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 xiaomi,ax3600)
37 xiaomi_initramfs_prepare
38 ;;
39 esac
40 }
41
42 platform_do_upgrade() {
43 case "$(board_name)" in
44 xiaomi,ax3600)
45 # Make sure that UART is enabled
46 fw_setenv boot_wait on
47 fw_setenv uart_en 1
48
49 # Enforce single partition.
50 fw_setenv flag_boot_rootfs 0
51 fw_setenv flag_last_success 0
52 fw_setenv flag_boot_success 1
53 fw_setenv flag_try_sys1_failed 8
54 fw_setenv flag_try_sys2_failed 8
55
56 # Kernel and rootfs are placed in 2 different UBI
57 CI_KERN_UBIPART="ubi_kernel"
58 CI_ROOT_UBIPART="rootfs"
59 nand_do_upgrade "$1"
60 ;;
61 *)
62 default_do_upgrade "$1"
63 ;;
64 esac
65 }