From 6a01a7b07b7459ac3ae54544c83a7aa68913343d Mon Sep 17 00:00:00 2001 From: Tianling Shen Date: Tue, 17 Jan 2023 19:53:29 +0800 Subject: [PATCH] ipq807x: add stock layout variant for xiaomi ax3600 Signed-off-by: Tianling Shen --- package/boot/uboot-envtools/files/ipq807x | 1 + .../ipq807x/base-files/etc/board.d/01_leds | 3 +- .../ipq807x/base-files/etc/board.d/02_network | 3 +- .../etc/hotplug.d/firmware/11-ath10k-caldata | 20 ++++++ .../etc/hotplug.d/firmware/11-ath11k-caldata | 1 + .../ipq807x/base-files/etc/init.d/bootcount | 6 ++ .../base-files/lib/upgrade/platform.sh | 26 ++++++++ .../boot/dts/qcom/ipq8071-ax3600-stock.dts | 61 +++++++++++++++++++ target/linux/ipq807x/image/generic.mk | 8 +++ 9 files changed, 127 insertions(+), 2 deletions(-) create mode 100644 target/linux/ipq807x/base-files/etc/hotplug.d/firmware/11-ath10k-caldata create mode 100644 target/linux/ipq807x/files/arch/arm64/boot/dts/qcom/ipq8071-ax3600-stock.dts diff --git a/package/boot/uboot-envtools/files/ipq807x b/package/boot/uboot-envtools/files/ipq807x index 63fd04ec5b..54ac6a1064 100644 --- a/package/boot/uboot-envtools/files/ipq807x +++ b/package/boot/uboot-envtools/files/ipq807x @@ -25,6 +25,7 @@ edimax,cax1800) ;; redmi,ax6|\ xiaomi,ax3600|\ +xiaomi,ax3600-stock|\ xiaomi,ax9000) idx="$(find_mtd_index 0:appsblenv)" [ -n "$idx" ] && \ diff --git a/target/linux/ipq807x/base-files/etc/board.d/01_leds b/target/linux/ipq807x/base-files/etc/board.d/01_leds index 0424958416..a6932d9f47 100644 --- a/target/linux/ipq807x/base-files/etc/board.d/01_leds +++ b/target/linux/ipq807x/base-files/etc/board.d/01_leds @@ -10,7 +10,8 @@ edgecore,eap102) ucidef_set_led_netdev "wan" "WAN" "green:wanpoe" "wan" ;; redmi,ax6|\ -xiaomi,ax3600) +xiaomi,ax3600|\ +xiaomi,ax3600-stock) ucidef_set_led_netdev "wan" "WAN" "blue:network" "wan" ;; qnap,301w) diff --git a/target/linux/ipq807x/base-files/etc/board.d/02_network b/target/linux/ipq807x/base-files/etc/board.d/02_network index e2bd46f095..ffed60c1a6 100644 --- a/target/linux/ipq807x/base-files/etc/board.d/02_network +++ b/target/linux/ipq807x/base-files/etc/board.d/02_network @@ -24,7 +24,8 @@ ipq807x_setup_interfaces() ucidef_set_interfaces_lan_wan "lan1 lan2 lan3 lan4 10g-2" "10g-1" ;; redmi,ax6|\ - xiaomi,ax3600) + xiaomi,ax3600|\ + xiaomi,ax3600-stock) ucidef_set_interfaces_lan_wan "lan1 lan2 lan3" "wan" ;; xiaomi,ax9000) diff --git a/target/linux/ipq807x/base-files/etc/hotplug.d/firmware/11-ath10k-caldata b/target/linux/ipq807x/base-files/etc/hotplug.d/firmware/11-ath10k-caldata new file mode 100644 index 0000000000..863435e05d --- /dev/null +++ b/target/linux/ipq807x/base-files/etc/hotplug.d/firmware/11-ath10k-caldata @@ -0,0 +1,20 @@ +#!/bin/sh + +[ -e /lib/firmware/$FIRMWARE ] && exit 0 + +. /lib/functions/caldata.sh + +board=$(board_name) + +case "$FIRMWARE" in +"ath10k/cal-pci-0000:01:00.0.bin") + case "$board" in + xiaomi,ax3600-stock) + caldata_extract "0:art" 0x33000 0x844 + ;; + esac + ;; +*) + exit 1 + ;; +esac diff --git a/target/linux/ipq807x/base-files/etc/hotplug.d/firmware/11-ath11k-caldata b/target/linux/ipq807x/base-files/etc/hotplug.d/firmware/11-ath11k-caldata index 974e7607aa..a77ab645d4 100644 --- a/target/linux/ipq807x/base-files/etc/hotplug.d/firmware/11-ath11k-caldata +++ b/target/linux/ipq807x/base-files/etc/hotplug.d/firmware/11-ath11k-caldata @@ -15,6 +15,7 @@ case "$FIRMWARE" in qnap,301w|\ redmi,ax6|\ xiaomi,ax3600|\ + xiaomi,ax3600-stock|\ xiaomi,ax9000) caldata_extract "0:art" 0x1000 0x20000 ;; diff --git a/target/linux/ipq807x/base-files/etc/init.d/bootcount b/target/linux/ipq807x/base-files/etc/init.d/bootcount index 6917446a9b..5d8c537585 100755 --- a/target/linux/ipq807x/base-files/etc/init.d/bootcount +++ b/target/linux/ipq807x/base-files/etc/init.d/bootcount @@ -9,5 +9,11 @@ boot() { # Unset changed flag after sysupgrade complete fw_setenv changed ;; + xiaomi,ax3600-stock) + # OTA handling should not be used. Reset it just in case. + fw_setenv flag_ota_reboot 0 + # Not strictly needed but useful to handle partition crash condition + fw_setenv flag_boot_success 1 + ;; esac } diff --git a/target/linux/ipq807x/base-files/lib/upgrade/platform.sh b/target/linux/ipq807x/base-files/lib/upgrade/platform.sh index 63f546444f..18099a1fc4 100644 --- a/target/linux/ipq807x/base-files/lib/upgrade/platform.sh +++ b/target/linux/ipq807x/base-files/lib/upgrade/platform.sh @@ -83,6 +83,32 @@ platform_do_upgrade() { # Kernel and rootfs are placed in 2 different UBI CI_KERN_UBIPART="ubi_kernel" CI_ROOT_UBIPART="rootfs" + nand_do_upgrade "$1" + ;; + xiaomi,ax3600-stock) + part_num="$(fw_printenv -n flag_boot_rootfs)" + if [ "$part_num" -eq "1" ]; then + CI_UBIPART="rootfs_1" + target_num=1 + # Reset fail flag for the current partition + # With both partition set to fail, the partition 2 (bit 1) + # is loaded + fw_setenv flag_try_sys2_failed 0 + else + CI_UBIPART="rootfs" + target_num=0 + # Reset fail flag for the current partition + # or uboot will skip the loading of this partition + fw_setenv flag_try_sys1_failed 0 + fi + + # Tell uboot to switch partition + fw_setenv flag_boot_rootfs "$target_num" + fw_setenv flag_last_success "$target_num" + + # Reset success flag + fw_setenv flag_boot_success 0 + nand_do_upgrade "$1" ;; *) diff --git a/target/linux/ipq807x/files/arch/arm64/boot/dts/qcom/ipq8071-ax3600-stock.dts b/target/linux/ipq807x/files/arch/arm64/boot/dts/qcom/ipq8071-ax3600-stock.dts new file mode 100644 index 0000000000..3739ba0450 --- /dev/null +++ b/target/linux/ipq807x/files/arch/arm64/boot/dts/qcom/ipq8071-ax3600-stock.dts @@ -0,0 +1,61 @@ +// SPDX-License-Identifier: GPL-2.0-or-later OR MIT + +#include "ipq8071-ax3600.dts" + +/ { + model = "Xiaomi AX3600 (stock layout)"; + compatible = "xiaomi,ax3600-stock", "qcom,ipq8074"; + + aliases { + /* Aliases as required by u-boot to patch MAC addresses */ + ethernet1 = &dp2; + ethernet2 = &dp3; + ethernet3 = &dp4; + ethernet4 = &dp5; + }; + + chosen { + bootargs-append = " root=/dev/ubiblock0_1"; + }; +}; + +&qpic_nand { + /delete-node/ partitions; + /delete-node/ nand@0; + + nand@0 { + reg = <0>; + nand-ecc-strength = <4>; + nand-ecc-step-size = <512>; + nand-bus-width = <8>; + + partitions { + compatible = "qcom,smem-part"; + }; + }; +}; + +&dp2 { + /delete-property/ nvmem-cells; + /delete-property/ nvmem-cell-names; +}; + +&dp3 { + /delete-property/ nvmem-cells; + /delete-property/ nvmem-cell-names; +}; + +&dp4 { + /delete-property/ nvmem-cells; + /delete-property/ nvmem-cell-names; +}; + +&dp5 { + /delete-property/ nvmem-cells; + /delete-property/ nvmem-cell-names; +}; + +&wifi0 { + /delete-property/ nvmem-cells; + /delete-property/ nvmem-cell-names; +}; diff --git a/target/linux/ipq807x/image/generic.mk b/target/linux/ipq807x/image/generic.mk index 811a32e942..8b9b7af5a2 100644 --- a/target/linux/ipq807x/image/generic.mk +++ b/target/linux/ipq807x/image/generic.mk @@ -98,6 +98,14 @@ endif endef TARGET_DEVICES += xiaomi_ax3600 +define Device/xiaomi_ax3600-stock + $(call Device/xiaomi_ax3600) + DEVICE_VARIANT := (stock layout) + KERNEL_SIZE := + ARTIFACTS := +endef +TARGET_DEVICES += xiaomi_ax3600-stock + define Device/xiaomi_ax9000 $(call Device/FitImage) $(call Device/UbiFit)