The mv88e6xxx DSA switch module is loaded from modules-boot.d, but its
Marvell PHY driver is only loaded later from modules.d. Without the PHY
driver registered at switch probe, the ports attach to the generic PHY
driver and use polling instead of the device-specific driver and IRQs.
Load marvell at boot priority 18, before the DSA switch at priority 41.
This restores the Marvell 88E1540 driver on the NEC IX2106 when using
kmod-dsa-mv88e6xxx.
Signed-off-by: Kosuke Shibuya <kakiringopcneko@gmail.com>
Link: https://github.com/openwrt/openwrt/pull/26522
Signed-off-by: Robert Marko <robimarko@gmail.com>
The Qualcomm Crypto Engine has no driver in this target
(CONFIG_CRYPTO_DEV_QCE is not set), so nothing binds the crypto and
cryptobam nodes. While they are enabled the GCC clock controller keeps
waiting for them and logs, on every boot:
qcom,gcc-ipq9574 1800000.clock-controller: sync_state() pending
due to 73a000.crypto
Disable both nodes in the SoC dtsi with a new kernel patch instead of
in each board, as suggested in review, and drop the now redundant
override from ipq9570-kiwi-dvk.dts. This also covers the SBE1V1K and
the other ipq9574 boards without touching their DTS.
Tested on an SBE1V1K (hardware 4.0) with kernel 6.18.60 by comparing
two otherwise identical builds, with the nodes disabled in the board
DTS.
Signed-off-by: Jackie Han <jackie.han@gmail.com>
Link: https://github.com/openwrt/openwrt/pull/26516
Signed-off-by: Robert Marko <robimarko@gmail.com>
Device specification
--------------------
SoC Type: Realtek RTL9302D
RAM: 512MB
Flash: Macronix MX25L25645G 32MiB
Ethernet: 2x4 port RTL8224 2.5G PHY (MDIO 1-4, 5-8)
2x SFP+ 10G
LEDs: 1x power green
1x SYS green (GPIO 7)
8x3 LEDs per RJ45 port
1x green (1G link/activity)
1x orange (2.5G link/activity)
1x orange PoE
2x2 LEDs per SFP+ port
1x green
1x red
Button: Reset (GPIO 5)
Console: 1x CISCO-style RJ45 RS232 port (38400 8n1)
USB ports: 1x USB2
Bootloader: Realtek U-Boot 2011.12
PoE: 2x Hasivo HS104PTI PSE (I2C 0x0d, 0x15)
MCU / Watchdog: Hasivo STC8 MFD (I2C 0x6f)
PoE LEDs: Hasivo STC8 MFD (I2C 0x4d)
RTC: NXP PCF8563 (I2C 0x51)
Technical notes
---------------
1. Partition Layout:
The switch ships with separate RUNTIME (0x300000, 7 MiB) and RUNTIME2
(0xa00000, 22 MiB) flash partitions. These are merged into a single
contiguous 29 MiB 'firmware' partition (0x300000..0x2000000) for the
OpenWrt kernel and rootfs.
2. Web UI Factory Image Format:
The stock firmware 'imi' daemon accepts web uploads packaged in a
proprietary multi-region format:
- A minimal reproducible tar.gz archive containing switch/other/do_next
(which issues 'reboot -f' if executed)
- Appended with an MD5 hash (OEM MD5 implementation, stopping at first
NUL byte)
- Followed by the raw sysupgrade image (kernel + squashfs, <= 7 MiB)
- Terminated by a 28-byte trailer (magic 0x90ABCDEF, model '9312',
tag 'owrt', region sizes, and a 4-byte folded SHA-256 checksum)
The factory image is generated by hasivo-web-factory.py during build.
During stock Web UI upload, 'imi' directly flashes the OpenWrt image
into RUNTIME (mtd10) while leaving RUNTIME2 (mtd12 / JFFS2) intact.
3. First-Boot MAC Address Migration:
Stock switches have a dummy 'ethaddr=00:E0:4C:00:00:00' in the U-Boot
environment (BDINFO) and store the factory MAC address in Cisco dotted
format in /mnt/mac.txt on the stock JFFS2 filesystem in RUNTIME2.
On first boot, mtd_jffs2_get_mac_txt in 02_network loops over the
firmware partition at offset 0x700000 using block2mtd, mounts JFFS2
read-only, and reads and canonicalizes mac.txt. When found, 02_network
immediately writes this MAC to the U-Boot environment on flash via
fw_setenv before rootfs_data is initialized.
4. PoE, LED MCU, and Peripheral Subsystem Support:
- Dual Hasivo HS104 4-channel PoE PSE controllers at 0x0d (ports 1-4)
and 0x15 (ports 5-8) on the shared I2C bus (i2c_poe) with direct
voltage telemetry and 500 ms status polling.
- Front-panel PoE status LEDs driven by an STC8 MCU at 0x4d via the
register-bit-led syscon binding, dynamically triggered by Linux
PSE-PD events (pse-0-000d:port* and pse-0-0015:port* delivering
triggers). The shared I2C bus is pinned to i2c0 in DTS aliases to
ensure deterministic LED trigger binding.
- STC8 management MCU at 0x6f providing hardware watchdog servicing
(kmod-hasivo-mcu-wdt) and board temperature telemetry
(kmod-hasivo-mcu-sensor).
- NXP PCF8563 RTC at 0x51 on the shared I2C bus.
- GPIOs 3, 4, 5, and 7 reclaimed from the SPI0 controller via pinctrl
on &gpio0.
Installing OpenWrt
------------------
Method 1: Stock Web UI (Recommended)
1. Log into the switch's web management interface.
2. Navigate to TOOLS -> Upgrade.
3. Select the OpenWrt factory image
(openwrt-realtek-rtl930x-horaco_zx-sw82ts-l2p-squashfs-factory.tar.gz).
4. Click Upgrade. The switch flashes RUNTIME and reboots into OpenWrt.
5. On first boot, OpenWrt automatically migrates the factory MAC address
from stock JFFS2 to u-boot-env.
Method 2: UART / TFTP Recovery
1. Connect to UART at 38400 8n1 using a CISCO-style console cable.
2. Enter the bootloader by pressing Ctrl-C, z, h in sequence during the
countdown.
3. Configure a compatible board model:
`setenv boardmodel RTL9301_8218B_4XGE`
4. Turn on networking: `rtk network on`
5. Connect a DAC cable to port 10 (right SFP+ port).
6. Turn on the port: `rtk 10g 27 dac50cm`
7. Load the initramfs image
(openwrt-realtek-rtl930x-horaco_zx-sw82ts-l2p-initramfs-kernel.bin)
via TFTP:
`tftpboot 0x84f00000 <TFTP-IP>:<initramfs-image.bin>`
8. Boot into OpenWrt: `bootm 0x84f00000`
9. Once booted, transfer the sysupgrade image
(openwrt-realtek-rtl930x-horaco_zx-sw82ts-l2p-squashfs-sysupgrade.bin)
to `/tmp` and run:
`sysupgrade -n /tmp/<sysupgrade-image.bin>`
Note: The switch has an external hardware watchdog managed by the STC8
MCU that reboots the switch after a few minutes if not serviced. OpenWrt
includes the kmod-hasivo-mcu-wdt driver to service the watchdog
automatically.
Signed-off-by: Manuel Stocker <mensi@mensi.ch>
Link: https://github.com/openwrt/openwrt/pull/23602
Signed-off-by: Markus Stockhausen <markus.stockhausen@gmx.de>
The l2_tbl_flush_ctrl member is only used by SoC-specific fast_age
implementations. Use the corresponding register constants directly,
as the RTL931x implementation already does.
Remove the member from rtldsa_config and all four SoC initializers.
Move the four flush control register defines into l2.c, their only
remaining user.
No functional change intended.
Assisted-by: ChatGPT (OpenAI GPT-6 Astra)
Link: https://github.com/openwrt/openwrt/pull/26515
Signed-off-by: Markus Stockhausen <markus.stockhausen@gmx.de>
The only users of l2_ctrl_0 are the SoC-specific RTL838x and RTL839x
L2 hash functions. Use their register constants directly, as the
RTL930x and RTL931x L2 code already does.
Remove the member from rtldsa_config and all four SoC initializers.
Move the corresponding register defines into l2.c, their only
remaining user.
No functional change intended.
Assisted-by: ChatGPT (OpenAI GPT-6 Astra)
Link: https://github.com/openwrt/openwrt/pull/26515
Signed-off-by: Markus Stockhausen <markus.stockhausen@gmx.de>
On openwrt-25.12 the initramfs kernels of BR200-WP, HiveAP-330 and
WS-AP3715i no longer fit below the simpleImage loader at 0x1500000. The
wrapper then links the loader at 0x1600000 while the uImage header still
points to 0x1500000, so these images cannot boot. On main they are within
0.2 MiB of the limit.
WS-AP3710i and WS-AP3825i already link their loader at 0x3000000. Use
this address for all simpleImage devices and drop the device-specific
wrapper entries. This also moves TL-WDR4900 v1, which is not affected
yet.
Link: https://github.com/openwrt/openwrt/issues/25302
Signed-off-by: Grische <github@grische.xyz>
Assisted-by: Claude:claude-opus-5 Claude:claude-opus-5-5
Link: https://github.com/openwrt/openwrt/pull/25257
Signed-off-by: Robert Marko <robimarko@gmail.com>
The board DTS deletes blsp1_spi4 before it adds the i2c node for the
second temperature sensor at the same address. The delete is not
needed: ipq8074.dtsi keeps blsp1_spi4 disabled, and it already
describes 0x78b9000 both ways, as blsp1_i2c5 and blsp1_spi5.
Drop the /delete-node/ and the blank line after it, so the comment
sits directly above the i2c node it describes.
Tested on a ZyXEL NBG7815: spi@78b8000 is in the DT, disabled and
without a device, while i2c@78b8000 probes as i2c-1 and the second
tmp103 at 0x70 reads as before.
Signed-off-by: Semih Baskan <strst.gs@gmail.com>
Link: https://github.com/openwrt/openwrt/pull/26512
Signed-off-by: Robert Marko <robimarko@gmail.com>
rockchip/armv8 defaults to IOMMU passthrough, so the AV1 decoder is
given the identity domain of the Verisilicon IOMMU and its frame buffers
still have to come from CMA. Give the masters of that IOMMU a translated
domain whatever the system default is, as is done for rockchip-iommu.
Signed-off-by: Daniel Golle <daniel@makrotopia.org>
The Verisilicon IOMMU driver hands its runtime PM operations to the
driver core through pm_sleep_ptr(), so on a kernel without
CONFIG_PM_SLEEP, as rockchip/armv8 builds it, the IOMMU has no runtime
PM callbacks: its clocks are never enabled and the first buffer the AV1
decoder maps ends in an asynchronous SError. Add the fix sent upstream,
which uses pm_ptr() instead.
Link: https://lore.kernel.org/r/e8114502dc91f5fb709509291fdd85e27545dfb6.1792716048.git.daniel@makrotopia.org
Signed-off-by: Daniel Golle <daniel@makrotopia.org>
The RK3588 AV1 decoder sits behind a Verisilicon IOMMU which Linux 6.18
does not drive, so the decoder has no IOMMU at all and allocates every
frame buffer from the CMA pool: a single 1080p AV1 stream exhausts it,
and AV1 playback fails with __cma_alloc errors.
Backport the driver, its two fixes and the RK3588 device tree node from
Linux 7.2, without the MAINTAINERS entry, and package it as
kmod-iommu-vsi. The device tree patches following the new node are
refreshed.
Signed-off-by: Daniel Golle <daniel@makrotopia.org>
procd creates /dev/dma_heap/* owned by root with mode 0600, as no rule
matches the dma_heap subsystem. A media player allocates its frame
buffers from the system heap when decoding in software for a KMS plane,
and as an unprivileged user it cannot open the heap: Kodi then finds no
buffer object able to allocate by size and drops every VP9 frame.
Create the heap nodes in video, like the DRM card nodes.
Signed-off-by: Daniel Golle <daniel@makrotopia.org>
The debloat hack collects the dma-buf objects in dma-buf-objs-y and
links them into dma-shared-buffer.o. Its heaps/Makefile hunk lists the
heap objects in dma-buf-objs as well, but only drivers/dma-buf/Makefile
reads that variable, so heaps/ builds nothing: DMABUF_HEAPS_SYSTEM and
DMABUF_HEAPS_CMA are silently ignored and /dev/dma_heap stays empty on
every target enabling them, rockchip/armv8 and bcm27xx among them.
Add the heap objects to dma-buf-objs in drivers/dma-buf/Makefile by
their path under heaps/, as is done for dma-heap.o, so that they are
linked into dma-shared-buffer.o. The objects built for targets without
DMABUF_HEAPS are unchanged.
Fixes: 33b6885975 ("generic: fix debloat dma-buf 5.10 patch")
Signed-off-by: Daniel Golle <daniel@makrotopia.org>
The HDMI transmitters of the RK3228, RK3328, RK3576 and RK3588 sit
behind a separate PHY driver. Without it the display stays dark, and on
the RK3588 the VOP2 takes a pixel clock from that PHY, so the DRM device
fails to probe with "failed to get pll_hdmiphy0". The Innosilicon PHY of
the RK3228 and RK3328 was not built at all, and the Samsung HDPTX PHY of
the RK3576 and RK3588 was a package of its own that nothing installed.
A PHY is of no use without the display driver, so kmod-drm-rockchip
now carries both and loads them before rockchipdrm. The RK3399, RK3566
and RK3568 drive their HDMI PHY from inside the bridge and need neither.
Fixes: 444686aecc ("rockchip: add display, GPU, codec and audio kernel modules")
Signed-off-by: Daniel Golle <daniel@makrotopia.org>
b0aaa81a166e client: keep request parsing inside the bytes that are actually buffered
8e0d492c1d3f client: release script slot when the peer closes with an unfinished body
8791d398c80c uhttpd: cap script slots per source to prevent pool monopolisation
93b05e0b65d9 ubus: keep ubus list response encoding within encodable bounds
Also expose the new -W option as max_requests_per_source UCI settings key
to allow tuning how many of the global script slots a single source
address may occupy at once. When the key is unspecified, the upstream
default of half of max_requests, rounded up, applies.
Fixes: https://github.com/openwrt/uhttpd/security/advisories/GHSA-788h-w5m4-j5xv
Fixes: https://github.com/openwrt/uhttpd/security/advisories/GHSA-p2hf-3hpj-hfpc
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
Enable SA/DA MAC filtering for non-CPU ports during RTL930x L2
initialization instead of configuring it on each port enable.
Remove the family_id check from rtldsa_port_enable() and replace
the sw_w32_mask() calls with regmap_set_bits().
Assisted-by: ChatGPT (OpenAI GPT-6 Astra)
Link: https://github.com/openwrt/openwrt/pull/26490
Signed-off-by: Markus Stockhausen <markus.stockhausen@gmx.de>
The Lianguo LG510S-4T2XS is a managed switch with four 10G RJ45 ports
and two SFP+ cages.
Hardware:
- SoC: Realtek RTL9303
- RAM: 128 MiB
- Flash: 16 MiB SPI NOR (Winbond W25Q128JV)
- Ethernet: 4x 10G RJ45 (RTL8264B), 2x SFP+
- LEDs: 1 system LED, 2 LEDs per port
- Buttons: 1 reset button
- UART: 3.3 V, 115200 8N1, header J5 (GND, TXD, RXD, 3V3)
- Power: 12 V DC, 2.5 A, barrel jack (centre positive)
Installation:
1. Back up the stock firmware first. Connect to the serial console and
stop U-Boot by pressing Esc during the countdown.
2. Boot the initramfs image over TFTP:
rtk network on
setenv ipaddr <switch IP>
setenv serverip <TFTP server IP>
tftpboot 0x84000000 openwrt-...-initramfs-kernel.bin
rtk network off
bootm 0x84000000
3. Save the stock runtime partition: cat /dev/mtd5 > /tmp/runtime.bin
and copy it off the switch.
4. Copy the sysupgrade image to /tmp and run
sysupgrade -n /tmp/openwrt-...-squashfs-sysupgrade.bin
Installation from the stock web interface:
1. Back up the stock image and configuration under the firmware and
configuration backup pages.
2. Upload the factory.bix image on the firmware upgrade page and wait
until it reports success.
3. Reboot. The stock firmware may hang while rebooting; if the switch
does not come back, power-cycle it. The image is already written.
MAC addresses:
All ports use the ethaddr value from the U-Boot environment in the
bdinfo partition.
Assisted-by: Claude:claude-opus-5-5
Signed-off-by: Andre Brait <andrebrait@gmail.com>
Link: https://github.com/openwrt/openwrt/pull/26346
Signed-off-by: Markus Stockhausen <markus.stockhausen@gmx.de>
Enable user control of history size both in memory and file size,
increasing the memory space to allow up to 2000 entries (or 256 on
SMALL_FLASH and LOW_MEMORY_FOOTPRINT devices). This is a follow
on to the busybox ash history series in e23b37b2d9 and 0ab0a1d669.
Default remains as before (256 entries, both for memory and disk),
so as to avoid possible issues with increased footprint.
On both x86 and ath79, busybox binary size is unchanged across
several test builds.
Signed-off-by: Eric Fahlgren <ericfahlgren@gmail.com>
Link: https://github.com/openwrt/openwrt/pull/26482
Signed-off-by: Robert Marko <robimarko@gmail.com>
mkfs.ext2 picks a random UUID and directory hash seed for the SYSA boot
partition of the WatchGuard Firebox T40 sdcard image. The hash seed also
decides the readdir order of the single block root directory, so the
rebuilder sees both the UUID and the file order change:
-Linux rev 1.0 ext2 filesystem data, UUID=0c77d998-0c7a-4958-ab70-b5bdc157e8ef, volume name "SYSA"
+Linux rev 1.0 ext2 filesystem data, UUID=d49bc495-9c93-455a-b31e-aa92e044359c, volume name "SYSA"
Derive both from IMG_PART_DISKGUID like apm821xx and gemini do, using
the partition number 3 as the last byte.
Link: https://github.com/openwrt/openwrt/pull/26376
Signed-off-by: Paul Spooren <mail@aparcar.org>
The initramfs is a bare arm64 Image without a device tree, so booting it via
tftpboot requires fetching the DTB separately. Falling back to U-Boot's control
DT ($fdtcontroladdr) is not an option: it lacks clocks and interrupts, and
mvneta/sdhci fail to probe, leaving no network.
Wrap the initramfs into a FIT with the board DTB, as done for the Turris Omnia
and Methode uDPU, so it boots with a single `tftpboot $kernel_addr_r <file>;
bootm $kernel_addr_r`.
The vendor U-Boot (turris_mox) supports FIT; tested with a FIT built from the
25.12.6 initramfs and DTB: eth0 links at 1Gbps.
Link: https://github.com/openwrt/openwrt/pull/26456
Signed-off-by: Paul Spooren <mail@aparcar.org>
CoreNet platforms use a separate device ID table which does not match
IFC nodes after the invalid "simple-bus" compatible was removed. As a
result, the IFC platform device and its flash children are not probed.
Add the fix submitted upstream. This restores NOR and NAND probing on
the T4240RDB and avoids the need for a device tree workaround on the
WatchGuard Firebox M200.
This also restores the switch ports on the WatchGuard Firebox M300.
Their MAC addresses come from NVMEM cells in NOR flash, so the missing
flash device causes the switch probe to defer indefinitely.
Signed-off-by: Pawel Dembicki <paweldembicki@gmail.com>
[use 100 as patch prefix; document M300 switch fix in commit message]
Signed-off-by: Stijn Tintel <stijn@linux-ipv6.be>
rteth hands frames to the switch with an uncomputed layer 2 FCS. On
RTL930x they only reach the link partner intact while CRC_CPU_RC_EN
(MAC_L2_GLOBAL_CTRL0, bits 24:23) is set. With 0 the link partner
receives none of them and counts receive errors instead; 1, 2 and 3
work (see #26463). Nothing in the tree writes the field; it reads 1 as
booted.
Set it to 1 in rteth_930x_hw_en_rxtx(), as already done for RTL838x.
RX_CHK_CRC_EN (bit 4 of the CPU port) stays as it is: the CPU's traffic
also got out with it cleared. Other families are not touched.
Tested on Hasivo S1100W-8XGT-SE (RTL9303), RAM-booted, host on a lan
port:
- After boot the field reads 1. The host gets the CPU's ARP requests
(3/3) and its ping replies (5/5).
- Field cleared by hand: none of them reach the host (0/3, 0/5) and its
NIC counts receive errors.
- With the field still cleared, eth0 down and up: a kprobe and a
kretprobe on rteth_930x_hw_en_rxtx() read MAC_L2_GLOBAL_CTRL0 as
0xc254014a at entry and 0xc2d4014a at return, i.e. the field goes
from 0 to 1. Once a network restart has brought the ports back up,
traffic is back (3/3, 5/5).
Assisted-by: Claude:claude-opus-5-5
Signed-off-by: Gennaro Cimmino <gcimmino@rayonra.net>
Link: https://github.com/openwrt/openwrt/pull/26483
Signed-off-by: Markus Stockhausen <markus.stockhausen@gmx.de>
A loop that accepts the mtd partition to scan,
an offset and the desired variable to test using printenv,
which gets the size and attempts different sizes
for the CRC calculation to find a match with the stored value.
Signed-off-by: Michael Pratt <mcpratt@pm.me>
Link: https://github.com/openwrt/openwrt/pull/24866
Signed-off-by: Robert Marko <robimarko@gmail.com>
When the u-boot-env layout driver probes successfully,
all of the variables are available as NVMEM cells in sysfs,
not just the ones used with a phandle in devicetree.
Use the new function mtd_get_mac_nvmem()
over the older deprecated mtd_get_mac_ascii(),
to avoid an unnecessary read of MTD devices.
Signed-off-by: Michael Pratt <mcpratt@pm.me>
Link: https://github.com/openwrt/openwrt/pull/24866
Signed-off-by: Robert Marko <robimarko@gmail.com>
Devicetree only allows for the base physical address of a device
to be set using NVMEM cells with a phandle to an NVMEM device.
This leaves out the ability to set a VLAN MAC, for example,
a WAN port of a switch to be a VLAN for the WAN firewall side
with a separate MAC address for isolated identification.
When the u-boot-env layout driver probes successfully,
all of the variables are available as NVMEM cells in sysfs,
not just the ones used with a phandle in devicetree.
Add a new function in system.sh that reads the cells in sysfs
based on the MTD device used in the NVMEM driver,
similar to mtd_get_mac_binary() and to how
u-boot tools are patched to detect NVMEM devices.
Ref: 8142c4554ffa ("fw_env: add fallback to Linux's NVMEM based access") # uboot.git
Signed-off-by: Michael Pratt <mcpratt@pm.me>
Link: https://github.com/openwrt/openwrt/pull/24866
Signed-off-by: Robert Marko <robimarko@gmail.com>
Similar to a psychopath, the bootloader of the ESR series demands
to check the CRC of the u-boot environment and replace it with
a CRC based on its own calculation on every boot cycle if it differs,
even if it is replaced with a correct and working one after boot.
When these boards were moved to using the u-boot-env layout driver
instead of userspace scripts for setting the MAC address,
some alternatives were discussed on how to handle this.
- a general fix to ignore the CRC would be inappropriate.
- upstream kernel would reject a method for ignoring the CRC.
- a kernel patch series to make NVMEM devices optional causes random MACs.
- a userspace fix to allow using the NVMEM driver as intended afterward.
After a deep investigation, it was discovered that the environment partitions
are 4k sector size despite being reported as 64k block size in bootloader console.
Therefore these other extreme measures are not necessary, however, the method
for fixing the CRC in userspace is provided by parent commits, and a helper function
to determine the correct size that represents an existing CRC is added afterward.
Thanks to recent kernel patches that added the env-size property
we can inform the layout driver of the true range to calculate the CRC with.
NVMEM detection with env-size is also supported in u-boot tools since version v2026.10.
In the uboot-tools scripts, we make sure to delete the "ubootenv" config file,
so that u-boot tools uses the NVMEM device instead of any previous uci settings.
Reviewed-by: Tomasz Maciej Nowak <tmn505@gmail.com>
Tested-by: Tomasz Maciej Nowak <tmn505@gmail.com>
Signed-off-by: Michael Pratt <mcpratt@pm.me>
Link: https://github.com/openwrt/openwrt/pull/24866
Signed-off-by: Robert Marko <robimarko@gmail.com>
Repair of a corrupted CRC in a u-boot environment can be done
with simple shell commands, thanks to the ability to abuse gzip.
When gzip compresses data, it creates a CRC32 little-endian checksum
in exactly the same form that a u-boot environment uses in the gzip footer.
For big-endian systems, u-boot uses a big-endian checksum,
so it must be read backwards from gzip. Therefore,
we have two versions of the function for endianness with mtd devices.
In order to facilitate different situations properly
these script functions allow for a userspace fix as a one-time execution
of a combined action that reads the environment, repairs the CRC,
adds an indicator variable, and writes the u-boot environment back
to the same or different partition so a bootloader doesn't mangle it further.
The success of correcting the CRC, and possibly migration, of the u-boot
environment is indicated by modifying it with a new variable "owrt_crc_fix".
The indicator variable is necessary to differentiate the fixed partition
from the bogus default environment, so that u-boot tools return an exit status
other than success when not properly discovering the fixed CRC partition.
Also, on the next sysupgrade, this prevents the fixup from happening again.
The uboot-tools are not allowed to write to the new partition directly,
as an NVMEM device is considered read-only by the kernel,
however, the mtd utility bypasses this if the parent mtd partition
is not marked as read-only in devicetree.
To handle writing a new variable,
another function writes a temporary uboot-tools environment config
so that the new variable can be written
to the new environment before it is written back to flash.
The function uses an optional while loop with sleep to ensure that
the NVMEM cells are available to use by checking the sysfs
for whether it exists yet so that later scripts can safely get values,
as using this is a rare situation that causes the NVMEM driver to probe late.
Signed-off-by: Michael Pratt <mcpratt@pm.me>
Link: https://github.com/openwrt/openwrt/pull/24866
Signed-off-by: Robert Marko <robimarko@gmail.com>
Support for changing the probe defer timeout in Kconfig was recently added.
This allows for using Kconfig to extend the time in which
devices are expected to be able to probe since the last probe
before the kernel declares an error and stops trying.
This helps all devices probe in rare cases where a device
takes an exceedingly long time to probe and has a dependent (consumer) device,
or, if an action in userspace is required to allow the device to probe,
the device will be given a chance to probe past late_initcall() during init.
In this case for Openwrt, it is possible to attempt userspace fixes in preinit
where otherwise the probe attempts would not occur again after preinit starts.
Signed-off-by: Michael Pratt <mcpratt@pm.me>
Link: https://github.com/openwrt/openwrt/pull/24866
Signed-off-by: Robert Marko <robimarko@gmail.com>
For the rare case in which a u-boot environment CRC is corrupted
and must be fixed in userspace during init in the boot cycle,
allow the associated NVMEM cells to defer their probe.
This allows userspace enough time to fix the CRC and make other changes
or migrate the environment before the last probe attempt,
or to allow debugging attempts during preinit where otherwise
the probe would not be attempted again after preinit starts,
so that dependent devices like ethernet drivers can successfully probe.
This also avoids the need to reboot the device after a fix during preinit
in order to have a working network and with a non-random MAC address.
Use a new devicetree property "allow-probe-defer" to make this hack
more upstream friendly and device optional, whether or not it is acceptable.
Signed-off-by: Michael Pratt <mcpratt@pm.me>
Link: https://github.com/openwrt/openwrt/pull/24866
Signed-off-by: Robert Marko <robimarko@gmail.com>
Similar to variable names with the pattern eth[0-9]addr,
some vendors have used variable names with the pattern RADIOADDR[0-9]
in order to store MAC addresses in the environment variables.
Because this variable name pattern is not documented,
processing them as binary addresses automatically
may not be upstreamable and the patch may need to be moved to hacks.
Signed-off-by: Michael Pratt <mcpratt@pm.me>
Link: https://github.com/openwrt/openwrt/pull/24866
Signed-off-by: Robert Marko <robimarko@gmail.com>
Variable names with the pattern eth[0-9]addr is documented by u-boot
in a README file doc/README.enetaddr as being the preferred way
to store MAC addresses in the environment variables,
so process them as a binary address automatically.
Suggested-by: Tomasz Maciej Nowak <tmn505@gmail.com>
Signed-off-by: Michael Pratt <mcpratt@pm.me>
Link: https://github.com/openwrt/openwrt/pull/24866
Signed-off-by: Robert Marko <robimarko@gmail.com>
Although it is not common, many other variable names for MAC addresses may be used,
particularly "athaddr", "wlanaddr", "wanaddr", and "mac_addr" in certain models.
Support a longer list of variable names for post processing as a MAC address.
Signed-off-by: Michael Pratt <mcpratt@pm.me>
Link: https://github.com/openwrt/openwrt/pull/24866
Signed-off-by: Robert Marko <robimarko@gmail.com>
Although it is not common, some board models from some vendors have
a MAC address stored in u-boot environment as a quoted form, e.g.
ethaddr="AA:BB:CC:DD:EE:FF"
This is acceptable formatting for a u-boot environment variable, however,
it makes parsing MACs in post processing inconsistent and currently fails.
Add a second condition for processing to match the MAC address with quotes
by allowing a longer length and setting a shifted offset to compensate.
The mac_pton() function has strict behavior on the length and location
of delimiters for each octet and that each digit is hexadecimal,
so attempting different offsets of the same string is not problematic.
Signed-off-by: Michael Pratt <mcpratt@pm.me>
Link: https://github.com/openwrt/openwrt/pull/24866
Signed-off-by: Robert Marko <robimarko@gmail.com>
Backport a small change in u-boot-env layout driver
which catches the case where "ethaddr" variable values
are quoted before post processing, in order to prevent
the nvmem cell not being created due to the post processing
function returning invalid when failing to parse due to large length.
This is a small step towards supporting quoted MAC addresses,
and at the very least guarantees that all variables
become an nvmem cell whether or not they can be processed as MACs.
Signed-off-by: Michael Pratt <mcpratt@pm.me>
Link: https://github.com/openwrt/openwrt/pull/24866
Signed-off-by: Robert Marko <robimarko@gmail.com>
Make the compiler happy by giving this header's functions
an initial NULL value for the created pointers.
An "uninitialized variable" warning was experienced on GCC 10.2.1 20210110.
Signed-off-by: Michael Pratt <mcpratt@pm.me>
Link: https://github.com/openwrt/openwrt/pull/24866
Signed-off-by: Robert Marko <robimarko@gmail.com>
The AN7583 carries the same TRNG block as the EN7581, at the same
address and on the same interrupt. CONFIG_HW_RANDOM_AIROHA is already
enabled, so this gives the subtarget a /dev/hwrng.
Signed-off-by: Vitaliy Sochnev <sochnev.v.74@gmail.com>
Link: https://github.com/openwrt/openwrt/pull/25290
Signed-off-by: Robert Marko <robimarko@gmail.com>
Backport U-Boot commit ce82cd191de2 to U-Boot 2026.07 and enable the
TRNG driver for Airoha builds. AN7581 and AN7583 boards have TRNG nodes,
allowing U-Boot to provide /chosen/kaslr-seed.
Signed-off-by: Vitaliy Sochnev <sochnev.v.74@gmail.com>
Link: https://github.com/openwrt/openwrt/pull/25290
Signed-off-by: Robert Marko <robimarko@gmail.com>
Every forwarded frame crosses the CPU port twice, so with LAN and WAN
behind switch port 8 alone, traffic in both directions adds up to at
most 1 Gbit/s. AMAC1 is connected to port 7: describe it, put wan1 and
wan2 on it with their DSA conduit, and keep LAN on port 8.
Give the AMAC1 interrupt (eth0) to CPU1 and keep RPS off: with each CPU
port on its own CPU, RPS only adds work, and the br-lan RPS to CPU1
used so far roughly halves bidirectional throughput.
AMAC1 probes first and is now eth0; AMAC2, which carries LAN, is eth1.
TCP forwarded through the router, before and after this commit
(Mbit/s):
before after
both directions, total 898 1554
WAN->LAN 915 922
LAN->WAN 917 921
LAN->WAN, MSS 536 795 685
A single direction with small packets is now handled by one CPU, which
costs that last case.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Rosen Penev <rosenp@gmail.com>
Link: https://github.com/openwrt/openwrt/pull/26005
Signed-off-by: Robert Marko <robimarko@gmail.com>
Let b53 move user ports to another CPU port with port_change_conduit,
keeping port 8 as the default one, and limit the port based VLAN of a
user port to its own CPU port so the host does not receive flooded
frames twice.
Port 8 of BCM58xx needs the prepended Broadcom tag while its other CPU
ports use the regular one, and a switch tree has one tagging protocol,
so make brcm-prepend use the regular tag layout on CPU ports other than
8.
Nothing changes until a board describes another CPU port and a port is
moved to it.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Rosen Penev <rosenp@gmail.com>
Link: https://github.com/openwrt/openwrt/pull/26005
Signed-off-by: Robert Marko <robimarko@gmail.com>
Move the ath79 PLL clock code from arch/mips/ath79/clock.c to
drivers/clk/clk-ath79.c. With the QCA956x timer workaround and the
bootstrap reference clock now in setup.c, it only uses the clk API and
its own PLL and SRIF registers. Copy the register definitions it needs
from ar71xx_regs.h into the driver, so it no longer depends on the
mach headers. It stays a CLK_OF_DECLARE driver for the MIPS timer.
COMMON_CLK_ATH79 defaults to ATH79 and is set in the target config.
Tested on an Archer C7 v2, together with the PCIe PLL clock on top:
CPU/DDR/AHB/ref stay at 960/800/266.7/40 MHz, the timer runs and
ath10k probes. COMPILE_TEST builds for other architectures are not
tested.
Assisted-by: LLM
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01X4fQYZAVx9sEHVTUpfBFRM
Signed-off-by: Rosen Penev <rosenp@gmail.com>
Link: https://github.com/openwrt/openwrt/pull/26304
Signed-off-by: Robert Marko <robimarko@gmail.com>
The clock code read the 25/40 MHz bootstrap pins through
ath79_reset_base, although a reference clock rate in the device tree
already took precedence. Every upstream DTS and most OpenWrt boards
give one, but 28 AR933x boards leave it out and rely on the pins.
Read the pins in plat_time_init() instead and register the reference
clock from them only when the device tree has no rate, so the clock
code only uses the clk API. When the device tree does give a rate,
warn if it disagrees with the pins. No board changes behaviour.
Tested on an Archer C7 v2 (QCA9558, pins and DT both 40 MHz):
- With the DT rate there is no warning, and CPU/DDR/AHB/ref stay at
960/800/266.7/40 MHz.
- With the DT rate removed by a test build, the fallback registers ref
at 40 MHz and all rates, MDIO, PCIe and the timer are unchanged.
No AR933x board was tested.
Assisted-by: LLM
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01X4fQYZAVx9sEHVTUpfBFRM
Signed-off-by: Rosen Penev <rosenp@gmail.com>
Link: https://github.com/openwrt/openwrt/pull/26304
Signed-off-by: Robert Marko <robimarko@gmail.com>
Move the enable of the MIPS timer interrupt in the misc interrupt
controller, which QCA956x needs before the clocks are set up, from
qca956x_clocks_init() to plat_time_init(), right before of_clk_init().
The clock code then no longer writes reset block registers, which is a
step towards moving it to drivers/clk.
The order is unchanged. TP9343 boards include qca956x.dtsi and went
through this path too, so the check covers both. Only boot tested on a
QCA9558 Archer C7 v2, where the code does not run: the clock rates and
the timer are unchanged. There is no QCA956x hardware here.
Assisted-by: LLM
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01X4fQYZAVx9sEHVTUpfBFRM
Signed-off-by: Rosen Penev <rosenp@gmail.com>
Link: https://github.com/openwrt/openwrt/pull/26304
Signed-off-by: Robert Marko <robimarko@gmail.com>
When pkg-config is not installed on the system and the openwrt
pkg-config has been compiled, the openwrt pkg-config will be invoked to
find the ncurses libraries to link against scripts/configs/mconf for
"make menuconfig". The openwrt pkg-config provides the path
-L/path/to/openwrt/staging_dir/hostpkg/lib, so if the openwrt ncurses
package has been built, the openwrt ncurses library will be what
scripts/configs/mconf gets linked against.
Commit 036016036e62 ("ncurses: Skip terminfo database install on host")
removed the terminfo database because on systems where the host has
pkg-config installed, the database attempted to install at /usr/lib and
would fatally fail on ncurses versions above 6.5. This is fine on
systems with pkg-config since scripts/configs/mconf will get dynamically
linked against the system's ncurses and use the system's terminfo
database. However, on systems where the host does not have pkg-config
installed and the ncurses package has been built and the pkg-config
package has been built, scripts/configs/mconf will get statically linked
against the ncurses package that no longer has a terminfo database,
causing a failure similar to:
$ make menuconfig
ncurses: cannot initialize terminal type ($TERM="xterm-256color"); exiting
To resolve this, pass the staging directory to host ncurses configure
such that the terminfo database will be installed into the correct
location regardless of the system's presence of pkg-config, instead of
skipping the installation.
Fixes: 036016036e62 ("ncurses: Skip terminfo database install on host")
Reported-by: Hannu Nyman <hannu.nyman@iki.fi>
Reported-by: Edoardo Pinci <epinci@outlook.com>
Tested-by: Hannu Nyman <hannu.nyman@iki.fi>
Signed-off-by: Charlie Jenkins <thecharlesjenkins@gmail.com>
The RPM on this board refuses to enable LDO5:
l5: failed to enable: -ENXIO
qcom_rpm_smd_regulator ...: l5: devm_regulator_register() failed, ret=-6
All RPM SMD regulators are registered from a single probe, so this
failure also removes s1, the CPU supply. cpufreq-dt then stays in
deferred probe and the CPUs never leave the 800 MHz set by the
bootloader.
Nothing in this device tree consumes L5, so drop the node. With it
gone, s1 registers and cpufreq scales between 936 MHz and 2.208 GHz.
Signed-off-by: Gael Julien <jgm509@protonmail.com>
Link: https://github.com/openwrt/openwrt/pull/26466
Signed-off-by: Robert Marko <robimarko@gmail.com>