Skip to content

airoha: add support for Nokia XG-040G-MD - #23569

Merged
openwrt-bot merged 6 commits into
openwrt:mainfrom
csharper2005:nokia_xg-040g-md
Jun 29, 2026
Merged

openwrt-bot merged 6 commits into
openwrt:mainfrom
csharper2005:nokia_xg-040g-md

Conversation

@csharper2005

@csharper2005 csharper2005 commented May 27, 2026 •

Copy link
Copy Markdown
Contributor

This commit adds support for Nokia XG-040G-MD XG-PON ONU. I know there's already another open pull request - openwrt/openwrt#21896. This PR doesn't require third-party bootloader:

Specification

- SoC       : Airoha AN7981DT 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.
    2. There are devices with SkyHigh and FUDAN MICRO SPI-NAND. FUDAN MICRO is currently not yet supported in OpenWrt. DON'T install OpenWrt on a device with FUDAN MICRO FM25G02BI3 chip.
    2. USB1 and USB2 leds don't work. Reason - airoha: add support for Nokia XG-040G-MD #23569 (comment). There is no good solution at this moment.

@csharper2005
csharper2005 marked this pull request as draft May 27, 2026 17:46
@github-actions github-actions Bot added kernel pull request/issue with Linux kernel related changes core packages pull request/issue for core (in-tree) packages target/airoha pull request/issue for airoha target labels May 28, 2026
@castiel652

Copy link
Copy Markdown
Contributor

MT7981?

@csharper2005

Copy link
Copy Markdown
Contributor Author

MT7981?

AN7581

@openwrt-ai openwrt-ai left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Commit checks

  • 55ba391 "airoha: add support for Nokia XG-040G-MD" — Several disagreements between commit message, PR body, and code:
    • SoC: commit says Airoha MT7981DT but PR body says Airoha AN7581DT and the subtarget is an7581. (Already noted in the PR comments.)
    • Switch: commit says LAN2-LAN4 (… Airoha AN7583 SoC switch) but PR body says Airoha AN7581 SoC switch — this is the AN7581.
    • Flash size: commit and PR body both say SPI-NAND 128 MiB (GigaDevice GD5F2GM7UEYIG), but GD5F2G… is a 2 Gbit (256 MiB) part. The DTS partition layout extends to 0xe1a0000 + 0xa00000 = 0xeba0000 (~235 MiB), which also only fits in a 256 MiB chip.
    • Stray comma: 1x WAN (red, gpio-controlled is missing the closing ).
    • Per .github/llm-review-rules.md, a new-device commit message must include three sections: hardware spec (present, partly), flash instructions (missing), and MAC address layout (missing). The PR description already lists "Documentation (install and other guides)" as an open point, but the commit message itself should carry the flash procedure and MAC layout (mac-base derived from factory@3e, used for gdm1 and gdm4).

Generated by Claude Code

Comment thread target/linux/airoha/image/an7581.mk Resolved
@csharper2005
csharper2005 force-pushed the nokia_xg-040g-md branch 2 times, most recently from d67bcb1 to 3b1cd8c Compare May 30, 2026 04:02
@csharper2005
csharper2005 marked this pull request as ready for review May 30, 2026 04:20

@openwrt-ai openwrt-ai left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Commit checks

  • 3b1cd8c "airoha: add support for Nokia XG-040G-MD" — the SoC/switch/flash-size disagreements from the previous review are resolved, and the commit now carries the flash and MAC-layout sections. Two leftover typos in the message body: "It needs to be upstreamed to the Linux kernel and and backported" (doubled "and"), and "The source code for is available" / "fill free make tests" read like they're missing words. Worth a quick fixup.

Otherwise the diff looks consistent with the message; remaining inline notes are nits.


Generated by Claude Code

};

