Skip to content

Commit

Permalink
ipq807x: add Xiaomi AX3600
Browse files Browse the repository at this point in the history
Xiaomi AX3600 is a budget 802.11ax dual-band router/AP.
Specifications:
* CPU: Qualcomm IPQ8071A Quad core Cortex-A53 1.4GHz
* RAM: 512MB of DDR3
* Storage: 256MB of parallel NAND
* Ethernet: 4x1G RJ45 ports (QCA8075) with 1x status LED per port
* WLAN:
	* PCI based Qualcomm QCA9889 1x1 802.11ac Wawe 2 for IoT
	* 2.4GHz: Qualcomm QCN5024 2x2 802.11b/g/n/ax 574 Mbps PHY rate
	* 5GHz: Qualcomm QCN5054 4x4@80MHz or 2x2@160MHz 802.11a/b/g/n/ac/ax 2402 PHY rate
* LED-s:
	* System (Blue and Yellow)
	* IoT (Blue)
	* Network (Blue and Yellow)
* Buttons: 1x Soft reset
* Power: 12V DC Jack

Installation instructions:

Obtaining SSH access is mandatory
https://openwrt.org/inbox/toh/xiaomi/xiaomi_ax3600#obtain_ssh_access

Installation is done by the ubiformat method, through SSH:
1. Open an SSH shell to the router
2. Copy the file openwrt-ipq807x-generic-xiaomi_ax3600-initramfs-factory.ubi to the /tmp directory
3. Check which rootfs partition is your router booted in (0 = rootfs | 1 = rootfs_1):
nvram get flag_boot_rootfs

4. Find the rootfs and rootfs_1 mtd indexes respectively:
cat /proc/mtd
Please confirm if mtd12 and mtd13 are the correct indexes from above!

5. Use the command ubiformat to flash the opposite mtd with UBI image:

If nvram get flag_boot_rootfs returned 0:
ubiformat /dev/mtd13 -y -f /tmp/openwrt-ipq807x-generic-xiaomi_ax3600-initramfs-factory.ubi -s 2048 -O 2048 && nvram set flag_boot_rootfs=1 && nvram set flag_last_success=1 && nvram commit

otherwise:
ubiformat /dev/mtd12 -y -f /tmp/openwrt-ipq807x-generic-xiaomi_ax3600-initramfs-factory.ubi -s 2048 -O 2048 && nvram set flag_boot_rootfs=0 && nvram set flag_last_success=0 && nvram commit

6. Reboot the device by:
reboot

Previous commands flashed an ubinized OpenWrt initramfs that will serve as the intermediate step
since OpenWrt uses unified rootfs in order to fully utilize NAND and provide enough space for packages.
Continue in order to pernamently flash OpenWrt:

7. SSH into OpenWrt from one of the LAN ports
8. Copy the file openwrt-ipq807x-generic-xiaomi_ax3600-squashfs-sysupgrade.bin to the /tmp directory
9. Sysupgrade the device:
sysupgrade -n /tmp/openwrt-ipq807x-generic-xiaomi_ax3600-squashfs-sysupgrade.bin

Device will reboot with OpenWrt, and then sysupgrade can be used to upgrade the device when desired.

Signed-off-by: Christian Marangi <ansuelsmth@gmail.com>
Signed-off-by: Robert Marko <robimarko@gmail.com>
  • Loading branch information
robimarko committed Jan 16, 2023
1 parent bc12052 commit 8364f08
Show file tree
Hide file tree
Showing 11 changed files with 569 additions and 3 deletions.
24 changes: 24 additions & 0 deletions package/boot/uboot-envtools/files/ipq807x
@@ -0,0 +1,24 @@
[ -e /etc/config/ubootenv ] && exit 0

touch /etc/config/ubootenv

. /lib/uboot-envtools.sh
. /lib/functions.sh

board=$(board_name)

case "$board" in
xiaomi,ax3600)
idx="$(find_mtd_index 0:appsblenv)"
[ -n "$idx" ] && \
ubootenv_add_uci_config "/dev/mtd$idx" "0x0" "0x10000" "0x20000"
idx2="$(find_mtd_index bdata)"
[ -n "$idx2" ] && \
ubootenv_add_uci_sys_config "/dev/mtd$idx2" "0x0" "0x10000" "0x20000"
;;
esac

config_load ubootenv
config_foreach ubootenv_add_app_config

exit 0
17 changes: 14 additions & 3 deletions package/firmware/ipq-wifi/Makefile
Expand Up @@ -41,6 +41,7 @@ ALLWIFIBOARDS:= \
qxwlan_e2600ac-c2 \
sony_ncp-hg100-cellular \
teltonika_rutx \
xiaomi_ax3600 \
zte_mf18a \
zte_mf289f

Expand All @@ -50,7 +51,7 @@ define Package/ipq-wifi-default
SUBMENU:=ath10k Board-Specific Overrides
SECTION:=firmware
CATEGORY:=Firmware
DEPENDS:=@(TARGET_ipq40xx||TARGET_ipq806x)
DEPENDS:=@(TARGET_ipq40xx||TARGET_ipq806x||TARGET_ipq807x)
TITLE:=Custom Board
endef

