]> git.ipfire.org Git - thirdparty/openwrt.git/commit
airoha: add support for Nokia XG-040G-MD 23569/head
authorMikhail Zhilkin <csharper2005@gmail.com>
Sat, 23 May 2026 14:42:33 +0000 (17:42 +0300)
committerHauke Mehrtens <hauke@hauke-m.de>
Mon, 29 Jun 2026 00:01:29 +0000 (02:01 +0200)
commita6ecb09985fa7c14bae1c1bad7d42495737bc0ba
tree0508d62b6153eb38c32f75bb8044751ffdf7abad
parent0277c8601ee48a687d1d27eddfc7175ea7f6874d
airoha: add support for Nokia XG-040G-MD

This commit adds support for Nokia XG-040G-MD XG-PON ONU.

Specification
-------------
- SoC       : Airoha AN7581DT Quad-core ARM Cortex-A53 1.2 GHz
- RAM       : 512 MiB DDR4 (ESMT M16U4G16256A-QLB)
- Flash     : SPI-NAND 256 MiB (SkyHigh ML02G300WHI00)
- WLAN      : -
- Ethernet  : 1x 2500 Mbps (LAN1, Airoha EN8811HN)
              3x 10/100/1000 Mbps (LAN2-LAN4, Airoha AN7581 SoC switch)
- XG-PON    : ECONET EN7572AN, SLIC: MaxLinear PEF32001VSV12
- USB       : 1x USB 3.0 (with power control via gpio)
              1x USB 2.0 (with power control via gpio)
- Buttons   : Reset
- LEDs      : 1x Power (green, gpio-controlled)
              1x WAN (green, gpio-controlled)
              1x WAN (red, gpio-controlled)
              4x LAN (green, gpio-controlled)
              2x USB (green)
- Power     : 12 VDC, 1 A

Unsupported functions and limitations
-------------------------------------
1. XG-PON won't be available after installing OpenWrt.

Installation (stock layout, UART)
---------------------------------
1. Attach UART and run picocom:
   picocom -b 115200 --send-cmd "sb -vv" /dev/ttyUSB0
2. Interrupt boot process by pressing Enter key to enter u-boot
   Username: telecomadmin
   Password: nE7jA%5m
3. Start download firmware via ymodem protocol (via UART):
   loady 0x85000000
4. Press Ctrl + A then Ctrl + S in the picocom terminal (if you are using
   a different terminal, please refer to the documentation) to start
   upload OpenWrt initramfs image using ymodem protocol. Enter local path
   to the OpenWrt initramfs image and press Enter.
5. Load OpenWrt initramfs image from the memory:
   bootm 0x85000000
5. Sysupgrade with OpenWrt sysupgrade image

Alternative for the p.3-4. Load and boot OpenWrt initramfs from tftp IP
192.168.1.254:
   tftpboot 0x85000000 192.168.1.254:openwrt-initramfs-uImage.itb
   bootm 0x85000000
I was unable to download the file without errors, the bootloader network
driver is very unstable. Perhaps you will be more fortunate.

Backup and installation (stock layout, without UART)
----------------------------------------------------
1. Unplug Fiber
2. Make ONU Reset
3. Navigate: http://192.168.1.1
   Username: CMCCAdmin
   Password: aDm8H%MdA
4. Go to Apps -> Home Storage -> FTP and check Enable FTP
5. Go to Apps -> Home Storage -> SAMBA Sharing and check Enable Samba
6. Visit the following URL to open Telnet:
   http://192.168.1.1/system.cgi?telnet
7. Telnet account login:
   Username: user
   Password: <see ONU label>
8. Get root privileges:
   su user_ftp
   Password: <see ONU label>
9. Copy 'squashfs-factory-kernel.bin', 'squashfs-factory-rootfs.bin' and
   'OpenWrt.mtd2.u-boot-env.bin' (backup of 'u-boot-env' partition from
   the another Nokia XG-040G-MD with OpenWrt installed)
9. Attach USB flash drive and check the new dir in /mnt:
   ls /mnt
10. Change current dir to the flash drive (change D to your flash drive
   label):
   cd /mnt/D
11. Make backup:
   for i in 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16; \
   do cat /dev/mtd$i | gzip -9 > mtd$i.bin.gz; done
12. Check image sizes:
   ls -l | awk '{if(NR>1) {$5=sprintf("0x%x", $5); print}}'