&gsw_phy2 {
status = "okay";

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Have you tested whether interrupts work on this platform?
89d8dc1

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It works with and without this property. Should I add interrupts?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

@openwrt-ai openwrt-ai left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed 2 new commits; no new issues found.


Generated by Claude Code

@csharper2005

Copy link
Copy Markdown
Contributor Author

The stock bootloader is ugly:

  • tftp exists but broken
  • uart is required for recovery
  • we're losing a ton of space because of BMT area

I've built an open source u-boot for this device and Nokia XG-040G-MF (Airoha AN7583). RAM-boot is ok. But bootloaders (even the stock one) written to spi-nand from open source u-boot are not recognized by bootrom (no any characters after reset). I guess it's an ECC issue. If anyone has any ideas on how or where to fix it, please let me know.

@csharper2005

Copy link
Copy Markdown
Contributor Author

Stock u-boot сontains some certificates. Does this mean there's no chance for open source u-boot?

Certificate:
    Data:
        Version: 3 (0x2)
        Serial Number:
            a8:ce:68:dc:6f:50:7c:4d
        Signature Algorithm: rsassaPss        
        Hash Algorithm: sha512
        Mask Algorithm: mgf1 with sha512
         Salt Length: 0x20
        Trailer Field: 0x01 (default)
        Issuer: CN = Trusted Boot FW Certificate
        Validity
            Not Before: Sep 12 02:58:36 2024 GMT
            Not After : Sep  7 02:58:36 2044 GMT
        Subject: CN = Trusted Boot FW Certificate
        Subject Public Key Info:
            Public Key Algorithm: rsaEncryption
                Public-Key: (4096 bit)
                Modulus:
                    00:d0:4f:5f:6a:0b:77:4b:e5:e1:c5:37:52:8a:ae:
                    12:ff:0b:e6:61:8a:6b:f9:c8:04:de:83:b2:5a:17:
                    06:93:2c:c1:ec:07:b2:48:ec:8f:44:f4:de:0d:b6:
                    15:6f:ae:0c:c8:e9:3f:72:46:bc:ab:fc:5b:25:cb:
                    0b:c2:04:fb:3f:c4:09:07:1d:d1:f8:74:23:03:85:
                    63:d3:16:0d:57:db:2e:b0:b1:57:92:d2:55:e4:3c:
                    01:41:bf:8c:97:43:15:1c:f0:41:bf:a1:f8:70:1f:
                    f3:6a:7b:28:31:50:e0:6a:2e:04:fd:f4:05:df:59:
                    0c:5f:12:6f:4d:27:da:c4:4f:34:c4:1c:4e:4b:88:
                    ca:d3:d8:20:b1:56:7d:28:7e:68:c1:a6:52:dc:86:
                    dd:11:f2:93:df:86:ab:0d:1a:ee:cc:94:69:1e:ce:
                    f6:a9:40:eb:31:82:a3:2f:2a:bf:66:19:87:1d:1c:
                    e0:59:ee:0e:2d:04:fb:0d:c7:e3:ac:a8:a1:5f:0f:
                    8a:02:f8:a1:1d:93:39:19:97:bd:a8:2b:ca:e9:e3:
                    a9:ac:91:3e:ca:c1:8a:f6:7c:01:50:7f:1f:c6:f5:
                    1a:b7:59:fd:6c:53:44:84:db:15:c5:85:23:02:f3:
                    0c:09:d2:2b:e8:53:a0:9f:9b:f8:d5:59:2f:0e:9e:
                    d3:19:99:aa:1c:0d:df:46:a9:db:39:b1:f6:24:77:
                    83:99:ff:61:1f:5f:e8:b6:f6:c4:9b:f5:45:da:a2:
                    03:24:a0:4a:8e:f9:cb:b0:60:3c:21:8f:a3:59:87:
                    71:f0:70:8b:34:b9:66:4a:89:80:fb:b0:c9:1d:da:
                    b0:a9:ec:2f:1b:b3:3f:9c:cd:f2:c3:52:e4:92:3b:
                    49:85:c1:1d:f7:91:e3:91:28:d3:39:65:0b:6b:49:
                    02:33:04:32:36:b1:3a:a3:c4:b2:c2:a9:ac:24:3e:
                    43:45:47:95:9b:bf:31:94:6a:16:47:b3:9d:bd:a2:
                    0a:c1:0c:f8:43:c6:35:99:c7:50:77:6f:ed:90:68:
                    5d:eb:fd:5d:f1:df:01:03:c5:f0:15:d3:68:7c:7d:
                    65:0e:00:23:ec:fa:d5:34:68:a2:ea:e8:96:5e:45:
                    5f:a5:fd:63:b4:cd:9b:45:c3:3f:d3:78:18:a6:8c:
                    89:4d:7d:ff:50:0b:87:ff:7c:02:c2:55:ed:5f:e4:
                    7c:c8:a2:59:21:3c:26:e1:ad:e1:6c:46:b6:d8:8e:
                    24:97:e1:63:93:0a:de:12:3d:a9:96:6a:70:a3:fb:
                    a0:90:94:03:a7:23:82:a5:78:83:a9:a3:57:7d:91:
                    16:ed:46:3e:50:3c:ee:46:b5:e4:4f:96:45:7b:9a:
                    c2:be:21
                Exponent: 65537 (0x10001)
        X509v3 extensions:
            X509v3 Subject Key Identifier: 
                6C:52:8B:5E:C7:38:19:55:D1:60:C2:A1:3F:72:B8:A3:43:69:FE:9F
            X509v3 Authority Key Identifier: 
                6C:52:8B:5E:C7:38:19:55:D1:60:C2:A1:3F:72:B8:A3:43:69:FE:9F
            X509v3 Basic Constraints: 
                CA:FALSE
            1.3.6.1.4.1.4128.2100.1: critical
                ...
            1.3.6.1.4.1.4128.2100.201: critical
..`[email protected]@w60.)./g....q......s..z....C@...#FB...C$YD..h..E..
            1.3.6.1.4.1.4128.2100.202: critical
..`.H.e.......@................................................................
            1.3.6.1.4.1.4128.2100.203: critical
..`.H.e.......@................................................................
    Signature Algorithm: rsassaPss
    Signature Value:        
        Hash Algorithm: sha512
        Mask Algorithm: mgf1 with sha512
         Salt Length: 0x20
        Trailer Field: 0x01 (default)
        34:8c:ed:f6:c2:4b:92:46:34:c7:b5:ff:42:6e:3b:8f:d9:e9:
        fb:95:22:d8:33:e6:51:6c:73:85:c4:60:d0:48:d5:9c:9d:0b:
        bd:c2:bb:eb:e1:ba:70:53:ca:12:35:da:bc:07:a9:9d:33:86:
        54:e3:a6:a3:17:0c:36:e1:3c:ac:96:1d:e7:c8:70:75:c9:56:
        aa:da:6f:84:d7:49:e1:dd:db:e8:9f:75:c3:ff:1d:95:d5:d5:
        bd:b7:da:f0:ee:fe:03:9f:ad:ee:36:02:d7:21:f1:40:52:2f:
        27:d0:a6:fa:8a:1a:8e:8e:8d:ca:b4:ad:fa:4f:31:ba:8e:9e:
        62:cf:44:3c:1f:30:09:2b:57:52:13:6c:4e:ff:09:f5:d6:79:
        75:1a:35:c8:36:73:fa:24:95:57:97:9e:9f:85:90:d4:49:72:
        9f:73:63:06:48:15:70:c4:05:b0:0b:60:bd:55:70:c1:6e:7d:
        17:02:7f:d0:89:36:6e:58:23:c2:35:d6:11:04:ce:98:03:d4:
        c7:0d:ff:eb:8f:d6:bf:df:85:38:8f:06:4c:93:20:17:c0:f0:
        ba:32:40:75:7f:fd:11:e5:d3:fa:b5:94:66:83:d4:81:80:d4:
        78:85:5e:37:12:3c:6e:1d:13:94:e5:49:33:8a:b3:ce:3f:07:
        27:92:e9:ef:f9:54:03:73:87:cb:b7:73:95:78:79:b1:71:45:
        83:4d:7e:75:96:76:0e:c0:df:1c:b8:34:0c:76:4a:cb:3a:32:
        90:0d:5a:1c:ac:51:f4:da:d7:58:62:14:94:1f:81:04:5f:7c:
        59:e5:29:b7:8e:76:a5:32:60:3c:2a:eb:9a:aa:0a:77:d2:cf:
        0e:79:00:1e:58:a6:5c:73:99:0a:13:03:88:78:ac:1f:86:22:
        82:08:72:70:dc:e3:e7:bd:7b:b2:7e:77:b0:98:8f:8f:a5:e1:
        bb:d5:71:4c:c8:e8:fa:79:f3:58:33:86:22:e0:d4:d1:41:19:
        62:45:13:e9:3f:ac:96:ca:b3:25:15:84:52:27:1f:6c:ed:e1:
        5b:cf:da:b2:80:03:38:34:a3:0a:c9:21:64:3d:1b:b7:c1:da:
        c3:d4:40:68:5f:a2:1f:0c:1d:fa:0e:91:56:e4:59:cf:3d:c0:
        8a:13:37:1f:8e:f9:ec:c5:f5:5a:34:fb:4c:19:a9:a7:74:84:
        d8:d6:23:39:0a:d7:ef:93:23:a6:28:00:aa:cf:1e:f6:22:e6:
        50:d0:79:78:ca:b8:9b:45:a2:cb:68:bf:65:0d:4e:17:f4:a5:
        d4:aa:49:5a:65:f7:6a:4a:96:ad:cf:af:5e:3c:6f:9a:91:26:
        75:d1:52:20:fc:f8:f7:92

@csharper2005

Copy link
Copy Markdown
Contributor Author

1e23753:

  • Add more guides:
    • Backup and installation (without UART)
    • Return to stock

@openwrt-ai openwrt-ai left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Commit checks

  • 1e23753 "airoha: add support for Nokia XG-040G-MD" — the new commit changes the sysupgrade bootcmd and the UART/ymodem install steps to load the initramfs at 0x85000000 (was 0x90000000), but the "Alternative ... tftp" lines in the same install section still load and bootm the same image at 0x90000000. Was leaving the tftp path at the old address intentional, or should those two lines also use 0x85000000 to match? The code change itself (platform.sh + the factory-image block, IMAGE_SIZE := 131968k = 0x80e0000 matching the data partition that heads the mtd-concat UBI) is consistent.

Generated by Claude Code

@csharper2005

Copy link
Copy Markdown
Contributor Author

Was leaving the tftp path at the old address intentional, or should those two lines also use 0x85000000 to match?

Should be 0x85000000 everywhere. I've updated the commit message. Thanks.

@namidairo

Copy link
Copy Markdown
Contributor

Stock u-boot сontains some certificates. Does this mean there's no chance for open source u-boot?

The units I've seen in the last 5 (!!!) pull requests for this device didn't appear to have secure boot keys burnt in, what does your unit say upon boot? Ie. Secure key exist or Secure key not exist

Ideally you'd also replace ATF (I think these ship with older one without some of the SMC handlers), but I'm not entirely sure what the progress was with getting the Airoha stuff upstreamed.

@openwrt-ai openwrt-ai left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed 1 new commit; no new issues found. The tftp install lines now load/bootm at 0x85000000, matching the rest of the install procedure and the sysupgrade bootcmd — the open question from the previous review is resolved.


Generated by Claude Code

@csharper2005

Copy link
Copy Markdown
Contributor Author

didn't appear to have secure boot keys burnt in, what does your unit say upon boot?

Hi!

Type [C-a] [C-h] to see available commands
Terminal ready
Secure key does not exist

AN7581DRAMC V0.9
pkg_type is BGA2

Does this mean we can use OpenWrt uboot?

Whats was done:

  1. I built OpenWrt uboot and managed to boot to RAM using this files:
xxd openwrt-airoha-an7581-nokia_xg-040g-md-ubi-preloader.bin | head -n 5
00000000: 0100 64aa 7856 3412 0000 0000 0000 0000  ..d.xV4.........
00000010: 5ff9 ec0b 4d22 3e4d a544 c39d 81c7 3f0a  _...M">M.D....?.
00000020: 6000 0000 0000 0000 c7ba 0100 0000 0000  `...............
00000030: 0000 0000 0000 0000 0000 0000 0000 0000  ................
00000040: 0000 0000 0000 0000 27bb 0100 0000 0000  ........'.......
xxd openwrt-airoha-an7581-nokia_xg-040g-md-ubi-bl31-uboot.fip | head -n 5
00000000: 0100 64aa 7856 3412 0000 0000 0000 0000  ..d.xV4.........
00000010: 47d4 086d 4cfe 9846 9b95 2950 cbbd 5a00  G..mL..F..)P..Z.
00000020: 8800 0000 0000 0000 77b2 0000 0000 0000  ........w.......
00000030: 0000 0000 0000 0000 d6d0 eea7 fcea d54b  ...............K
00000040: 9782 9934 f234 b6e4 ffb2 0000 0000 0000  ...4.4.......... 
  1. The problem: I can't boot from the flash (nothing in the serial console). I tried writing these files at different offsets.
  2. I noticed that the stock uboot and the third-party uboot (airoha: an7581: Add support Nokia Bell XG-040G-MD #21896 (comment)) have a different structure and contain certificates. The data at 0x800 similar to those with which OpenWrt uboot begins.
xxd bootloader_0.bin | head -n 10
00000000: 00f0 20e3 00f0 20e3 00f0 20e3 00f0 20e3  .. ... ... ... .
00000010: 00f0 20e3 00f0 20e3 00f0 20e3 00f0 20e3  .. ... ... ... .
00000020: 00f0 20e3 00f0 20e3 00f0 20e3 00f0 20e3  .. ... ... ... .
00000030: 00f0 20e3 00f0 20e3 00f0 20e3 00f0 20e3  .. ... ... ... .
00000040: cc00 9fe5 100f 01ee 6ff0 7ff5 1600 02f1  ........o.......
00000050: 6ff0 7ff5 bc00 9fe5 100f 0cee 300f 0cee  o...........0...
00000060: 6ff0 7ff5 6901 00eb ac10 9fe5 100f 11ee  o...i...........
00000070: 0100 80e1 100f 01ee 6ff0 7ff5 020c a0e3  ........o.......
00000080: 110f 01ee 0001 08f1 6ff0 7ff5 510f 11ee  ........o...Q...
00000090: 0708 00e2 030b 80e3 510f 01ee 6ff0 7ff5  ........Q...o...

xxd -s 0x800 bootloader_0.bin | head -n 5
00000800: 0100 64aa 7856 3412 0000 0000 0000 0000  ..d.xV4.........
00000810: 5ff9 ec0b 4d22 3e4d a544 c39d 81c7 3f0a  _...M">M.D....?.
00000820: 0004 0000 0000 0000 99c1 0100 0000 0000  ................
00000830: 0000 0000 0000 0000 d6e2 69ea 5d63 e411  ..........i.]c..
00000840: 8d8c 9fba be99 56a5 00c8 0100 0000 0000  ......V.........

