From cbe75a7bb17aa8a73bcf231fb3158b790ee32577 Mon Sep 17 00:00:00 2001 From: Mikhail Zhilkin Date: Sun, 9 Aug 2026 13:28:53 +0300 Subject: [PATCH] airoha: add support for Nokia XG-040G-MF (UBI) This commit adds support for OpenWrt U-Boot variant of Nokia XG-040G-MF XG-PON ONU. Notes ----- 1. A simple installation without serial console is also possible using a fork of @dangowrt's UBI Installer Link: https://github.com/dangowrt/owrt-ubi-installer Installation / recovery ----------------------- 1. Make sure that you have 'bosa' and 'ri' partitions mtd backups before you start 2. Place OpenWrt images on the tftp server (IP: 192.168.1.254): openwrt-airoha-an7583-nokia_xg-040g-mf-ubi-bl31-uboot.fip openwrt-airoha-an7583-nokia_xg-040g-mf-ubi-initramfs-recovery.itb openwrt-airoha-an7583-nokia_xg-040g-mf-ubi-preloader.bin 3. Attach serial console and start terminal with XMODEM support: picocom -b 115200 --send-cmd "sx -vvX" /dev/ttyUSB0 4. Push reset button and power on the router 5. Press 'x', then 'Ctrl + A' and 'Ctrl + S' 6. Paste full path to the bl2 image: 'openwrt-airoha-an7583-nokia_xg-040g-mf-ubi-preloader.bin' 7. Wait until the file is downloaded and the following prompt appears: Press x to load BL31 + U-Boot FIP 8. Press 'x', then 'Ctrl + A' and 'Ctrl + S' 9. Paste full path to the fip image: 'openwrt-airoha-an7583-nokia_xg-040g-mf-ubi-bl31-uboot.fip' 10. Wait until the file is downloaded, u-boot will prepare ubi partition automatically 11. Wait for U-Boot menu 12. Run 'Load BL31+U-Boot FIP via TFTP then write to NAND' 13. Run 'Load BL2 preloader via TFTP then write to NAND' 14. Run 'Boot system via TFTP' 15. Once in OpenWrt perform standard sysupgrade 16. Once in OpenWrt upload 'bosa' and 'ri' partitions mtd backups to the /tmp dir using scp protocol 17. Check ID of the UBI volumes: ubinfo -d 0 -N bosa | grep "Volume ID" ubinfo -d 0 -N ri | grep "Volume ID" 18. Write backups according to the volume ID: ubiupdatevol /dev/ubi0_2 /tmp/bosa.bin ubiupdatevol /dev/ubi0_3 /tmp/ri.bin 19. Reboot: reboot UART ---- A view from the back side of the PCB: ------------------------ | GND RX TX | X X X Connection parameters: 115200, 8N1, 3.3V Signed-off-by: Mikhail Zhilkin Link: https://github.com/openwrt/openwrt/pull/24654 Signed-off-by: Robert Marko --- .../uboot-envtools/files/airoha_an7583 | 3 ++ .../an7583/base-files/etc/board.d/01_leds | 3 +- .../an7583/base-files/etc/board.d/02_network | 3 +- .../an7583/base-files/lib/upgrade/platform.sh | 7 ++++ .../dts/an7583-nokia_xg-040g-mf-ubi.dts | 10 ++++++ target/linux/airoha/image/an7583.mk | 35 ++++++++++++++++--- 6 files changed, 54 insertions(+), 7 deletions(-) create mode 100644 target/linux/airoha/dts/an7583-nokia_xg-040g-mf-ubi.dts diff --git a/package/boot/uboot-tools/uboot-envtools/files/airoha_an7583 b/package/boot/uboot-tools/uboot-envtools/files/airoha_an7583 index d691a71315a..f250afbbfe2 100644 --- a/package/boot/uboot-tools/uboot-envtools/files/airoha_an7583 +++ b/package/boot/uboot-tools/uboot-envtools/files/airoha_an7583 @@ -15,6 +15,9 @@ case "$board" in nokia,xg-040g-mf) ubootenv_add_mtd "u-boot-env" "0x1c000" "0x4000" "0x4000" ;; +nokia,xg-040g-mf-ubi) + ubootenv_add_ubi_default + ;; esac config_load ubootenv diff --git a/target/linux/airoha/an7583/base-files/etc/board.d/01_leds b/target/linux/airoha/an7583/base-files/etc/board.d/01_leds index 099d51bdbce..dbe380ec559 100644 --- a/target/linux/airoha/an7583/base-files/etc/board.d/01_leds +++ b/target/linux/airoha/an7583/base-files/etc/board.d/01_leds @@ -9,7 +9,8 @@ board_config_update board=$(board_name) case "$board" in -nokia,xg-040g-mf) +nokia,xg-040g-mf|\ +nokia,xg-040g-mf-ubi) ucidef_set_led_netdev "lan2" "lan2" "mt7530-0:0a:green:lan-2" "lan2" "link tx rx" ucidef_set_led_netdev "lan3" "lan3" "mt7530-0:0b:green:lan-3" "lan3" "link tx rx" ucidef_set_led_netdev "lan4" "lan4" "mt7530-0:0c:green:lan-4" "lan4" "link tx rx" diff --git a/target/linux/airoha/an7583/base-files/etc/board.d/02_network b/target/linux/airoha/an7583/base-files/etc/board.d/02_network index 482a18fbfcd..952e2ddc88c 100644 --- a/target/linux/airoha/an7583/base-files/etc/board.d/02_network +++ b/target/linux/airoha/an7583/base-files/etc/board.d/02_network @@ -14,7 +14,8 @@ an7583_setup_interfaces() airoha,an7583-evb) ucidef_set_interface_lan "lan1 lan2 lan3 lan4 eth1" ;; - nokia,xg-040g-mf) + nokia,xg-040g-mf|\ + nokia,xg-040g-mf-ubi) ucidef_set_interface_lan "lan1 lan2 lan3 lan4" ;; *) diff --git a/target/linux/airoha/an7583/base-files/lib/upgrade/platform.sh b/target/linux/airoha/an7583/base-files/lib/upgrade/platform.sh index a8557232c28..81744b21983 100644 --- a/target/linux/airoha/an7583/base-files/lib/upgrade/platform.sh +++ b/target/linux/airoha/an7583/base-files/lib/upgrade/platform.sh @@ -13,6 +13,10 @@ platform_check_image() { local board=$(board_name) case "$board" in + nokia,xg-040g-mf-ubi) + fit_check_image "$1" + return $? + ;; *) nand_do_platform_check "$board" "$1" return $? @@ -26,6 +30,9 @@ platform_do_upgrade() { local board=$(board_name) case "$board" in + nokia,xg-040g-mf-ubi) + fit_do_upgrade "$1" + ;; *) nand_do_upgrade "$1" ;; diff --git a/target/linux/airoha/dts/an7583-nokia_xg-040g-mf-ubi.dts b/target/linux/airoha/dts/an7583-nokia_xg-040g-mf-ubi.dts new file mode 100644 index 00000000000..57a40e9f15b --- /dev/null +++ b/target/linux/airoha/dts/an7583-nokia_xg-040g-mf-ubi.dts @@ -0,0 +1,10 @@ +// SPDX-License-Identifier: GPL-2.0-only OR MIT + +#include "an7583-nokia_xg-040g-mf-common.dtsi" +#include "an758x-nokia_xg-040g-ubi-parts.dtsi" + +/ { + model = "Nokia XG-040G-MF (UBI)"; + compatible = "nokia,xg-040g-mf-ubi", "airoha,an7583", + "airoha,en7583"; +}; diff --git a/target/linux/airoha/image/an7583.mk b/target/linux/airoha/image/an7583.mk index d97debb6bc6..ce97984b981 100644 --- a/target/linux/airoha/image/an7583.mk +++ b/target/linux/airoha/image/an7583.mk @@ -47,22 +47,47 @@ define Device/airoha_an7583-evb-emmc endef TARGET_DEVICES += airoha_an7583-evb-emmc -define Device/nokia_xg-040g-mf +define Device/nokia_xg-040g-mf-common $(call Device/FitImageLzma) DEVICE_VENDOR := Nokia DEVICE_MODEL := XG-040G-MF - DEVICE_DTS := an7583-nokia_xg-040g-mf - DEVICE_DTS_CONFIG := config@1 BLOCKSIZE := 128k PAGESIZE := 2048 UBINIZE_OPTS := -E 5 + DEVICE_PACKAGES := kmod-phy-airoha-en8811h \ + kmod-regulator-userspace-consumer kmod-usb-ledtrig-usbport +endef + +define Device/nokia_xg-040g-mf + $(call Device/nokia_xg-040g-mf-common) + DEVICE_DTS := an7583-nokia_xg-040g-mf + DEVICE_DTS_CONFIG := config@1 IMAGE_SIZE := 131968k KERNEL_SIZE := 8192k IMAGES += factory-kernel.bin factory-rootfs.bin IMAGE/factory-kernel.bin := append-kernel IMAGE/factory-rootfs.bin := append-ubi | check-size IMAGE/sysupgrade.bin := sysupgrade-tar | append-metadata - DEVICE_PACKAGES := kmod-phy-airoha-en8811h kmod-regulator-userspace-consumer \ - kmod-usb-ledtrig-usbport endef TARGET_DEVICES += nokia_xg-040g-mf + +define Device/nokia_xg-040g-mf-ubi + $(call Device/nokia_xg-040g-mf-common) + DEVICE_VARIANT := (UBI) + DEVICE_DTS := an7583-nokia_xg-040g-mf-ubi + 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 + DEVICE_PACKAGES += fitblk + ARTIFACT/bl31-uboot.fip := an7583-bl31-uboot nokia_xg-040g-mf + ARTIFACT/preloader.bin := an7583-preloader nokia_xg-040g-mf + ARTIFACTS := bl31-uboot.fip preloader.bin +endef +TARGET_DEVICES += nokia_xg-040g-mf-ubi