Commit graph

25232 commits

Author SHA1 Message Date
dechao_gong
0c3839973b arch/arm/ameba: fix CI failures in RTL8730E port
Two CI issues in the RTL8730E (AmebaSmart CA32) port:

1. PREBUILD used $(ARCHOPTIMIZATION) which injects --param=min-pagesize=0
   on GCC>=12.  arm-none-eabi-gcc in CI does not recognise this flag.
   Fix: replace $(ARCHOPTIMIZATION) with explicit -Os -ffunction-sections
   -fdata-sections in both the fwlib and wifi PREBUILD loops, matching the
   pattern already used by the other Ameba ICs (rtl8721dx/8720f/8721f).

2. boards/arm/rtl8730e/rtl8730e_evb/configs/nsh/defconfig was out of sync
   with `make savedefconfig` output (missing CONFIG_ARCH_CHIP_RTL8730E_CA32,
   wrong ordering of several NETUTILS options, and redundant entries that
   are auto-selected by Kconfig).  Regenerated with olddefconfig+savedefconfig.

Signed-off-by: dechao_gong <dechao_gong@realsil.com.cn>
Assisted-by: Claude <noreply@anthropic.com>
2026-09-21 18:43:22 +08:00
dechao_gong
d8224051e7 arch/arm/ameba: fix nxstyle and cmake-format issues in RTL8730E port
Fix all nxstyle and cmake-format violations found by CI checkpatch:

- tools/nxstyle.c: add whitelist entries for SDK mixed-case symbols
  (CPU_, Diag, TRNG_, System_, vPort) used in amebasmart stubs
- arch/arm/src/rtl8730e/rtl8730e_serial.c: fix block comment lengths,
  long lines (replace Unicode arrows with ASCII), align inline comments
- arch/arm/src/rtl8730e/rtl8730e_flash_stubs.c: fix long lines and
  missing blank line after declaration
- arch/arm/src/rtl8730e/rtl8730e_wifi_stubs.c: rename nDeviceId to
  device_id, add Public Functions section header
- arch/arm/src/rtl8730e/rtl8730e_memorymap.h: fix block comment lengths
  and inline comment column alignment
- arch/arm/src/rtl8730e/hardware/rtl8730e_loguart.h: wrap long comment
- arch/arm/src/common/ameba/ameba_os_wrap.c: add missing blank lines
  after declarations
- boards/arm/rtl8730e/rtl8730e_evb/src/rtl8730e_bringup.c: add missing
  blank line after extern declaration
- arch/arm/src/rtl8730e/CMakeLists.txt: apply cmake-format
- boards/arm/rtl8730e/rtl8730e_evb/src/CMakeLists.txt: apply cmake-format

Signed-off-by: dechao_gong <dechao_gong@realsil.com.cn>
2026-09-21 18:43:22 +08:00
dechao_gong
c4ddd5add7 arch/arm/ameba: implement CMake build for RTL8730E (AmebaSmart CA32)
Replace the CMake skeleton with full SDK build machinery, mirroring
the make-side ameba_board.mk.  RTL8730E differs from the KM4-based
ICs in three ways that prevent a direct include(ameba_board.cmake):
- No SDK autoconf / image2 ldscript generation: the board uses its own
  dramboot.ld and a static prebuilt platform_autoconf.h
- No NP firmware build: KM0/KM4 are prebuilt blobs in prebuilt/
- No -mcmse: CA32 is ARMv7-A, not Cortex-M33; uses -DCONFIG_ARM_CORE_CA32

The ameba_build_lib() helper (adapted from ameba_board.cmake) compiles
SDK sources with an isolated flag set into libameba_fwlib.a and
libameba_wifi.a, avoiding NuttX header conflicts.

Key additions:
- libameba_fwlib.a: arch.c + log.c + sscanf_minimal.c always; IPC for
  WiFi/FlashFS; ameba_flash_ram.c for FlashFS
