From 3b7d72bc2ecca2f962319b0a4fb9beb7609a0222 Mon Sep 17 00:00:00 2001 From: INAGAKI Hiroshi Date: Tue, 11 Feb 2025 00:34:29 +0900 Subject: [PATCH] qualcommax: add support for ELECOM WRC-X3000GS2 MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit ELECOM WRC-X3000GS2 is a 2.4/5 GHz band 11ax (Wi-Fi 6) router, based on IPQ5018. Specification: - SoC : Qualcomm IPQ5018 - RAM : DDR3 256 MiB (Zentel A3T2GF40CBF-HP) - Flash : SPI-NAND 128 MiB (Macronix MX35UF1G24AD-Z4I) - WLAN : 2.4/5 GHz 2T2R - 2.4 GHz : Qualcomm IPQ5018 (SoC) - 5 GHz : Qualcomm Atheros QCN6102 - Ethernet : 5x 10/100/1000 Mbps - wan (phy) : Qualcomm IPQ5018 (SoC) - lan (switch) : Qualcomm Atheros QCA8337 - LEDs/Keys (GPIO): 8x/3x - UART : through-hole on PCB, 4pins near the barcode - assignment : 3.3V, TX, RX, NC, GND from the barcode side - settings : 115200n8 - Power : 12 VDC, 1 A (Max. 11.5W) Flash instruction using initramfs-factory.bin image: 1. Boot WRC-X3000GS2 normally with router mode 2. Access to the WebUI ("http://192.168.2.1/") on the device and open the firmware update page ("ファームウェア更新") 3. Select the OpenWrt factory.bin image and click apply ("適用") button 4. Wait ~120 seconds to complete flashing Switching to the stock firmware: 1. Load the elecom.sh script . /lib/upgrade/elecom.sh 2. Check the current index of rootfs bootconfig_rw_index 0:bootconfig rootfs 3. Set the index to inverted value bootconfig_rw_index 0:bootconfig rootfs bootconfig_rw_index 0:bootconfig1 rootfs example: - step2 returned "0": bootconfig_rw_index 0:bootconfig rootfs 1 bootconfig_rw_index 0:bootconfig1 rootfs 1 - step2 returned "1": bootconfig_rw_index 0:bootconfig rootfs 0 bootconfig_rw_index 0:bootconfig1 rootfs 0 4. Reboot Partition Layout (Stock FW): 0x000000000000-0x000000080000 : "0:SBL1" 0x000000080000-0x000000100000 : "0:MIBIB" 0x000000100000-0x000000140000 : "0:BOOTCONFIG" 0x000000140000-0x000000180000 : "0:BOOTCONFIG1" 0x000000180000-0x000000280000 : "0:QSEE" 0x000000280000-0x000000380000 : "0:QSEE_1" 0x000000380000-0x0000003c0000 : "0:DEVCFG" 0x0000003c0000-0x000000400000 : "0:DEVCFG_1" 0x000000400000-0x000000440000 : "0:CDT" 0x000000440000-0x000000480000 : "0:CDT_1" 0x000000480000-0x000000500000 : "0:APPSBLENV" 0x000000500000-0x000000640000 : "0:APPSBL" 0x000000640000-0x000000780000 : "0:APPSBL_1" 0x000000780000-0x000000880000 : "0:ART" 0x000000880000-0x000000900000 : "0:TRAINING" 0x000000900000-0x000003c40000 : "rootfs" 0x000003c40000-0x000003fc0000 : "Config" 0x000003fc0000-0x000007300000 : "rootfs_1" 0x000007300000-0x000007680000 : "Config_2" 0x000007680000-0x000007b80000 : "Reserved" 0x000007b80000-0x000007c00000 : "FWHEADER" 0x000007c00000-0x000007c80000 : "Factory" Known Issues: - All Wi-Fi related peripherals are disabled. This device has only 256 MiB RAM and it's too few for ath11k. To prevent OOM when using LuCI or other softwares, disable Wi-Fi related peripherals in device tree at the moment. - This device has a Macronix MX35UF1G24AD SPI-NAND chip registered as oobsize=128 in Linux Kernel. But using BCH8 breaks I/O on the chip with the following errors, so this support uses BCH4 instead. root@OpenWrt:~# strings /dev/mtdblock10 [26427.133154] mtdblock: MTD device '0:appsblenv' is NAND, please consider using UBI block devices instead. [26427.134125] I/O error, dev mtdblock10, sector 0 op 0x0:(READ) flags 0x80700 phys_seg 4 prio class 2 [26427.142240] I/O error, dev mtdblock10, sector 8 op 0x0:(READ) flags 0x80700 phys_seg 3 prio class 2 [26427.151427] I/O error, dev mtdblock10, sector 16 op 0x0:(READ) flags 0x80700 phys_seg 2 prio class 2 [26427.160440] I/O error, dev mtdblock10, sector 24 op 0x0:(READ) flags 0x80700 phys_seg 1 prio class 2 [26427.169619] I/O error, dev mtdblock10, sector 0 op 0x0:(READ) flags 0x0 phys_seg 1 prio class 2 [26427.178083] Buffer I/O error on dev mtdblock10, logical block 0, async page read Notes: - This device has dual-boot feature and it's managed by the index in the 0:bootconfig and 0:bootconfig1 partitions. MAC Addresses: LAN : 38:97:A4:xx:xx:60 (0:APPSBLENV, "eth1addr"/"ethaddr" (text)) WAN : 38:97:A4:xx:xx:63 (0:APPSBLENV, "eth0addr" (text)) 2.4 GHz: 38:97:A4:xx:xx:61 (0:APPSBLENV, "wifi0" (text)) 5 GHz : 38:97:A4:xx:xx:62 (0:APPSBLENV, "wifi1" (text)) Signed-off-by: INAGAKI Hiroshi Link: https://github.com/openwrt/openwrt/pull/18543 Signed-off-by: Robert Marko --- package/firmware/ipq-wifi/Makefile | 2 + .../boot/dts/qcom/ipq5018-wrc-x3000gs2.dts | 503 ++++++++++++++++++ target/linux/qualcommax/image/ipq50xx.mk | 35 ++ .../ipq50xx/base-files/etc/board.d/01_leds | 3 + .../ipq50xx/base-files/etc/board.d/02_network | 7 +- .../etc/hotplug.d/firmware/11-ath11k-caldata | 12 + .../ipq50xx/base-files/lib/upgrade/elecom.sh | 119 +++++ .../base-files/lib/upgrade/platform.sh | 15 +- 8 files changed, 692 insertions(+), 4 deletions(-) create mode 100644 target/linux/qualcommax/files/arch/arm64/boot/dts/qcom/ipq5018-wrc-x3000gs2.dts create mode 100644 target/linux/qualcommax/ipq50xx/base-files/lib/upgrade/elecom.sh diff --git a/package/firmware/ipq-wifi/Makefile b/package/firmware/ipq-wifi/Makefile index 03ccc1a24ae..b33e261ef21 100644 --- a/package/firmware/ipq-wifi/Makefile +++ b/package/firmware/ipq-wifi/Makefile @@ -38,6 +38,7 @@ ALLWIFIBOARDS:= \ dynalink_dl-wrx36 \ edgecore_eap102 \ edimax_cax1800 \ + elecom_wrc-x3000gs2 \ glinet_gl-ax1800 \ glinet_gl-axt1800 \ glinet_gl-b3000 \ @@ -189,6 +190,7 @@ $(eval $(call generate-ipq-wifi-package,compex_wpq873,Compex WPQ-873)) $(eval $(call generate-ipq-wifi-package,dynalink_dl-wrx36,Dynalink DL-WRX36)) $(eval $(call generate-ipq-wifi-package,edgecore_eap102,Edgecore EAP102)) $(eval $(call generate-ipq-wifi-package,edimax_cax1800,Edimax CAX1800)) +$(eval $(call generate-ipq-wifi-package,elecom_wrc-x3000gs2,ELECOM WRC-X3000GS2)) $(eval $(call generate-ipq-wifi-package,glinet_gl-ax1800,GL.iNet GL-AX1800)) $(eval $(call generate-ipq-wifi-package,glinet_gl-axt1800,GL.iNet GL-AXT1800)) $(eval $(call generate-ipq-wifi-package,glinet_gl-b3000,GL.iNet GL-B3000)) diff --git a/target/linux/qualcommax/files/arch/arm64/boot/dts/qcom/ipq5018-wrc-x3000gs2.dts b/target/linux/qualcommax/files/arch/arm64/boot/dts/qcom/ipq5018-wrc-x3000gs2.dts new file mode 100644 index 00000000000..fc3e86b8702 --- /dev/null +++ b/target/linux/qualcommax/files/arch/arm64/boot/dts/qcom/ipq5018-wrc-x3000gs2.dts @@ -0,0 +1,503 @@ +// SPDX-License-Identifier: GPL-2.0-or-later OR MIT + +/dts-v1/; + +#include "ipq5018.dtsi" +#include "ipq5018-ess.dtsi" + +#include +#include +#include + +/ { + model = "ELECOM WRC-X3000GS2"; + compatible = "elecom,wrc-x3000gs2", "qcom,ipq5018"; + + aliases { + serial0 = &blsp1_uart1; + led-boot = &led_power_green; + led-failsafe = &led_power_red; + led-running = &led_power_green; + led-upgrade = &led_power_green; + label-mac-device = <&dp1>; + }; + + chosen { + bootargs-append = " root=/dev/ubiblock0_1 coherent_pool=2M"; + stdout-path = "serial0:115200n8"; + }; + + keys { + compatible = "gpio-keys"; + pinctrl-0 = <&button_pins>; + pinctrl-names = "default"; + + switch-router { + label = "router"; + gpios = <&tlmm 14 GPIO_ACTIVE_HIGH>; + linux,code = ; + linux,input-type = ; + }; + + reset-button { + label = "reset"; + gpios = <&tlmm 22 GPIO_ACTIVE_LOW>; + linux,code = ; + }; + + wps-button { + label = "wps"; + gpios = <&tlmm 38 GPIO_ACTIVE_LOW>; + linux,code = ; + }; + }; + + leds { + compatible = "gpio-leds"; + pinctrl-0 = <&led_pins>; + pinctrl-names = "default"; + + led-0 { + gpios = <&tlmm 12 GPIO_ACTIVE_HIGH>; + color = ; + function = LED_FUNCTION_WPS; + }; + + led_power_green: led-1 { + gpios = <&tlmm 13 GPIO_ACTIVE_HIGH>; + color = ; + function = LED_FUNCTION_POWER; + }; + + led_power_red: led-2 { + gpios = <&tlmm 16 GPIO_ACTIVE_HIGH>; + color = ; + function = LED_FUNCTION_POWER; + }; + + led-3 { + gpios = <&tlmm 24 GPIO_ACTIVE_HIGH>; + color = ; + function = LED_FUNCTION_WLAN_5GHZ; + linux,default-trigger = "phy1radio"; + }; + + led-4 { + gpios = <&tlmm 25 GPIO_ACTIVE_HIGH>; + color = ; + function = LED_FUNCTION_WLAN_5GHZ; + }; + + led-5 { + gpios = <&tlmm 26 GPIO_ACTIVE_HIGH>; + color = ; + function = LED_FUNCTION_WLAN_2GHZ; + linux,default-trigger = "phy0radio"; + }; + + led-6 { + gpios = <&tlmm 28 GPIO_ACTIVE_HIGH>; + color = ; + function = LED_FUNCTION_WLAN_2GHZ; + }; + + led-7 { + gpios = <&tlmm 46 GPIO_ACTIVE_HIGH>; + color = ; + function = LED_FUNCTION_WAN; + }; + }; + + reserved-memory { + q6_mem_regions: q6_mem_regions@4b000000 { + no-map; + reg = <0x0 0x4b000000 0x0 0x3000000>; + status = "disabled"; + }; + }; +}; + +&sleep_clk { + clock-frequency = <32000>; +}; + +&xo_board_clk { + clock-frequency = <24000000>; +}; + +&blsp1_uart1 { + status = "okay"; + + pinctrl-0 = <&serial_0_pins>; + pinctrl-names = "default"; +}; + +&crypto { + status = "okay"; +}; + +&cryptobam { + status = "okay"; +}; + +&prng { + status = "okay"; +}; + +&qfprom { + status = "okay"; +}; + +&qpic_bam { + status = "okay"; +}; + +&qpic_nand { + pinctrl-0 = <&qpic_pins>; + pinctrl-names = "default"; + status = "okay"; + + flash@0 { + compatible = "spi-nand"; + reg = <0>; + #address-cells = <1>; + #size-cells = <1>; + + nand-ecc-engine = <&qpic_nand>; + + /* strength=8 breaks NAND I/O, use 4 instead */ + nand-ecc-strength = <4>; + nand-ecc-step-size = <512>; + nand-bus-width = <8>; + + partitions { + compatible = "qcom,smem-part"; + + partition-0-appsblenv { + compatible = "fixed-partitions"; + label = "0:appsblenv"; + #address-cells = <1>; + #size-cells = <1>; + + partition@0 { + label = "env-data"; + reg = <0x0 0x40000>; + + nvmem-layout { + compatible = "u-boot,env"; + + macaddr_appsblenv_ethaddr: ethaddr { + compatible = "mac-base"; + #nvmem-cell-cells = <1>; + }; + }; + }; + }; + }; + }; +}; + +&switch { + status = "okay"; + + switch_mac_mode = ; + + qcom,port_phyinfo { + port@0 { + port_id = <1>; + mdiobus = <&mdio0>; + phy_address = <7>; + }; + + port@1 { + port_id = <2>; + forced-speed = <1000>; + forced-duplex = <1>; + }; + }; +}; + +&dp1 { + status = "okay"; + + label = "wan"; + nvmem-cells = <&macaddr_appsblenv_ethaddr 3>; + nvmem-cell-names = "mac-address"; +}; + +&dp2 { + status = "okay"; + + nvmem-cells = <&macaddr_appsblenv_ethaddr 0>; + nvmem-cell-names = "mac-address"; + + fixed-link { + speed = <1000>; + full-duplex; + }; +}; + +&mdio0 { + status = "okay"; +}; + +&mdio1 { + status = "okay"; + + pinctrl-0 = <&mdio1_pins>, <&switch_reset_pins>; + pinctrl-names = "default"; + reset-gpios = <&tlmm 39 GPIO_ACTIVE_LOW>; + + qca8337_0: ethernet-phy@0 { + reg = <0>; + }; + + qca8337_1: ethernet-phy@1 { + reg = <1>; + }; + + qca8337_2: ethernet-phy@2 { + reg = <2>; + }; + + qca8337_3: ethernet-phy@3 { + reg = <3>; + }; + + ethernet-switch@18 { + compatible = "qca,qca8337"; + reg = <0x18>; + #address-cells = <1>; + #size-cells = <0>; + + ports { + #address-cells = <1>; + #size-cells = <0>; + + port@1 { + reg = <1>; + label = "lan1"; + phy-handle = <&qca8337_0>; + }; + + port@2 { + reg = <2>; + label = "lan2"; + phy-handle = <&qca8337_1>; + }; + + port@3 { + reg = <3>; + label = "lan3"; + phy-handle = <&qca8337_2>; + }; + + port@4 { + reg = <4>; + label = "lan4"; + phy-handle = <&qca8337_3>; + }; + + port@6 { + reg = <6>; + phy-mode = "sgmii"; + ethernet = <&dp2>; + qca,sgmii-enable-pll; + + fixed-link { + speed = <1000>; + full-duplex; + }; + }; + }; + }; +}; + +&tlmm { + button_pins: button-state { + button-pins { + pins = "gpio22", "gpio38"; + function = "gpio"; + drive-strength = <8>; + bias-pull-up; + }; + + switch-pins { + pins = "gpio14"; + function = "gpio"; + drive-strength = <8>; + bias-pull-down; + }; + }; + + led_pins: led-state { + pins = "gpio12", "gpio13", "gpio16", "gpio24", + "gpio25", "gpio26", "gpio28", "gpio46"; + function = "gpio"; + drive-strength = <8>; + bias-pull-down; + }; + + mdio1_pins: mdio-state { + mdc-pins { + pins = "gpio36"; + function = "mdc"; + drive-strength = <8>; + bias-pull-up; + }; + + mdio-pins { + pins = "gpio37"; + function = "mdio"; + drive-strength = <8>; + bias-pull-up; + }; + }; + + qpic_pins: qpic-state { + clock-pins { + pins = "gpio9"; + function = "qspi_clk"; + drive-strength = <8>; + bias-disable; + }; + + cs-pins { + pins = "gpio8"; + function = "qspi_cs"; + drive-strength = <8>; + bias-disable; + }; + + data-pins { + pins = "gpio4", "gpio5", "gpio6", "gpio7"; + function = "qspi_data"; + drive-strength = <8>; + bias-disable; + }; + }; + + serial_0_pins: uart0-state { + pins = "gpio20", "gpio21"; + function = "blsp0_uart0"; + bias-disable; + }; + + switch_reset_pins: switch-reset-state { + pins = "gpio39"; + function = "gpio"; + drive-strength = <8>; + bias-pull-down; + }; +}; + +&tsens { + status = "okay"; +}; + +/* + * ath11k Wi-Fi consumes too large memory spaces and too few spaces are + * available for users. To prevent OOM when using LuCI or other softwares, + * disable Wi-Fi related peripherals at the moment. + */ +&q6v5_wcss { + status = "disabled"; + + memory-region = <&q6_mem_regions>; + firmware-name = "ath11k/IPQ5018/hw1.0/q6_fw.mdt", + "ath11k/IPQ5018/hw1.0/m3_fw.mdt", + "ath11k/QCN6122/hw1.0/m3_fw.mdt"; + + boot-args = <0x2 4 2 18 0 0>; /* pcie:1, len:4, updid:2, reset:gpio18 */ + + q6_wcss_pd1: pd-1 { + firmware-name = "ath11k/IPQ5018/hw1.0/q6_fw.mdt"; + + resets = + <&gcc GCC_WCSSAON_RESET>, + <&gcc GCC_WCSS_BCR>, + <&gcc GCC_CE_BCR>; + reset-names = + "wcss_aon_reset", + "wcss_reset", + "ce_reset"; + + clocks = + <&gcc GCC_WCSS_AHB_S_CLK>, + <&gcc GCC_WCSS_ACMT_CLK>, + <&gcc GCC_WCSS_AXI_M_CLK>; + clock-names = + "gcc_wcss_ahb_s_clk", + "gcc_wcss_acmt_clk", + "gcc_wcss_axi_m_clk"; + + interrupts-extended = + <&wcss_smp2p_in 8 IRQ_TYPE_NONE>, + <&wcss_smp2p_in 9 IRQ_TYPE_NONE>, + <&wcss_smp2p_in 12 IRQ_TYPE_NONE>, + <&wcss_smp2p_in 11 IRQ_TYPE_NONE>; + interrupt-names = + "fatal", + "ready", + "spawn-ack", + "stop-ack"; + + qcom,smem-states = + <&wcss_smp2p_out 8>, + <&wcss_smp2p_out 9>, + <&wcss_smp2p_out 10>; + qcom,smem-state-names = + "shutdown", + "stop", + "spawn"; + }; + + q6_wcss_pd2: pd-2 { + firmware-name = "ath11k/IPQ5018/hw1.0/q6_fw.mdt"; + + interrupts-extended = + <&wcss_smp2p_in 16 IRQ_TYPE_NONE>, + <&wcss_smp2p_in 17 IRQ_TYPE_NONE>, + <&wcss_smp2p_in 20 IRQ_TYPE_NONE>, + <&wcss_smp2p_in 19 IRQ_TYPE_NONE>; + interrupt-names = + "fatal", + "ready", + "spawn-ack", + "stop-ack"; + + qcom,smem-states = + <&wcss_smp2p_out 16>, + <&wcss_smp2p_out 17>, + <&wcss_smp2p_out 18>; + qcom,smem-state-names = + "shutdown", + "stop", + "spawn"; + }; +}; + +&wifi0 { + qcom,rproc = <&q6_wcss_pd1>; + qcom,userpd-subsys-name = "q6v5_wcss_userpd1"; + qcom,ath11k-calibration-variant = "ELECOM-WRC-X3000GS2"; + qcom,ath11k-fw-memory-mode = <2>; + qcom,bdf-addr = <0x4c400000>; + + ieee80211-freq-limit = <2400000 2483000>; + + status = "disabled"; +}; + +&wifi1 { + qcom,rproc = <&q6_wcss_pd2>; + qcom,userpd-subsys-name = "q6v5_wcss_userpd2"; + qcom,ath11k-calibration-variant = "ELECOM-WRC-X3000GS2"; + qcom,ath11k-fw-memory-mode = <2>; + qcom,bdf-addr = <0x4d100000>; + qcom,m3-dump-addr = <0x4df00000>; + + ieee80211-freq-limit = <5150000 5730000>; + + status = "disabled"; +}; diff --git a/target/linux/qualcommax/image/ipq50xx.mk b/target/linux/qualcommax/image/ipq50xx.mk index e791832b876..bcd25f8a2c2 100644 --- a/target/linux/qualcommax/image/ipq50xx.mk +++ b/target/linux/qualcommax/image/ipq50xx.mk @@ -1,5 +1,40 @@ DEVICE_VARS += BOOT_SCRIPT +define Build/mstc-header + $(eval version=$(1)) + gzip -c $@ | tail -c8 > $@.crclen + ( \ + printf "CMOC"; \ + tail -c+5 $@.crclen; head -c4 $@.crclen; \ + printf '$(call toupper,$(LINUX_KARCH)) $(VERSION_DIST) Linux-$(LINUX_VERSION)' | \ + dd bs=64 count=1 conv=sync 2>/dev/null; \ + printf "$(version)" | \ + dd bs=64 count=1 conv=sync 2>/dev/null; \ + dd if=/dev/zero bs=884 count=1 2>/dev/null; \ + cat $@; \ + ) > $@.new + mv $@.new $@ + rm -f $@.crclen +endef + +define Device/elecom_wrc-x3000gs2 + $(call Device/FitImageLzma) + $(call Device/UbiFit) + DEVICE_VENDOR := ELECOM + DEVICE_MODEL := WRC-X3000GS2 + DEVICE_DTS_CONFIG := config@mp03.3 + SOC := ipq5018 + BLOCKSIZE := 128k + PAGESIZE := 2048 + IMAGE_SIZE := 52480k + NAND_SIZE := 128m + IMAGES += factory.bin + IMAGE/factory.bin := append-ubi | qsdk-ipq-factory-nand | \ + mstc-header 4.04(XZF.0)b90 | elecom-product-header WRC-X3000GS2 + DEVICE_PACKAGES := ath11k-firmware-qcn6122 ipq-wifi-elecom_wrc-x3000gs2 +endef +TARGET_DEVICES += elecom_wrc-x3000gs2 + define Device/glinet_gl-b3000 $(call Device/FitImage) DEVICE_VENDOR := GL.iNet diff --git a/target/linux/qualcommax/ipq50xx/base-files/etc/board.d/01_leds b/target/linux/qualcommax/ipq50xx/base-files/etc/board.d/01_leds index 3969f233abc..c12c61d61c1 100644 --- a/target/linux/qualcommax/ipq50xx/base-files/etc/board.d/01_leds +++ b/target/linux/qualcommax/ipq50xx/base-files/etc/board.d/01_leds @@ -9,6 +9,9 @@ board_config_update board=$(board_name) case "$board" in +elecom,wrc-x3000gs2) + ucidef_set_led_netdev "wan" "WAN" "green:wan" "wan" "tx rx link_10 link_100 link_1000" + ;; linksys,mr5500) ucidef_set_led_netdev "lan1-port-link" "LAN1-PORT-LINK" "qca8k-0.0:00:green:lan" "lan1" "link_10 link_100 link_1000" ucidef_set_led_netdev "lan1-port-activity" "LAN1-PORT-ACTIVITY" "qca8k-0.0:00:amber:lan" "lan1" "tx rx" diff --git a/target/linux/qualcommax/ipq50xx/base-files/etc/board.d/02_network b/target/linux/qualcommax/ipq50xx/base-files/etc/board.d/02_network index 5ab9cc975af..fb942af6cee 100644 --- a/target/linux/qualcommax/ipq50xx/base-files/etc/board.d/02_network +++ b/target/linux/qualcommax/ipq50xx/base-files/etc/board.d/02_network @@ -7,12 +7,13 @@ ipq50xx_setup_interfaces() { local board="$1" case $board in - glinet,gl-b3000) - ucidef_set_interfaces_lan_wan "lan1 lan2" "wan" - ;; + elecom,wrc-x3000gs2|\ linksys,mr5500) ucidef_set_interfaces_lan_wan "lan1 lan2 lan3 lan4" "wan" ;; + glinet,gl-b3000) + ucidef_set_interfaces_lan_wan "lan1 lan2" "wan" + ;; linksys,mx2000|\ linksys,mx5500|\ linksys,spnmx56) diff --git a/target/linux/qualcommax/ipq50xx/base-files/etc/hotplug.d/firmware/11-ath11k-caldata b/target/linux/qualcommax/ipq50xx/base-files/etc/hotplug.d/firmware/11-ath11k-caldata index 6d1319c71c5..6385b004882 100644 --- a/target/linux/qualcommax/ipq50xx/base-files/etc/hotplug.d/firmware/11-ath11k-caldata +++ b/target/linux/qualcommax/ipq50xx/base-files/etc/hotplug.d/firmware/11-ath11k-caldata @@ -9,6 +9,12 @@ board=$(board_name) case "$FIRMWARE" in "ath11k/IPQ5018/hw1.0/cal-ahb-c000000.wifi.bin") case "$board" in + elecom,wrc-x3000gs2) + caldata_extract "0:art" 0x1000 0x20000 + wlan_mac=$(mtd_get_mac_ascii 0:appsblenv wifi0) + ath11k_patch_mac $wlan_mac 0 + ath11k_set_macflag + ;; glinet,gl-b3000) caldata_extract "0:art" 0x1000 0x20000 ath11k_patch_mac $(macaddr_add $(get_mac_label_dt) 3) 0 @@ -28,6 +34,12 @@ case "$FIRMWARE" in ;; "ath11k/QCN6122/hw1.0/cal-ahb-b00a040.wifi1.bin") case "$board" in + elecom,wrc-x3000gs2) + caldata_extract "0:art" 0x26800 0x20000 + wlan_mac=$(mtd_get_mac_ascii 0:appsblenv wifi1) + ath11k_patch_mac $wlan_mac 0 + ath11k_set_macflag + ;; glinet,gl-b3000) caldata_extract "0:art" 0x26800 0x20000 ath11k_patch_mac $(macaddr_add $(get_mac_label_dt) 4) 0 diff --git a/target/linux/qualcommax/ipq50xx/base-files/lib/upgrade/elecom.sh b/target/linux/qualcommax/ipq50xx/base-files/lib/upgrade/elecom.sh new file mode 100644 index 00000000000..14f8992721c --- /dev/null +++ b/target/linux/qualcommax/ipq50xx/base-files/lib/upgrade/elecom.sh @@ -0,0 +1,119 @@ +. /lib/functions.sh + +bootconfig_find_entry() { + local cfgbin="$1" + local partname="$2" + local i part parts offset + + parts=$(hexdump -n 4 -s 8 -e '1/4 "%d"' "$cfgbin") + # partition count: <= 10 + [ -z "$parts" ] || [ "$parts" = "0" ] || [ "$parts" -gt "10" ] && \ + return 1 + + for i in $(seq 1 $parts); do + offset=$((0xc + 0x14 * (i - 1))) + part=$(dd if="$cfgbin" iflag=skip_bytes \ + skip=$offset bs=16 count=1 2>/dev/null) + if [ "$part" = "$partname" ]; then + printf "0x%08x" $offset + return + fi + done + + return 1 +} + +# Read or update an entry in Qualcomm bootconfig partition +# +# parameters: +# $1: partition name of bootconfig (ex.: "0:bootconfig", "0:bootconfig1", etc) +# $2: entry name in bootconfig (ex.: "0:hlos", "rootfs", etc) +# $3: index to set for the entry (0/1) +# +# operations: +# read : bootconfig_rw_index +# write: bootconfig_rw_index +bootconfig_rw_index() { + local bootcfg="$1" + local partname="$2" + local index="$3" + local mtddev + local offset + local current + + if [ -z "$bootcfg" ] || [ -z "$partname" ]; then + echo "no value specified for bootconfig or partition entry" + return 1 + fi + + case "$index" in + 0|1|"") ;; + *) echo "invalid bootconfig index specified \"$index\""; return 1 ;; + esac + + mtddev="$(find_mtd_part $bootcfg)" + [ -z "$mtddev" ] && \ + return 1 + + dd if=$mtddev of=/tmp/${mtddev##*/} bs=1k + + offset=$(bootconfig_find_entry "/tmp/${mtddev##*/}" $partname) || return 1 + current=$(hexdump -n 4 -s $((offset + 0x10)) -e '1/4 "%d"' /tmp/${mtddev##*/}) + + [ -z "$index" ] && \ + echo "$current" && return 0 + + if [ "$current" != "$index" ]; then + printf "\x$index" | \ + dd of=$mtddev conv=notrunc bs=1 seek=$((offset + 0x10)) + fi +} + +# Qcom U-Boot always sets a name of current active partition to "rootfs" and +# inactive partition is named as "rootfs_1", in the smem partition table. +# When the second partition is active, "rootfs" and "rootfs_1" are swapped. +smempart_next_root() { + local index="$1" + local root_idx="$(find_mtd_index rootfs)" + local root1_idx="$(find_mtd_index rootfs_1)" + local root_offset root1_offset + + [ -z "$root_idx" ] || [ -z "$root1_idx" ] && \ + return 1 + + root_offset=$(cat /sys/block/mtdblock$root_idx/device/offset) + root1_offset=$(cat /sys/block/mtdblock$root1_idx/device/offset) + + case "$index" in + 0) + [ "$root_offset" -lt "$root1_offset" ] && \ + echo "rootfs" || \ + echo "rootfs_1" + ;; + 1) + [ "$root_offset" -lt "$root1_offset" ] && \ + echo "rootfs_1" || \ + echo "rootfs" + ;; + *) + echo "invalid index specified..." + return 1 + ;; + esac +} + +elecom_upgrade_prepare() { + local index + + if ! index=$(bootconfig_rw_index "0:bootconfig" rootfs); then + v "failed to read bootconfig index..." + nand_do_upgrade_failed + fi + + if ! CI_UBIPART=$(smempart_next_root $index); then + v "failed to get next root..." + nand_do_upgrade_failed + fi + + v "next rootfs: $index (current: $CI_UBIPART)" +} diff --git a/target/linux/qualcommax/ipq50xx/base-files/lib/upgrade/platform.sh b/target/linux/qualcommax/ipq50xx/base-files/lib/upgrade/platform.sh index 60971472a18..0f6ae73cc6b 100644 --- a/target/linux/qualcommax/ipq50xx/base-files/lib/upgrade/platform.sh +++ b/target/linux/qualcommax/ipq50xx/base-files/lib/upgrade/platform.sh @@ -1,7 +1,7 @@ PART_NAME=firmware REQUIRE_IMAGE_METADATA=1 -RAMFS_COPY_BIN='dumpimage fw_printenv fw_setenv head' +RAMFS_COPY_BIN='dumpimage fw_printenv fw_setenv head seq' RAMFS_COPY_DATA='/etc/fw_env.config /var/lock/fw_printenv.lock' remove_oem_ubi_volume() { @@ -71,6 +71,19 @@ platform_check_image() { platform_do_upgrade() { case "$(board_name)" in + elecom,wrc-x3000gs2) + local delay index + + delay=$(fw_printenv bootdelay) + [ -z "$delay" ] || [ "$delay" -eq "0" ] && \ + fw_setenv bootdelay 3 + + elecom_upgrade_prepare + + remove_oem_ubi_volume ubi_rootfs + remove_oem_ubi_volume wifi_fw + nand_do_upgrade "$1" + ;; glinet,gl-b3000) glinet_do_upgrade "$1" ;; -- 2.47.2