[openwrt/openwrt] ramips: add support for ELECOM WRC-X1800GS

LEDE Commits lede-commits at lists.infradead.org
Sat May 25 10:34:38 PDT 2024


hauke pushed a commit to openwrt/openwrt.git, branch main:
https://git.openwrt.org/50ae9337d62ce7991f80436eadf4415179c039d2

commit 50ae9337d62ce7991f80436eadf4415179c039d2
Author: INAGAKI Hiroshi <musashino.open at gmail.com>
AuthorDate: Sat May 11 15:35:50 2024 +0900

    ramips: add support for ELECOM WRC-X1800GS
    
    ELECOM WRC-X1800GS is a 2.4/5 GHz band 11ax (Wi-Fi 6) router, based on
    MT7621A.
    
    Specification:
    
    - SoC               : MediaTek MT7621A
    - RAM               : DDR3 256 MiB
    - Flash             : RAW-NAND 128 MiB (Macronix MX30LF1G28AD-TI)
    - WLAN              : 2.4/5 GHz 2T2R (MediaTek MT7915D)
    - Ethernet          : 5x 10/100/1000 Mbps
      - switch          : MediaTek MT7530 (SoC)
    - LEDs/Keys (GPIO)  : 7x/4x
    - UART              : pin-header on PCB ("J5")
      - arrangement     : 3.3V, TX, RX, NC, GND from tri-angle marking
      - settings        : 115200n8
    - Power             : 12 VDC, 1 A
    
    Flash instruction using initramfs-factory image:
    
    1. Boot WRC-X1800GS normally with "Router" mode
    2. Access to "http://192.168.2.1/" and open firmware update page
       ("ファームウェア更新")
    3. Select the OpenWrt initramfs-factory image and click apply ("適用")
       button
    4. After flashing initramfs-factory image and reboot, upload the
       sysupgrade image and perform sysupgrade with it
    5. Wait ~120 seconds to complete flashing
    
    Notes:
    
    - WRC-X1800GS has 2x os images. Those are switched on every firmware
      updating on stock firmware, but dual-boot feature on this device
      cannot be handled on OpenWrt. So the 1st image is always used on
      OpenWrt.
      This is controlled by "bootnum" variable embedded in "persist"
      partition (addr: 0x4).
    
    - WRC-X1800GS has 2x HW revisions. There are some small changes, but the
      same DeviceTree in stock firmware is used for both revisions.
      On this support of WRC-X1800GS, 2x green:wlan-2g-N LEDs are defined
      for each revision and the same default triggers are set.
    
    MAC addresses:
    
    LAN    : 38:97:A4:xx:xx:38 (Factory, 0x1fdfa (hex) / Ubootenv, ethaddr (text))
    WAN    : 38:97:A4:xx:xx:3B (Factory, 0x1fdf4 (hex))
    2.4 GHz: 38:97:A4:xx:xx:39
    5 GHz  : 38:97:A4:xx:xx:3A
    
    Signed-off-by: INAGAKI Hiroshi <musashino.open at gmail.com>
---
 .../linux/ramips/dts/mt7621_elecom_wrc-x1800gs.dts | 279 +++++++++++++++++++++
 target/linux/ramips/image/mt7621.mk                |  21 ++
 .../mt7621/base-files/etc/board.d/02_network       |   1 +
 .../mt7621/base-files/lib/upgrade/platform.sh      |   6 +
 4 files changed, 307 insertions(+)