Expand All @@ -59,17 +60,26 @@ define ipq-wifi-install-one-to
$(INSTALL_DATA) $(1) $(2)/lib/firmware/ath10k/$(3)/board-2.bin
endef

define ipq-wifi-install-ath11-one-to
$(INSTALL_DIR) $(2)/lib/firmware/ath11k/$(3)/
$(INSTALL_DATA) $(1) $(2)/lib/firmware/ath11k/$(3)/board-2.bin
endef

define ipq-wifi-install-one
$(if $(filter $(suffix $(1)),.QCA4019 .qca4019),\
$(call ipq-wifi-install-one-to,$(1),$(2),QCA4019/hw1.0),\
$(if $(filter $(suffix $(1)),.QCA9888 .qca9888),\
$(call ipq-wifi-install-one-to,$(1),$(2),QCA9888/hw2.0),\
$(if $(filter $(suffix $(1)),.QCA9889 .qca9889),\
$(call ipq-wifi-install-one-to,$(1),$(2),QCA9887/hw1.0),\
$(if $(filter $(suffix $(1)),.QCA9984 .qca9984),\
$(call ipq-wifi-install-one-to,$(1),$(2),QCA9984/hw1.0),\
$(if $(filter $(suffix $(1)),.QCA99X0 .qca99x0),\
$(call ipq-wifi-install-one-to,$(1),$(2),QCA99X0/hw2.0),\
$(if $(filter $(suffix $(1)),.IPQ8074 .ipq8074),\
$(call ipq-wifi-install-ath11-one-to,$(1),$(2),IPQ8074/hw2.0),\
$(error Unrecognized board-file suffix '$(suffix $(1))' for '$(1)')\
))))
))))))

endef
# Blank line required at end of above define due to foreach context
Expand Down Expand Up @@ -102,7 +112,7 @@ Do not install it for any other device!
endef

# Add board name to ALLWIFIBOARDS
# Place files in this directory as board-<devicename>.<qca4019|qca9888|qca9984|qca99x0>
# Place files in this directory as board-<devicename>.<qca4019|qca9888|qca9889|qca9984|qca99x0|ipq8074>
# Add $(eval $(call generate-ipq-wifi-package,<devicename>,<display name>))

$(eval $(call generate-ipq-wifi-package,aruba_ap-365,Aruba AP-365))
Expand All @@ -121,6 +131,7 @@ $(eval $(call generate-ipq-wifi-package,qxwlan_e2600ac-c1,Qxwlan E2600AC C1))
$(eval $(call generate-ipq-wifi-package,qxwlan_e2600ac-c2,Qxwlan E2600AC C2))
$(eval $(call generate-ipq-wifi-package,sony_ncp-hg100-cellular,Sony NCP-HG100/Cellular))
$(eval $(call generate-ipq-wifi-package,teltonika_rutx,Teltonika RUTX))
$(eval $(call generate-ipq-wifi-package,xiaomi_ax3600,Xiaomi AX3600))
$(eval $(call generate-ipq-wifi-package,zte_mf18a,ZTE MF18A))
$(eval $(call generate-ipq-wifi-package,zte_mf289f,ZTE MF289F))

Expand Down
Binary file not shown.
Binary file not shown.
16 changes: 16 additions & 0 deletions target/linux/ipq807x/base-files/etc/board.d/01_leds
@@ -0,0 +1,16 @@

. /lib/functions/uci-defaults.sh

board_config_update

board=$(board_name)

case "$board" in
xiaomi,ax3600)
ucidef_set_led_netdev "wan" "WAN" "blue:network" "wan"
;;
esac

board_config_flush

exit 0
28 changes: 28 additions & 0 deletions target/linux/ipq807x/base-files/etc/board.d/02_network
@@ -0,0 +1,28 @@
#
# Copyright (c) 2015 The Linux Foundation. All rights reserved.
# Copyright (c) 2011-2015 OpenWrt.org
#

. /lib/functions/uci-defaults.sh
. /lib/functions/system.sh

ipq807x_setup_interfaces()
{
local board="$1"

case "$board" in
xiaomi,ax3600)
ucidef_set_interfaces_lan_wan "lan1 lan2 lan3" "wan"
;;
*)
echo "Unsupported hardware. Network interfaces not initialized"
;;
esac
}

board_config_update
board=$(board_name)
ipq807x_setup_interfaces $board
board_config_flush

exit 0
@@ -0,0 +1,20 @@
#!/bin/sh

[ -e /lib/firmware/$FIRMWARE ] && exit 0

. /lib/functions/caldata.sh

board=$(board_name)

