airoha: add support for Gemtek XR1710G

Gemtek XR1710G, sold by Brightspeed, is an AN7581 Wi-Fi 7 gateway.
It is a close relative of the Gemtek W1700K: the Silabs
Bluetooth/Zigbee radio and the Airoha GPS are gone, and the LEDs of
the two 1 GbE ports are driven by the internal switch PHYs instead of
GPIOs. The device tree shares an7581-gemtek-common.dtsi with
the W1700K and only adds these LEDs and the label MAC.

Specification:

- SoC       : Airoha AN7581GT, 4x Cortex-A53
- RAM       : 2 GiB DDR4-2666 (ESMT M16U8G16512A)
- Flash     : 512 MiB SPI-NAND (Winbond W25N04KV)
- WLAN      : MediaTek MT7996 (BE19000) on PCIe
  - 2.4 GHz : 4x4, MT7976GN
  - 5 GHz   : 4x4, MT7977BN
  - 6 GHz   : 4x4, MT7977AN
- Ethernet  : 2x 10 GbE (Realtek RTL8261BE, wan and lan2),
              2x 1 GbE (AN7581 internal switch, lan3 and lan4)
- LEDs      : 1x status, red/green/blue/white (GPIO),
              2x2 lan3/lan4 green/amber (switch PHY)
- Button    : reset
- Fan       : PWM controlled by a Nuvoton NCT7802 on I2C
- UART      : 5-pin header next to the case screw, 115200n8
  - pinout  : TX, GND, VCC, N/C, RX, starting at the screw
- Power     : 12 VDC, 5 A, barrel jack, center positive
- Bootloader: U-Boot 2014.04-rc1 "AXON 1.6", signed, vendor BMT/BBT

The vendor bootloader verifies the image it boots by default and uses
Airoha BMT/BBT for bad block management, which Linux does not know
about. As on the W1700K, a U-Boot chainloader is therefore placed into
the "chainloader" partition (the start of the first vendor firmware
bank), which the vendor bootloader writes and loads, and everything
else lives in UBI, which handles bad blocks itself. The vendor
bootloader and its 66 MiB BMT pool at the end of flash are left alone.

The factory UBI volume holds the MT7996 EEPROM and the MAC addresses.
All of it comes from the vendor partition, which OpenWrt never writes:
the DSD block at 0x400000 holds the MACs, fan_id and the serial number
as text, the EEPROM is in the first good block from 0x405000. When the
volume is missing or holds no valid EEPROM and MACs, as on a new
install, sysupgrade builds it from there before writing the firmware.
The serial number has to match the board, and nothing is written when
the vendor data does not look right.

Installation (via serial console):

1. Open the case: there is a Torx T10 screw under the QR code label,
   then pry the grey and white halves apart starting at the ports.
2. Connect to the UART header and interrupt the vendor bootloader with
   any key.
3. Make the vendor bootloader boot the chainloader from flash, write
   the chainloader with TFTP (server 192.168.1.254), and erase the rest
   of the stock firmware. The vendor Ethernet driver is flaky, the
   tftpboot may need a few attempts:

     setenv serverip 192.168.1.254
     setenv ipaddr 192.168.1.1
     tftpboot 0x89000000 openwrt-airoha-an7581-gemtek_xr1710g-ubi-chainload-uboot.itb
     setenv one flash read 0x600000 0x100000 \$loadaddr
     setenv two "; bootm"
     setenv bootcmd "$one$two"
     saveenv
     flash erase 0x600000 0x100000
     flash write 0x600000 0x100000 0x89000000
     flash erase 0x700000 0x1b700000
     reset

   The last erase matters: the stock firmware keeps its own UBI in this
   area, which the chainloader would otherwise attach and keep.

   If tftpboot keeps failing, load the chainloader over the serial
   console instead: run "loady 0x89000000" in place of the tftpboot,
   send the file with YMODEM (about 30 s at 115200 baud), then go on
   with the setenv commands.

4. The chainloader creates UBI in the erased ubi partition with the
   ubootenv, ubootenv2 and an empty factory volume, and saves its
   environment. With nothing to boot, it lights the blue LED and loads
   openwrt-airoha-an7581-gemtek_xr1710g-ubi-initramfs-recovery.itb via
   TFTP from 192.168.1.254 until a server answers.