diff --git a/target/linux/ramips/dts/mt7621_elecom_wrc-x1800gs.dts b/target/linux/ramips/dts/mt7621_elecom_wrc-x1800gs.dts
new file mode 100644
index 0000000000..c0bb5e4969
--- /dev/null
+++ b/target/linux/ramips/dts/mt7621_elecom_wrc-x1800gs.dts
@@ -0,0 +1,279 @@
+// SPDX-License-Identifier: GPL-2.0-or-later OR MIT
+
+#include "mt7621.dtsi"
+
+#include <dt-bindings/gpio/gpio.h>
+#include <dt-bindings/input/input.h>
+#include <dt-bindings/leds/common.h>
+
+/ {
+	compatible = "elecom,wrc-x1800gs", "mediatek,mt7621-soc";
+	model = "ELECOM WRC-X1800GS";
+
+	aliases {
+		led-boot = &led_power_green;
+		led-failsafe = &led_power_red;
+		led-running = &led_power_green;
+		led-upgrade = &led_power_green;
+		label-mac-device = &gmac0;
+	};
+
+	chosen {
+		bootargs-override = "console=ttyS0,115200n8";
+	};
+
+	leds {
+		compatible = "gpio-leds";
+
+		/* available on 1st HW rev. */
+		led-0 {
+			gpios = <&gpio 0 GPIO_ACTIVE_LOW>;
+			color = <LED_COLOR_ID_GREEN>;
+			function = LED_FUNCTION_WLAN_2GHZ;
+			function-enumerator = <1>;
+			linux,default-trigger = "phy0tpt";
+		};
+
+		led_power_green: led-1 {
+			gpios = <&gpio 3 GPIO_ACTIVE_HIGH>;
+			color = <LED_COLOR_ID_GREEN>;
+			function = LED_FUNCTION_POWER;
+		};
+
+		led_power_red: led-2 {
+			gpios = <&gpio 4 GPIO_ACTIVE_HIGH>;
+			color = <LED_COLOR_ID_RED>;
+			function = LED_FUNCTION_POWER;
+		};
+
+		led-3 {
+			gpios = <&gpio 5 GPIO_ACTIVE_HIGH>;
+			color = <LED_COLOR_ID_RED>;
+			function = LED_FUNCTION_WLAN_2GHZ;
+		};
+
+		led-4 {
+			gpios = <&gpio 8 GPIO_ACTIVE_LOW>;
+			color = <LED_COLOR_ID_RED>;
+			function = LED_FUNCTION_WPS;
+		};
+
+		led-5 {
+			gpios = <&gpio 13 GPIO_ACTIVE_LOW>;
+			color = <LED_COLOR_ID_GREEN>;
+			function = LED_FUNCTION_WLAN_5GHZ;
+			linux,default-trigger = "phy1tpt";
+		};
+
+		/* available on 2nd HW rev. */
+		led-6 {
+			gpios = <&gpio 15 GPIO_ACTIVE_LOW>;
+			color = <LED_COLOR_ID_GREEN>;
+			function = LED_FUNCTION_WLAN_2GHZ;
+			function-enumerator = <2>;
+			linux,default-trigger = "phy0tpt";
+		};
+
+		led-7 {
+			gpios = <&gpio 17 GPIO_ACTIVE_HIGH>;
+			color = <LED_COLOR_ID_RED>;
+			function = LED_FUNCTION_WLAN_5GHZ;
+		};
+
+	};
+
+	keys {
+		compatible = "gpio-keys";
+
+		button-reset {
+			label = "reset";
+			gpios = <&gpio 6 GPIO_ACTIVE_LOW>;
+			linux,code = <KEY_RESTART>;
+		};
+
+		switch-ap {
+			label = "ap";
+			gpios = <&gpio 7 GPIO_ACTIVE_LOW>;
+			linux,code = <BTN_0>;
+		};
+
+		switch-router {
+			label = "router";
+			gpios = <&gpio 14 GPIO_ACTIVE_LOW>;
+			linux,code = <BTN_1>;
+		};
+
+		button-wps {
+			label = "wps";
+			gpios = <&gpio 18 GPIO_ACTIVE_LOW>;
+			linux,code = <KEY_WPS_BUTTON>;
+		};
+	};
+};
+
+&nand {
+	status = "okay";
+	pinctrl-0 = <&nand_pins>;
+	pinctrl-names = "default";
+
+	partitions {
+		compatible = "fixed-partitions";
+		#address-cells = <1>;
+		#size-cells = <1>;
+
+		partition at 0 {
+			reg = <0x0 0x100000>;
+			label = "u-boot";
+			read-only;
+		};
+
+		partition at 100000 {
+			reg = <0x100000 0x100000>;
+			label = "u-boot-env";
+		};
+
+		partition at 200000 {
+			reg = <0x200000 0x1c0000>;
+			label = "factory";
+			read-only;
+
+			nvmem-layout {
+				compatible = "fixed-layout";
+				#address-cells = <1>;
+				#size-cells = <1>;
+
+				eeprom_factory_0: eeprom at 0 {
+					reg = <0x0 0xe00>;
+				};
+
+				precal_factory_e10: precal at e10 {
+					reg = <0xe10 0x19c10>;
+				};
+
+				macaddr_factory_1fdf4: macaddr at 1fdf4 {
+					reg = <0x1fdf4 0x6>;
+				};
+
+				macaddr_factory_1fdfa: macaddr at 1fdfa {
+					reg = <0x1fdfa 0x6>;
+				};
+			};
+		};
+
+		/* "RAS1" on stock fw */
+		partition at 3c0000 {
+			compatible = "fixed-partitions";
+			reg = <0x3c0000 0x3240000>;
+			label = "firmware";
+			#address-cells = <1>;
+			#size-cells = <1>;
+
+			partition at 0 {
+				reg = <0x0 0x800000>;
+				label = "kernel";
+			};
+
+			partition at 800000 {
+				reg = <0x800000 0x2a40000>;
+				label = "ubi";
+			};
+		};
+
+		partition at 3600000 {
+			reg = <0x3600000 0x100000>;
+			label = "Config";
+			read-only;
+		};
+
+		/* "RAS2" on stock fw */
+		partition at 3700000 {
+			reg = <0x3700000 0x3240000>;
+			label = "firmware2";
+		};
+
+		partition at 6940000 {
+			reg = <0x6940000 0x100000>;
+			label = "Config_2";
+			read-only;
+		};
+
+		partition at 6a40000 {
+			reg = <0x6a40000 0x100000>;
+			label = "persist";
+		};
+
+		partition at 6b40000 {
+			reg = <0x6b40000 0x100000>;
+			label = "mesh";
+			read-only;
+		};
+
+		partition at 6c40000 {
+			reg = <0x6c40000 0x1340000>;
+			label = "backup";
+			read-only;
+		};
+	};
+};
+
+&gmac0 {
+	nvmem-cells = <&macaddr_factory_1fdfa>;
+	nvmem-cell-names = "mac-address";
+};
+
+&gmac1 {
+	status = "okay";
+	label = "wan";
+	phy-handle = <&ethphy0>;
+
+	nvmem-cells = <&macaddr_factory_1fdf4>;
+	nvmem-cell-names = "mac-address";
+};
+
+&ethphy0 {
+	/delete-property/ interrupts;
+};
+
+&pcie {
+	status = "okay";
+};
+
+&pcie1 {
+	wifi at 0,0 {
+		compatible = "mediatek,mt76";
+		reg = <0x0000 0 0 0 0>;
+		nvmem-cells = <&eeprom_factory_0>, <&precal_factory_e10>;
+		nvmem-cell-names = "eeprom", "precal";
+		mediatek,disable-radar-background;
+	};
+};
+
+&pcie2 {
+	status = "disabled";
+};
+
+&switch0 {
+	ports {
+		port at 1 {
+			status = "okay";
+			label = "lan2";
+		};
+
+		port at 2 {
+			status = "okay";
+			label = "lan1";
+		};
+	};
+};
+
+&state_default {
+	gpio {
+		groups = "i2c", "uart3", "jtag", "wdt";
+		function = "gpio";
+	};
+};
+
+&uartlite {
+	pinctrl-0 = <&uart1_pins>;
+	pinctrl-names = "default";
+};
diff --git a/target/linux/ramips/image/mt7621.mk b/target/linux/ramips/image/mt7621.mk
index 1c6cd237d3..ff071213ef 100644
--- a/target/linux/ramips/image/mt7621.mk
+++ b/target/linux/ramips/image/mt7621.mk
@@ -1120,6 +1120,27 @@ define Device/elecom_wrc-2533gst2
 endef
 TARGET_DEVICES += elecom_wrc-2533gst2
 