Do you know how to combine openwrt-airoha-an7581-nokia_xg-040g-md-ubi-preloader.bin and openwrt-airoha-an7581-nokia_xg-040g-md-ubi-bl31-uboot.fip to get working bootloader for the spi-nand?

@csharper2005

Copy link
Copy Markdown
Contributor Author

Changes:

@openwrt-ai openwrt-ai left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed the new head; the two PR commits (1d9a9dc mtd-concat, 0e66a17 device support) are unchanged in content since the last review — the head SHA moved due to a rebase onto current main. The rebase correctly carries CONFIG_MTD_VIRT_CONCAT=y into config-6.18 (the base now defaults to kernel 6.18), and the device block, DTS, and install/MAC sections match the prior reviewed state. No new issues found.


Generated by Claude Code

@csharper2005

Copy link
Copy Markdown
Contributor Author

Changes:

  • Add OpenWrt U-Boot and All-in-UBI layout support
Screenshot from 2026-06-06 17-06-02

The patch was copied from mediatek target.

Signed-off-by: Mikhail Zhilkin <[email protected]>
Link: openwrt#23569
Signed-off-by: Hauke Mehrtens <[email protected]>
This command is required to read and set device MAC address. The patch
was copied from mediatek target.

Signed-off-by: Mikhail Zhilkin <[email protected]>
Link: openwrt#23569
Signed-off-by: Hauke Mehrtens <[email protected]>
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 <[email protected]>
Link: openwrt#23569
Signed-off-by: Hauke Mehrtens <[email protected]>
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 [email protected]:/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 <[email protected]>
Link: openwrt#23569
Signed-off-by: Hauke Mehrtens <[email protected]>
@hauke
hauke force-pushed the nokia_xg-040g-md branch from 91fc9f2 to a6ecb09 Compare June 29, 2026 00:03
@openwrt-bot
openwrt-bot merged commit a6ecb09 into openwrt:main Jun 29, 2026
1 check passed
@science2468

