ramips: add support for ELECOM WRC-X1800GS
authorINAGAKI Hiroshi <musashino.open@gmail.com>
Sat, 11 May 2024 06:35:50 +0000 (15:35 +0900)
committerHauke Mehrtens <hauke@hauke-m.de>
Sat, 25 May 2024 17:33:28 +0000 (19:33 +0200)
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@gmail.com>
target/linux/ramips/dts/mt7621_elecom_wrc-x1800gs.dts [new file with mode: 0644]
target/linux/ramips/image/mt7621.mk
target/linux/ramips/mt7621/base-files/etc/board.d/02_network
target/linux/ramips/mt7621/base-files/lib/upgrade/platform.sh

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 (file)
index 0000000..c0bb5e4
--- /dev/null
@@ -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@0 {
+                       reg = <0x0 0x100000>;
+                       label = "u-boot";
+                       read-only;
+               };
+
+               partition@100000 {
+                       reg = <0x100000 0x100000>;
+                       label = "u-boot-env";
+               };
+
+               partition@200000 {
+                       reg = <0x200000 0x1c0000>;
+                       label = "factory";
+                       read-only;
+
+                       nvmem-layout {
+                               compatible = "fixed-layout";
+                               #address-cells = <1>;
+                               #size-cells = <1>;
+
+                               eeprom_factory_0: eeprom@0 {
+                                       reg = <0x0 0xe00>;
+                               };
+
+                               precal_factory_e10: precal@e10 {
+                                       reg = <0xe10 0x19c10>;
+                               };
+
+                               macaddr_factory_1fdf4: macaddr@1fdf4 {
+                                       reg = <0x1fdf4 0x6>;
+                               };
+
+                               macaddr_factory_1fdfa: macaddr@1fdfa {
+                                       reg = <0x1fdfa 0x6>;
+                               };
+                       };
+               };
+
+               /* "RAS1" on stock fw */
+               partition@3c0000 {
+                       compatible = "fixed-partitions";
+                       reg = <0x3c0000 0x3240000>;
+                       label = "firmware";
+                       #address-cells = <1>;
+                       #size-cells = <1>;
+
+                       partition@0 {
+                               reg = <0x0 0x800000>;
+                               label = "kernel";
+                       };
+
+                       partition@800000 {
+                               reg = <0x800000 0x2a40000>;
+                               label = "ubi";
+                       };
+               };
+
+               partition@3600000 {
+                       reg = <0x3600000 0x100000>;
+                       label = "Config";
+                       read-only;
+               };
+
+               /* "RAS2" on stock fw */
+               partition@3700000 {
+                       reg = <0x3700000 0x3240000>;
+                       label = "firmware2";
+               };
+
+               partition@6940000 {
+                       reg = <0x6940000 0x100000>;
+                       label = "Config_2";
+                       read-only;
+               };
+
+               partition@6a40000 {
+                       reg = <0x6a40000 0x100000>;
+                       label = "persist";
+               };
+
+               partition@6b40000 {
+                       reg = <0x6b40000 0x100000>;
+                       label = "mesh";
+                       read-only;
+               };
+
+               partition@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@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@1 {
+                       status = "okay";
+                       label = "lan2";
+               };
+
+               port@2 {
+                       status = "okay";
+                       label = "lan1";
+               };
+       };
+};
+
+&state_default {
+       gpio {
+               groups = "i2c", "uart3", "jtag", "wdt";
+               function = "gpio";
+       };
+};
+
+&uartlite {
+       pinctrl-0 = <&uart1_pins>;
+       pinctrl-names = "default";
+};
index 1c6cd237d302906e75c2382564560587620bee46..ff071213efa90f1192e74c12f8c30489aefe63e0 100644 (file)
@@ -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
index 2ed8c387322b972946e7e95b69aee4b2c90b9724..ea479ddd38be7eebf9181e27e0f120ea14009385 100644 (file)
@@ -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|\
index 258bb1fe96e114768282ed25e2b84ab969fd4ffe..3c8c4b36eef6e65946503ea9714dbc04b039be73 100755 (executable)
@@ -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|\