case "$FIRMWARE" in
"ath11k/IPQ8074/hw2.0/cal-ahb-c000000.wifi.bin")
case "$board" in
xiaomi,ax3600)
caldata_extract "0:art" 0x1000 0x20000
;;
esac
;;
*)
exit 1
;;
esac
65 changes: 65 additions & 0 deletions target/linux/ipq807x/base-files/lib/upgrade/platform.sh
@@ -0,0 +1,65 @@
PART_NAME=firmware
REQUIRE_IMAGE_METADATA=1

RAMFS_COPY_BIN='fw_printenv fw_setenv'
RAMFS_COPY_DATA='/etc/fw_env.config /var/lock/fw_printenv.lock'

xiaomi_initramfs_prepare() {
# Wipe UBI if running initramfs
[ "$(rootfs_type)" = "tmpfs" ] || return 0

local rootfs_mtdnum="$( find_mtd_index rootfs )"
if [ ! "$rootfs_mtdnum" ]; then
echo "unable to find mtd partition rootfs"
return 1
fi

local kern_mtdnum="$( find_mtd_index ubi_kernel )"
if [ ! "$kern_mtdnum" ]; then
echo "unable to find mtd partition ubi_kernel"
return 1
fi

ubidetach -m "$rootfs_mtdnum"
ubiformat /dev/mtd$rootfs_mtdnum -y

ubidetach -m "$kern_mtdnum"
ubiformat /dev/mtd$kern_mtdnum -y
}

platform_check_image() {
return 0;
}

platform_pre_upgrade() {
case "$(board_name)" in
xiaomi,ax3600)
xiaomi_initramfs_prepare
;;
esac
}

platform_do_upgrade() {
case "$(board_name)" in
xiaomi,ax3600)
# Make sure that UART is enabled
fw_setenv boot_wait on
fw_setenv uart_en 1

# Enforce single partition.
fw_setenv flag_boot_rootfs 0
fw_setenv flag_last_success 0
fw_setenv flag_boot_success 1
fw_setenv flag_try_sys1_failed 8
fw_setenv flag_try_sys2_failed 8

# Kernel and rootfs are placed in 2 different UBI
CI_KERN_UBIPART="ubi_kernel"
CI_ROOT_UBIPART="rootfs"
nand_do_upgrade "$1"
;;
*)
default_do_upgrade "$1"
;;
esac
}
@@ -0,0 +1,73 @@
// SPDX-License-Identifier: GPL-2.0-or-later OR MIT
/* Copyright (c) 2021, Robert Marko <robimarko@gmail.com> */

/dts-v1/;

#include "ipq8071-ax3600.dtsi"

/ {
model = "Xiaomi AX3600";
compatible = "xiaomi,ax3600", "qcom,ipq8074";

leds {
compatible = "gpio-leds";

led_system_blue: system-blue {
label = "blue:system";
gpios = <&tlmm 42 GPIO_ACTIVE_HIGH>;
};

led_system_yellow: system-yellow {
label = "yellow:system";
gpios = <&tlmm 43 GPIO_ACTIVE_HIGH>;
};

network-yellow {
label = "yellow:network";
gpios = <&tlmm 22 GPIO_ACTIVE_HIGH>;
};

network-blue {
label = "blue:network";
gpios = <&tlmm 21 GPIO_ACTIVE_HIGH>;
};

aiot {
label = "blue:aiot";
gpios = <&tlmm 51 GPIO_ACTIVE_HIGH>;
linux,default-trigger = "phy0tpt";
};
};
};

&pcie_qmp0 {
status = "okay";
};

&pcie0 {
status = "okay";

perst-gpio = <&tlmm 52 GPIO_ACTIVE_HIGH>;

bridge@0,0 {
reg = <0x00000000 0 0 0 0>;
#address-cells = <3>;
#size-cells = <2>;
ranges;

wifi0: wifi@1,0 {
status = "okay";

compatible = "qcom,ath10k";
reg = <0x00010000 0 0 0 0>;

qcom,ath10k-calibration-variant = "Xiaomi-AX3600";
nvmem-cell-names = "calibration";
nvmem-cells = <&caldata_qca9889>;
};
};
};

&wifi {
qcom,ath11k-calibration-variant = "Xiaomi-AX3600";
};

2 comments on commit 8364f08

@legale
Copy link
Contributor

@legale legale commented on 8364f08 Feb 5, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome. I got 2 devices with similar chipsets. One is Yuncore ax840 (IPQ6010) and other is Yuncore ax880 (IPQ8072A). One of these device is supported by TIP project:
ax840 Telecominfraproject/wlan-ap@c2c75b6

For the second (ax880) i've made a commit in my TIP project fork.
ax880 legale/wlan-ap@73cee09

On both devices there is a very very annoying bug with monitor mode wifi traffic capture: http://lists.infradead.org/pipermail/ath11k/2022-December/003764.html

@Ansuel @robimarko as i see in this commit there is a few changes to add support for ax3600.

Is there any chance to add support for IPQ60xx in the master owrt branch? Where are the pitfalls?

Ruslan

@robimarko
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you stop pinging all over, IPQ60xx is not supported, period.

Please sign in to comment.