+define Device/elecom_wrc-x1800gs
+  $(Device/nand)
+  DEVICE_VENDOR := ELECOM
+  DEVICE_MODEL := WRC-X1800GS
+  KERNEL := kernel-bin | lzma | \
+	fit lzma $$(KDIR)/image-$$(firstword $$(DEVICE_DTS)).dtb | \
+	znet-header 4.04(XVF.1)b90 COMC 0x68 | elecom-product-header WRC-X1800GS
+  KERNEL_INITRAMFS := kernel-bin | lzma | \
+	fit lzma $$(KDIR)/image-$$(firstword $$(DEVICE_DTS)).dtb
+  KERNEL_SIZE := 8192k
+  IMAGE_SIZE := 51456k
+ifneq ($(CONFIG_TARGET_ROOTFS_INITRAMFS),)
+  ARTIFACTS := initramfs-factory.bin
+  ARTIFACT/initramfs-factory.bin := append-image-stage initramfs-kernel.bin | \
+	znet-header 4.04(XVF.1)b90 COMC 0x68 | elecom-product-header WRC-X1800GS | \
+	check-size
+endif
+  DEVICE_PACKAGES := kmod-mt7915-firmware
+endef
+TARGET_DEVICES += elecom_wrc-x1800gs
+
 define Device/etisalat_s3
   $(Device/sercomm_dxx)
   IMAGE_SIZE := 32768k
diff --git a/target/linux/ramips/mt7621/base-files/etc/board.d/02_network b/target/linux/ramips/mt7621/base-files/etc/board.d/02_network
index 2ed8c38732..ea479ddd38 100644
--- a/target/linux/ramips/mt7621/base-files/etc/board.d/02_network
+++ b/target/linux/ramips/mt7621/base-files/etc/board.d/02_network
@@ -71,6 +71,7 @@ ramips_setup_interfaces()
 	asiarf,ap7621-nv1|\
 	beeline,smartbox-flash|\
 	beeline,smartbox-giga|\
+	elecom,wrc-x1800gs|\
 	glinet,gl-mt1300|\
 	iodata,wn-deax1800gr|\
 	iptime,a3002mesh|\
diff --git a/target/linux/ramips/mt7621/base-files/lib/upgrade/platform.sh b/target/linux/ramips/mt7621/base-files/lib/upgrade/platform.sh
index 258bb1fe96..3c8c4b36ee 100755
--- a/target/linux/ramips/mt7621/base-files/lib/upgrade/platform.sh
+++ b/target/linux/ramips/mt7621/base-files/lib/upgrade/platform.sh
@@ -131,6 +131,12 @@ platform_do_upgrade() {
 	zyxel,nwa55axe)
 		nand_do_upgrade "$1"
 		;;
+	elecom,wrc-x1800gs)
+		[ "$(fw_printenv -n bootmenu_delay)" != "0" ] || \
+			fw_setenv bootmenu_delay 3
+		iodata_mstc_set_flag "bootnum" "persist" "0x4" "1,2" "1"
+		nand_do_upgrade "$1"
+		;;
 	iodata,wn-ax1167gr2|\
 	iodata,wn-ax2033gr|\
 	iodata,wn-dx1167r|\




More information about the lede-commits mailing list