- lib_rom.a linked for GPIO or FlashFS (GPIO_Init, Pinmux_Config, etc.)
- libameba_wifi.a + prebuilt WHC host libs for WiFi
- VFS1 geometry extracted from platform_autoconf.h via
  target_compile_definitions (set_property(SOURCE) has scope issues in
  NuttX's include()-based CMake structure)
- `flash` target calls ameba_smart_flash.sh

Verified: gpio (1186 targets) and nsh (1530 targets) configs both
build cleanly; /data mounts at correct 2 MB partition size.

Signed-off-by: dechao_gong <dechao_gong@realsil.com.cn>
Assisted-by: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-09-21 18:43:22 +08:00
dechao_gong
4416660ce2 arch/arm/ameba: enable SMP on AmebaSmart CA32 (RTL8730E)
RTL8730E has dual Cortex-A32 cores (CA32) in the AP domain.  Core1 is
powered off by default and requires an explicit HSYS power-on sequence
before ATF SP_MIN can service the PSCI CPU_ON call.  Without it, SP_MIN
writes the entry point to the mailbox and times out waiting for Core1 to
poll it.

Add rtl8730e_core1_power_on() that mirrors SDK smp.c:rtk_core1_power_on():
assert reset, assert isolation, two-stage power-on with up_udelay() for
correct 50/50/500/50 us timing, then release isolation and reset.  Call it
from up_cpu_start() before psci_cpu_on().

Enable CONFIG_SMP / CONFIG_SMP_NCPUS=2 / CONFIG_ARM_PSCI in the nsh
defconfig.

Enabling SMP also exposed a latent WHC skb alignment bug: the Realtek
WHC WiFi driver keeps the AP/NP DDR views coherent with by-VA
DCache_Clean/Invalidate at SKB_CACHE_SZ (64 on RTL8730E) granularity,
which requires every skb buffer to be cache-line aligned.  The port had
omitted CONFIG_MM_DEFAULT_ALIGNMENT (defaulting to 8; the 8721Dx parts
set 32), so heap-allocated skb buffers were unaligned and the cache
maintenance spilled onto the neighbouring skb struct, corrupting its
immutable buf pointer (seen as skb->buf = 0x05 and a TX memcpy data
abort on "renew wlan0").  This was harmless on single core -- the
non-shareable DDR mapping made the stray maintenance a no-op -- but the
SMP shareable mapping plus real dual-core concurrency turned it into a
hard fault.  Set CONFIG_MM_DEFAULT_ALIGNMENT=64 in the nsh defconfig.

Hardware verified on RTL8730E (C-cut): /proc/cpuinfo shows both processor 0
and processor 1; getprime 2 completes two concurrent threads in ~573 ms
(same as single-thread), confirming true parallel execution across both cores.
"renew wlan0" now obtains a DHCP lease (192.168.1.101) without faulting.

Assisted-by: Claude Sonnet 4.6 <noreply@anthropic.com>
Signed-off-by: dechao_gong <dechao_gong@realsil.com.cn>
2026-09-21 18:43:22 +08:00
dechao_gong
7b5861122f arch/arm/ameba: use the real efuse WiFi MAC on AmebaSmart
On AmebaSmart the standard WHC_API_WIFI_GET_MAC_ADDR pull API times out:
the KM4 NP firmware snapshot linked into this image does not register a
handler for it, so wifi_get_mac_address() blocks ~12s per call and cannot
be used to fill the netdev MAC.

The NP does, however, PUSH its real efuse MAC to the host at wifi-on time
via WHC_API_SET_NETIF_INFO, which lands in the host-side
lwip_wlan_set_netif_info() glue.  Previously that glue discarded the
address and ameba_wifi_get_mac() synthesised a random locally-administered
MAC, which then diverged from the MAC the NP actually associates with (the
NP's 802.11 RX filter drops unicast frames addressed to the random MAC, so
DHCP OFFERs never arrive).

Cache the pushed efuse MAC in lwip_wlan_set_netif_info() and return it from
ameba_wifi_get_mac(); the random MAC remains only as a fallback for the
window before the NP has pushed.  ameba_wifi_connect() then mirrors it to
the NP with wifi_set_mac_address() so both sides agree.  The per-IC guard
uses CONFIG_AMEBASMART, not CONFIG_ARCH_CHIP_RTL8730E: these files are
compiled by the board PREBUILD step with the vendor SDK autoconf, where
NuttX Kconfig symbols are invisible.  The other Ameba parts keep their
working GET_MAC efuse path unchanged.

Verified end to end: ifconfig shows the real Realtek OUI MAC
(00:e0:4c:..), association and DHCP complete in a single round.

Signed-off-by: dechao_gong <dechao_gong@realsil.com.cn>
2026-09-21 18:43:22 +08:00
dechao_gong
f156812c0c arch/arm: add Realtek AmebaSmart (RTL8730E) CA32 support
Add NuttX support for the Realtek AmebaSmart (RTL8730E) running on the
CA32 (Cortex-A32) application core, with the KM4/KM0 cores kept as
vendor firmware (KM4 acts as the WiFi network processor over WHC IPC).

Stage 1 bring-up, hardware verified:

  - CA32 boot / exception vectors / MMU + page allocator / heap
  - LOGUART console (RX via KM0-owned IPC + shared memory)
  - IRQ controller, timer, serial
  - On-chip SPI NOR flash MTD -> littlefs mounted at /data
  - WHC-host WiFi netdev (STA): scan / connect / DHCP, verified end to
    end (association -> 4-way -> DHCP -> ping, bidirectional TCP)

IC-agnostic Ameba glue is shared from arch/arm/src/common/ameba via a
relative VPATH entry (matching the rtl8721dx pattern), which also avoids
the empty mkdeps --dep-path that a leading-":" VPATH entry produced and
which intermittently broke parallel .ddc dependency generation.

The FIP packaging / flash image assembly is driven by
common/ameba/tools/ameba_smart_flash.sh from the board scripts.

Vendor blobs and build artefacts under the board prebuilt/ directory are
kept out of the tree via prebuilt/.gitignore.

Signed-off-by: dechao_gong <dechao_gong@realsil.com.cn>
2026-09-21 18:43:22 +08:00
Justin Hammond
a763b873b4 arch/risc-v/eic7700x: Name the reset lines through procfs.
Implements get_line, so /proc/reset names all 324 lines and gives the
register and bit each lives in.  The framework asks status() for the
asserted state.

The names do not survive compilation: they live in the enumeration, so
without a table a listing gives only numbers, and working back from one
to a peripheral means counting through the header.  The table costs
about 8 KiB and is built only when the procfs entry is.

The ids are sparse, 324 lines across a space of 1952, so the table is
sorted by id and searched rather than indexed, and an id naming no line
returns -ENODEV.  The framework skips those, which is what leaves the
listing dense.

Assisted-by: Claude:claude-opus-5
Signed-off-by: Justin Hammond <justin@dynam.ac>
2026-09-21 16:29:12 +08:00
Justin Hammond
74ac90f692 arch/risc-v/eic7700x: Add the CRG reset controller.
The Clock and Reset Generator holds the reset line for every block on
the SoC.  This registers all 324 of them with the NuttX reset framework
as a provider implementing assert, deassert, reset and status.

A line is addressed as its control register index times thirty two plus
its bit, across 61 registers, so the ids are sparse in a space of 1952
and decoding one is arithmetic rather than a lookup.

Each register carries three masks over the same bits: which bits are
lines at all, which the hardware will not let software drive, and which
would take down the system that asserted them.  The last are still
registered and can be read and released; only assert and reset refuse
them.  Where each line falls, and why, is recorded beside the table.

The lines are active low, which the manual never states.  It is inferred
from the field naming, the reset defaults and both vendor Linux drivers.
If that inference is wrong then deassert asserts, so the evidence for it
is written out in full rather than left as a convention.

Several lines are absent from the manual, the GPIO resets at offset
0x438 among them.  They were recovered from the vendor device tree and
confirmed by asserting each one and watching the block stop responding.

Registration writes nothing to the hardware.

Assisted-by: Claude:claude-opus-5
Signed-off-by: Justin Hammond <justin@dynam.ac>
2026-09-21 16:29:12 +08:00
Ulaş Sertan Kemeç
2cb30ac13d arch/arm/am67: Answer the remoteproc shutdown request in rptun.
The mailbox handler drained the FIFO without checking the message body.
That caused shutdown messages to be lost, hence being unable to start/stop
the R5 cores from the Linux side.

The additions allow checking messages for control and virtqueue types.
Shutdown messages fall to the control branch, which ACKs the shutdown
request and parks the core in WFI.

Virtqueues still work as intended; the only difference is that control
messages are now handled correctly.

Assisted-by: Claude Code:claude-opus-5
Signed-off-by: Ulaş Sertan Kemeç <sertan.usk@gmail.com>
2026-09-21 16:28:36 +08:00
Ulaş Sertan Kemeç
cd4fe549ee arch/arm/am67: Add a RAT sliding window for 36-bit DDR access.
J722S maps DDR above the first 2 GB at 0x8_8000_0000, out of reach of the
32-bit R5F, while a 64-bit Linux peer posts virtio buffers there.

Dedicates RAT region 0 as a 16 MB window at 0xFE000000.  am67_rat_map() re-aims
it and returns a pointer plus the bytes left before the edge, so callers can
split copies that straddle it.

The window is Non-cacheable, since it retargets at runtime and cached lines
would alias across physical blocks.  A mapping is valid only until the next
call; the sole user, vhost-net, is serialised on the netdev work thread.

Assisted-by: Claude Code:claude-fable-5
Signed-off-by: Ulaş Sertan Kemeç <sertan.usk@gmail.com>
2026-09-21 16:28:36 +08:00
Ulaş Sertan Kemeç
a2edd99159 arch/arm/am67: Add rptun IPC with the Linux A53 (remoteproc/rpmsg).
Connects the R5F to Linux remoteproc over the NAVSS mailbox.

The mailbox ISR only drains the FIFO and acknowledges; OpenAMP delivery is
deferred to HPWORK, because the rpmsg rx path takes mutexes and allocates.

The resource table publishes two vdevs, rpmsg and virtio-net, leaving every
vring address FW_RSC_ADDR_ANY: Linux allocates them from the R5F DMA pool and
rejects fixed addresses outside it.

Shared IPC memory is mapped Non-cacheable, since the R5F is not coherent with
the A53 and cached mappings leave NuttX reading stale vring state.

Also drops the duplicate arm_mpu.c from CHIP_CSRCS.

Assisted-by: Claude Code:claude-fable-5
Signed-off-by: Ulaş Sertan Kemeç <sertan.usk@gmail.com>
2026-09-21 16:28:36 +08:00
Daniel P. Carvalho
e3dfc9875d arch/arm/stm32h7: timestamp the received PTP frames.
Add STM32_ETH_TIMESTAMP_RX for the STM32H7, as the one of the legacy
STM32 that provides the timestamp of the frames received.

Timestamp the PTP version 2 messages, over Ethernet and over UDP, except
for the announce, management and signaling messages. The MAC writes the
timestamp in a context descriptor after the last descriptor of the frame.
The driver reads it before giving the frame to the network stack and
passes it in d_rxtime, in the time of the system time of the MAC, the same
as /dev/ptp0. A frame that is not timestamped has a time of zero.

The timestamp goes over the address of the buffer of the context
descriptor, and the code that dropped the context descriptors used a
pointer that was never set. Keep the address of the buffer of each RX
descriptor, and restore it when a context descriptor is given back.

The timestamps of the PTP frames of a grandmaster clock were checked on
hardware against the system time of the MAC, and were within the delay of
the reads.

Signed-off-by: Daniel P. Carvalho <danieloak@gmail.com>
Assisted-by: Claude:claude-sonnet-5
2026-09-21 15:11:15 +08:00
Daniel P. Carvalho
e2d5b8f29c arch/arm/stm32h7: add the PTP hardware clock of the Ethernet MAC.
The MAC has a system time that is the base of the PTP hardware
timestamps, but the driver never started it, and STM32_ETH_PTP only
printed a warning.

Add the registers of the timestamp unit and start the system time with
the fine update method and the digital rollover, so that the nanoseconds
count up to 10^9. The increment is 2 * 10^9 / HCLK ns, and the addend
makes the update rate half of HCLK, which leaves room to trim the
frequency in both directions. The time starts at zero right after the MAC
reset, not with the MAC configuration, so it does not depend on the PHY
having a link. The reset clears it, so it starts again each time the
interface goes up.

With STM32_ETH_PTP_GPIO, start the pulse-per-second output as a pulse
train with a period of one second and a width of half of it, at the whole
seconds of the system time. The fixed frequency mode of the MAC gives a
pulse too short to be seen, so the flexible mode is used. The interrupt
of the timestamp unit is not enabled in the MAC: it is set each time the
target time of the PPS output is reached and is cleared by reading
MACTSSR, which the interrupt handler does not do, so it would stay
pending and keep the handler running until the network stops.

Register /dev/ptp0 when CONFIG_PTP_CLOCK is set, so that a PTP daemon can
read and set the system time and correct its frequency and its phase.
The frequency is corrected by changing the addend, by up to 50% each way.
A step of the time is added or subtracted with the update register; with
the digital rollover a subtraction is programmed with the negated seconds
and with 10^9 minus the nanoseconds. The pulse train counts by itself, so
it does not follow a step of the system time and would be displaced by the
same amount: after the time is set or stepped, it is started again at the
next whole second.

With HCLK at 200 MHz the system time advanced 10.0018 s while a host
clock advanced 10.002 s, and the pulse train was seen on the pin. Reading,
setting, steps of +0.5 s and -1.25 s and a change of 100 ppm were done
through /dev/ptp0 on hardware, and the edges of the PPS output stayed at
the whole seconds of the system time.

Signed-off-by: Daniel P. Carvalho <danieloak@gmail.com>
Assisted-by: Claude:claude-sonnet-5
2026-09-21 15:11:15 +08:00
Daniel P. Carvalho
8e5e3c081a arch/arm/stm32h7: configure the PPS pin only with STM32_ETH_PTP_GPIO.
The driver configured the pulse-per-second pin whenever STM32_ETH_PTP
was set, so a board that uses the timestamp unit without the pin still
had to define GPIO_ETH_PPS_OUT, and the pin was taken away from other
uses. The STM32F4 driver configures the pin with STM32_ETH_PTP_GPIO,
the option meant for it, but that option could not be selected on the
STM32H7, because it depended on the legacy STM32 families.

Configure the pin only with STM32_ETH_PTP_GPIO, and allow that option
on the STM32H7 and STM32H5.

Signed-off-by: Daniel P. Carvalho <danieloak@gmail.com>
Assisted-by: Claude:claude-sonnet-5
2026-09-21 15:11:15 +08:00
Daniel P. Carvalho
d357c54549 arch/arm/stm32: fix PTP multicast filter and RX/TX frame routing
- Under CONFIG_NET_PROMISCUOUS, forward all control frames
  (ETH_MACFFR_PCF_ALL) instead of only non-PAUSE ones, so link-local
  PTP multicast reaches the DMA.
- Move ptp_to_timespec() above its first user so the TX timestamp path
  can call it.
- stm32_receive(): do not log frames already delivered to packet
  sockets (PTP, IPv6) as "Dropped, Unknown type".
- stm32_txtstamp_flush(): clear io_conn before freeing the looped-back
  IOB.

Signed-off-by: Daniel P. Carvalho <danieloak@gmail.com>
Assisted-by: Claude:claude-sonnet-5
2026-09-21 15:07:04 +08:00
Daniel P. Carvalho
b850fc0205 arch/arm/stm32: implement hardware TX timestamping via SO_TIMESTAMPING loopback
Implement hardware TX timestamping support for STM32 Ethernet MAC
(stm32_eth_m3m4_v1.c) following the upstream SO_TIMESTAMPING loopback
architecture (PR #20161).

When an outgoing packet is flagged with SO_TIMESTAMPING (dev->d_iob->io_conn != NULL):
- Clone the IOB and hold a reference in priv->txmeta[txindex]
- Set ETH_TDES0_TTSE on the transmit DMA descriptor
- On transmission completion (stm32_freeframe), retrieve the hardware
  timestamp from TDES6/TDES7, convert to timespec via ptp_to_timespec(),
  and enqueue the clone onto priv->txtstampq
- Deliver pending TX timestamp clones back to netdev RX path in stm32_receive
  using pkt_input(), where net/pkt intercepts the frame and delivers it to
  userspace via recvmsg(..., MSG_ERRQUEUE)
- Properly drain pending queues and clones on interface down (stm32_ifdown)

Assisted-by: Gemini:gemini-3.8-pro
Signed-off-by: Daniel P. Carvalho <danieloak@gmail.com>
2026-09-21 15:07:04 +08:00
Daniel P. Carvalho
c1938018e8 arch/arm/stm32h7: fix the bit of ETH_MTLOMR_DTXSTS.
The Drop Transmit Status field of the MTL operation mode register is
bit 1, but it was defined as bit 0. The driver does not use it.

Signed-off-by: Daniel P. Carvalho <danieloak@gmail.com>
Assisted-by: Claude:claude-sonnet-5
2026-09-21 15:06:45 +08:00
Matteo Golin
f39b15d28b sched/pthread: Implement pthread_sigqueue
Implements the pthread_sigqueue Linux extension to pthreads. Follows a
similar implementation to sigqueue, except targeting a specific thread
through nxsig_dispatch.

Signed-off-by: Matteo Golin <matteo.golin@gmail.com>
2026-09-21 14:53:26 +08:00
Daniel P. Carvalho
9d861ca27e arch/arm/stm32h7: wait for the PHY link in milliseconds.
The PHY was polled with nxsched_usleep(100) in a loop of 0x1998
iterations, so the time the link had to come up depended on the period
of the system tick. With the usual 10 ms tick that is about 65 s, but
with CONFIG_SCHED_TICKLESS and a 100 us tick it is about 0.65 s, shorter
than the auto-negotiation of the PHY (about 1.7 s on the board tested),
and the interface could not be brought up.

Poll every 10 ms and give the PHY up to 5 s, both for the link and for
the auto-negotiation to complete, whatever the tick.

Signed-off-by: Daniel P. Carvalho <danieloak@gmail.com>
Assisted-by: Claude:claude-sonnet-5
2026-09-21 14:46:24 +08:00
Daniel P. Carvalho
392107954b arch/arm/stm32: fix the comment of the RX timestamp conversion.
The comment of stm32_eth_ptp_convert_rxtime() said that it converts to
CLOCK_REALTIME. Since the timestamp is delivered as the value of the
PTP counter of the MAC, which is the time base of /dev/ptp0, say
that.

Signed-off-by: Daniel P. Carvalho <danieloak@gmail.com>
Assisted-by: Claude:claude-sonnet-5
2026-09-20 17:54:48 -03:00
Royyan Zahir
abbfb31a02 arch/arm64: implement up_addrenv_va_to_pa().
up_addrenv_va_to_pa() is declared in include/nuttx/arch.h but implemented
only by armv7-a, so no arm64 port can map a virtual address to a physical
one. A driver whose device addresses memory physically has nothing to call.

The translation is asked of the MMU with AT S1E1R rather than walked in
software, so it answers for whatever is actually mapped: any granule size,
block or page, at any level, and it cannot drift from the tables in use.

PAR_EL1 is one register per CPU, so nothing may run between the translation
and reading the result. Interrupts are banked with it, so masking them
locally is sufficient and SMP needs nothing further.

Returns zero for an address that is not mapped for a privileged read, which
is what the declaration in arch.h specifies. Note this differs from the
armv7-a implementation, which returns the virtual address unchanged.

Signed-off-by: Royyan Zahir <royzah@gmail.com>
2026-09-20 11:58:33 -03:00
Daniel P. Carvalho
3589fceab3 arch/arm/stm32: implement PTP hardware clock driver (/dev/ptp0)
Implement lower-half PTP hardware clock operations (struct ptp_lowerhalf_s
and struct ptp_ops_s) in the STM32 Ethernet driver and register it with the
generic PTP clock framework (drivers/timers/ptp_clock.c) to expose /dev/ptp0.

Supported operations:
- adjfine: adjust PTP clock frequency in parts per billion (ppb)
- adjphase: adjust PTP clock phase via hardware TSSTU
- adjtime: shift PTP clock time by signed delta in nanoseconds
- gettime: atomic double-read of hardware timestamp registers
- settime: initialize hardware timestamp counter via TSSTI
- getres: return 1 ns clock resolution

Also fix a sign bug in stm32_eth_ptp_adjust() where uint64_t addend
promoted negative ppb adjustments to unsigned, corrupting frequency trim
for crystals running faster than nominal.

Follow-up to #20148 per review recommendation to use the standard POSIX
/dev/ptp0 character driver instead of custom socket ioctls.

Assisted-by: Gemini:gemini-3.8-pro
Signed-off-by: Daniel P. Carvalho <danieloak@gmail.com>
2026-09-19 18:32:45 -03:00
Daniel P. Carvalho
c21d96eb68 arch/arm/stm32: deliver direct hardware counter timestamps for PTP.
The MAC hardware counter is the PTP clock reference. Delivering its
raw timestamp directly (instead of synthesizing one against
CLOCK_REALTIME, which starts at an arbitrary boot-time phase) lets the
PTP daemon close the feedback loop and phase-lock the MAC counter -
and therefore the physical PPS output - to the master.

Assisted-by: Gemini:gemini-3.8-flash-medium
Signed-off-by: Daniel P. Carvalho <danieloak@gmail.com>
2026-09-19 18:32:45 -03:00
Daniel P. Carvalho
6f7d54d096 arch/arm/stm32: Disable reception of self-transmitted frames.
Set ETH_MACCR_ROD unconditionally when configuring the MAC. In
half-duplex mode the MAC otherwise reflects every frame it transmits
back to its own receiver, flooding the receive path with our own
traffic right as a genuine reply arrives. The bit has no effect in
full-duplex (confirmed on our hardware: fduplex=1), so setting it
unconditionally is safe and changes nothing observable for boards
already running full-duplex.

The sibling stm32f7 driver has the same gap (ETH_MACCR_ROD cleared
but never set) and stm32h7's equivalent ETH_MACCR_DO bit has the same
issue; both are left out of scope here since only m3m4_v1 hardware
was available to validate against.

Assisted-by: Claude:claude-sonnet-5
Signed-off-by: Daniel P. Carvalho <danieloak@gmail.com>
(cherry picked from commit 41536cb8c9f5ff448864d2eb490b35aea7cdafcf)
2026-09-19 18:32:45 -03:00
Daniel P. Carvalho
5938f58fd8 arch/arm/stm32: Convert RX hardware timestamp before pkt_input().
stm32_receive() called pkt_input() before
stm32_eth_ptp_convert_rxtime(), so every packet handed to a packet
socket carried the previous frame's RX timestamp instead of its own
in dev->d_rxtime. Reorder so the timestamp is converted first.

Assisted-by: Claude:claude-sonnet-5
Signed-off-by: Daniel P. Carvalho <danieloak@gmail.com>
(cherry picked from commit 9bfa20da28da79a567e3b38cb127767cf9e03042)
2026-09-19 18:32:45 -03:00
Daniel P. Carvalho
774387d980 stm32/comp: propagate enable error and handle lock in ioctl
In comp_ioctl(), propagate the return code of comp_enable() to caller so
failures (such as when the comparator CSR register is locked) return -EPERM.
Also call comp_lock_set() if the comparator was configured with locking,
handling cases where initialization was delayed.

Assisted-by: Gemini:gemini-3.8-pro
Signed-off-by: Daniel P. Carvalho <danieloak@gmail.com>
2026-09-19 22:41:17 +08:00
Daniel P. Carvalho
e433409fcc stm32: implement comp ioctl and update nucleo-g431kb defconfig
Implement ao_ioctl in stm32_comp_m3m4_v2.c to handle ANIOC_COMP_ENABLE and
ANIOC_COMP_DISABLE commands. Also add CONFIG_STM32_COMP_INIT_DISABLED to
allow keeping the comparator disabled after driver initialization until
explicitly enabled.

Update nucleo-g431kb:comp defconfig to enable CONFIG_EXAMPLES_COMP and
set default DAC path for comparator ramp verification.

Assisted-by: Gemini:gemini-2.5-pro
Signed-off-by: Daniel P. Carvalho <danieloak@gmail.com>
2026-09-19 22:41:17 +08:00
Jukka Laitinen
be5bf6133b arch/arm/imxrt: Add support for ELE FW for imxrt1180-evk
Add support for loading the secure element firmware.

Signed-off-by: Jukka Laitinen <jukka.laitinen@tii.ae>
2026-09-19 22:38:45 +08:00
Jukka Laitinen
c5e2c4b3f7 arch/arm/imxrt: Configure MPU for imxrt118x
We must enable the MPU on IMXRT118x to be able to keep writeback dcache on.

Signed-off-by: Jukka Laitinen <jukka.laitinen@tii.ae>
2026-09-19 22:38:45 +08:00
Jukka Laitinen
e71c9c799a arch/arm/imxrt: Add a function imxrt118x_release_cm7 to start M7 core
Add a function which can be called from M33 core on imx118x to start
executing on M7 core.

The function:
- Configures the M7 clock root
- Releases M7 from reset
- Asks the secure element to release the M7 (ENABLE_APC)
- Enables the M7 clock

The function is compiled in when a configuration flag
CONFIG_IMXRT_CM7_BOOT=y

Signed-off-by: Jukka Laitinen <jukka.laitinen@tii.ae>
2026-09-19 22:38:45 +08:00
Jukka Laitinen
5b7d69307c arch/arm/imxrt: Add iMXRT118x capable eDMA driver
- Add driver supporting the DMA3 and DMA4 in iMXRT118x chips. The driver is first copied
  from imx93, and then changed just the relevant parts (function names, clocking and
  irq handling) to match the imx118x configuration.
- Add the DMA channel numbering in hardware/rt118x/imxrt118x_dmamux.h from RM
  by claude.

Assisted-by: Claude Code:claude-opus-4-7
Signed-off-by: Jukka Laitinen <jukka.laitinen@tii.ae>
2026-09-19 22:38:45 +08:00
Jukka Laitinen
a3fb91e0ba arch/arm/imxrt: Small fixes for I2C&SPI to build for iMXRT118x
Add a few !defined(CONFIG_ARCH_FAMILY_IMXRT118x) gates similar to 1176 to
buid the common drivers also for 118x variants.

Signed-off-by: Jukka Laitinen <jukka.laitinen@tii.ae>
2026-09-19 22:38:45 +08:00
Jukka Laitinen
3693257175 arc/arm/imxrt/imxrt_usbdev.c: Fix for imxrt118x-evk
- Move/make sure that ep0buf is in usb dma capable memory. Especially if
  .data/.bss are in TCM, the buffers need to be placed in another section.
  If the section .dmamemory doesn't exist, they will end up in .data like before
- change "#ifdef CONFIG_ARCH_FAMILY_IMXRT117x" into
  "#if defined(CONFIG_ARCH_FAMILY_IMXRT117x) || defined(CONFIG_ARCH_FAMILY_IMXRT118x)"
- In imxrt_epcomplete dtd->buffer0 must NOT be used to compute the data buffer's
  cache-maintenance address range. The hardware advances buffer0 (and its
  "current offset" low-order bits) as the transfer progresses, so by completion
  time it points *past* the start of the buffer (at start + xfer_len), not at
  the buffer itself. Instead, use the original privreq->req.buf when the transfer
  is complete.

Signed-off-by: Jukka Laitinen <jukka.laitinen@tii.ae>
2026-09-19 22:38:45 +08:00
Jukka Laitinen
cb731d7791 arch/arm/imxrt: Add support for iMXRT118x in lowputc & serial drivers
- Small additions to existing drivers to support more UARTs
- Properly invalidate the cache over DMA RX buffer initially

Signed-off-by: Jukka Laitinen <jukka.laitinen@tii.ae>
2026-09-19 22:38:45 +08:00
Jukka Laitinen
80d6f34cd7 arch/arm/imxrt: Add support for IOMUXC and rgpio for imxrt118x
- Add imxrt118x compatible IOMUX definitions, named as IOMUX_VER3. This is the
same IP as what is used for example for IMX9. Instead of directly copying the support
from imx9, pack the padconfig into the same 32-bit value used for GPIO for easy use.

- Add imxrt118x compatible rgpio driver. This is the same GPIO block as what has been used
in imx9. Instead of directly copying the support from IMX9, add pin muxing directly
into GPIO driver as well, to keep the usage compatible with existing IMXRT boards.

Signed-off-by: Jukka Laitinen <jukka.laitinen@tii.ae>
2026-09-19 22:38:45 +08:00
Jukka Laitinen
5137e583d6 arch/arm/imxrt: Add iMXRT118x XBAR register definitions
Add the definitions for the Inter-Peripheral Crossbar Switch for iMXRT118x

Signed-off-by: Jukka Laitinen <jukka.laitinen@tii.ae>
2026-09-19 22:38:45 +08:00
Jukka Laitinen
2c51ec655c arch/arm/imxrt: ELE, TRDC and TCM fixes in __start for iMXRT118x platform
- Initialize the internal secure element, if configured
- Initialize the TRDC, if configured
- Disable the TCM enabling code when compiling for other than Cortex-M7 chip.
  This needs to be skipped for M33 core on imx118x

Signed-off-by: Jukka Laitinen <jukka.laitinen@tii.ae>
2026-09-19 22:38:45 +08:00
Jukka Laitinen
438eadd880 arch/arm/imxrt: Port the imx93 ELE driver for iMXRT118x
iMXRT118x uses the same security element as the imx93. Just add iMXRT specific
register definitions and port over the driver code.

Signed-off-by: Jukka Laitinen <jukka.laitinen@tii.ae>
2026-09-19 22:38:45 +08:00
Jukka Laitinen
9b0d998082 arch/arm/imxrt: Port trdc driver from imx93 for imxrt118x
The trdc driver has been copied from arm64/imx93, and modified to fit imxrt118x.

The relevant register definitions have been generated by AI from the RM.

Assisted-by: Claude Code:claude-opus-4-7
Signed-off-by: Jukka Laitinen <jukka.laitinen@tii.ae>
2026-09-19 22:38:45 +08:00
Jukka Laitinen
09db067af0 arch/arm/imxrt: Add imxrt118x blkctrl definitions
Add IMXRT AONMIX register addresses and bit definitions in a separate header file
"imxrt118x_blkctrl.h".

The header is generated using AI from imxrt118x reference manual.

Assisted-by: Claude Code:claude-opus-4-7
Signed-off-by: Jukka Laitinen <jukka.laitinen@tii.ae>
2026-09-19 22:38:45 +08:00
Jukka Laitinen
e24158d38f arch/arm/imxrt: Initial support for OCOTP on imxrt1180
Support reading the OCOTP via the shadow register on imxrt chips with integrated
ELE. On these chips, writing is done via ELE, this is not yet implemented.

Signed-off-by: Jukka Laitinen <jukka.laitinen@tii.ae>
2026-09-19 22:38:45 +08:00
Jukka Laitinen
ec6e653dc7 arch/arm/imxrt: Add register definitions for imxrt118x ANADIG
Add register definitions for IMXRT118x Analog-Digital top level block.

Assisted-by: Claude Code:claude-opus-4-7
Signed-off-by: Jukka Laitinen <jukka.laitinen@tii.ae>
2026-09-19 22:38:45 +08:00
Jukka Laitinen
9740ce3aa4 arch/arm/imxrt: Add register definitions for imxrt118x general power controller
Add a header file defining the imxrt118x GPC registers

Assisted-by: Claude Code:claude-opus-4-7
Signed-off-by: Jukka Laitinen <jukka.laitinen@tii.ae>
2026-09-19 22:38:45 +08:00
Jukka Laitinen
d4a3d255a4 arch/arm/src/imxrt: Add the clock configuration for iMXRT118x
Port the ccm / clock configuration from iMX93 to iMXRT118x.
Register definitions are generated from RM using AI

Assisted-by: Claude Code:claude-opus-4-7
Signed-off-by: Jukka Laitinen <jukka.laitinen@tii.ae>
2026-09-19 22:38:45 +08:00
Jukka Laitinen
f6aa5c115e arch/arm/src/imxrt/chip.h: Add cache line definitions for Cortex-M33
i.MXRT118x have a Cortex-M33, which is ARMv8-M. Add cache line definitions
for this one.

Signed-off-by: Jukka Laitinen <jukka.laitinen@tii.ae>
2026-09-19 22:38:45 +08:00
Jukka Laitinen
caa09a6557 arch/arm/imxrt: Add imxrt118x irq definitions
Add interrupt numbering for imxrt118x in imxrt118x_irq.h, and support
for more interrupts in imxrt_irq.c and imxrt_clrpend.c.

The interrupt numbers are generated from the Reference Manual by AI

Assisted-by: Claude Code:claude-opus-4-7
Signed-off-by: Jukka Laitinen <jukka.laitinen@tii.ae>
2026-09-19 22:38:45 +08:00
Jukka Laitinen
5095237337 arch/arm/imxrt: Add imxrt118x_memorymap
Add imxrt118x memorymaps as hardware/rt118x/imxrt118x_memorymap.h

Assisted-by: Claude Code:claude-opus-4-8
Signed-off-by: Jukka Laitinen <jukka.laitinen@tii.ae>
2026-09-19 22:38:45 +08:00
Jukka Laitinen
6b0f85b768 arch/arm/imxrt: LPUART DMA fixes
- Only submit and account for a wrapped second TX segment when scatter/gather descriptors
  are available. Without in-memory TCDs, submitting the second segment overwrites the
  active hardware descriptor and incorrectly advances the serial buffer past unsent data.
- Invalidate DMA RX buffer initially

Signed-off-by: Jukka Laitinen <jukka.laitinen@tii.ae>
2026-09-19 22:38:45 +08:00
Jukka Laitinen
b59d3aadf5 arch/arm/imxrt: Allow placing primary ram into TCM in allocateheap
Add support for placing the primary ram into SysTCM on M33 cores or DTCM on M7

Signed-off-by: Jukka Laitinen <jukka.laitinen@tii.ae>
2026-09-19 22:38:45 +08:00
Marcio Ribeiro
80ccc5d9aa arch/risc-v/espressif: pick oneshot TIMG from SoC instance count
Some SoCs have a single timer group, so a hardcoded GROUP_ID of 1
overflowed soc_timg_gptimer_signals and crashed in
periph_rcc_acquire_enter. Guard gptimer group 1 behind
TIMG_LL_GET(INST_NUM) as well.

Assisted-by: Claude:claude-opus-5
Signed-off-by: Marcio Ribeiro <marcio.ribeiro@espressif.com>
2026-09-19 22:33:34 +08:00