Copy link
Copy Markdown

@csharper2005
Hi, This U-Boot support FM25G02B and SkyHigh or only support SkyHigh ?

@csharper2005

Copy link
Copy Markdown
Contributor Author

@csharper2005 Hi, This U-Boot support FM25G02B and SkyHigh or only support SkyHigh ?

SkyHigh only, since I don't have a device with FudanMicro to prepare and test patch for uboot.

@science2468

Copy link
Copy Markdown

@csharper2005 Hi, This U-Boot support FM25G02B and SkyHigh or only support SkyHigh ?

SkyHigh only, since I don't have a device with FudanMicro to prepare and test patch for uboot.

I have a xg-140g-md that use fm25g02b spi-nand. I want try. Could you point me in the right direction?

@csharper2005
csharper2005 deleted the nokia_xg-040g-md branch June 29, 2026 15:50
@csharper2005

Copy link
Copy Markdown
Contributor Author

@science2468

science2468 commented Jun 30, 2026 •

Copy link
Copy Markdown

@csharper2005
Hi, Thanks your help!
The U-BOOT tested on xg-140g-md with 402-mtd-spinand-fmsh-add-fm25g0102b.patch.
TTL log:teraterm.log

U-Boot 2026.01-OpenWrt-r0-cc69709 (Jun 29 2026 - 16:17:08 +0000)

