/dev/kvm comes out 0600 root:root, so a hypervisor runs as root.
Add a kvm-support package which allocates the kvm group and puts the node
into it. KVM is built into the kernel where it exists, so no module
carries a dependency on the package; userspace depends on it.
Signed-off-by: Daniel Golle <daniel@makrotopia.org>
The DVB adapter nodes under /dev/dvb come out 0600 root:root, so a
tuner daemon runs as root.
Add a dvb-support package which allocates the dvb group and puts those
nodes into it, and make kmod-dvb-core depend on it.
Signed-off-by: Daniel Golle <daniel@makrotopia.org>
The evdev character devices come out 0600 root:root, so a display server
or any other process reading keyboards and pointers runs as root.
Add an input-support package which allocates the input group and puts the
input nodes into it, and make the evdev and joydev modules depend on it.
The one device profile that ships evdev lists the package directly.
kmod-input-core stays ungated: it carries no device node of its own, and
most drivers built on it deliver their events to in-kernel consumers such
as the keyboard and button handlers.
Signed-off-by: Daniel Golle <daniel@makrotopia.org>
The DRM render and compute nodes, /dev/dri/renderD*, /dev/accel/accel*
and /dev/kfd, come out 0600 root:root, so anything using a GPU for
compute or for accelerated rendering runs as root. They also share the
video group with the modesetting nodes wherever a distribution grants it,
which hands scanout control to every process allowed to compute.
Add an accel-support package which allocates the render group and puts
those nodes into it. No kernel module carries a dependency on it: whether
a device offers a render node is a property of the driver, not of the
module, so userspace that wants the group depends on the package.
Signed-off-by: Daniel Golle <daniel@makrotopia.org>
The display target feature gates every DRM module, but it says nothing
useful: it is set on ten targets, so a mediatek/mt7623 board can have a
display while a filogic board with a MIPI DBI panel cannot, and rockchip
claims it for a NanoPi R2S as much as for a Rock 5B. Whether a board
drives a panel is a per-device choice, not a property of the SoC family.
The DRM and V4L2 nodes also end up 0600 root:root, so a display server
runs as root or not at all.
Add a video-support package which allocates the video and video-capture
groups and installs the hotplug rules for the DRM and V4L2 nodes, and
make the modules depend on it. The dependency is a plain one, not a
select, so the modules are offered once the feature is chosen. Targets
whose display drivers are built into the kernel carry the package in
DEFAULT_PACKAGES, since no module pulls it in for them, and the one
device profile that ships a DRM module on another target lists it
directly. DISPLAY_SUPPORT stays for now, so this changes no existing
selection.
Signed-off-by: Daniel Golle <daniel@makrotopia.org>
The audio group and the rule that puts the ALSA character devices in it
are part of procd and base-files, so every image carries them whether or
not it has a sound card, and a package wanting the group has nothing to
depend on. Playback, capture and MIDI all land in one group as well, so a
process allowed to play is also allowed to record.
Move the lot into a new audio-support package with three groups, audio,
audio-capture and midi, and a hotplug fragment that sorts the sound nodes
between them. kmod-sound-core depends on the package, and so do the image
profiles that ship a sound driver. The dependency is a plain one, not a
select, so sound support is offered once the feature is chosen; userspace
that needs one of the groups depends on the same package. Images without
it fall back to the generic rule and get /dev/snd/* as 0600 root:root.
Signed-off-by: Daniel Golle <daniel@makrotopia.org>
Categories other than Base system are emitted in alphabetical order, so
a category describing the hardware a device has would land halfway down
the package menu among unrelated ones. Emit Hardware support first
instead, ahead of Base system, since which device classes an image
supports is the first thing to choose and everything else follows from
it.
print_package_config_category() returns early for a category no package
uses, so this has no effect until such a package exists.
Signed-off-by: Daniel Golle <daniel@makrotopia.org>
The hotplug rules live in a single /etc/hotplug.json, so a package
that needs a device node named, owned or grouped its own way has no
way to contribute one; the alternatives are patching the shared file
or falling back to a shell script under /etc/hotplug.d.
Load /etc/hotplug.json.d/*.json from inside the device node branch,
ahead of the built-in name rules, and /etc/hotplug-preinit.json.d/*
at the end of the preinit script. Fragments are run in sorted order.
A fragment that creates a node keeps it: the generic rule below still
runs, but its mknod() fails with EEXIST and leaves the node alone.
This is done in preparation for deprecating some of the subtarget-wide
FEATURES flags, instead introducing feature-umbrella packages such as
`video-support` and `audio-support` shipping the hotplug rule snippets
and having all providers (ie. kmods) and users depend on them.
Signed-off-by: Daniel Golle <daniel@makrotopia.org>
The Mercusys MA530 dongle (2c4e:0115) is a Realtek RTL8761BUV, but the
6.18 btusb quirks table does not list the ID, so the controller comes up
without its firmware patch: HCI works, yet LE discovery never reports a
single device. Backport the v7.2 commit that adds the ID with the
Realtek and wideband speech flags.
Signed-off-by: Daniel Golle <daniel@makrotopia.org>
If SGMII with in-band is used on MX86211C then 2.5G will be missing.
Solve it by backporting upstream switch to gpy21x_config_init that also
advertises 2500Base-X.
Signed-off-by: Robert Marko <robert.marko@sartura.hr>
A route through a nexthop object is left out of the offload, but the
switch still looks its destination up. When an offloaded shorter prefix
covers it, the switch forwards that traffic through the prefix's
gateway, and the route the kernel holds never sees a packet.
Where the host table can hold the route, write a trap entry for it, the
way otto_l3_fib_add_v4() already does for a host route with no gateway:
the lookup stops there and the CPU forwards by the kernel's route. A
delete for such a route now reaches the worker as well, and takes that
entry out with the same otto_l3_route_find() and
otto_l3_route_teardown() pair the replace uses.
A prefix route through a nexthop object still gets no entry: here the
prefix table only takes a route once its gateway resolves. Neither does
a host route on a family without a host table.
Tested on an RTL9303 (Hasivo S1100W-8XGT-SE) with the L3 offload on,
this series on main at 248601f492. With 10.99.0.0/16 offloaded through
one host and 10.99.1.1/32 through a nexthop object to the same host,
the /32 gets a trap entry in the host table. Five pings from a second
host reach the first with ttl 63 for 10.99.1.1, forwarded by the CPU,
and with ttl 64 for 10.99.2.2, which only the /16 covers: on this tree
the hardware path leaves the ttl alone. A replace through a gateway
turns the entry into a forwarding one, a replace back makes it a trap
again, and the delete takes it out. A /24 through the nexthop object
gets no entry. No warning or oops in the log.
Assisted-by: Claude:claude-opus-5-5
Signed-off-by: Gennaro Cimmino <gcimmino@rayonra.net>
Link: https://github.com/openwrt/openwrt/pull/25310
Signed-off-by: Markus Stockhausen <markus.stockhausen@gmx.de>
The previous commit leaves a route through a nexthop object out of the
offload. "ip route replace <dst> nhid N" reaches the notifier as a
FIB_EVENT_ENTRY_REPLACE for the new route alone, with no delete for the
route it replaces (fib_table_insert() in net/ipv4/fib_trie.c). If <dst>
was offloaded, its hardware entry stayed programmed with the old
gateway, and nothing took it out afterwards.
Let add, replace and append events for such a route through to
otto_l3_fib_add_v4(). There, before the first nexthop read, which moves
out of the variable initialisers, take out an entry offloaded for the
same table and destination with the otto_l3_route_find() and
otto_l3_route_teardown() pair its replace path already uses, then
return. The teardown cannot sit in the notifier itself: the FIB
notifier chain is atomic, and the teardown takes the table mutex.
A delete for such a route still stops in the notifier: the route was
never offloaded, and otto_l3_fib_del_v4() reads the nexthop array.
Tested on an RTL9303 (Hasivo S1100W-8XGT-SE) with the L3 offload on,
this series on main at 248601f492. A /24 and a /32 through a gateway
each get a hardware entry; replacing either with "nhid 17" takes the
entry out while the kernel keeps the route, replacing it back through
the other gateway programs an entry again, and deleting it afterwards
leaves none. A replace between two gateways without a nexthop object
still leaves exactly one entry. No warning or oops in the log. The
stale entry this commit removes was read from the code, not reproduced.
Assisted-by: Claude:claude-opus-5-5
Signed-off-by: Gennaro Cimmino <gcimmino@rayonra.net>
Link: https://github.com/openwrt/openwrt/pull/25310
Signed-off-by: Markus Stockhausen <markus.stockhausen@gmx.de>
A route through a nexthop object keeps its nexthops in that object, and
the fib_info behind it is allocated with none of its own: for a route
carrying an nhid, fib_create_info() sets the nexthop count to zero and
sizes the structure by it, then points fi->nh at the object
(net/ipv4/fib_semantics.c). fib_info_nh() says the same by warning when
it is asked for a nexthop of such a route, before handing back the
address where the array would have started.
The IPv4 FIB handler reads that address in the variable initialisers of
three of its functions, ahead of every test any of them makes, so
"ip route add ... nhid N" on a switch whose L3 setup is in place takes
the warning and then dereferences whatever follows the allocation as a
net_device. The RTL839x carries that setup outside any config symbol, so
a stock build gets there.
Leave the route alone where the notifier already screens the IPv4 events
it cannot use, which is ahead of all three reads. Leaving it alone
rather than refusing it, as the check on the next line does for an IPv6
gateway, is deliberate: the kernel still installs the route, and an
error returned from this notifier would come back out of
register_fib_notifier(), which replays the routes that already exist -
so one such route present at probe would cost the switch its whole L3
offload rather than that one entry.
Assisted-by: Claude:claude-opus-5
Assisted-by: Claude:claude-opus-5-5
Signed-off-by: Gennaro Cimmino <gcimmino@rayonra.net>
Link: https://github.com/openwrt/openwrt/pull/25310
Signed-off-by: Markus Stockhausen <markus.stockhausen@gmx.de>
When a route is programmed while the switch holds no L2 entry for the
gateway, rtldsa_l2_nexthop_add() invents one carrying the don't-care
port priv->r->port_ignore. Observed on an RTL9303: with such a next hop
the destination receives every forwarded frame twice, once from the
switch and once from the Linux stack. Where the route entry can trap,
do not invent the row, and trap the route to the CPU instead, which is
what otto_l3_fib_add_v4() already does for a host route with no
gateway.
The invented row is written static, so it does not age, and the software
bridge offers no replacement: dsa_user_fdb_event() drops an address
learned on an offloaded port before the driver sees it. Leaving the slot
to the address lets the switch learn it from the traffic the CPU routes,
and a later neighbour update programs a real port. From the code, not
tested: a gateway held as a permanent or NOARP neighbour produces no
such update, so its route stays in software. A route that only claims
entries the switch learned never clears the route count of the entry it
claims: that count may still hold routes forwarding through the entry.
Tested on an RTL9303 (Hasivo S1100W-8XGT-SE) against pristine main,
same board and same rig (main at 19ff245b92; this patch on c09e3f28ba,
which only adds an SPI backport): two hosts on one bridge port, one
untagged in VLAN 1 and one tagged in VLAN 3, a /32 route to each,
programmed after 340 s of neighbour silence so the gateways' L2 entries
have aged out. On main both get a static next hop with the don't-care
port, and five pings collect twelve duplicates: tcpdump at the
destination shows each echo request twice with the same IP id, once at
ttl 64 and once at ttl 63, and the entry is still static afterwards.
With this patch both routes are trapped and the five pings cross in
software without loss or duplicates, each request once at ttl 63. A
trapped route stays trapped while nothing crosses it (ten readings 30 s
apart); the pings let the switch learn the address, and after them the
route is back in hardware on a learned, dynamic entry with the real
port. Programmed while the neighbours are fresh, both kernels behave the
same: a real port and no duplicates. A /24 through the same gateway,
which lands in the prefix table rather than the host one, is trapped the
same way, and its five pings cross at ttl 63 without duplicates.
Not changed here, and the same on both kernels: an entry that ages
while a route already forwards through it keeps its next-hop bit with
the don't-care port, so after 340 s of silence the first of five pings
drew one duplicate before the switch learned the address again.
RTL838x and RTL931x never reach this code: their otto_l3_config carries
no .setup, and both notifiers return early without one, as does an
RTL930x built without CONFIG_NET_DSA_RTL83XX_RTL930X_L3_OFFLOAD. RTL839x
reaches it, but routes through a PIE rule rather than a route entry with
an action, and what its switch does with a route rule that no longer
forwards is not something I could find in the SDK or test. The change is
therefore keyed on use_l3_tables: RTL839x still gets the invented entry
and a PIE rule forwarding through it, exactly as before. Whether it
shows the duplicates too was not tested.
Assisted-by: Claude:claude-opus-5
Assisted-by: Claude:claude-opus-5-5
Signed-off-by: Gennaro Cimmino <gcimmino@rayonra.net>
Link: https://github.com/openwrt/openwrt/pull/25353
Signed-off-by: Markus Stockhausen <markus.stockhausen@gmx.de>
gmac0 used a fixed-link with no phy-handle, so the AR8035 was never
attached and never configured. The PHY comes out of reset with the
RGMII RX delay enabled and the TX delay disabled, and the IPQ8064 MAC
has no internal RGMII delay of its own, so nothing ever enables it and
LAN1 receives but never transmits when booting from flash. Booting via
tftpboot + bootm masked this, as U-Boot leaves the PHY configured.
Point gmac0 at phy1 on mdio0 and use rgmii-id, which is the mode that
makes the at803x driver enable both delays. The fixed-link has to go,
as phylink does not attach a PHY for fixed-link MACs, which also means
the port now autonegotiates instead of being pinned to 1000/full.
Signed-off-by: Rosen Penev <rosenp@gmail.com>
Link: https://github.com/openwrt/openwrt/pull/25452
Signed-off-by: Robert Marko <robimarko@gmail.com>
Passing target flags through EXTRA_CFLAGS leaks them into kernel
module builds on Linux 6.6 and 6.12, causing ARM hard-float ABI
mismatches in generated module objects. Linux 6.18 also forwards
these flags to host tools, where the host compiler rejects them.
Reuse SAN_CFLAGS, normally used for sanitizer options, to pass
target flags to both userspace selftests and their target libbpf
builds on Linux 6.6, 6.12 and 6.18. Host tools and kernel modules
do not consume this variable. USERCFLAGS would only cover the
selftests, leaving their libbpf builds without the target flags.
This covers the targets built by this package; CROSS_BPFTOOL
does not consume SAN_CFLAGS.
Signed-off-by: Tianling Shen <cnsztl@immortalwrt.org>
Link: https://github.com/openwrt/openwrt/pull/25345
Signed-off-by: Robert Marko <robimarko@gmail.com>
phylink_bringup_phy() stores the PHY in pl->phydev before its last
step that can fail. If that step fails, the pointer outlives the
failed connect: a later phylink_connect_phy() gets a permanent -EBUSY,
the SFP path is left with a pointer to a freed phy_device, and a
disconnect detaches the same PHY twice. The fix publishes the pointer
only after the last call that can fail.
It is also the base the pending phylink late-PHY series relies on:
retrying a connect after a failed bringup is what makes this window
reachable.
The fix is in net:
https://git.kernel.org/netdev/net/c/a940003f44e7
The phylink patches that apply on top of it are refreshed for hunk
offsets.
Assisted-by: LLM
Signed-off-by: Aleksei Sviridkin <f@lex.la>
Link: https://github.com/openwrt/openwrt/pull/25459
Signed-off-by: Jonas Jelonek <jonas@jonasjelonek.de>
swconfig,port is used in only two places, here and ramips. This stuff is
already handled in userspace. No need for it here.
This aliases node is not only in the wrong location, it serves no
purpose. Remove.
Signed-off-by: Rosen Penev <rosenp@gmail.com>
Link: https://github.com/openwrt/openwrt/pull/25406
Signed-off-by: Jonas Jelonek <jonas@jonasjelonek.de>
Add support for RTL9313-based Ubiquiti UniFi USW Pro XG 10 PoE switch
with 10x 10G RJ45 and 2x SFP+ ports.
Hardware
========
- RTL9313 switch SoC
- 512 MiB RAM
- 32 MiB SPI-NOR flash
- 10x 100M/1G/2.5G/5G/10G RJ45 ports via RTL8264B and RTL8261BE
- PoE: 10x 802.3bt, 90W per port, 400W total budget
- 2x 1G/2.5G/10G SFP+ ports
- Buttons: 1x Reset
- LEDs:
- System LED white/blue
- RGBW LED per port
- Console: TTL 3.3V, 115200 8N1, populated 4-pin header J19,
front to back: VCC, RX, TX and GND
(device must be opened to access header)
- Etherlighting feature (lighting patterns and color control)
- Vendor firmware: U-Boot + LEDE-based Ubiquiti OS
MAC address
===========
Single MAC address in EEPROM partition, applied to all ports.
Known issues
============
- Etherlighting not controllable, driver WIP. Port LEDs for link work
though. By default, the controller keeps the LEDs in a breathing
state, gated by the link state delivered by the Realtek SoC.
Disclaimer
==========
Stock firmware uses a dual-bank layout (kernel0/kernel1, ~15 MiB each).
OpenWrt replaces both banks with a single contiguous firmware partition.
Flashing OpenWrt overwrites both stock kernel slots; U-Boot remains
intact and can be used for recovery.
Installation
============
1. Enable SSH on the stock UniFi OS and log in with user account.
(at this stage you may make backups of the flash, just to be sure)
2. Copy the OpenWrt sysupgrade image to /tmp on the switch (e.g. via
scp).
3. Adjust IMG below to point at the copied file, then run the block as a
whole. It writes kernel0, splits into kernel1 if the image is larger
than that slot (otherwise invalidates kernel1 so U-Boot cannot pick
a stale bank), and reboots:
IMG=/tmp/openwrt-realtek-rtl931x-ubnt_usw-pro-xg-10-poe-squashfs-sysupgrade.bin
K0_BLOCKS=$((0xec0000 / 0x10000))
dd if="$IMG" of=/dev/mtdblock2 bs=64k count=$K0_BLOCKS conv=fsync
if [ "$(wc -c < "$IMG")" -gt $((0xec0000)) ]; then
dd if="$IMG" of=/dev/mtdblock3 bs=64k skip=$K0_BLOCKS conv=fsync
else
dd if=/dev/zero of=/dev/mtdblock3 bs=64k count=1 conv=fsync
fi
sync
reboot
Then it comes up in OpenWrt.
You may also install the image in any other way, just make sure to
write it to the kernel0 partition and if the image is larger than
15,104 kiB, write the rest to the kernel1 partition, otherwise invalidate
it so U-Boot cannot boot from the second bank.
4. It is recommended to modify the bootcmd to speedup the boot and prevent
any issues due to the dual-boot selection. Since U-Boot by default
uses bootubnt which does a lot of (unneeded) RTK initialization,
quite some time passes until Linux is started. Additionally, the
U-boot logic fiddles with some bits on flash which causes JFFS2
errors in OpenWrt. While this doesn't seem to cause issues yet, be
defensive and set the bootcmd to:
bootm 0xb4150000
This directly boots the uImage from flash, without doing all the
initialization. OpenWrt is able to bootstrap the networking completely
on its own.
It does not matter which bank stock booted from when the dd block
runs: both banks are touched in the same pass (kernel0 written, kernel1
either written or invalidated). With kernel1 invalidated, U-Boot's
internal fallback kicks in and permanently switches to kernel0 on the
next boot, so the device stays on OpenWrt as long as kernel0 is
bootable.
Recovery
========
Since the installation procedure invalidates or partially overwrites
the second bank, recovery requires serial console access (see Hardware
above for pinout).
1. Interrupt U-Boot autoboot by spamming the Escape key during early
boot to drop into the U-Boot prompt.
2. Bring up networking:
rtk network on
3. Transfer an OpenWrt initramfs image via TFTP and boot it:
setenv ipaddr <switch-ipaddr>
setenv serverip <tftpserver-ipaddr>
setenv bootfile openwrt-realtek-rtl931x-ubnt_usw-pro-xg-10-poe-initramfs-kernel.bin
tftpboot
bootm
4. From the running initramfs OpenWrt, do a sysupgrade to reflash
OpenWrt or whatever you want to recover. There is no need for the
complicated procedure from installation since OpenWrt sees the
firmware partition already as a whole.
Return to stock firmware
========================
There is no fully-supported revert path. The stock firmware blob is a
Ubiquiti UBNT archive (header + parts, see firmware-utils' fw.h) that
embeds a u-boot and a kernel0 uImage payload; only the latter is
relevant when writing back to the kernel partitions.
The snippet below extracts the kernel0 uImage from such a blob by
locating the uImage offset and size using binwalk. It is provided as a
best-effort starting point; verify the result before flashing,
otherwise you're on your own:
BLOB=US3.rtl93xx_7.4.1+X.Y.Z.bin
binwalk $BLOB | grep uImage > uimage-info.txt
OFF=$(cut -d\ -f1 uimage-info.txt)
SIZE=$(sed -nE 's/^.*image size: ([0-9]+) bytes,.*/\1/p' uimage-info.txt)
dd if="$BLOB" of=kernel0.uImage bs=1 skip="$OFF" count="$SIZE"
Once you have a clean uImage, it can be written to the kernel partition
from within OpenWrt. If you adjusted the bootcmd during installation,
make sure to restore it to the default "bootcmd=bootubnt". After a reboot,
Ubiquiti's firmware should boot.
Or, if you did backups of the flash before, just write the backup to the
flash.
(lightly modified from Jonas commit adding support for usw-pro-8-poe)
Signed-off-by: Russell Senior <russell@personaltelco.net>
Link: https://github.com/openwrt/openwrt/pull/25425
Signed-off-by: Jonas Jelonek <jonas@jonasjelonek.de>
The BPi-R4 Pro 4E is a Wi-Fi 7 router board based on the MT7988A SoC.
Difference to 8X is that board has only 4GB RAM and does not contain
the Aeonsemi 10G phys.
Wan port uses MT7988 internal 2.5GBit/s phy with no ethmux chip between
so it need overlays to switch between this wan-phy and SFP-Slot.
Specification
-------------
- SoC: Mediatek MT7988A (4x Cortex-A73 @1.8GHz)
- RAM: 4GB DDR4
- Flash: 256MB SPI-NAND, 8GB eMMC, microSD Slot
- Switch: MT7988A built-in switch, MxL86252C
- Ports: 9 ports, 8 usable simultaneously
* 2x 1G RJ45 LAN
* 4x 2.5G RJ45 LAN
* 1x SFP (LAN)
* 1x 2.5G RJ45/SFP Combo (WAN)
- Buttons: Reset, WPS
- LEDs: Power
- USB: On-board VIA VL822 USB3.2/USB2.0 hub
* 1x USB-A 2.0 connector
* 1x USB-A 3.2 connector
* 3x NGFF-KEYB
- PCIe:
* 2x mini-PCIe slots with PCIe 3.0 2-lane interface
* 2x M.2 M-Key slots with PCIe 3.0 1-lane interface (switchable
PCIe signal with M.2 B-Key)
- Debug: USB Type-C console port
- Power: USB Type-C PD 20V or DC barrel connector
Note: This device comes without a MAC address programmed from the
factory. The randomly generated MAC is stored in the U-Boot env on first
boot and used persistently afterwards.
Installation
------------
Uncompress *sdcard.img.gz and write to microSD card, eg. using 'dd'. Use
bootloader menu on the serial console to install SPI-NAND once installed
to SPI-NAND you can used the bootloader menu to install to eMMC. See
instructions for BananaPi R4 for details.
Description is taken from 8X patch and changed to 4E variant.
R4Pro needed a patch for adding aliases to ensure right probe order so add
this here too.
Co-authored-by: Wilfried Teiken <wteiken@teiken.org>
Signed-off-by: Frank Wunderlich <frank-w@public-files.de>
The BPi R4 Pro 4E can boot from microSD, SPI-NAND and eMMC. Add support
for each storage option.
NVME (via pcie3) works in uboot, but bootloader only supports spi and mmc.
Patches are taken from R4Pro 8X and modified for 4E variant.
Co-authored-by: Andrew LaMarche <andrewjlamarche@gmail.com>
Signed-off-by: Frank Wunderlich <frank-w@public-files.de>
The switch applies the egress spanning-tree port state to frames the
CPU sends to a port, so a port that is not forwarding drops them:
kernel STP cannot announce a designated port during the forward
delay, user-space RSTP cannot send proposals from a discarding port,
and LLDP stays silent on blocked ports.
Set BP_FLTR2 in the TX CPU tag. It bypasses the egress spanning-tree
port state and egress VLAN filtering, as IGNORE_STP does when
transmitting on RTL93xx. Skipping the VLAN filter does not widen
where frames go: the CPU names each frame's single destination port
(AS_DPM).
Signed-off-by: Paul Tobias <openwrt-commits@tobias.pt>
Link: https://github.com/openwrt/openwrt/pull/25442
Signed-off-by: Markus Stockhausen <markus.stockhausen@gmx.de>
rtldsa_port_fdb_dump() walks fib_entries rows of the hash table and 64
rows of the CAM, and rtldsa_find_l2_cam_entry() searches 64 CAM rows.
On RTL931x otto_table.c maps the hash table with 32768 rows and the
CAM with 128, but fib_entries stays at 16384 there. So bridge fdb show
misses the entries of the second hash block, which starts at row
16384, and the CAM search never uses rows 64 to 127.
Take the row counts from otto_table_rows() on l2_uc_tbl and
l2_cam_tbl, as the debugfs dump does. The bounds do not change on
RTL838x, RTL839x and RTL930x. On RTL931x the FDB add path can now place
entries in CAM rows 64 to 127. fib_entries itself is left alone, since
it also sizes l2_uc_map.
Compile-tested. On an RTL9303, where the bounds do not change, bridge
fdb show still listed every unicast row of the hardware table. Not
tested on RTL931x hardware.
Assisted-by: Claude:claude-opus-5-5
Signed-off-by: Gennaro Cimmino <gcimmino@rayonra.net>
Link: https://github.com/openwrt/openwrt/pull/25448
Signed-off-by: Markus Stockhausen <markus.stockhausen@gmx.de>
The L2 table dump prints the members and the primary port of a trunk
entry by indexing lags_port_members[] and lag_primary[] with the trunk
id read from the table. Both arrays have MAX_LAGS (16) entries, while
the RTL930x and RTL931x fill functions take the id from a 6-bit and an
8-bit field. The driver should never program an id that large, but a
row carrying one would make the dump read past both arrays.
Print only the id when it is out of range.
Compile-tested. On an RTL9303 the dump still works, but no trunk rows
were present, so neither branch of the check ran on hardware.
Assisted-by: Claude:claude-opus-5-5
Signed-off-by: Gennaro Cimmino <gcimmino@rayonra.net>
Link: https://github.com/openwrt/openwrt/pull/25448
Signed-off-by: Markus Stockhausen <markus.stockhausen@gmx.de>
The GS310TP's PoE MCU (Nuvoton M05xx in front of a BCM59121) is not on
UART1 as the device tree assumed: nothing is received on UART and
realtek-poe logs "No response from PoE controller" every 2 s. The
vendor firmware talks to the MCU over bit-banged I2C on SoC GPIO 4
(SCL) and 5 (SDA), slave address 0x20 (board_conf.ko: poeSmiConf and
its boardI2c entry; ski.ko: poe_bcm59121_* over drv_i2c_*), and a
get-system-info frame sent that way is answered: mode "Auto I2C", 8
ports, device id 0xe121, gen1 dialect.
Describe that bus and the MCU with the realtek-pse-mcu SMBus transport,
map the eight copper PHYs to its PIs like the GS110TPP, and replace
realtek-poe and its board.d PoE budget with the kernel modules. UART1,
where nothing answers, goes back to disabled. The enable line on RTL8231
pin 10 moves from a gpio hog to the driver's disable-ports-gpios, so the
ports are released once the MCU has answered, as the vendor firmware
does.
Signed-off-by: Paul Tobias <openwrt-commits@tobias.pt>
Link: https://github.com/openwrt/openwrt/pull/25451
Signed-off-by: Jonas Jelonek <jonas@jonasjelonek.de>
This commit implements the OpenWrt UBI layout for the ASUS RT-AX59U. The
primary goal is get working Kernel Address Space Layout Randomization
(KASLR). Additionally, this layout frees up ~6MB of extra storage space
for package installation.
Preparation
------------
Make a backup (from OpenWrt for stock bootloader):
* Backup partitions:
apk update && apk add nand-utils
nanddump /dev/mtd0 | gzip -1 -c > /tmp/mtd0_u-boot.bin.gz
nanddump /dev/mtd1 | gzip -1 -c > /tmp/mtd1_UBI_DEV.bin.gz
* Backup nvram, Factory and Factory2 volumes:
cat /dev/ubi0_0 > /tmp/nvram.bin
cat /dev/ubi0_1 > /tmp/Factory.bin
cat /dev/ubi0_2 > /tmp/Factory2.bin
* Copy backup from the /tmp dir on your router to a safe place using scp
Installation
------------
* Attach UART (see 'UART' section for details)
* Run mtkuartboot (see 'mtkuartboot recovery' section for details), exit
the boot menu, and run:
mtd erase ubi
* Run mtkuartboot again and write ubi bl2 and fip via the network, then
reboot.
Default tftp server ip: 192.168.1.254
Default router ip: 192.168.1.1
* Load the ubi initramfs image via tftpboot and execute sysupgrade to
write OpenWrt to spi-nand.
* Copy Factory backup to your router:
scp -O Factory.bin root@192.168.1.1:/tmp
* Check factory volume index:
ubinfo -a
* Prepare and write new factory ubi volume (substitute X with your
factory volume index):
dd if=/tmp/Factory.bin of=/tmp/factory.bin bs=1 count=$((0x65000))
ubiupdatevol /dev/ubi0_X /tmp/factory.bin
UART
----
UART pins are silkscreened on PCB. Connection parameters:
115200, 8N1, 3.3V
U-Boot tftp recovery
--------------------
* Place OpenWrt ubi-initramfs-recovery.itb image on the tftp server (IP:
192.168.1.254)
* Press reset button and power on the router. After ~10 sec release the
button.
* Use OpenWrt initramfs system for recovery (for example, run sysupgrade)
mtkuartboot recovery
--------------------
Use mtk_uartboot and UART connetion for the installation or if BL2 or FIP
in UBI is destroyed:
Link: https://github.com/981213/mtk_uartboot
Start script:
'''
sudo ./mtk_uartboot \
-p mt7986-ram-ddr4-bl2.bin \
--aarch64 \
-f openwrt-mediatek-filogic-asus_rt-ax59u-ubi-preloader.bin \
-s /dev/ttyUSB0
picocom -b 115200 /dev/ttyUSB0
'''
Notes
-----
1. A simple installation without serial console is also possible using a
fork of Daniel's UBI Installer (requires adaptation)
Link: https://github.com/dangowrt/owrt-ubi-installer
Signed-off-by: Mikhail Zhilkin <csharper2005@gmail.com>
Link: https://github.com/openwrt/openwrt/pull/25278
Signed-off-by: Robert Marko <robimarko@gmail.com>
Add a new Trusted Firmware-A (TF-A) build profile for the MediaTek
MT7986 SoC named 'mt7986-spim-nand-ubi-1m-ddr4'.
This profile reduces the UBI starting address (UBI_START_ADDR) from
0x200000 (2MB) down to 0x100000 (1MB). This layout adjustment matches
devices like the ASUS RT-AX59U factory partition offsets and frees up
flash space for the main operating system layout.
Signed-off-by: Mikhail Zhilkin <csharper2005@gmail.com>
Link: https://github.com/openwrt/openwrt/pull/25278
Signed-off-by: Robert Marko <robimarko@gmail.com>
Refactor how OVERRIDE_UBI_START_ADDR is passed to the TF-A build system.
Instead of using hardcoded string matches against the $(PLAT) variable
inside global make flags, move the UBI start address directly into
target-specific definition blocks using a new UBI_START_ADDR variable.
This aligns the UBI partition boundary setup with how FIP_OFFSET and
FIP_SIZE are cleanly tracked across different MediaTek SoCs.
Signed-off-by: Mikhail Zhilkin <csharper2005@gmail.com>
Link: https://github.com/openwrt/openwrt/pull/25278
Signed-off-by: Robert Marko <robimarko@gmail.com>
Define the factory pre-calibration data partition at offset 0x1010 and
pass it to the wifi node via nvmem-cells. This ensures the mt7986
wireless hardware can properly utilize factory-calibrated RF settings.
Signed-off-by: Mikhail Zhilkin <csharper2005@gmail.com>
Link: https://github.com/openwrt/openwrt/pull/25278
Signed-off-by: Robert Marko <robimarko@gmail.com>
Increase the spi-max-frequency from 20MHz to 52MHz for the SPI-NAND flash
on the ASUS RT-AX59U. The underlying Winbond W25N01KV chip natively
supports up to 104MHz, and the MediaTek MT7986A SoC safely handles 52MHz.
It's also 52 MHz in the stock U-Boot:
...
spi-max-frequency = <0x3197500>;
...
Testing with 'dd' reading 16MB from /dev/mtd1 shows a significant
performance improvement (~48% reduction in read time):
Before (20MHz):
256+0 records in
256+0 records out
real 0m 2.86s
After (52MHz):
256+0 records in
256+0 records out
real 0m 1.50s
Signed-off-by: Mikhail Zhilkin <csharper2005@gmail.com>
Link: https://github.com/openwrt/openwrt/pull/25278
Signed-off-by: Robert Marko <robimarko@gmail.com>
GL.iNet GL-X2000 (Spitz Plus) is a dual-SIM 4G LTE Wi-Fi 6 router.
Specifications:
SoC: Qualcomm IPQ5018, dual-core Cortex-A53 @ 1.0 GHz
RAM: 512 MiB DDR3
Flash: 128 MiB SPI NAND (Winbond W25N01GWZEIG)
WLAN: IPQ5018 2x2 2.4 GHz, QCN6122 2x2 5 GHz (802.11ax)
Ethernet: 1x GbE WAN (IPQ5018 internal GE PHY)
1x GbE LAN (Atheros AR8031, SGMII)
WWAN: Quectel EG120K-EA, LTE Cat.12, USB 3.0 SuperSpeed
USB: 1x USB 2.0 host behind an internal hub
Buttons: reset
LEDs: power, internet, 2.4G, 5G, 4x signal strength
Serial: 3v3 TTL, 115200 8N1; 4-pin header labelled GND/RX/TX/3V3 on
the mainboard, under the Quectel module in the top right
corner. The case opens after pulling the four rubber feet
Power: DC 9-35 V, shipped with a 12 V 2.5 A supply
Misc: PWM fan, dual SIM slots (muxed inside the modem)
The base MAC address is stored at offset 0x6 of the 0:art partition; the
first six bytes are erased, which is why U-Boot reports the ART address as
invalid. WAN uses the base address (this is the one on the label), LAN
base+1, the 2.4 GHz radio base+2 and the 5 GHz radio base+3. The ethernet
addresses come from nvmem cells. The board deliberately has no ethernetN
aliases: GL.iNet's U-Boot uses them to write its own mac-address
properties into both GMAC nodes (a placeholder for WAN, the base address
for LAN), which of_get_mac_address() would prefer over the nvmem cells.
The modem enumerates at SuperSpeed and therefore requires the IPQ5018 USB3
UNIPHY, so both usbphy0 and usbphy1 are enabled. uqmi cannot communicate
with this modem, so modemmanager has to be installed separately to use it.
The QCN6122 is wired to the second radio instance, so wifi@b00b040 with
userpd3 is enabled rather than wifi@b00a040: the stock device tree enables
wifi2@/userpd3 and leaves wifi1@/userpd2 disabled. That instance places
its BDF and M3 dump above the default q6 region, so the reserved region
is grown accordingly.
Board data for the two radios is submitted separately to
firmware_qca-wireless. It is taken from the stock firmware's wifi_fw
partition, which is a squashfs image: bdwlan.b24 for the IPQ5018 2.4 GHz
radio and qcn6122/bdwlan.b60 for the QCN6122 5 GHz radio, matching the
qcom,board_id values of 0x24 and 0x60 that the stock device tree assigns
to the respective radios. The two radios require distinct board data;
sharing a single BDF leaves the front-end misconfigured and the affected
radio unable to transmit or receive at usable power.
The device tree started from the initial port by Hostle, was largely
rewritten by georgem83 and further reworked by Andreas Boeckler, published
in the OpenWrt forum thread linked below. It is carried here with fixes for
the WLAN board data, the QCN6122 radio instance, the U-Boot environment
partition and the fan cooling map.
Link: https://forum.openwrt.org/t/plain-openwrt-on-gl-x2000/231554
Installation:
Interrupt the bootloader over serial (115200 8N1) by typing "gl", then
TFTP the initramfs image and boot it:
tftpboot 0x44000000 openwrt-qualcommax-ipq50xx-glinet_gl-x2000-initramfs-uImage.itb
bootm 0x44000000
Then flash the factory image with sysupgrade.
Signed-off-by: Gilberto Conde <gilbertorconde@gmail.com>
The U-Boot script embedded in the GL.iNet QSDK factory image hardcodes
the GL-B3000 flash layout. Replace the UBI offset and size with
placeholders filled in by the gl-qsdk-factory recipe, so other GL.iNet
boards with a different layout can use the same script.
The script is copied under a per-device name, which keeps the FIT
description unchanged and avoids devices overwriting each other's
substituted copy in KDIR_TMP.
Signed-off-by: Gilberto Conde <gilbertorconde@gmail.com>
The pinctrl driver leaves GPIO13's fourth function slot empty, so PWM3
cannot be routed there. The GL.iNet GL-X2000 drives its fan from PWM3 on
GPIO13, and the stock firmware muxes the pin with select value 4:
gpio13 : out low func4 8mA no pull
pin 13 (GPIO_13): 1941010.pwm function pwm3 group gpio13
Select value 4 corresponds to the empty slot, so add pwm3 there and list
gpio13 in pwm3_groups.
Accepted upstream via pinctrl-qcom/for-current, so this can be dropped
once the kernel is bumped to 7.3 or later. The backport carries the
upstream diff unchanged; 0305, which adds gpio30 to pwm3_groups
downstream, is refreshed to apply on top of it.
Link: https://patch.msgid.link/20260921093419.2870168-1-gilbertorconde@gmail.com
Signed-off-by: Gilberto Conde <gilbertorconde@gmail.com>
Two real commits since the previous pin:
mediatek: mt7622: move PMIC init before PLL/DRAM stage
Fixes a hang in DRAM calibration on reboot when cpufreq had lowered
Vcore before the reset, by moving PMIC init earlier so it no longer
depends on the Vcore level left over from the previous boot.
mediatek: mt7981, mt7986, mt7987, mt7988: add SMCCC TRNG support
Implements the standard SMCCC TRNG interface (upstream U-Boot
doesn't support the MTK-specific one, our uboot-mediatek does).
Tested on MT7981 by upstream; not yet verified on the other three
SoCs by upstream.
Mirror hash verified via an independent fresh clone of the pinned
commit.
Signed-off-by: Daniel Golle <daniel@makrotopia.org>
The property dates back to the CAF snps_gmac driver, where it told the
MAC which MDIO bus its PHY was on, and has been carried over from device
to device since the driver was replaced by upstream stmmac in 2015.
Nothing in the tree parses it anymore.
The MDIO bus a PHY lives on is taken from the bus the phy node itself was
registered on, so the phy-handle references do not need the extra hint and
nothing changes functionally by dropping it.
Signed-off-by: Rosen Penev <rosenp@gmail.com>
Link: https://github.com/openwrt/openwrt/pull/25453
Signed-off-by: Robert Marko <robimarko@gmail.com>
Several rtw88 USB and SDIO chips do not always report the TX status of a
frame within RTW_TX_PROBE_TIMEOUT (500 ms). The driver then drops the
tracking skbs and warns
rtw_8822bu 3-1:1.0: failed to get tx report from firmware
every one to three seconds on an access point serving clients that use
power save. mac80211 never learns the ACK status of those frames, which
hostapd uses to tell whether a polled station is still there.
Add the pending upstream patch that uses the 2500 ms timeout, so far
applied only to RTL8723DU, for every USB and SDIO device and keeps
500 ms for PCIe. It is adapted to backports 7.2, which does not have
the RTL8723BS condition yet.
Pending upstream, submitted to rtw-next:
https://lore.kernel.org/linux-wireless/20260924004637.9958-1-pkshih@realtek.com/
Tested with backports 6.12.96 on a TP-Link Archer T4U v3 (RTL8812BU,
handled by rtw_8822bu) as a 2.4 GHz AP with six associated clients.
Signed-off-by: Josef Schlehofer <pepe.schlehofer@gmail.com>
Link: https://github.com/openwrt/openwrt/pull/25303
Signed-off-by: Jonas Jelonek <jonas@jonasjelonek.de>
BlueZ creates Bluetooth Low Energy HID devices through uhid, so a
Bluetooth remote or keyboard needs it in addition to kmod-bluetooth.
Signed-off-by: Daniel Golle <daniel@makrotopia.org>
The L2 table dump now lives in l2.c as realtek_otto_l2/fdb and reads
the whole table on every family. Remove the old rtl838x/l2_table copy,
which stopped at half the table on RTL931x and could print stack
contents as trunk data on RTL838x and RTL839x.
The other files in the rtl838x debugfs directory are unchanged.
Tested on an RTL9303 (Hasivo S1100W-8XGT-SE): rtl838x/l2_table is gone
and realtek_otto_l2/fdb lists 150 static FDB entries next to the
learned ones.
Assisted-by: Claude:claude-opus-5-5
Signed-off-by: Gennaro Cimmino <gcimmino@rayonra.net>
Link: https://github.com/openwrt/openwrt/pull/25394
Signed-off-by: Markus Stockhausen <markus.stockhausen@gmx.de>