The LED(s) does not have a label for status, ethernet, or whatsoever.
These two LEDs, are used to form one dual-color indicator. On vendor
firmware, the light is turned from orange to white, when external
storage is detected and ready to use. However, if we use white for any
other triggers (USB / SD card / ethernet), it is difficult to see while
the orange is on. Thus, we change led-running to white to indicate a
successful startup.
Also add the missing pinmux config for uart3 since LEDs take GPIO 7 and
8.
Signed-off-by: David Yang <mmyangfl@gmail.com>
Link: https://github.com/openwrt/openwrt/pull/23182
Signed-off-by: Jonas Jelonek <jelonek.jonas@gmail.com>
The mesh capability check unconditionally ran wpa_supplicant -vmesh to
detect driver support. On devices where wpa_supplicant is not installed,
this produces a "/bin/sh: wpa_supplicant: not found" error in the logs
on every wifi reconfiguration even when no mesh interface is configured.
Guard the invocation with fs.access() so the binary is only executed
when it is actually present, and use its absolute path to avoid relying
on $PATH.
Signed-off-by: Florian Maurer <fmaurer@disroot.org>
Link: https://github.com/openwrt/openwrt/pull/23607
Signed-off-by: Jonas Jelonek <jelonek.jonas@gmail.com>
mac80211's ieee80211_set_antenna() rejects calls with -EOPNOTSUPP once
the radio is started (local->started == true). The spurious failure
triggers a wpa_supplicant invocation in the error path, producing both
a "command failed: Not supported (-122)" message and (where wpa_supplicant
is not installed) a "/bin/sh: wpa_supplicant: not found" message in the
log on every wifi reconfiguration.
In this code path, reset_config() tears down all interfaces before the
antenna is touched, so local->started is false exactly when the antenna
config has changed. Skip the iw phy set antenna call otherwise, matching
the behaviour of mainline OpenWrt's bash mac80211.sh. The trade-off is
that we no longer re-assert the antenna mask on warm reconf if it was
cleared out-of-band (e.g. by a driver reload); in practice drivers do
not clear it mid-life.
Also split the antenna details out of the generic "Configuring '${phy}'
distance: ..." log line so it isn't claimed when the call was skipped.
Assisted-by: Claude:claude-sonnet-4-6
Signed-off-by: Florian Maurer <fmaurer@disroot.org>
Link: https://github.com/openwrt/openwrt/pull/23607
Signed-off-by: Jonas Jelonek <jelonek.jonas@gmail.com>
The NanoPi R2S Plus is a NanoPi R2S with on-board eMMC added. The device
tree (rk3328-nanopi-r2s-plus.dts) is already present in kernel 6.12, and
U-Boot support has been present since v2025.01, so neither a kernel DTS
backport nor a U-Boot patch is required.
Hardware
--------
Rockchip RK3328 (4x Cortex-A53, up to 1.4 GHz)
1GB DDR4 RAM
32GB eMMC 5.1
microSD slot (up to 128GB)
1x 1000 Base-T (native, RTL8211F via GMAC) - WAN
1x 1000 Base-T (USB 3.0, RTL8153B) - LAN
Optional M.2 SDIO Wi-Fi
2x USB 2.0 Type-A host
1x USB-C (5V power input, USB device for Maskrom update)
1x USB-C (onboard USB-to-UART debug console, 1500000 bps)
1x serial debug header / UART0 (3.3V TTL, 3-pin 2.54mm)
2 Buttons (GPIO key, Maskrom)
3 LEDs (SYS red, WAN green, LAN green)
DC 5V/2A power
Operating temperature 0 to 70 C
The MAC addresses are derived from the eMMC CID, so they are stable
regardless of whether the device boots from microSD or eMMC.
Installation
------------
On RK3328 the BootROM boots the eMMC before the microSD slot, so the
Maskrom button must be held to boot from microSD while stock firmware is
still on the eMMC.
How to boot from eMMC:
1. Write the uncompressed sysupgrade image to sdcard
2. Hold the "Mask" button while powering on the device
3. Wait until OpenWrt is fully booted
4. Copy the compressed .gz sysupgrade image to the machine's /tmp folder using scp
5. Run: gunzip -c /tmp/openwrt-...-friendlyarm_nanopi-r2s-plus-squashfs-sysupgrade.img.gz | dd of=/dev/mmcblk1 bs=4M conv=fsync
6. Power the device off, remove the sdcard and power it back on
Tested:
- microSD boot (via Maskrom button) and native eMMC boot
- Both Ethernet ports (RTL8211F WAN, RTL8153B LAN)
- eMMC-derived MAC addresses
Signed-off-by: Grische <github@grische.xyz>
Assisted-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Link: https://github.com/openwrt/openwrt/pull/23854
Signed-off-by: Jonas Jelonek <jelonek.jonas@gmail.com>
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>
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>
Reduce repetition in dcvs_manual, dcvs_get, vth_manual and tap_manual
by hoisting the per-channel enable bit write out of per-case branches
and encoding per-channel register/bit mappings as lookup tables where
the pattern is uniform across channels.
This also fixes two bugs in dcvs_get that were hidden in the switch:
- DCVS1 read never populated dcvs_sign_out; it wrote the sign bit read
(0x14[4:4]) into dcvs_coef_bin and then immediately overwrote it with
the coefficient read, leaving the sign always zero for that channel.
- DCVS3 assigned the manual bit read directly to a bool without the !!
normalisation applied to all other cases.
Link: https://github.com/openwrt/openwrt/pull/23983
Signed-off-by: Jonas Jelonek <jelonek.jonas@gmail.com>
Replace the mode-based approximation in the LEQ adapt+lock step with
proper media-based logic using the newly stored sds->media field. Those
adjustments are based on SDK code and digging through some basics of
signal conditioning.
PCB connections route through an external PHY (PHY-attached); that PHY
handles its own equalization so the SerDes LEQ is left in free-running
auto-adapt with no correction offset. DAC and fiber SFP connect directly
to the SerDes without an intermediate PHY and require a calibrated lock.
Replace the SDK's dacLongCableOffset/eqHoldEnable variable pair with a
single direct_serdes bool and encode the full per-media LEQ correction
into one switch: fiber +3 (direct SerDes, no cable), DAC short +4
(base 3 + 1), DAC long +6 (base 3 + 3).
Fix the MAXHOLD_EN bit (0x17[7]) and the 0x0c[8] write to be gated on
direct_serdes; both were previously conditioned on PCB which is the
PHY-attached case and thus wrong. Fix the LEQ lock to apply to all
direct SerDes connections (DAC + fiber), not just PCB. Also drop the
spurious dead-code branch that was an artifact of the original
transplanting.
No behavioral change because this particular function of calibration is
not used right now but will be in the future.
Link: https://github.com/openwrt/openwrt/pull/23983
Signed-off-by: Jonas Jelonek <jelonek.jonas@gmail.com>
Track the resolved media type in struct rtpcs_serdes alongside hw_mode,
storing it as soon as rtpcs_sds_select_media() resolves it so all
subsequent ops (set_hw_mode, activate, post_config) can access it.
This is unused for now and will be used only in dead code in next
patches. Though, this dead code is going to be used with subsequent
patches.
Link: https://github.com/openwrt/openwrt/pull/23983
Signed-off-by: Jonas Jelonek <jelonek.jonas@gmail.com>
Adapted from the SDK, the calibration functions are just named after
their sequential logic and with a numbering scheme. This doesn't help
understanding what the code is doing. Instead, give some of them
meaningful names where possible, revealing kind of a logical structure.
Link: https://github.com/openwrt/openwrt/pull/23983
Signed-off-by: Jonas Jelonek <jelonek.jonas@gmail.com>
The calibration code is deeply nested with multiple function using
numeric nesting. Though it tries to follow the SDK pattern, this makes
it just unnecessarily complex and confusing. Dissolve some of this
unneeded nesting, together with some minor cleanup here and there.
Link: https://github.com/openwrt/openwrt/pull/23983
Signed-off-by: Jonas Jelonek <jelonek.jonas@gmail.com>
The RTL8367S-VB (Family D) uses a software-emulated VLAN MC table
(emu_vlanmc) since it lacks hardware support for the VLAN MC registers
used by earlier chips.
- Add missing NULL check after kzalloc() in rtl8367b_init_regs() to
prevent NULL pointer dereference on allocation failure.
- Add missing kfree(smi->emu_vlanmc) in rtl8367b_remove() to prevent
memory leak on driver unload.
Signed-off-by: Mieczyslaw Nalewaj <namiltd@yahoo.com>
Link: https://github.com/openwrt/openwrt/pull/23970
Signed-off-by: Jonas Jelonek <jelonek.jonas@gmail.com>
All the layer 3 device specific functions and attributes currently
live in the DSA driver. Add a configuration structure to the layer
3 code. For now provide and fill a dummy value. It will be replaced
with meaningful data with the next patches.
Link: https://github.com/openwrt/openwrt/pull/23963
Signed-off-by: Markus Stockhausen <markus.stockhausen@gmx.de>
This commit removes unnecessary pinctrl nodes for the PHY LEDs. The LEDs are
controlled directly via GPIO pins. Alternate function of gpio33/34 is CTS/RTS
for UART2. It looks like this pinctrl is somehow conflicting with HSUART. This
is likely an errata in the early silicon revision. HSUART is connected to GPS.
The comment incorrectly states that the PHY driver doesn't attach. The driver
attaches correctly, the only drawback is a warning in the log.
Warning:
[ 10.463371] mdio_bus mt7530-0: Failed to setup PHY LED pinctrl
[ 10.494230] mdio_bus mt7530-0: Failed to setup PHY LED pinctrl
[ 10.926028] mt7530-mmio 1fb58000.switch: configuring for fixed/internal link mode
[ 10.933640] mt7530-mmio 1fb58000.switch lan3 (uninitialized): PHY [mt7530-0:09] driver [Airoha AN7581 PHY] (irq=50)
[ 10.944890] mt7530-mmio 1fb58000.switch lan4 (uninitialized): PHY [mt7530-0:0a] driver [Airoha AN7581 PHY] (irq=51)
GPS test:
root@OpenWrt:~# minicom -D /dev/ttyS2 -b 460800
...
$GNGGA,000106.012,,,,,0,0,,,M,,M,,*52
$GNGLL,,,,,000106.012,V,N*60
$GNGSA,A,1,,,,,,,,,,,,,,,,1*1D
$GNGSA,A,1,,,,,,,,,,,,,,,,2*1E
$GNGSA,A,1,,,,,,,,,,,,,,,,3*1F
$GNGSA,A,1,,,,,,,,,,,,,,,,4*18
$GPGSV,1,1,00,1*64
...
Fixes: 99307582de ("airoha: add support for Gemtek W1700K")
Signed-off-by: Aleksander Jan Bajkowski <olek2@wp.pl>
Link: https://github.com/openwrt/openwrt/pull/23936
Signed-off-by: Jonas Jelonek <jelonek.jonas@gmail.com>
GCC 15 defaults to C23, where an empty parameter list "()" means
"(void)" instead of an unspecified argument list. This broke two spots
in the bundled tinysrp sources:
- The interrupt() signal handler in t_truerand.c was declared with
"()", so its type became "void (*)(void)" and no longer matched the
"void (*)(int)" expected by signal():
t_truerand.c:100:32: error: passing argument 2 of 'signal' from
incompatible pointer type [-Wincompatible-pointer-types]
Give it the proper signal handler signature instead.
- The pre-ANSI fallback in t_defines.h declared strchr(), strrchr()
and strtok() with "()". ead.c is compiled without -DHAVE_CONFIG_H,
so STDC_HEADERS is undefined and that legacy branch is taken, where
the zero-argument prototypes now conflict with the declarations in
the standard headers:
tinysrp/t_defines.h:90:30: error: conflicting types for 'strtok';
have 'char *(void)'
Drop the dead K&R branch and include <stdlib.h> and <string.h>
unconditionally; the library's own objects already take this path
via config.h.
Assisted-by: Claude:claude-opus-4-8
Link: https://github.com/openwrt/openwrt/pull/23955
Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
GCC 15 defaults to C23, where an empty parameter list "()" means
"(void)" instead of an unspecified argument list. This broke thc-ipv6 in
two ways:
- thc-ipv6.h declared thc_open_ipv6() with an empty argument list, so
its prototype became "int(void)" and conflicted with the actual
definition "int thc_open_ipv6(char *interface)" and all of its
callers:
thc-ipv6-lib.c:127:36: error: too many arguments to function
'thc_open_ipv6'; expected 0, have 1
thc-ipv6-lib.c:2555:5: error: conflicting types for 'thc_open_ipv6';
have 'int(char *)'
- The alarming() SIGALRM handlers in detect_sniffer6.c and thcping6.c
were declared with "()", so their type became "void (*)(void)" and no
longer matched the "void (*)(int)" expected by signal():
detect_sniffer6.c:140:19: error: passing argument 2 of 'signal'
from incompatible pointer type [-Wincompatible-pointer-types]
Add patches giving the prototype and the signal handlers their proper
signatures.
Assisted-by: Claude:claude-opus-4-8
Link: https://github.com/openwrt/openwrt/pull/23956
Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>