]> git.ipfire.org Git - thirdparty/openwrt.git/commitdiff
uboot-airoha: add support for Nokia XG-040G-MD
authorMikhail Zhilkin <csharper2005@gmail.com>
Sat, 6 Jun 2026 12:08:36 +0000 (15:08 +0300)
committerHauke Mehrtens <hauke@hauke-m.de>
Mon, 29 Jun 2026 00:01:29 +0000 (02:01 +0200)
Add support for Nokia XG-040G-MD.

Known issues
------------
1. Reset button is currently doesn't work and cannot be used to start
tftp recovery:
   Button 'reset' not found (err=-19)
   LED 'green:power' not found (err=-19)

Signed-off-by: Mikhail Zhilkin <csharper2005@gmail.com>
Link: https://github.com/openwrt/openwrt/pull/23569
Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
package/boot/uboot-airoha/Makefile
package/boot/uboot-airoha/patches/401-add-nokia-xg-040g-md.patch [new file with mode: 0644]

index 6f2e02c0643ad9fb37f8101441741b68b0f4b9dd..129081268ce91244e6ba77fbd3b8c0ebe1d64ff3 100644 (file)
@@ -34,6 +34,16 @@ define U-Boot/an7581_nokia_valyrian
   BL31_IMAGE:=an7581-bl31.bin
 endef
 
+define U-Boot/an7581_nokia_xg-040g-md
+  NAME:=Nokia XG-040G-MD
+  UBOOT_CONFIG:=an7581_nokia_xg-040g-md
+  BUILD_DEVICES:=nokia_xg-040g-md-ubi
+  BUILD_SUBTARGET:=an7581
+  UBOOT_IMAGE:=u-boot.fip
+  BL2_IMAGE:=an7581-bl2.bin
+  BL31_IMAGE:=an7581-bl31.bin
+endef
+
 define U-Boot/an7581_rfb
   NAME:=AN7581 Reference Board
   UBOOT_CONFIG:=an7581_evb
@@ -67,6 +77,7 @@ endef
 UBOOT_TARGETS := \
        an7581_gemtek_w1700k \
        an7581_nokia_valyrian \
+       an7581_nokia_xg-040g-md \
        an7581_rfb \
        an7583_rfb \
        en7523_rfb