13. Write images:
   mtd_debug erase /dev/mtd0 0x60000 0x20000
   mtd_debug write /dev/mtd0 0x60000 0x20000 OpenWrt.mtd2.u-boot-env.bin
   mtd_debug erase /dev/mtd14 0x0 0x2880000
   mtd_debug write /dev/mtd14 0x0 0x3e6cfc squashfs-factory-kernel.bin
   mtd_debug erase /dev/mtd11 0x0 0x80e0000
   mtd_debug write /dev/mtd11 0x0 0x440000 squashfs-factory-rootfs.bin
   0x3e6cfc - size of your 'squashfs-factory-kernel.bin'
   0x440000 - size of your 'squashfs-factory-rootfs.bin'
14. Reboot:
   reboot

Recovery (stock layout)
-----------------------
The same as described in Installation (UART).

Return to stock (stock layout)
------------------------------
1. Follow the steps 1-5 of the Installation (UART)
2. Once in OpenWrt upload you backup to the /tmp dir of the router:
   scp -O mtd16.bin.gz root@192.168.1.1:/tmp
5. Connect to the router using ssh and install kmod-mtd-rw:
   apk update && apk add kmod-mtd-rw
   insmod mtd-rw i_want_a_brick=1
6. Unlock bootloader:
   mtd unlock bootloader
7. Restore stock:
   zcat /tmp/mtd16.bin.gz | mtd write - all_flash
8. Reboot:
   reboot

Notes (OpenWrt U-Boot layout)
-----------------------------
1. Only devices with SkyHigh ML02G300WHI00 spi-nand are supported. Driver
   for FudanMicro FM25G02B is absent in current U-Boot.
2. 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 (OpenWrt U-Boot layout)
-----------------------------------------------
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-an7581-nokia_xg-040g-md-ubi-bl31-uboot.fip
    openwrt-airoha-an7581-nokia_xg-040g-md-ubi-initramfs-recovery.itb
    openwrt-airoha-an7581-nokia_xg-040g-md-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-an7581-nokia_xg-040g-md-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-an7581-nokia_xg-040g-md-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

Stock layout
------------
+-------+------------+---------+---------+
| mtd   | label      | start   | size    |
+-------+------------+---------+---------+
| mtd0  | bootloader | 0       | 80000   |
| mtd1  | romfile    | 80000   | 40000   |
| mtd14 | nsb_master | c0000   | 2880000 |
| mtd15 | nsb_slave  | 2940000 | 2880000 |
| mtd6  | bosa       | 51c0000 | 40000   |
| mtd7  | ri         | 5200000 | 40000   |
| mtd8  | flag       | 5240000 | 40000   |
| mtd9  | flagback   | 5280000 | 40000   |
| mtd10 | config     | 52c0000 | a00000  |
| mtd11 | data       | 5cc0000 | 80e0000 |
| mtd12 | oopsfs     | dda0000 | 400000  |
| mtd13 | log        | e1a0000 | a00000  |
+-------+------------+---------+---------+

USB power control
-----------------
Disable (both ports):
   echo disabled > /sys/devices/platform/usb-power/state
Enable (both ports):
   echo enabled > /sys/devices/platform/usb-power/state

UART
----
A view from the back side of the PCB:
   ------------------------
   |       GND RX TX
   |        X  X  X
Connection parameters:
115200, 8N1, 3.3V

MAC addresses
-------------
+---------+-------------------+-----------+
|         | MAC               | Algorithm |
+---------+-------------------+-----------+
| LAN     | 04:xx:xx:xx:xx:0d | label     |
| WAN     | 04:xx:xx:xx:xx:0e | label + 1 |
+---------+-------------------+-----------+
The LAN MAC (hex) was found in 'ri', 0x3e

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-tools/uboot-envtools/files/airoha_an7581
target/linux/airoha/an7581/base-files/etc/board.d/02_network
target/linux/airoha/an7581/base-files/lib/upgrade/platform.sh
target/linux/airoha/dts/an7581-nokia_xg-040g-md-common.dtsi [new file with mode: 0644]
target/linux/airoha/dts/an7581-nokia_xg-040g-md-ubi.dts [new file with mode: 0644]
target/linux/airoha/dts/an7581-nokia_xg-040g-md.dts [new file with mode: 0644]
target/linux/airoha/image/an7581.mk