5. In the recovery system (192.168.1.1), copy over the sysupgrade.itb
   image and run sysupgrade. It fills the factory volume with the Wi-Fi
   calibration data and the MAC addresses from the vendor partition and
   installs OpenWrt. The recovery volume is optional; without it, the
   chainloader falls back to TFTP when the system does not boot.
6. Further updates use the sysupgrade.itb image.

Reverting to the stock firmware is not documented: the stock firmware
needs an ISP account to be useful.

MAC addresses ("factory" UBI volume):

- WAN     : 0x5000           xx:xx:xx:xx:xx:xx
- LAN     : 0x6000           xx:xx:xx:xx:xx:xx
- 2.4 GHz : 0x6000 + 1
- 5 GHz   : 0x6000 + 2
- 6 GHz   : 0x6000 + 3

Known issues:

- The 10 GbE ports (wan and lan2) may come up without link or lose
  link: the AN7581 USXGMII PCS sometimes fails RX calibration ("No
  FBCK Lock") with the RTL8261BE. The PCS and PHY fixes are being
  worked on separately.

Based on the XR1710G support by Kenneth Kasilag (openwrt/openwrt#22397).

Assisted-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Andrey Korshunov <razor1702@gmail.com>
Link: https://github.com/openwrt/openwrt/pull/26296
Signed-off-by: Robert Marko <robimarko@gmail.com>
This commit is contained in:
Andrey Korshunov authored and Robert Marko committed 2026-11-24 11:00:54 +01:00
1 parent b8d878f0b6
commit 980a7404d7
8 files changed
+225 -8

No files matched your search

+1 -1
View File
@@ -2,7 +2,7 @@ include $(TOPDIR)/rules.mk
PKG_DISTNAME:=u-boot
PKG_VERSION:=2026.10
PKG_RELEASE:=3
PKG_RELEASE:=4
PKG_SOURCE:=$(PKG_DISTNAME)-$(PKG_VERSION).tar.bz2
PKG_SOURCE_URL:= \
@@ -13,6 +13,7 @@ board=$(board_name)
case "$board" in
gemtek,w1700k-ubi|\
gemtek,xr1710g-ubi|\
nokia,xg-040g-md-ubi)
ubootenv_add_ubi_default
;;
@@ -23,6 +23,12 @@ gemtek,w1700k-ubi)
ucidef_set_led_netdev "lan4-yellow" "lan4" "yellow:lan-4" "lan4" "link_10 link_100"
ucidef_set_led_netdev "lan4-green" "lan4" "green:lan-4" "lan4" "link_1000 tx rx"
;;
gemtek,xr1710g-ubi)
ucidef_set_led_netdev "lan3-amber" "lan3" "mt7530-0:09:amber:lan-3" "lan3" "link_10 link_100"
ucidef_set_led_netdev "lan3-green" "lan3" "mt7530-0:09:green:lan-3" "lan3" "link_1000 tx rx"
ucidef_set_led_netdev "lan4-amber" "lan4" "mt7530-0:0a:amber:lan-4" "lan4" "link_10 link_100"
ucidef_set_led_netdev "lan4-green" "lan4" "mt7530-0:0a:green:lan-4" "lan4" "link_1000 tx rx"
;;
nokia,xg-040g-md|\
nokia,xg-040g-md-ubi)
ucidef_set_led_netdev "lan2" "lan2" "mt7530-0:0a:green:lan-2" "lan2" "link tx rx"
@@ -14,7 +14,8 @@ an7581_setup_interfaces()
airoha,an7581-evb)
ucidef_set_interfaces_lan_wan "lan1 lan2 lan3 lan4" "eth1"
;;
gemtek,w1700k-ubi)
gemtek,w1700k-ubi|\
gemtek,xr1710g-ubi)
ucidef_set_interfaces_lan_wan "lan2 lan3 lan4" "wan"
;;
nokia,valyrian)
@@ -21,7 +21,8 @@ find_nct7802()
boot()
{
case $(board_name) in
gemtek,w1700k-ubi)
gemtek,w1700k-ubi|\
gemtek,xr1710g-ubi)
hwmon=$(find_nct7802)
# Temporarily disable automatic fan control to configure curve
@@ -1,7 +1,94 @@
RAMFS_COPY_BIN='fitblk fit_check_sign'
RAMFS_COPY_BIN='fitblk fit_check_sign tr'
REQUIRE_IMAGE_METADATA=1
gemtek_factory_valid() {
local vol="$1"
local off mac
[ "$(hexdump -v -n 2 -e '2/1 "%02x"' "$vol")" = "9079" ] || return 1
for off in 0x5000 0x6000; do
mac="$(hexdump -v -s $((off)) -n 6 -e '6/1 "%02x"' "$vol")"
case "$mac" in
000000000000|ffffffffffff|?[13579bdf]*)
return 1
;;
esac
done
}
gemtek_mac_bytes() {
printf "$(echo "$1" | sed 's/^/\\x/;s/:/\\x/g')"
}
# The factory volume (MT7996 EEPROM and the MAC addresses) is built from the
# vendor partition, which the install leaves untouched. Rebuild it when it is
# missing or empty, as after the chainloader formatted the ubi partition.
gemtek_prepare_factory() {
local ubidev vol mtd dsd ebs off eeprom wan lan fan serial mac
local blob="/tmp/factory.bin"
ubidev="$(nand_find_ubi ubi)" || return 0
vol="$(nand_find_volume "$ubidev" factory)"
[ -n "$vol" ] && gemtek_factory_valid "/dev/$vol" && return 0
mtd="$(find_mtd_index vendor)"
[ -n "$mtd" ] || return 0
mtd="/dev/mtd$mtd"
dsd="$(dd if="$mtd" bs=4096 skip=$((0x400000 / 4096)) count=1 2>/dev/null | tr -c ' -~' '\n')"
wan="$(echo "$dsd" | sed -n '/^wan_mac=/{s///p;q}')"
lan="$(echo "$dsd" | sed -n '/^lan_mac=/{s///p;q}')"
fan="$(echo "$dsd" | sed -n '/^fan_id=/{s///p;q}')"
serial="$(echo "$dsd" | sed -n '/^serial_number=/{s///p;q}')"
case "$serial" in
XR1710G*) ;;
*)
v "factory: serial number '$serial' does not match, not rebuilding"
return 0
;;
esac
for mac in "$wan" "$lan"; do
echo "$mac" | grep -qE '^[0-9A-Fa-f]{2}(:[0-9A-Fa-f]{2}){5}$' || {
v "factory: invalid MAC '$mac' in the vendor partition, not rebuilding"
return 0
}
done
# The EEPROM is in the first good block from 0x405000.
ebs="$(cat /sys/class/mtd/${mtd#/dev/}/erasesize)"
for off in 0 1 2 3; do
off=$((0x405000 + off * ebs))
[ "$(hexdump -v -s "$off" -n 2 -e '2/1 "%02x"' "$mtd")" = "9079" ] && {
eeprom="$off"
break
}
done
[ -n "$eeprom" ] || {
v "factory: no EEPROM in the vendor partition, not rebuilding"
return 0
}
dd if=/dev/zero of="$blob" bs=4096 count=16 2>/dev/null
dd if="$mtd" bs=512 skip=$((eeprom / 512)) count=15 2>/dev/null | \
dd of="$blob" conv=notrunc 2>/dev/null
gemtek_mac_bytes "$wan" | dd of="$blob" bs=4096 seek=5 conv=notrunc 2>/dev/null
gemtek_mac_bytes "$lan" | dd of="$blob" bs=4096 seek=6 conv=notrunc 2>/dev/null
printf '%s' "$fan" | dd of="$blob" bs=4096 seek=7 conv=notrunc 2>/dev/null
printf '%s' "$serial" | dd of="$blob" bs=4096 seek=8 conv=notrunc 2>/dev/null
[ -n "$vol" ] || {
ubimkvol "/dev/$ubidev" -N factory -t static -s $((0x10000)) && \
vol="$(nand_find_volume "$ubidev" factory)"
}
[ -n "$vol" ] && ubiupdatevol "/dev/$vol" "$blob" && \
v "factory: rebuilt from the vendor partition (WAN $wan, LAN $lan)"
rm -f "$blob"
}
nokia_initial_setup()
{
[ "$(rootfs_type)" = "tmpfs" ] || return 0
@@ -15,15 +102,16 @@ platform_check_image() {
[ "$#" -gt 1 ] && return 1
case "$board" in
nokia,xg-040g-md)
nand_do_platform_check "$board" "$1"
return $?
;;
gemtek,xr1710g-ubi|\
nokia,xg-040g-md-ubi|\
quantum,q1000k-ubi)
fit_check_image "$1"
return $?
;;
nokia,xg-040g-md)
nand_do_platform_check "$board" "$1"
return $?
;;
esac
return 0
@@ -38,6 +126,10 @@ platform_do_upgrade() {
quantum,q1000k-ubi)
fit_do_upgrade "$1"
;;
gemtek,xr1710g-ubi)
gemtek_prepare_factory
fit_do_upgrade "$1"
;;
*)
nand_do_upgrade "$1"
;;
@@ -0,0 +1,87 @@
// SPDX-License-Identifier: GPL-2.0-or-later OR MIT
/dts-v1/;
#include "an7581-gemtek-common.dtsi"
/ {
model = "Gemtek XR1710G (UBI)";
compatible = "gemtek,xr1710g-ubi", "airoha,an7581", "airoha,en7581";
aliases {
label-mac-device = &gdm2;
};
};
&en7581_pinctrl {
/* The lan3/lan4 LEDs are driven by the internal switch PHYs */
gswp1_led0_pins: gswp1-led0-pins {
mux {
function = "phy1_led0";
pins = "gpio33";
};
};
gswp1_led1_pins: gswp1-led1-pins {
mux {
function = "phy1_led1";
pins = "gpio43";
};
};
gswp2_led0_pins: gswp2-led0-pins {
mux {
function = "phy2_led0";
pins = "gpio34";
};
};
gswp2_led1_pins: gswp2-led1-pins {
mux {
function = "phy2_led1";
pins = "gpio44";
};
};
};
&gsw_phy1 {
pinctrl-names = "gbe-led";
pinctrl-0 = <&gswp1_led0_pins>, <&gswp1_led1_pins>;
};
&gsw_phy1_led0 {
status = "okay";
color = <LED_COLOR_ID_GREEN>;
function = LED_FUNCTION_LAN;
function-enumerator = <3>;
active-low;
};
&gsw_phy1_led1 {
status = "okay";
color = <LED_COLOR_ID_AMBER>;
function = LED_FUNCTION_LAN;
function-enumerator = <3>;
active-low;
};
&gsw_phy2 {
pinctrl-names = "gbe-led";
pinctrl-0 = <&gswp2_led0_pins>, <&gswp2_led1_pins>;
};
&gsw_phy2_led0 {
status = "okay";
color = <LED_COLOR_ID_GREEN>;
function = LED_FUNCTION_LAN;
function-enumerator = <4>;
active-low;
};
&gsw_phy2_led1 {
status = "okay";
color = <LED_COLOR_ID_AMBER>;
function = LED_FUNCTION_LAN;
function-enumerator = <4>;
active-low;
};
+29
View File
@@ -106,6 +106,35 @@ define Device/gemtek_w1700k-ubi
endef
TARGET_DEVICES += gemtek_w1700k-ubi
define Device/gemtek_xr1710g-ubi
DEVICE_VENDOR := Gemtek
DEVICE_MODEL := XR1710G
DEVICE_VARIANT := (UBI)
DEVICE_ALT0_VENDOR := Brightspeed
DEVICE_ALT0_MODEL := XR1710G
DEVICE_ALT0_VARIANT := (UBI)
DEVICE_DTS := an7581-gemtek_xr1710g-ubi
DEVICE_PACKAGES := airoha-en7581-mt7996-npu-firmware fitblk \
kmod-hwmon-nct7802 kmod-mt7996-firmware wpad-basic-mbedtls \
rtl826x-firmware
UBINIZE_OPTS := -E 5
BLOCKSIZE := 128k
PAGESIZE := 2048
UBOOTENV_IN_UBI := 1
KERNEL_IN_UBI := 1
KERNEL := kernel-bin | gzip
KERNEL_INITRAMFS := kernel-bin | lzma | \
fit lzma $$(KDIR)/image-$$(firstword $$(DEVICE_DTS)).dtb with-initrd | pad-to 128k
KERNEL_INITRAMFS_SUFFIX := -recovery.itb
IMAGES := sysupgrade.itb
IMAGE/sysupgrade.itb := append-kernel | \
fit gzip $$(KDIR)/image-$$(firstword $$(DEVICE_DTS)).dtb external-static-with-rootfs | append-metadata
ARTIFACTS := chainload-uboot.itb
ARTIFACT/chainload-uboot.itb := an7581-chainloader gemtek_xr1710g
SOC := an7581
endef
TARGET_DEVICES += gemtek_xr1710g-ubi
define Device/nokia_valyrian
DEVICE_VENDOR := Nokia
DEVICE_MODEL := Valyrian