From: Jascha Sundaresan Date: Thu, 18 Sep 2025 18:32:41 +0000 (+0400) Subject: filogic: add support for Netgear EAX17 X-Git-Url: http://git.openwrt.org/?a=commitdiff_plain;h=46ab9f3f1c0e6ac2a17efa5a3f34e466a0c2d4e0;p=openwrt%2Fstaging%2Fxback.git filogic: add support for Netgear EAX17 Hardware -------- SOC: MediaTek MT7981 RAM: 512MB DDR4 FLASH: 128MB SPI-NAND WIFI: Mediatek MT7915 (integrated) 2x2 802.11ax 2.4 / 5 GHz ETH: Mediatek MT7981 internal 1 GbE PHY UART: 3V3 115200 8N1 (Pinout silkscreened / Do not connect VCC) Installation ------------ 1. Download the OpenWrt initramfs image. Copy the image to a TFTP server 2. Connect the TFTP server to the EAX17. Conect to the serial console, interrupt the autoboot process by pressing '0' when prompted. 3. Download & Boot the OpenWrt initramfs image. $ tftpboot openwrt.bin $ bootm 4. Wait for OpenWrt to boot. Transfer the sysupgrade image to the device using scp and install using sysupgrade. $ sysupgrade -n Signed-off-by: Jascha Sundaresan Link: https://github.com/openwrt/openwrt/pull/20354 Signed-off-by: Hauke Mehrtens --- diff --git a/include/image-commands.mk b/include/image-commands.mk index a9a3d13241..feeeb5b074 100644 --- a/include/image-commands.mk +++ b/include/image-commands.mk @@ -430,7 +430,7 @@ define Build/initrd_compression $(if $(CONFIG_TARGET_INITRAMFS_COMPRESSION_ZSTD),.zstd) endef -define Build/fit +define Build/fit-its $(if $(findstring with-rootfs,$(word 3,$(1))), \ $(call locked,dd if=$(IMAGE_ROOTFS) of=$(IMAGE_ROOTFS).pagesync bs=4096 conv=sync, \ gen-cpio$(if $(TARGET_PER_DEVICE_ROOTFS),.$(ROOTFS_ID/$(DEVICE_NAME))))) @@ -452,12 +452,20 @@ define Build/fit $(if $(DEVICE_DTS_OVERLAY),$(foreach dtso,$(DEVICE_DTS_OVERLAY), -O $(dtso):$(KERNEL_BUILD_DIR)/image-$(dtso).dtbo)) \ -c $(if $(DEVICE_DTS_CONFIG),$(DEVICE_DTS_CONFIG),"config-1") \ -A $(LINUX_KARCH) -v $(LINUX_VERSION) +endef + +define Build/fit-image $(call locked,PATH=$(LINUX_DIR)/scripts/dtc:$(PATH) mkimage $(if $(findstring external,$(word 3,$(1))),\ -E -B 0x1000 $(if $(findstring static,$(word 3,$(1))),-p 0x1000)) -f $@.its $@.new, \ gen-cpio$(if $(TARGET_PER_DEVICE_ROOTFS),.$(ROOTFS_ID/$(DEVICE_NAME)))) @mv $@.new $@ endef +define Build/fit + $(call Build/fit-its,$(1)) + $(call Build/fit-image,$(1)) +endef + define Build/libdeflate-gzip $(STAGING_DIR_HOST)/bin/libdeflate-gzip -f -12 -c $@ $(1) > $@.new @mv $@.new $@ diff --git a/scripts/gen_netgear_rootfs_node.sh b/scripts/gen_netgear_rootfs_node.sh new file mode 100755 index 0000000000..b9e6b6b58d --- /dev/null +++ b/scripts/gen_netgear_rootfs_node.sh @@ -0,0 +1,39 @@ +#!/bin/sh +# +# SPDX-License-Identifier: GPL-2.0-or-later +# +# Author: Jascha Sundaresan +# +# This helper script generates a top-level 'rootfs' node for inclusion +# in a Flattened Image Tree (FIT) source (.its) file. The node includes +# the size and SHA1 hash of a given root filesystem image and is used by +# certain Netgear devices which expect this metadata at the top level of +# the FIT structure. +# +# The resulting block is written to standard output and can be appended +# or inserted into an existing .its file by the OpenWrt build system. +# Example: +# scripts/gen_netgear_rootfs_node.sh build_dir/.../root.squashfs > node.txt +# +# See also: scripts/mkits.sh, which generates the main FIT .its source. + +ROOTFS_FILE="$1" +ROOTFS_SIZE=$(stat -c %s "${ROOTFS_FILE}") +ROOTFS_SHA1=$( + sha1sum "${ROOTFS_FILE}" | awk '{ print "<0x" substr($0, 1, 8) \ + " 0x" substr($0, 9, 8) \ + " 0x" substr($0, 17, 8) \ + " 0x" substr($0, 25, 8) \ + " 0x" substr($0, 33, 8) ">" }' +) +cat <; + + hash-1 { + value = ${ROOTFS_SHA1}; + algo = "sha1"; + }; +}; + +EOF diff --git a/target/linux/generic/backport-6.12/010-v6.19-nvmem-layouts-u-boot-env-add-optional-env-size-property.patch b/target/linux/generic/backport-6.12/010-v6.19-nvmem-layouts-u-boot-env-add-optional-env-size-property.patch new file mode 100644 index 0000000000..207161a40d --- /dev/null +++ b/target/linux/generic/backport-6.12/010-v6.19-nvmem-layouts-u-boot-env-add-optional-env-size-property.patch @@ -0,0 +1,62 @@ +From 06e92afca89075628b12c9b4085b4cc7320081ac Mon Sep 17 00:00:00 2001 +From: Jascha Sundaresan +Date: Thu, 23 Oct 2025 03:07:41 +0400 +Subject: nvmem: layouts: u-boot-env: add optional "env-size" property + +Some devices reserve a larger NVMEM region for the U-Boot environment +than the actual environment data length used by U-Boot itself. The CRC32 +in the U-Boot header is calculated over the smaller data length, causing +CRC validation to fail when Linux reads the full partition. + +Allow an optional device tree property "env-size" to specify the +environment data size to use for CRC computation. + +v2: add missing $ref line to DT binding + +Signed-off-by: Jascha Sundaresan +Reviewed-by: Rob Herring (Arm) +Signed-off-by: Srinivas Kandagatla +--- + Documentation/devicetree/bindings/nvmem/layouts/u-boot,env.yaml | 7 +++++++ + drivers/nvmem/layouts/u-boot-env.c | 4 +++- + 2 files changed, 10 insertions(+), 1 deletion(-) + +--- a/Documentation/devicetree/bindings/nvmem/layouts/u-boot,env.yaml ++++ b/Documentation/devicetree/bindings/nvmem/layouts/u-boot,env.yaml +@@ -46,6 +46,12 @@ properties: + type: object + description: Command to use for automatic booting + ++ env-size: ++ description: ++ Size in bytes of the environment data used by U-Boot for CRC ++ calculation. If omitted, the full NVMEM region size is used. ++ $ref: /schemas/types.yaml#/definitions/uint32 ++ + ethaddr: + type: object + description: Ethernet interfaces base MAC address. +@@ -104,6 +110,7 @@ examples: + + partition-u-boot-env { + compatible = "brcm,env"; ++ env-size = <0x20000>; + + ethaddr { + }; +--- a/drivers/nvmem/layouts/u-boot-env.c ++++ b/drivers/nvmem/layouts/u-boot-env.c +@@ -99,10 +99,12 @@ int u_boot_env_parse(struct device *dev, + uint32_t crc32; + uint32_t calc; + uint8_t *buf; ++ u32 env_size; + int bytes; + int err; + +- dev_size = nvmem_dev_size(nvmem); ++ dev_size = device_property_read_u32(dev, "env-size", &env_size) ? ++ nvmem_dev_size(nvmem) : (size_t)env_size; + + buf = kzalloc(dev_size, GFP_KERNEL); + if (!buf) { diff --git a/target/linux/mediatek/dts/mt7981b-netgear-eax17.dts b/target/linux/mediatek/dts/mt7981b-netgear-eax17.dts new file mode 100644 index 0000000000..a478d53ea7 --- /dev/null +++ b/target/linux/mediatek/dts/mt7981b-netgear-eax17.dts @@ -0,0 +1,272 @@ +// SPDX-License-Identifier: (GPL-2.0 OR MIT) + +/dts-v1/; +#include "mt7981b.dtsi" + +/ { + model = "Netgear EAX17"; + compatible = "netgear,eax17", "mediatek,mt7981-spim-snand-rfb"; + + aliases { + led-boot = &led_power_green; + led-failsafe = &led_power_red; + led-running = &led_power_green; + led-upgrade = &led_power_red; + serial0 = &uart0; + }; + + chosen { + stdout-path = "serial0:115200n8"; + }; + + memory@40000000 { + reg = <0 0x40000000 0 0x20000000>; + device_type = "memory"; + }; + + gpio-keys { + compatible = "gpio-keys"; + + reset { + label = "reset"; + linux,code = ; + gpios = <&pio 1 GPIO_ACTIVE_LOW>; + }; + + wps { + label = "wps"; + linux,code = ; + gpios = <&pio 0 GPIO_ACTIVE_LOW>; + }; + }; + + gpio-leds { + compatible = "gpio-leds"; + + led_power_green: power_green { + color = ; + function = LED_FUNCTION_POWER; + gpios = <&pio 9 GPIO_ACTIVE_LOW>; + }; + + led_power_red: power_red { + color = ; + function = LED_FUNCTION_POWER; + gpios = <&pio 12 GPIO_ACTIVE_LOW>; + }; + + led_rlink_red: rlink_red { + color = ; + function = LED_FUNCTION_LAN; + gpios = <&pio 6 GPIO_ACTIVE_LOW>; + }; + + led_rlink_green: rlink_green { + color = ; + function = LED_FUNCTION_LAN; + gpios = <&pio 7 GPIO_ACTIVE_LOW>; + }; + + led_clink_red: clink_red { + color = ; + function = LED_FUNCTION_WAN; + gpios = <&pio 10 GPIO_ACTIVE_LOW>; + }; + + led_clink_green: clink_green { + color = ; + function = LED_FUNCTION_WAN; + gpios = <&pio 11 GPIO_ACTIVE_LOW>; + }; + + led_wps_green: wps_green { + color = ; + function = LED_FUNCTION_WPS; + gpios = <&pio 5 GPIO_ACTIVE_LOW>; + }; + + led_lan_speed_fast: lan_speed_fast { + color = ; + function = LED_FUNCTION_STATUS; + gpios = <&pio 13 GPIO_ACTIVE_LOW>; + }; + + led_lan_speed_slow: lan_speed_slow { + color = ; + function = LED_FUNCTION_STATUS; + gpios = <&pio 8 GPIO_ACTIVE_LOW>; + }; + + }; + +}; + +ð { + status = "okay"; + + gmac0: mac@0 { + status = "disabled"; + }; + + gmac1: mac@1 { + compatible = "mediatek,eth-mac"; + reg = <1>; + phy-mode = "gmii"; + phy-handle = <&int_gbe_phy>; + + nvmem-cells = <ðaddr 0>; + nvmem-cell-names = "mac-address"; + }; +}; + +&crypto { + status = "okay"; +}; + +&pio { + spi_flash_pins: spi0-pins { + mux { + function = "spi"; + groups = "spi0", "spi0_wp_hold"; + }; + + conf-pu { + pins = "SPI0_CS", "SPI0_HOLD", "SPI0_WP"; + drive-strength = ; + bias-pull-up = ; + }; + + conf-pd { + pins = "SPI0_CLK", "SPI0_MOSI", "SPI0_MISO"; + drive-strength = ; + bias-pull-down = ; + }; + }; +}; + +&spi0 { + pinctrl-names = "default"; + pinctrl-0 = <&spi_flash_pins>; + status = "okay"; + + spi_nand_flash: flash@0 { + #address-cells = <1>; + #size-cells = <1>; + compatible = "spi-nand"; + reg = <0>; + + spi-max-frequency = <52000000>; + spi-tx-bus-width = <4>; + spi-rx-bus-width = <4>; + + partitions { + #address-cells = <1>; + #size-cells = <1>; + compatible = "fixed-partitions"; + + partition@0 { + label = "bl2"; + reg = <0x0 0x100000>; + read-only; + }; + + partition@100000 { + label = "u-boot-env"; + reg = <0x0100000 0x0080000>; + }; + + factory: partition@180000 { + label = "factory"; + reg = <0x180000 0x200000>; + compatible = "nvmem-cells"; + #address-cells = <1>; + #size-cells = <1>; + + eeprom_factory_0: eeprom@0 { + reg = <0x0 0x1000>; + }; + }; + + partition@380000 { + label = "fip"; + reg = <0x380000 0x0200000>; + }; + + partition@580000 { + label = "ubi"; + reg = <0x580000 0x5000000>; + compatible = "linux,ubi"; + + volumes { + ubi-volume-u-boot-env { + volname = "u-boot-env"; + + nvmem-layout { + compatible = "u-boot,env"; + env-size = <0x80000>; + + ethaddr: ethaddr { + #nvmem-cell-cells = <1>; + }; + }; + }; + }; + }; + + partition@5580000 { + label = "facenv"; + reg = <0x5580000 0x200000>; + }; + + partition@5780000 { + label = "rae"; + reg = <0x5780000 0x600000>; + }; + + partition@5D80000 { + label = "pot"; + reg = <0x5D80000 0x020000>; + }; + + partition@5DA0000 { + label = "log"; + reg = <0x5DA0000 0x040000>; + }; + + }; + }; +}; + +&xhci { + status = "disabled"; +}; + +&uart0 { + status = "okay"; +}; + +&watchdog { + status = "okay"; +}; + +&wifi { + status = "okay"; + nvmem-cells = <&eeprom_factory_0>; + nvmem-cell-names = "eeprom"; + + band@0 { + reg = <0>; + nvmem-cells = <ðaddr 2>; + nvmem-cell-names = "mac-address"; + }; + + band@1 { + reg = <1>; + nvmem-cells = <ðaddr 3>; + nvmem-cell-names = "mac-address"; + }; +}; + +&pcie { + status = "disabled"; +}; diff --git a/target/linux/mediatek/filogic/base-files/etc/board.d/01_leds b/target/linux/mediatek/filogic/base-files/etc/board.d/01_leds index 7afd9927bd..20a53671e7 100644 --- a/target/linux/mediatek/filogic/base-files/etc/board.d/01_leds +++ b/target/linux/mediatek/filogic/base-files/etc/board.d/01_leds @@ -122,6 +122,17 @@ netcore,n60-pro) ucidef_set_led_netdev "wanact" "WANACT" "mdio-bus:06:green:wan" "eth1" "tx rx" ucidef_set_led_netdev "wanlink" "WANLINK" "blue:wan" "eth1" "link" ;; +netgear,eax17) + ucidef_set_led_default power_green "Power (green)" green:power 1 + ucidef_set_led_default power_red "Power (red)" red:power 0 + ucidef_set_led_default rlink_red "Client (red)" red:lan 0 + ucidef_set_led_default clink_red "Router (red)" red:wan 0 + ucidef_set_led_wps wps_green "WPS (green)" green:wps + ucidef_set_led_netdev lan_speed_fast "LAN Link (green)" green:status eth0 + uci -q set system.lan_speed_fast.mode='link' + ucidef_set_led_netdev lan_speed_slow "LAN Activity (yellow)" yellow:status eth0 + uci -q set system.lan_speed_slow.mode='tx rx' + ;; netgear,wax220) ucidef_set_led_netdev "eth0" "LAN" "green:lan" "eth0" ;; diff --git a/target/linux/mediatek/filogic/base-files/etc/board.d/02_network b/target/linux/mediatek/filogic/base-files/etc/board.d/02_network index d9388bd756..54a68bf57f 100644 --- a/target/linux/mediatek/filogic/base-files/etc/board.d/02_network +++ b/target/linux/mediatek/filogic/base-files/etc/board.d/02_network @@ -106,6 +106,7 @@ mediatek_setup_interfaces() cudy,ap3000outdoor-v1|\ cudy,ap3000-v1|\ cudy,re3000-v1|\ + netgear,eax17|\ netgear,wax220|\ openfi,6c|\ ubnt,unifi-6-plus|\ diff --git a/target/linux/mediatek/filogic/base-files/lib/upgrade/platform.sh b/target/linux/mediatek/filogic/base-files/lib/upgrade/platform.sh index 498cee3fe3..3d9307249d 100755 --- a/target/linux/mediatek/filogic/base-files/lib/upgrade/platform.sh +++ b/target/linux/mediatek/filogic/base-files/lib/upgrade/platform.sh @@ -189,6 +189,17 @@ platform_do_upgrade() { CI_UBIPART="ubi0" nand_do_upgrade "$1" ;; + netgear,eax17) + echo "UPGRADING SECOND SLOT" + CI_KERNPART="kernel2" + CI_ROOTPART="rootfs2" + nand_do_flash_file "$1" || nand_do_upgrade_failed + echo "UPGRADING PRIMARY SLOT" + CI_KERNPART="kernel" + CI_ROOTPART="rootfs" + nand_do_flash_file "$1" || nand_do_upgrade_failed + nand_do_upgrade_success + ;; tplink,fr365-v1) CI_UBIPART="ubi" CI_KERNPART="kernel" diff --git a/target/linux/mediatek/filogic/config-6.12 b/target/linux/mediatek/filogic/config-6.12 index 45e8617f0d..9928fb3090 100644 --- a/target/linux/mediatek/filogic/config-6.12 +++ b/target/linux/mediatek/filogic/config-6.12 @@ -337,8 +337,10 @@ CONFIG_NVMEM_AN8855_EFUSE=y CONFIG_NVMEM_BLOCK=y CONFIG_NVMEM_LAYOUTS=y CONFIG_NVMEM_LAYOUT_ADTRAN=y +CONFIG_NVMEM_LAYOUT_U_BOOT_ENV=y CONFIG_NVMEM_MTK_EFUSE=y CONFIG_NVMEM_SYSFS=y +CONFIG_NVMEM_U_BOOT_ENV=y CONFIG_OF=y CONFIG_OF_ADDRESS=y CONFIG_OF_DYNAMIC=y diff --git a/target/linux/mediatek/image/filogic.mk b/target/linux/mediatek/image/filogic.mk index b3b6d787d4..62a46fbc78 100644 --- a/target/linux/mediatek/image/filogic.mk +++ b/target/linux/mediatek/image/filogic.mk @@ -8,6 +8,15 @@ define Image/Prepare echo -ne '\xde\xad\xc0\xde' > $(KDIR)/ubi_mark endef +define Build/fit-with-netgear-top-level-rootfs-node + $(call Build/fit-its,$(1)) + $(TOPDIR)/scripts/gen_netgear_rootfs_node.sh $(KERNEL_BUILD_DIR)/root.squashfs > $@.rootfs + awk '/configurations/ { system("cat $@.rootfs") } 1' $@.its > $@.its.tmp + @mv -f $@.its.tmp $@.its + @rm -f $@.rootfs + $(call Build/fit-image,$(1)) +endef + define Build/mt7981-bl2 cat $(STAGING_DIR_IMAGE)/mt7981-$1-bl2.img >> $@ endef @@ -1981,6 +1990,48 @@ define Device/netcore_n60-pro endef TARGET_DEVICES += netcore_n60-pro +define Device/netgear_eax17 + DEVICE_VENDOR := NETGEAR + DEVICE_MODEL := EAX17 + DEVICE_ALT0_VENDOR := NETGEAR + DEVICE_ALT0_MODEL := EAX11 + DEVICE_ALT0_VARIANT := v3 + DEVICE_ALT1_VENDOR := NETGEAR + DEVICE_ALT1_MODEL := EAX15 + DEVICE_ALT1_VARIANT := v3 + DEVICE_ALT2_VENDOR := NETGEAR + DEVICE_ALT2_MODEL := EAX14 + DEVICE_ALT2_VARIANT := v3 + DEVICE_ALT3_VENDOR := NETGEAR + DEVICE_ALT3_MODEL := EAX12 + DEVICE_ALT3_VARIANT := v2 + DEVICE_ALT4_VENDOR := NETGEAR + DEVICE_ALT4_MODEL := EAX16 + DEVICE_ALT5_VENDOR := NETGEAR + DEVICE_ALT5_MODEL := EAX19 + DEVICE_DTS := mt7981b-netgear-eax17 + DEVICE_DTS_DIR := ../dts + SUPPORTED_DEVICES += mediatek,mt7981-spim-snand-rfb + UBINIZE_OPTS := -E 5 + BLOCKSIZE := 128k + PAGESIZE := 2048 + NETGEAR_ENC_MODEL := EAX17 + NETGEAR_ENC_REGION := US + NETGEAR_ENC_HW_ID_LIST := 1010000013120000_NETGEAR + NETGEAR_ENC_MODEL_LIST := EAX17;EAX11v3;EAX15v3;EAX14v3;EAX12v2;EAX16;EAX19 + DEVICE_PACKAGES := kmod-mt7915e kmod-mt7981-firmware mt7981-wo-firmware + KERNEL = kernel-bin | lzma | \ + fit-with-netgear-top-level-rootfs-node lzma $$(KDIR)/image-$$(firstword $$(DEVICE_DTS)).dtb + KERNEL_IN_UBI := 1 + IMAGE_SIZE := 81920k + IMAGE/sysupgrade.bin := sysupgrade-tar | append-metadata + IMAGES += factory.img + # Padding to 10M seems to be required by OEM web interface + IMAGE/factory.img := sysupgrade-tar | \ + pad-to 10M | check-size | netgear-encrypted-factory +endef +TARGET_DEVICES += netgear_eax17 + define Device/netgear_wax220 DEVICE_VENDOR := NETGEAR DEVICE_MODEL := WAX220