$(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)))))
$(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))),\
gen-cpio$(if $(TARGET_PER_DEVICE_ROOTFS),.$(ROOTFS_ID/$(DEVICE_NAME))))
endef
+define Build/fit
+ $(call Build/fit-its,$(1))
+ $(call Build/fit-image,$(1))
+endef
+
define Build/libdeflate-gzip
--- /dev/null
+#!/bin/sh
+#
+# SPDX-License-Identifier: GPL-2.0-or-later
+#
+#
+# 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 <<EOF | sed 's/^/\t/'
+rootfs {
+ size = <${ROOTFS_SIZE}>;
+
+ hash-1 {
+ value = ${ROOTFS_SHA1};
+ algo = "sha1";
+ };
+};
+
+EOF
--- /dev/null
+From 06e92afca89075628b12c9b4085b4cc7320081ac Mon Sep 17 00:00:00 2001
+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
+
+---
+ 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) {
--- /dev/null
+// 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 = <KEY_RESTART>;
+ gpios = <&pio 1 GPIO_ACTIVE_LOW>;
+ };
+
+ wps {
+ label = "wps";
+ linux,code = <KEY_WPS_BUTTON>;
+ gpios = <&pio 0 GPIO_ACTIVE_LOW>;
+ };
+ };
+
+ gpio-leds {
+ compatible = "gpio-leds";
+
+ led_power_green: power_green {
+ color = <LED_COLOR_ID_GREEN>;
+ function = LED_FUNCTION_POWER;
+ gpios = <&pio 9 GPIO_ACTIVE_LOW>;
+ };
+
+ led_power_red: power_red {
+ color = <LED_COLOR_ID_RED>;
+ function = LED_FUNCTION_POWER;
+ gpios = <&pio 12 GPIO_ACTIVE_LOW>;
+ };
+
+ led_rlink_red: rlink_red {
+ color = <LED_COLOR_ID_RED>;
+ function = LED_FUNCTION_LAN;
+ gpios = <&pio 6 GPIO_ACTIVE_LOW>;
+ };
+
+ led_rlink_green: rlink_green {
+ color = <LED_COLOR_ID_GREEN>;
+ function = LED_FUNCTION_LAN;
+ gpios = <&pio 7 GPIO_ACTIVE_LOW>;
+ };
+
+ led_clink_red: clink_red {
+ color = <LED_COLOR_ID_RED>;
+ function = LED_FUNCTION_WAN;
+ gpios = <&pio 10 GPIO_ACTIVE_LOW>;
+ };
+
+ led_clink_green: clink_green {
+ color = <LED_COLOR_ID_GREEN>;
+ function = LED_FUNCTION_WAN;
+ gpios = <&pio 11 GPIO_ACTIVE_LOW>;
+ };
+
+ led_wps_green: wps_green {
+ color = <LED_COLOR_ID_GREEN>;
+ function = LED_FUNCTION_WPS;
+ gpios = <&pio 5 GPIO_ACTIVE_LOW>;
+ };
+
+ led_lan_speed_fast: lan_speed_fast {
+ color = <LED_COLOR_ID_GREEN>;
+ function = LED_FUNCTION_STATUS;
+ gpios = <&pio 13 GPIO_ACTIVE_LOW>;
+ };
+
+ led_lan_speed_slow: lan_speed_slow {
+ color = <LED_COLOR_ID_YELLOW>;
+ 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 = <MTK_DRIVE_8mA>;
+ bias-pull-up = <MTK_PUPD_SET_R1R0_11>;
+ };
+
+ conf-pd {
+ pins = "SPI0_CLK", "SPI0_MOSI", "SPI0_MISO";
+ drive-strength = <MTK_DRIVE_8mA>;
+ bias-pull-down = <MTK_PUPD_SET_R1R0_11>;
+ };
+ };
+};
+
+&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";
+};
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"
;;
cudy,ap3000outdoor-v1|\
cudy,ap3000-v1|\
cudy,re3000-v1|\
+ netgear,eax17|\
netgear,wax220|\
openfi,6c|\
ubnt,unifi-6-plus|\
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"
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
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 >
[email protected]
+ $(call Build/fit-image,$(1))
+endef
+
define Build/mt7981-bl2
cat $(STAGING_DIR_IMAGE)/mt7981-$1-bl2.img >> $@
endef
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