diff --git a/package/boot/uboot-airoha/patches/401-add-nokia-xg-040g-md.patch b/package/boot/uboot-airoha/patches/401-add-nokia-xg-040g-md.patch
new file mode 100644 (file)
index 0000000..be59a76
--- /dev/null
@@ -0,0 +1,295 @@
+--- /dev/null
++++ b/configs/an7581_nokia_xg-040g-md_defconfig
+@@ -0,0 +1,134 @@
++CONFIG_ARM=y
++CONFIG_ARCH_AIROHA=y
++CONFIG_POSITION_INDEPENDENT=y
++CONFIG_BOOTDELAY=3
++CONFIG_AUTOBOOT_KEYED=y
++CONFIG_AUTOBOOT_MENU_SHOW=y
++CONFIG_TARGET_AN7581=y
++CONFIG_TEXT_BASE=0x81e00000
++CONFIG_SYS_MALLOC_F_LEN=0x4000
++CONFIG_NR_DRAM_BANKS=1
++CONFIG_DM_GPIO=y
++CONFIG_DEFAULT_DEVICE_TREE="airoha/an7581-nokia-xg-040g-md"
++CONFIG_SYS_LOAD_ADDR=0x81800000
++CONFIG_BUILD_TARGET="u-boot.bin"
++# CONFIG_EFI_LOADER is not set
++CONFIG_FIT=y
++CONFIG_FIT_VERBOSE=y
++CONFIG_DEFAULT_FDT_FILE="airoha/an7581-nokia-xg-040g-md.dtb"
++CONFIG_LOGLEVEL=9
++CONFIG_LOG=y
++CONFIG_SYS_PBSIZE=1049
++CONFIG_SYS_CONSOLE_IS_IN_ENV=y
++# CONFIG_DISPLAY_BOARDINFO is not set
++CONFIG_HUSH_PARSER=y
++CONFIG_SYS_PROMPT="AN7581> "
++CONFIG_SYS_MAXARGS=8
++CONFIG_CMD_CPU=y
++CONFIG_CMD_LICENSE=y
++CONFIG_CMD_BOOTMENU=y
++CONFIG_CMD_ASKENV=y
++CONFIG_CMD_ERASEENV=y
++CONFIG_CMD_ENV_FLAGS=y
++CONFIG_CMD_RNG=y
++CONFIG_CMD_STRINGS=y
++CONFIG_CMD_DM=y
++CONFIG_CMD_GPIO=y
++CONFIG_CMD_GPT=y
++CONFIG_CMD_MTD=y
++CONFIG_CMD_MTD_MARKBAD=y
++CONFIG_CMD_MTD_NAND_READ_TEST=y
++CONFIG_CMD_MTD_NAND_WRITE_TEST=y
++CONFIG_CMD_PART=y
++CONFIG_CMD_TFTPSRV=y
++CONFIG_CMD_RARP=y
++CONFIG_CMD_CDP=y
++CONFIG_CMD_SNTP=y
++CONFIG_CMD_LINK_LOCAL=y
++CONFIG_CMD_DHCP=y
++CONFIG_CMD_DNS=y
++CONFIG_CMD_PING=y
++CONFIG_CMD_PXE=y
++CONFIG_CMD_CACHE=y
++CONFIG_CMD_UUID=y
++CONFIG_CMD_HASH=y
++CONFIG_CMD_SMC=y
++CONFIG_CMD_UBI=y
++CONFIG_CMD_UBI_RENAME=y
++CONFIG_OF_EMBED=y
++CONFIG_ENV_OVERWRITE=y
++CONFIG_ENV_IS_IN_UBI=y
++CONFIG_ENV_REDUNDANT=y
++CONFIG_ENV_UBI_PART="ubi"
++CONFIG_ENV_UBI_VOLUME="ubootenv"
++CONFIG_ENV_UBI_VOLUME_REDUND="ubootenv2"
++CONFIG_ENV_RELOC_GD_ENV_ADDR=y
++CONFIG_ENV_USE_DEFAULT_ENV_TEXT_FILE=y
++CONFIG_ENV_DEFAULT_ENV_TEXT_FILE="defenvs/an7581_nokia_xg-040g-md_env"
++CONFIG_ENV_VARS_UBOOT_RUNTIME_CONFIG=y
++# CONFIG_ENV_IS_IN_MTD is not set
++# CONFIG_MMC is not set
++CONFIG_MTD=y
++CONFIG_DM_MTD=y
++CONFIG_MTD_SPI_NAND=y
++CONFIG_MTD_UBI=y
++CONFIG_MTD_UBI_MODULE=y
++CONFIG_MTD_UBI_WL_THRESHOLD=4096
++CONFIG_MTD_UBI_BEB_LIMIT=20
++# CONFIG_MTD_UBI_FASTMAP is not set
++CONFIG_UBI_BLOCK=y
++# CONFIG_UBIFS_SILENCE_MSG is not set
++# CONFIG_UBIFS_SILENCE_DEBUG_DUMP is not set
++CONFIG_VERSION_VARIABLE=y
++CONFIG_NETCONSOLE=y
++CONFIG_USE_IPADDR=y
++CONFIG_IPADDR="192.168.1.1"
++CONFIG_USE_SERVERIP=y
++CONFIG_SERVERIP="192.168.1.254"
++CONFIG_NET_RANDOM_ETHADDR=y
++CONFIG_BUTTON=y
++CONFIG_BUTTON_GPIO=y
++CONFIG_OF_UPSTREAM=y
++CONFIG_SYS_RELOC_GD_ENV_ADDR=y
++CONFIG_SYS_RX_ETH_BUFFER=8
++CONFIG_REGMAP=y
++CONFIG_SYSCON=y
++CONFIG_CLK=y
++CONFIG_DMA=y
++CONFIG_GPIO_HOG=y
++CONFIG_LED=y
++CONFIG_LED_BLINK=y
++CONFIG_LED_GPIO=y
++CONFIG_SPI_FLASH=y
++CONFIG_SPI_FLASH_EON=y
++CONFIG_SPI_FLASH_GIGADEVICE=y
++CONFIG_SPI_FLASH_ISSI=y
++CONFIG_SPI_FLASH_MACRONIX=y
++CONFIG_SPI_FLASH_SPANSION=y
++CONFIG_SPI_FLASH_STMICRO=y
++CONFIG_SPI_FLASH_WINBOND=y
++CONFIG_SPI_FLASH_MTD=y
++CONFIG_AIROHA_ETH=y
++CONFIG_DM_MDIO=y
++CONFIG_CMD_MII=y
++CONFIG_CMD_MDIO=y
++CONFIG_PCS_AIROHA_AN7581=y
++CONFIG_PHY=y
++CONFIG_PINCTRL=y
++CONFIG_PINCONF=y
++CONFIG_POWER_DOMAIN=y
++CONFIG_DM_REGULATOR=y
++CONFIG_DM_REGULATOR_FIXED=y
++CONFIG_RAM=y
++CONFIG_DM_SERIAL=y
++CONFIG_SYS_NS16550=y
++CONFIG_SPI=y
++CONFIG_DM_SPI=y
++CONFIG_AIROHA_SNFI_SPI=y
++CONFIG_SHA512=y
++CONFIG_USE_DEFAULT_ENV_FILE=y
++CONFIG_DEFAULT_ENV_FILE="defenvs/an7581_nokia_xg-040g-md_env"
++CONFIG_PCS_AIROHA_AN7581=y
++CONFIG_PHY_AIROHA_EN8811=y
++CONFIG_PHY_ANEG_TIMEOUT=10000
++CONFIG_PHY_ETHERNET_ID=y
+--- /dev/null
++++ b/defenvs/an7581_nokia_xg-040g-md_env
+@@ -0,0 +1,53 @@
++ipaddr=192.168.1.1
++serverip=192.168.1.254
++loadaddr=0x90000000
++console=earlycon=uart8250,mmio32,0x11002000 console=ttyS0
++bootcmd=run check_buttons ; run boot_ubi
++bootconf=config-1
++bootdelay=0
++bootfile=openwrt-airoha-an7581-nokia_xg-040g-md-ubi-initramfs-recovery.itb
++bootfile_bl2=openwrt-airoha-an7581-nokia_xg-040g-md-ubi-preloader.bin
++bootfile_fip=openwrt-airoha-an7581-nokia_xg-040g-md-ubi-bl31-uboot.fip
++bootfile_upg=openwrt-airoha-an7581-nokia_xg-040g-md-ubi-squashfs-sysupgrade.itb
++bootled_status=green:power
++bootmenu_confirm_return=askenv - Press ENTER to return to menu ; bootmenu 60
++bootmenu_default=0
++bootmenu_delay=0
++bootmenu_title=      \e[0;34m( ( ( \e[1;39mOpenWrt\e[0;34m ) ) )
++bootmenu_0=Initialize environment.=run _firstboot
++bootmenu_0d=Run default boot command.=run boot_default
++bootmenu_1=Boot system via TFTP=run boot_tftp ; run bootmenu_confirm_return
++bootmenu_2=Boot production system from NAND=run boot_production ; run bootmenu_confirm_return
++bootmenu_3=Load production system via TFTP then write to NAND=setenv noboot 1 ; setenv replacevol 1 ; run boot_tftp_production ; setenv noboot ; setenv replacevol ; run bootmenu_confirm_return
++bootmenu_4=\e[31mLoad BL31+U-Boot FIP via TFTP then write to NAND\e[0m=run boot_tftp_write_fip ; run bootmenu_confirm_return
++bootmenu_5=\e[31mLoad BL2 preloader via TFTP then write to NAND\e[0m=run boot_tftp_write_bl2 ; run bootmenu_confirm_return
++bootmenu_6=Reboot=reset
++bootmenu_7=Reset all settings to factory defaults=run reset_factory ; reset
++boot_first=if button reset ; then led $bootled_status on ; run boot_default ; fi ; bootmenu
++boot_default=run bootcmd ; run boot_tftp_forever
++boot_production=led $bootled_status on ; run ubi_read_production && bootm $loadaddr#$bootconf ; led $bootled_status off
++boot_ubi=run boot_production ; run boot_tftp_forever
++boot_tftp_forever=led $bootled_status on ; while true ; do run boot_tftp ; sleep 1 ; done
++boot_tftp_production=tftpboot $loadaddr $bootfile_upg && env exists replacevol && iminfo $loadaddr && run ubi_write_production ; if env exists noboot ; then else bootm $loadaddr#$bootconf ; fi
++boot_tftp_recovery=tftpboot $loadaddr $bootfile && env exists replacevol && iminfo $loadaddr && run ubi_write_recovery ; if env exists noboot ; then else bootm $loadaddr#$bootconf ; fi
++boot_tftp=tftpboot $loadaddr $bootfile && bootm $loadaddr#$bootconf
++boot_tftp_write_bl2=mw.b $loadaddr 0xff 0x800 ; setexpr loadaddr_bl2 $loadaddr + 0x800 ; tftpboot $loadaddr_bl2 $bootfile_bl2 && run mtd_write_bl2
++boot_tftp_write_fip=tftpboot $loadaddr $bootfile_fip && run ubi_write_fip && run reset_factory
++preboot=led $bootled_status on
++check_buttons=if button reset ; then run boot_tftp ; fi
++ethaddr_factory=ubi read 0x90000000 ri && env readmem -b ethaddr 0x9000003e 0x6 ; setenv ethaddr_factory
++part_default=production
++reset_factory=ubi part ubi ; mw $loadaddr 0x0 0x800 ; ubi write $loadaddr ubootenv 0x800 ; ubi write $loadaddr ubootenv2 0x800
++mtd_write_bl2=mtd erase bl2 && mtd write bl2 $loadaddr
++ubi_create_board_data=ubi check bosa || ubi create bosa 0x40000 || run ubi_format ; ubi check ri || ubi create ri 0x40000 || run ubi_format
++ubi_create_env=ubi check ubootenv || ubi create ubootenv 0x1f000 dynamic || run ubi_format ; ubi check ubootenv2 || ubi create ubootenv2 0x1f000 dynamic || run ubi_format
++ubi_format=ubi detach ; mtd erase ubi && ubi part ubi ; reset
++ubi_prepare_rootfs=if ubi check rootfs_data ; then else if env exists rootfs_data_max ; then ubi create rootfs_data $rootfs_data_max dynamic || ubi create rootfs_data - dynamic ; else ubi create rootfs_data - dynamic ; fi ; fi
++ubi_read_production=ubi read $loadaddr fit && iminfo $loadaddr && run ubi_prepare_rootfs
++ubi_remove_rootfs=ubi check rootfs_data && ubi remove rootfs_data
++ubi_write_fip=run ubi_remove_rootfs ; ubi check fip && ubi remove fip ; ubi create fip 0x100000 static && ubi write $loadaddr fip $filesize
++ubi_write_production=ubi check fit && ubi remove fit ; run ubi_remove_rootfs ; ubi create fit $filesize dynamic && ubi write $loadaddr fit $filesize
++_init_env=setenv _init_env ; run ubi_create_env ; saveenv ; saveenv ; run ubi_create_board_data
++_firstboot=setenv _firstboot ; run ethaddr_factory ; run _switch_to_menu ; run _init_env ; run boot_first
++_switch_to_menu=setenv _switch_to_menu ; setenv bootdelay 3 ; setenv bootmenu_delay 3 ; setenv bootmenu_0 $bootmenu_0d ; setenv bootmenu_0d ; run _bootmenu_update_title
++_bootmenu_update_title=setenv _bootmenu_update_title ; setenv bootmenu_title "$bootmenu_title       \e[33m$ver\e[0m"
+--- /dev/null
++++ b/dts/upstream/src/arm64/airoha/an7581-nokia-xg-040g-md.dts
+@@ -0,0 +1,99 @@
++// SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
++/dts-v1/;
++
++#include <dt-bindings/leds/common.h>
++#include <dt-bindings/gpio/gpio.h>
++#include <dt-bindings/input/input.h>
++#include "en7581.dtsi"
++
++/ {
++      model = "Nokia XG-040G-MD";
++      compatible = "nokia,xg-040g-md",
++                   "airoha,an7581",
++                   "airoha,en7581";
++
++      chosen {
++              bootargs = "console=ttyS0,115200 earlycon";
++              stdout-path = "serial0:115200n8";
++              linux,usable-memory-range = <0x0 0x80200000 0x0 0x1fe00000>;
++      };
++
++      memory@80000000 {
++              device_type = "memory";
++              reg = <0x0 0x80000000 0x0 0x20000000>;
++      };
++
++      keys {
++              compatible = "gpio-keys";
++
++              button-0 {
++                      label = "reset";
++                      linux,code = <KEY_RESTART>;
++                      gpios = <&en7581_pinctrl 0 GPIO_ACTIVE_LOW>;
++              };
++      };
++
++      leds {
++              compatible = "gpio-leds";
++
++              led-0 {
++                      label = "green:power";
++                      gpios = <&en7581_pinctrl 17 GPIO_ACTIVE_LOW>;
++              };
++
++              led-1 {
++                      label = "green:wan";
++                      gpios = <&en7581_pinctrl 18 GPIO_ACTIVE_LOW>;
++              };
++
++              led-2 {
++                      label = "red:wan";
++                      gpios = <&en7581_pinctrl 19 GPIO_ACTIVE_LOW>;
++              };
++
++              led-3 {
++                      label = "green:wan-online";
++                      gpios = <&en7581_pinctrl 20 GPIO_ACTIVE_LOW>;
++              };
++
++              led-4 {
++                      label = "green:usb-2";
++                      gpios = <&en7581_pinctrl 34 GPIO_ACTIVE_LOW>;
++              };
++
++              led-5 {
++                      label = "green:usb-1";
++                      gpios = <&en7581_pinctrl 35 GPIO_ACTIVE_LOW>;
++              };
++      };
++};
++
++&snfi {
++      status = "okay";
++};
++
++&spi_nand {
++      partitions {
++              compatible = "fixed-partitions";
++              #address-cells = <1>;
++              #size-cells = <1>;
++
++              partition@0 {
++                      label = "bl2";
++                      reg = <0x0 0x20000>;
++              };
++
++              partition@20000 {
++                      label = "ubi";
++                      reg = <0x20000 0xffe0000>;
++              };
++      };
++};
++
++&i2c0 {
++      status = "okay";
++};
++
++&eth {
++      status = "okay";
++};