CPU:   Airoha AN7581
DRAM:  512 MiB
Core:  31 devices, 19 uclasses, devicetree: embed
Loading Environment from UBI... spi-nand: spi_nand nand@0: Fudan Micro SPI NAND was found.
spi-nand: spi_nand nand@0: 256 MiB, block size: 128 KiB, page size: 2048, OOB size: 128
Volume ubootenv not found!

Could you please review this patch and push it to the mainline?

@csharper2005

Copy link
Copy Markdown
Contributor Author

@science2468 that's nice. I'm not a big expert, but your patch itself looks good to me. I suggest change the patch number (for example to 100-mtd-spinand-fmsh-add-fm25g0102b.patch since 4xx are intended for the new devices) and open a PR (because you're the author).

@science2468

Copy link
Copy Markdown

@science2468 that's nice. I'm not a big expert, but your patch itself looks good to me. I suggest change the patch number (for example to 100-mtd-spinand-fmsh-add-fm25g0102b.patch since 4xx are intended for the new devices) and open a PR (because you're the author).

Thanks, i will try push it.

@xiangtailiang

Copy link
Copy Markdown

Hi @csharper2005, thanks for getting this merged.

Could you clarify the recommended flashing path for devices that have already been converted to tcboot / the third-party U-Boot layout from #21896?

For that case, should users flash the new OpenWrt U-Boot / All-in-UBI images directly, for example using:

  • openwrt-airoha-an7581-nokia_xg-040g-md-ubi-preloader.bin
  • openwrt-airoha-an7581-nokia_xg-040g-md-ubi-bl31-uboot.fip
  • openwrt-airoha-an7581-nokia_xg-040g-md-ubi-initramfs-recovery.itb

Or is it safer/required to first restore the stock layout and then follow the documented “OpenWrt U-Boot layout” installation steps?

If direct migration from tcboot is possible, could you outline the exact commands/steps and which partitions/UBI volumes must be preserved or restored (bosa, ri, ubootenv, etc.)?

@csharper2005

Copy link
Copy Markdown
Contributor Author

Hi @xiangtailiang

Could you clarify the recommended flashing path for devices that have already been converted to tcboot / the third-party U-Boot layout from #21896?

A method that works right here and now -a6ecb09
Check Installation / recovery (OpenWrt U-Boot layout) and please read Notes (OpenWrt U-Boot layout) first.

Or is it safer/required to first restore the stock layout and then follow the documented “OpenWrt U-Boot layout” installation steps?

There is no need for that. You only need a backup of the ri partition.

If direct migration from tcboot is possible, could you outline the exact commands/steps and which partitions/UBI volumes must be preserved or restored (bosa, ri, ubootenv, etc.)?

I have never installed tcpboot and the firmware for it. Therefore, I have no specific recommendations.
But I am almost certain that an installer can be created for a simple transition from one partition layout to another
based on https://github.com/dangowrt/owrt-ubi-installer

Vladdrako pushed a commit to Vladdrako/openwrt that referenced this pull request Aug 22, 2026
This is required for upcoming Nokia XG-040G-MD support.

Signed-off-by: Mikhail Zhilkin <[email protected]>
Link: openwrt#23569
Signed-off-by: Hauke Mehrtens <[email protected]>
Vladdrako pushed a commit to Vladdrako/openwrt that referenced this pull request Aug 22, 2026
This commit fixes sorting in Makefile.

Signed-off-by: Mikhail Zhilkin <[email protected]>
Link: openwrt#23569
Signed-off-by: Hauke Mehrtens <[email protected]>
Vladdrako pushed a commit to Vladdrako/openwrt that referenced this pull request Aug 22, 2026
The patch was copied from mediatek target.

Signed-off-by: Mikhail Zhilkin <[email protected]>
Link: openwrt#23569
Signed-off-by: Hauke Mehrtens <[email protected]>
Vladdrako pushed a commit to Vladdrako/openwrt that referenced this pull request Aug 22, 2026
This command is required to read and set device MAC address. The patch
was copied from mediatek target.

Signed-off-by: Mikhail Zhilkin <[email protected]>
Link: openwrt#23569
Signed-off-by: Hauke Mehrtens <[email protected]>
Vladdrako pushed a commit to Vladdrako/openwrt that referenced this pull request Aug 22, 2026
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 <[email protected]>
Link: openwrt#23569
Signed-off-by: Hauke Mehrtens <[email protected]>
Vladdrako pushed a commit to Vladdrako/openwrt that referenced this pull request Aug 22, 2026
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 [email protected]:/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 <[email protected]>
Link: openwrt#23569
Signed-off-by: Hauke Mehrtens <[email protected]>
Quarx2k pushed a commit to Quarx2k/OpenWRT-BE7000 that referenced this pull request Sep 22, 2026
This is required for upcoming Nokia XG-040G-MD support.

Signed-off-by: Mikhail Zhilkin <[email protected]>
Link: openwrt/openwrt#23569
Signed-off-by: Hauke Mehrtens <[email protected]>
Quarx2k pushed a commit to Quarx2k/OpenWRT-BE7000 that referenced this pull request Sep 22, 2026
This commit fixes sorting in Makefile.

Signed-off-by: Mikhail Zhilkin <[email protected]>
Link: openwrt/openwrt#23569
Signed-off-by: Hauke Mehrtens <[email protected]>
Quarx2k pushed a commit to Quarx2k/OpenWRT-BE7000 that referenced this pull request Sep 22, 2026
The patch was copied from mediatek target.

Signed-off-by: Mikhail Zhilkin <[email protected]>
Link: openwrt/openwrt#23569
Signed-off-by: Hauke Mehrtens <[email protected]>
Quarx2k pushed a commit to Quarx2k/OpenWRT-BE7000 that referenced this pull request Sep 22, 2026
This command is required to read and set device MAC address. The patch
was copied from mediatek target.

Signed-off-by: Mikhail Zhilkin <[email protected]>
Link: openwrt/openwrt#23569
Signed-off-by: Hauke Mehrtens <[email protected]>
Quarx2k pushed a commit to Quarx2k/OpenWRT-BE7000 that referenced this pull request Sep 22, 2026
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 <[email protected]>
Link: openwrt/openwrt#23569
Signed-off-by: Hauke Mehrtens <[email protected]>
Quarx2k pushed a commit to Quarx2k/OpenWRT-BE7000 that referenced this pull request Sep 22, 2026
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 [email protected]:/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 <[email protected]>
Link: openwrt/openwrt#23569
Signed-off-by: Hauke Mehrtens <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

core packages pull request/issue for core (in-tree) packages kernel pull request/issue with Linux kernel related changes target/airoha pull request/issue for airoha target

Projects

None yet

Development

Successfully merging this pull request may close these issues.