Commit graph

25281 commits

Author SHA1 Message Date
Marcio Ribeiro
25a3aaaa9d arch/risc-v/esp32c2: add ESP32-C2 chip support
Introduce RV32IMC chip architecture with HAL integration and Espressif
common Kconfig for the ESP8684 SoC, including XTAL, UART0 pin range,
and SPI flash clock options.

Assisted-by: Claude:claude-opus-5
Signed-off-by: Marcio Ribeiro <marcio.ribeiro@espressif.com>
2026-09-25 21:08:00 +08:00
Marco Casaroli
5513029711 arch/arm: Build a loadable module and a shared library as FDPIC too.
CONFIG_FDPIC teaches the ELF module path what an FDPIC object is, so an
application built as a module gets -mfdpic -fPIC and the
arm-uclinuxfdpiceabi linker.  The loadable module path, which apps builds
with DYNLIB = y and which apps/Library.mk uses for a shared library, was
left as it was: a -r partial link with the stock linker.  That leaves an
object with no dynamic section, so the loader has nothing to bind an import
to, and there is no way to build a library an FDPIC module can call.

Give that path the same treatment.  CMODULEFLAGS and CXXMODULEFLAGS gain the
FDPIC compiler flags, and LDMODULEFLAGS links a shared object rather than a
partial one.  The entry point is left to the caller, because a module is
entered at _start while a library is only ever called into.

CXXMODULEFLAGS is also defined for the first time.  apps/Library.mk compiles
every C++ source of a shared library with it and no architecture defined it,
so those sources were compiled with no architecture flags at all.

Assisted-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
Signed-off-by: Marco Casaroli <marco.casaroli@gmail.com>
2026-09-25 09:56:10 -03:00
Austin.Chen
5197329b67 arch/arm/stm32h5: add SDMMC1/SDMMC2 driver
Add the STM32H5 SDMMC1/SDMMC2 lower-half SDIO driver (interrupt-mode and
IDMA transfers, SD/SDIO card mode), following the same structure as the
existing STM32H7 SDMMC driver.

Three fixes were needed to get this actually building, selectable, and
correct:

- The driver checked CONFIG_STM32H5_SDMMC1/CONFIG_STM32H5_SDMMC_IDMA/
  CONFIG_STM32H5_SDMMC_XFRDEBUG, but the real Kconfig symbols selected by
  this chip are the shared CONFIG_STM32_SDMMC1/CONFIG_STM32_SDMMC_IDMA/
  CONFIG_STM32_SDMMC_XFRDEBUG (see arch/arm/src/common/stm32/Kconfig.sdio,
  Kconfig.periph). With the old names the driver silently compiled out.
  Renamed all guards in stm32_sdmmc.c to match. Also fixed a similar typo,
  STM32H5_SRAM3_SIZE -> STM32_SRAM3_SIZE, in the IDMA-reach check.

- arch/arm/src/common/stm32/Kconfig.sdio's STM32_SDMMC_IDMA and the
  SDMMC1/2 SDIO-mode/pull-up options depended on ARCH_CHIP_STM32H7 /
  STM32_COMMON_F7_H7 only. Extended STM32_SDMMC_IDMA to also allow
  ARCH_CHIP_STM32H5, and switched the SDIO-mode/pull-up options to
  STM32_COMMON_F7_H7_H5, matching the pattern already used for other
  STM32H5 peripherals (Ethernet, ADC, SPI, timers).

- stm32_sdmmc.c was only added to Make.defs, not to CMakeLists.txt, so
  the driver would silently be omitted from CMake builds. Added it to
  the same unconditional source list as stm32_exti_gpio.c.

Also ports a fix from a related STM32H7 SDMMC commit
(2cb7b7c03e): stm32_recvdma()'s aligned
IDMA receive path invalidated the destination buffer before the DMA but
never again after it completed, so a speculative cache prefetch into
that buffer between those two points could shadow the freshly-received
data with a stale line. Added the missing post-DMA invalidate, matching
the pattern already used elsewhere on this chip for other DMA-capable
peripherals (e.g. stm32_ethernet.c's RX path).

Needed for a custom STM32H5 board that uses SDMMC1 in SDIO mode with
IDMA to talk to an onboard WiFi module.

Co-authored-by: Liam Howatt <liamhowatt@geotab.com>
Signed-off-by: Marwan Madkour <marwanmadkour@geotab.com>
2026-09-25 18:30:40 +08:00
raiden00pl
425e77e44e arch/nrf52,nrf53,nrf91: fix nxstyle issues
arch/nrf52,nrf53,nrf91: fix nxstyle issues

Signed-off-by: raiden00pl <raiden00@railab.me>
2026-09-25 18:24:36 +08:00
raiden00pl
058da97e95 arm/nrf52,nrf53: fix SAADC channel limit register value
CHLIMIT was written with (limith < 16) | limith, which put the high
limit into the low field and a boolean into bit 0. Shift the high
limit to bits 16-31 and the low limit to bits 0-15.

Assisted-by: Claude Code
Signed-off-by: raiden00pl <raiden00@railab.me>
2026-09-25 18:24:36 +08:00
raiden00pl
574bbf618f arm/nrf52,nrf53,nrf91: fix SPI sndblock ops field
The non-exchange ops table initialized .sndlock, which does not exist
in struct spi_ops_s and fails to compile without CONFIG_SPI_EXCHANGE.

Assisted-by: Claude Code
Signed-off-by: raiden00pl <raiden00@railab.me>
2026-09-25 18:24:36 +08:00
raiden00pl
e5e06d6bde arm/nrf52,nrf53,nrf91: fix PWM driver bugs
- SEQSTARTED0 and STOPPED events were not cleared before waiting for
  them, so the second start or stop returned immediately
- PWM_DECODER_MODE_* shifted 8 instead of shifting to bit 8
- PWM_PSEL_PIN_MASK and PWM_PSEL_PORT_MASK referenced TWI shift names
- PWM_PSEL_CONNECTED described the disconnected state

Assisted-by: Claude Code
Signed-off-by: raiden00pl <raiden00@railab.me>
2026-09-25 18:24:36 +08:00
raiden00pl
c8f699a4e3 arm/nrf52,nrf53,nrf91: fix GPIOTE driver bugs
- set_port_event checked the wrong port when deciding whether the
  PORT interrupt can be disabled
- set_event could pick a free channel instead of the one already
  assigned to the pin
- LATCH registers were cleared by writing zeros
- header declared nrfxx_gpio_set_task for a function defined as
  nrfxx_gpiote_set_task

Assisted-by: Claude Code
Signed-off-by: raiden00pl <raiden00@railab.me>
2026-09-25 18:24:36 +08:00
raiden00pl
f86b05351f arm/nrf52,nrf53,nrf91: fix RTC driver bugs
- setcc/getcc accepted channel index equal to the channel count
- init never marked the instance as in use
- NRFxx_RTC_GETCC called setcc instead of getcc

Assisted-by: Claude Code
Signed-off-by: raiden00pl <raiden00@railab.me>
2026-09-25 18:24:36 +08:00
raiden00pl
d490c80df2 arm/nrf52,nrf53,nrf91: fix TIMER driver bugs
- setcc/getcc accepted channel index equal to the channel count
- init never marked the instance as in use
- TIM_PRESCALER_MASK used the maximum value as the mask

Assisted-by: Claude Code
Signed-off-by: raiden00pl <raiden00@railab.me>
2026-09-25 18:24:36 +08:00
raiden00pl
0942bae6ef arm/nrf54l: add GRTC and tickless scheduling
arm/nrf54l: add GRTC and tickless scheduling

Assisted-by: Codex:GPT-6
Signed-off-by: raiden00pl <raiden00@railab.me>
2026-09-25 10:48:00 +02:00
raiden00pl
04d2c9013c arm/nrf54l: add TIMER support
arm/nrf54l: add TIMER support

Assisted-by: Codex:GPT-6
Signed-off-by: raiden00pl <raiden00@railab.me>
2026-09-25 10:48:00 +02:00
rongbaichuan
00a379c3f7 sched/semaphore: Fix pre-existing nxstyle issues in the touched files
The CI style check runs nxstyle over every file a pull request touches,
so the files changed by the previous two commits have to comply even
where the problems were not introduced here.  504 errors in 25 files are
fixed: whitespace, blank lines, brace placement, switch/case indentation,
label indentation and comment blocks only, with no functional change.

Assisted-by: DeepSeek Harness:deepseek-flash
Signed-off-by: rongbaichuan <rongbaichuan1027@163.com>
2026-09-25 10:37:43 +02:00
rongbaichuan
59d5ce0f31 sched/semaphore: Remove the return value check of nxsem_init/nxmutex_init
nxsem_init(), nxsem_destroy(), nxmutex_init() and nxmutex_destroy()
always return OK, so checking the result only leaves dead code: the
compiler cannot remove it, because these are cross-translation-unit calls
and the nxrmutex_destroy() test is duplicated into every inlined call
site.

Apply the convention already established in commit a47a36bc5b (PR #7473)
to the two definitions which still test the value and to the 54 remaining
call sites. No signature or prototype is changed.

Testing: stm32f103-minimum:nsh builds with -Os without new warnings.

Assisted-by: DeepSeek Harness:deepseek-flash
Signed-off-by: rongbaichuan <rongbaichuan1027@163.com>
2026-09-25 10:37:43 +02:00
Alan Carvalho de Assis
31d3598f6a arch/sim: buffer several mouse reports
sim_mouse registered /dev/mouse0 with room for a single report.  The
X11 event loop handles all pending X events at once every
CONFIG_SIM_X11EVENT_INTERVAL ms, so a quick click (button press and
release in the same period) overwrote the press before the application
could read it, and the click was lost.

Add CONFIG_SIM_MOUSE_BUFFSIZE (default 16) for the number of buffered
reports, like CONFIG_SIM_KEYBOARD_BUFFSIZE for the keyboard.

Assisted-by: Claude Opus 5.5 (1M context)
Signed-off-by: Alan Carvalho de Assis <acassis@gmail.com>
2026-09-25 10:36:28 +02:00
Marco Casaroli
27d621e4c7 arch/x86_64: Let the architecture select ARCH_HAVE_FORK.
Review of #19772 asked for this shape, and it applies to every architecture in
the series.

ARCH_HAVE_FORK described when it was available from inside its own definition,
which put the per-architecture condition somewhere nobody looks.  The
architecture now says so itself.

The condition repeats the ARCH_ADDRENV dependency rather than relying on it,
because a select bypasses depends on:  without that repetition an architecture
could offer fork() where there is no address environment to duplicate.

Assisted-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
Signed-off-by: Marco Casaroli <marco.casaroli@gmail.com>
2026-09-24 18:02:36 -03:00
Marco Casaroli
95c326704e arch/x86_64: Implement up_addrenv_fork() and provide POSIX fork().
Duplicate an address environment into freshly allocated pages mapped at the
same virtual addresses, which is what POSIX fork() is built on.

x86_64_fork_syscall() then lets the child run at the parent's stack addresses.
A pointer to a stack local taken before fork() must name the same object in
the child that it named in the parent, so the child adopts the parent's stack
geometry rather than being given a relocated copy; the parent's stack is
already in the duplicate, at the parent's address, with its contents.  That
shows up as a zero offset, which also means the copy would have the same
source and destination, so both the copy and the frame-pointer relocation are
skipped.

Build-verified on qemu-intel64:knsh_romfs.  NuttX on qemu-intel64 requires
tsc-deadline and pcid, which TCG does not implement, so it cannot be run on
this host.

Assisted-by: Claude Code:claude-opus-5
Signed-off-by: Marco Casaroli <marco.casaroli@gmail.com>
2026-09-24 18:02:36 -03:00
Royyan Zahir
026f77d940 arch/arm64/imx9: give the ELE a physical address and the cache a virtual one.
The ELE addresses memory physically; cache maintenance takes a virtual
address. Both buffer calls supply one and use it for both, in opposite
directions: get_random() runs up_flush_dcache() on a physical address,
get_key() hands the enclave a virtual one. Both fail silently, and both
are correct only while the two are equal.

Take the virtual address in both, maintain the cache on it, and translate
for the message. get_random() also gains the alignment check get_key()
already has.

Signed-off-by: Royyan Zahir <royzah@gmail.com>
2026-09-24 10:36:52 -03:00
dechao_gong
ec7ee53f6f arch/arm/rtl8730e: add UART character driver support
Expose the RTL8730E general-purpose UARTs through the shared Ameba
serial driver (arch/arm/src/common/ameba/ameba_uart.c) by adding the
chip-specific glue, build wiring and a board port table.  The change is
gated by CONFIG_AMEBA_UART (default disabled); the LOG-UART keeps the
console and /dev/ttyS0.

Chip glue (ameba_uart_chip.h) supplies the three UART controller
register bases, GIC IRQ numbers (SPI 50/51/52 -> NuttX IRQ 82/83/84),
APB clock masks and pin-mux codes.  The board registers UART0-2 as
/dev/ttyS1-3 at 115200 8N1; UART3 is reserved for Bluetooth.  Pads are
picked from the EVB break-out (the UART crossbar maps each controller to
many pads, so this is purely a board choice).

Also fix an RX-timeout interrupt storm in the shared driver: the
RX-timeout status (LSR bit9) is latched and is not cleared by draining
the RX FIFO, so on a level-triggered GIC (RTL8730E) the ISR must
explicitly write TOICF, matching the vendor SDK serial_api.c.  The
extra register write is harmless on the NVIC-based M33 Ameba parts and
was regression-tested on them.

Signed-off-by: dechao_gong <dechao_gong@realsil.com.cn>
Assisted-by: Claude <noreply@anthropic.com>
2026-09-24 21:24:35 +08:00
Marcio Ribeiro
ccf67497c7 arch/risc-v/espressif: keep RTC backup data in DRAM without RTC memory
SoCs such as the ESP32-C2 have no RTC retention memory, so RTC_DATA_ATTR
cannot be used for the persistent RTC time.  Place the backup data in DRAM
on those chips, where the saved time does not survive deep sleep.

Assisted-by: Claude:claude-opus-5
Signed-off-by: Marcio Ribeiro <marcio.ribeiro@espressif.com>
2026-09-24 09:54:28 +02:00
Afonso Oliveira
0b35d45b2c riscv/erbium: Add standalone Minion emulator support.
Add an initial port for the AIFoundry Erbium Minion core running on the
public ET-platform system emulator (erbium_emu). NuttX boots directly
from a firmware ELF at 0x40000200, runs in machine mode on hart 0 with
SMP disabled, and parks secondary harts before they touch memory.

The chip layer provides startup, PLIC interrupts, the UART0 console
driver and the machine timer. Context switching, FPU save/restore,
heap, idle and timer handling reuse the common RISC-V code. Atomics use
interrupt masking because the core does not implement the A extension.

Erbium implements the F extension but executes fdiv/fsqrt and FENCE.I
in microcode, which a standalone image does not provide. The board build
files pass -mno-fdiv to GCC when the FPU is enabled, so those operations
use software helpers. Startup initializes the FPU without the common
FENCE.I sequence, and the board configurations disable the dynamic ELF
loader, which also relies on FENCE.I.

Add minion:nsh and minion:ostest configurations, Make and CMake
support, CMake CI build entries, and a host script that runs prebuilt
images in the emulator and checks the console and OS test results.

Tested with emulator revision 836a4ab600e9 and xPack GCC 14.3.0: both
configurations build with Make and CMake, ostest exits with status 0
including the FPU tests, and the NSH console, procfs, timer and UART
receive paths work. Silicon, SMP, protected builds and reboot are not
covered by this initial port.

Signed-off-by: Afonso Oliveira <afonso.oliveira707@gmail.com>
2026-09-24 15:38:14 +08:00
raiden00pl
95cdd306f0 arm/nrf54l: add initial nrf54l support
add initial nrf54l support (Cortex-M33 only)

Assisted-by: Codex:GPT-6
Signed-off-by: raiden00pl <raiden00@railab.me>
2026-09-24 11:10:46 +08:00
Felipe Moura
3c3afd04bd espressif/esp_pm.c: restore GPIO config after using it as a wake source
Arming a pin as a light-sleep wake source destroyed whatever it was
configured as, permanently.

esp_pm_gpio_wakeup_prepare() has to reconfigure each masked pin to plain
INPUT and hand it to gpio_wakeup_enable(), because the wakeup path only
supports level triggering.  It then never put anything back.  A pin that
was also a normal peripheral interrupt -- a sensor's data-ready line, say
-- came out of the first light sleep with its trigger mode gone and never
interrupted again.  Nothing failed loudly; the device just went silent.

Fixed generically rather than per-board:

  - esp_configgpio() now remembers the last attr applied to each pin, and
    a new esp_getconfiggpio() hands it back.  This is what lets the PM
    code restore a pin without having to know what the pin is for.

  - esp_pm_gpio_wakeup_prepare() saves each masked pin's attr before
    overwriting it, and a new esp_pm_gpio_wakeup_restore() puts it back
    as soon as esp_pm_light_sleep_start() returns.

Tied to the physical sleep/wake cycle deliberately, not to PM state
transitions.  An earlier attempt used a board-level pm_register()/notify()
callback and never fired at all, because the board sits in PM_STANDBY
without transitioning back to PM_NORMAL -- there is no state change to
hang the restore on.  The return from esp_pm_light_sleep_start() is the
one event that always happens exactly once per sleep.

Assisted-by: Claude:claude-opus-5
Signed-off-by: Felipe Moura <moura.fmo@gmail.com>
2026-09-23 08:36:17 -03:00
Daniel P. Carvalho
87f2744e6c arch/arm/stm32h5: fail the PHY initialization when the reset times out.
The driver has the same code as the one of the STM32H7. When the PHY did
not clear the reset bit in time, stm32_phyinit() returned the result of
the last MDIO read. The bus reads all ones when the PHY does not answer
yet, and that read succeeds, so the function returned OK and the driver
went on with its default of 10 Mbps and half duplex, while the PHY could
negotiate 100 Mbps and full duplex.

Return -ETIMEDOUT, so that bringing the interface up fails and the
failure is not hidden.

It builds for nucleo-h563zi:netnsh, but it was not tested on hardware.

Signed-off-by: Daniel P. Carvalho <danieloak@gmail.com>
Assisted-by: Claude:claude-sonnet-5
2026-09-23 08:21:59 +02:00
Daniel P. Carvalho
a4c608c591 arch/arm/stm32h7: do not log the frames of packet sockets as unknown.
A frame that a packet socket consumes was given to pkt_input() and then
logged as "Dropped, Unknown type" because it is neither IP nor ARP. With
a PTP grandmaster on the network that is one warning for each frame, and
the log of RAM fills in seconds, so it hides the messages of the start of
the system.

Do not log the frames of the type of PTP or of IPv6 when packet sockets
are enabled, as the driver of the legacy STM32 does.

Signed-off-by: Daniel P. Carvalho <danieloak@gmail.com>
Assisted-by: Claude:claude-sonnet-5
2026-09-23 08:21:59 +02:00
Daniel P. Carvalho
0a4ab69e52 arch/arm/stm32h7: fail the PHY initialization when the reset times out.
When the PHY did not clear the reset bit in time, stm32_phyinit()
returned the result of the last MDIO read. The bus reads all ones when
the PHY does not answer yet, and that read succeeds, so the function
returned OK and the driver went on with its default of 10 Mbps and half
duplex, while the PHY negotiated 100 Mbps and full duplex. The interface
was up and could not talk to anyone.

Return -ETIMEDOUT, so that bringing the interface up fails and the
failure is not hidden.

Signed-off-by: Daniel P. Carvalho <danieloak@gmail.com>
Assisted-by: Claude:claude-sonnet-5
2026-09-23 08:21:59 +02:00
Ahmed Ashraf NourEldeen
af65d2e04a arch/xtensa/espressif: Add IRQ lookup by interrupt handle.
Add esp_get_irq() to retrieve the IRQ associated with an interrupt
handle.

This allows the ESP OS abstraction to recover the IRQ when freeing an
interrupt from its handle.

The corresponding change in esp-hal-3rdparty is required to use this
API when freeing interrupts.

Related: #20216

Signed-off-by: Ahmed Ashraf NourEldeen <a.programmer55559@gmail.com>
2026-09-23 12:22:26 +08:00
Ahmed Ashraf NourEldeen
162369111e arch/risc-v/espressif: Add IRQ lookup by interrupt handle.
Add esp_get_irq() to retrieve the IRQ associated with an interrupt
handle.

This allows the ESP OS abstraction to recover the IRQ when freeing an
interrupt from its handle.

The corresponding change in esp-hal-3rdparty is required to use this
API when freeing interrupts.

Related: #20216

Signed-off-by: Ahmed Ashraf NourEldeen <a.programmer55559@gmail.com>
2026-09-23 12:22:26 +08:00
Michal Lenc
6431b299cc arch/arm/src/samv7/sam_mcan.c: fix coding style issues
Fix coding style to pass NXstyle check.

Signed-off-by: Michal Lenc <michallenc@seznam.cz>
2026-09-23 11:28:27 +08:00
Michal Lenc
c2595870e5 arch/arm/src/samv7/sam_mcan.c: fix potential false debug assertions
MCAN controller keeps track of empty TX HW FIFO slots in priv->txfsem
semaphore. The semaphore is incremented from TX complete interrupt
and taken before new frame is inserted to the HW FIFO.

There may be a situation when TX HW FIFO is not full but the
semaphore is not yet incremented because the driver didn't handle the
interrupt. I managed to reproduce this issue when sending large
data chunks over CAN bus and keeping the buffers full for most of
the transmission process. This situation leads to the debug assertion
although technically it's not a big issue -> the sending function
waits on the semaphore until it's posted by the interrupt handler.

Moreover, the sanity checks should not be necessary because
mcan_buffer_reserve function will take care of fixing the semaphore
value if it doesn't match with the FIFO.

The entire semaphore logic is a bit weird and probably not
necessary. All we need to do is to check SAM_MCAN_TXFQS register
if there is at least one free slot in the queue. But this would
require a bigger SAMv7 MCAN rewrite, this is rather a hot fix.

Signed-off-by: Michal Lenc <michallenc@seznam.cz>
2026-09-23 11:28:27 +08:00
Jukka Laitinen
d49d3bff9e arch/arm/src/imxrt/hardware/imxrt_gpio.h: Small fix for imxrt118x
Harmonize including the variant specific gpio header in imxrt_gpio.h, correct
a mistake in include paths.

Signed-off-by: Jukka Laitinen <jukka.laitinen@tii.ae>
2026-09-23 11:24:44 +08:00
Jukka Laitinen
bf840595f7 arch/arm/imxrt: Fix EDMA_ALIGN for Cortex-M33 in imxrt_edma_ver2.c
Small fix to compile imxrt_edma_ver2.c correctly also for M33.

Signed-off-by: Jukka Laitinen <jukka.laitinen@tii.ae>
2026-09-23 11:24:44 +08:00
Jukka Laitinen
e0f2c881bf arch/arm/imxrt: Add missing imxrt118x IRQ 238/239 definitions
On imxrt1180 there are 240 IRQs. Add the missiong ones:

  IRQ 238  ECAT   EtherCAT Reset out (ECAT_RESET_OUT pin-mux signal)
  IRQ 239  EdgeLock  EdgeLock interrupt

Signed-off-by: Jukka Laitinen <jukka.laitinen@tii.ae>
2026-09-23 11:24:44 +08:00
Royyan Zahir
44a3873222 arch/arm/imxrt: add a CAAM-backed /dev/random driver
The part has a hardware random number generator and nothing registers
it, so up_randompool_initialize() is never seeded from hardware. There
is no CAAM, TRNG or RNG driver anywhere in arch/arm/src/imxrt, and the
RT117x headers describe the block only as an address-map comment.

imxrt_caam.c brings up job ring zero and instantiates the RNG state
handle when the boot ROM has not, retrying with a longer entropy sample
until the self test passes. imxrt_rng.c registers /dev/random and
/dev/urandom on top, and is the i.MX9 driver's sibling: same health
checks, same FIPS 140-2 continuous test, same refusal to return a short
read and call it entropy.

The instantiation descriptor posts no job ring completion, so the state
handle is what reports it, and the ring is taken back to a known state
to latch it. Job ring zero is started and the cache and watchdog bits
set first: RDSTA and JRSTART both read zero out of reset on this part.

Scoped to RT117x, which is the family that carries CAAM.

Built for imxrt1170-evk:nsh with the driver on, and for imxrt1060-evk:nsh
to confirm the shared clock-gate header still builds without it.

Run on an FMU-v6X-RT (i.MX RT1176): /dev/random and /dev/urandom both
return, the first read after a cold boot included, and five consecutive
reads are distinct.

Signed-off-by: Royyan Zahir <royzah@gmail.com>
2026-09-22 09:37:17 -03:00
raiden00pl
6255f2a474 stm32l5: Fix nxstyle errors in drivers and board LEDs
Correct switch and declaration indentation, separate declarations from code,
and wrap a long comment in the SPI driver. Fix the timer driver and both
STM32L5 board LED implementations checked by the commonization PR.

These are formatting changes only.

Signed-off-by: raiden00pl <raiden00@railab.me>
2026-09-22 09:21:35 -03:00
raiden00pl
93a40354c0 arch/arm/stm32l5: Use common Cortex-M33 USART support
Select STM32_HAVE_IP_USART_M33_V3 and drop the family serial and
low-level console sources in favor of the common Cortex-M33 v3
implementation. Provide the USART clock and RCC gate definitions in
stm32_rcc_m33.h.

Add the LPUART BRR computation (256 * fCK / baud) to the common serial
and low-level console code, taken from the STM32L5 driver.

Signed-off-by: raiden00pl <raiden00@railab.me>
Assisted-by: Claude Code
2026-09-22 09:21:35 -03:00
raiden00pl
6e7ea6019e arch/arm/stm32l5: Use common Cortex-M33 core support
Enable STM32_COMMON_M33 for STM32L5 and drop the family reset, NVIC,
SysTick, idle, and heap sources in favor of the common Cortex-M33 v1
implementation.

Rename the family RCC header to stm32_rcc_m33.h for the common RCC
dispatch and define STM32_PRIMARY_SRAM_SIZE for the common heap
allocator.

Signed-off-by: raiden00pl <raiden00@railab.me>
Assisted-by: Claude Code
2026-09-22 09:21:35 -03:00
raiden00pl
cc8c7d0769 arch/arm/stm32l5: Use common Cortex-M33 GPIO and EXTI drivers
Select STM32_HAVE_IP_GPIO_M33_V1 and STM32_HAVE_IP_EXTI_M33_V1 and
drop the family GPIO and EXTI sources and headers in favor of the
common Cortex-M33 v1 implementation.

Define both EXTI register banks and retain the named bit definitions.
Use shared line and selector helpers without per-line conditionals.
Clear each GPIO selector with the same byte mask, as the H5 driver does.
Cover both 32-bit banks and H5 line inventories for later migration.

The common EXTI driver also routes the selected port through EXTICR,
which the family driver never programmed, so GPIO interrupts now work
on ports other than GPIOA.

Signed-off-by: raiden00pl <raiden00@railab.me>
Assisted-by: Claude Code
2026-09-22 09:21:35 -03:00
dechao_gong
7e34d1c6b4 arch/arm/ameba: add GPIO driver for RTL8730E (AmebaSmart CA32)
Wire the shared ameba_gpio driver to the RTL8730E CA32 core.

The CA32 replaces the vendor CA32 OS as BL33; the SDK startup that
normally initialises GPIO_PORTx[] never runs under NuttX.  The three
GPIO port base addresses are patched at runtime inside
rtl8730e_gpio_initialize() before any ROM GPIO function is called.
GPIO_INTStatusGet and GPIO_INTStatusClearEdge are absent from the
RTL8730E ROM and are provided as static inline helpers in the new
ameba_gpio_chip.h.

Key changes:
- ameba_gpio_chip.h (new): chip parameters, split AMEBA_APBPERIPH_GPIO
  / AMEBA_APBPERIPH_GPIO_CLK bits, inline INTStatus helpers
- ameba_gpio.c: add AMEBA_APBPERIPH_GPIO_CLK fallback macro so chips
  with separate periph/clock enable bits work without driver changes
- Make.defs: enable ameba_gpio.c + rtl8730e_flash_stubs.c + lib_rom.a
  under CONFIG_AMEBA_GPIO; consolidate flash_stubs into GPIO||FLASH_FS
- ameba_board.mk: remove duplicate lib_rom.a (Make.defs is authoritative)
- rtl8730e_flash_stubs.c: make _strcmp weak; delegate Pinmux_Config to
  lib_rom.a's _Pinmux_Config so GPIO pad mux is configured correctly
- Kconfig: source common/ameba/Kconfig to expose CONFIG_AMEBA_GPIO
- dramboot.ld: include .sramdram.only.data in .data so GPIO_PORTx[] is
  copied to RAM by the normal arm_data_initialize() path
- scripts/Make.defs: extend --no-warn-mismatch to GPIO and WiFi configs
- rtl8730e_gpio.c (new): pin table (PB19 output /dev/gpio0, PB20 input
  /dev/gpio1, PB11 falling-edge interrupt /dev/gpio2) + GPIO_PORTx patch
- configs/gpio/ (new): defconfig for GPIO example verification
- nxstyle.c: add _Pinmux_ to mixed-case whitelist (ROM symbol)

Hardware verified on RTL8730E CA32:
- PB19 output write 0/1, readback matches
- PB20 input reads PB19-driven level
- PB11 falling-edge interrupt triggers correctly

Signed-off-by: dechao_gong <dechao_gong@realsil.com.cn>
Assisted-by: Claude <noreply@anthropic.com>
2026-09-22 09:18:16 -03:00
Daniel P. Carvalho
1f9793b7b5 arch/arm/stm32h7: fix the period of the PPS output.
The interval and the width of the pulse train of the PPS output were
programmed as the number of increments of the system time minus one,
but the MAC takes them as they are. Each period was one increment (10 ns
with HCLK at 200 MHz) shorter than a second, so the pulses came 10 ns
early each second, about 36 us in an hour, and the output drifted away
from the system time.

Program the interval and the width without subtracting one.

On a run of 8.2 hours against a grandmaster clock the pulse moved 0.29 ms
ahead of the system time, which is 10 ns per second, while the system time
stayed within 1 us of the grandmaster. With the change, a run of 11 hours
showed no drift of the pulse against the system time, within 3 us per hour
on samples of 1 ms of resolution.

Signed-off-by: Daniel P. Carvalho <danieloak@gmail.com>
Assisted-by: Claude:claude-sonnet-5
2026-09-22 09:17:40 -03:00
Felipe Moura
89b8c5fc7f espressif: stop double-counting light sleep in the system clock
esp_pmstandby() fed up_step_idletime() the sleep duration it *asked* for
(time_in_us) rather than the one it actually got (rtc_diff_us), and did so
unconditionally.  Both halves are wrong.

esp_pm_light_sleep_start() already stalls and restores the systimer
itself, but only where SOC_SLEEP_SYSTIMER_STALL_WORKAROUND is defined --
esp32c3 and esp32p4.  On every other SoC, esp32s3 included, the systimer
keeps counting straight through light sleep, so the time is already in
the clock and stepping it again adds it twice.

Measured on an esp32s3-xiao: over 54 min with 1919 light sleeps totalling
454.7 s, the monotonic clock ran 443.2 s fast -- 0.97 of the time slept,
i.e. counted exactly twice, leaving the clock 13.8% fast.  Anything that
reconstructs wall time from CLOCK_MONOTONIC inherits that error; for this
collar it corrupted every IMU sample timestamp.

Invisible until light sleep started happening for real, because a board
that never sleeps never steps the clock.

Note for upstream: the risc-v copy here only switches to the measured
duration and does not gate on SOC_SLEEP_SYSTIMER_STALL_WORKAROUND.  The
two should be reconciled before this is proposed -- it is kept as-is so
the asymmetry is visible rather than silently decided.

Signed-off-by: Felipe Moura <moura.fmo@gmail.com>
Assisted-by: Claude:claude-opus-5
2026-09-22 19:30:21 +08:00
Felipe Moura
3d267aab2a espressif/esp_irq.c: fix up_disable_irq()/up_enable_irq() for GPIO IRQs
esp_gpio_irq() registers per-pin GPIO interrupts through
gpio_isr_handler_add(), never through esp_setup_irq(), so
esp_get_handle() never finds them and up_disable_irq()/up_enable_irq()
silently no-op for any GPIO-derived irq number. Fall back to
esp_gpioirqdisable()/esp_gpioirqenable() (translating irq back to a
pin via ESP_IRQ2PIN()) when the normal interrupt-matrix lookup misses.

This surfaced through drivers/sensors/lsm6ds3trc_uorb.c: its ISR
schedules a worker to drain the sensor's FIFO over I2C and disables
its own IRQ until the worker re-enables it, so a level-triggered
source (e.g. a PM GPIO wake source left in level mode) doesn't
refire continuously and starve every task, HPWORK included, before
the worker ever gets to run. That disable/enable only works now that
up_disable_irq()/up_enable_irq() actually do something for GPIO irqs.

Signed-off-by: Felipe Moura <moura.fmo@gmail.com>
Assisted-by: Claude:claude-sonnet-5
2026-09-22 13:50:01 +08:00
David Vidrie Leon
074c8e3034 arch/arm/stm32h5: add missing I2C2/I2C4 pin remap options
Add 8 missing AF4 I2C2/I2C4 pin remap defines to
stm32h56xxx_pinmap.h, per ST's datasheet. Needed by boards that wire
I2C2/I2C4 to these pins; without them such configs fail to compile.

Reduced from a larger internal patch; the stm32_i2c.c part of that
patch is already upstream, so only this pinmap gap remained.

Co-authored-by: David Vidrie Leon <davidvidrie@geotab.com>
Signed-off-by: Marwan Madkour <marwanmadkour@geotab.com>
2026-09-22 13:32:10 +08:00
Felipe Moura
66831010e5 esp32s3/esp32s3_i2c.c: hold off light sleep for the duration of an I2C transfer
Light sleep gates the APB clock the I2C peripheral runs on.  A transfer
in flight stops mid-message and never raises its completion interrupt, so
the caller blocks in i2c_sem_waitdone() until ESP32S3_I2CTIMEOTICKS
expires and gets -ETIMEDOUT for a bus that was working perfectly.

The caller is what causes it.  Blocking in i2c_sem_waitdone() is exactly
what makes the idle task runnable, and the idle task is what decides to
sleep -- so the longer the transfer, the likelier it is to be cut in half
by its own wait.  Nothing about this is driver-specific.

Seen on an esp32s3-xiao reading an LSM6DS3TR-C FIFO: 6000 bytes in one
transaction, some 135 ms of bus time at 400 kHz, failing with -110 over
and over.  A WHO_AM_I probe and the FIFO status read, both short, never
failed once in the same runs -- only the long burst did.

The consequences went well past one failed read.  With the FIFO left
undrained the sensor's level-triggered INT1 stayed asserted, the worker
was re-entered the moment the IRQ was re-enabled, and that hot loop
starved every other task until the board wedged with no console output
and no crash dump.

pm_stay(PM_IDLE_DOMAIN, PM_IDLE) is the lightest lock that suffices:
greedy_governor_checkstate() walks up from PM_NORMAL and stops at the
first state holding a wakelock, so a stay at PM_IDLE keeps the domain out
of PM_STANDBY and PM_SLEEP while still allowing the plain WFI idle.
There is no early return between the stay and the relax.

Validated over 3 h 45 of continuous acquisition across two sessions:
wakes and drains stayed 1:1 (302/302, then 375/375), zero I2C failures of
any kind, and light sleep itself unaffected -- 11.8% of wall time asleep
in both, median sleep 2.08 s.

Signed-off-by: Felipe Moura <moura.fmo@gmail.com>
Assisted-by: Claude:claude-opus-5
2026-09-22 13:31:30 +08:00
Felipe Moura
7c02367483 esp32s3/esp32s3_idle.c: report light-sleep time to the PM statistics
/proc/pm/state0 reported a flat 0 s in its SLEEP column on a board that
was demonstrably light-sleeping, because this port never told the PM core
it had slept.

pm_stats() (drivers/power/pm/pm_changestate.c) splits the time since the
last transition into dom->wake[state] or dom->sleep[state] depending on
whether the state it is handed is PM_RESTORE.  up_idlepm() called
esp_pmstandby() and carried straight on, so every second -- including the
ones spent in light sleep -- was billed to wake[].  The statistics
CONFIG_PM_PROCFS advertises were simply never true here.

Read from an esp32s3-xiao that had just spent 89 s in PM_STANDBY:

  DOMAIN0                   WAKE           SLEEP          TOTAL
  standby                  89s  83%        0s   0%       89s  83%

Only PM_STANDBY needs this.  PM_SLEEP is deep sleep and does not return
at all -- the chip resets -- so there is nothing to attribute on its way
back.

pm_changestate(domain, PM_RESTORE) is the documented way to say this: it
skips the driver prepare/veto phase, records the statistic, notifies
drivers of the restore, and deliberately does not overwrite the domain's
state, so the domain stays in PM_STANDBY as it should.

Signed-off-by: Felipe Moura <moura.fmo@gmail.com>
Assisted-by: Claude:claude-opus-5
2026-09-22 13:29:13 +08:00
Felipe Moura
d31609d8dd esp32s3/esp32s3_idle.c: unwedge the PM state machine after the first wakeup
up_idlepm() put the domain back in PM_NORMAL with pm_changestate() but
left its local oldstate holding whatever it was before sleeping, usually
PM_STANDBY.  The pm_checkstate() below then returned PM_STANDBY again,
the "newstate != oldstate" test compared PM_STANDBY against a stale
PM_STANDBY, and the whole block was skipped -- including the
esp_pmstandby() call that is the only thing in here that ever sleeps.

So after the very first wakeup the board reported PM_NORMAL essentially
forever, and light-slept only when something else happened to perturb
oldstate, such as an application taking and releasing a PM_IDLE wakelock
around a transmission window.

Measured on the esp32s3-xiao collar before this fix: 4.1 s of actual
light sleep in 2 h of near-total idleness, a 1780:1 awake-to-asleep
ratio.  After it: ~13.5% of wall time asleep, thousands of sleeps, no
storms.

The dead "newstate = PM_NORMAL" assignment that used to sit here was
presumably meant to be this; it is overwritten by pm_checkstate() a few
lines below and never had any effect.

Note that fixing this is what exposed two further bugs that had been
dormant behind a board that never slept: the systimer double-count in
esp_pmstandby(), and I2C transfers being cut in half by sleep.  Both are
fixed in their own commits.

Signed-off-by: Felipe Moura <moura.fmo@gmail.com>
Assisted-by: Claude:claude-opus-5
2026-09-22 13:29:13 +08:00
Daniel P. Carvalho
267408861c arch/arm/stm32h7: timestamp the transmitted frames in hardware.
Support STM32_ETH_TIMESTAMP_TX on the STM32H7, as the legacy STM32 do,
with the timestamp returned through SO_TIMESTAMPING.

When a packet socket asks for the transmit timestamp of a frame, keep a
copy of the frame and ask the MAC to timestamp it in the descriptor. When
the transmission is done, take the timestamp from the descriptor and give
the copy back to the network stack with it, that delivers it to the error
queue of the socket. The MAC writes the timestamp over the address of the
buffer in the descriptor, so the driver keeps the buffer of these
descriptors. The copies that still wait for their timestamp are released
when the interface goes down.

With a PTP daemon using the peer-to-peer delay mechanism against a
grandmaster clock, the path delay measured was between 9.0 and 9.1 us.

Signed-off-by: Daniel P. Carvalho <danieloak@gmail.com>
Assisted-by: Claude:claude-sonnet-5
2026-09-21 21:45:01 +08:00
Ulaş Sertan Kemeç
fa935ecae1 drivers/vhost: Add vhost-net, a device-role virtio network driver.
Implements the device end of virtio-net, so a peer running the stock
virtio-net driver sees this side as a network card, and registers a netdev
lowerhalf.

Ring layout follows the peer's numbering: vq[0] is its RX queue, which we fill
to transmit, and vq[1] its TX queue, which we harvest.  No features are
negotiated, so every frame carries the zeroed legacy virtio_net_hdr.

Peer buffers are reached by raw 64-bit address through an arch-provided
translation window -- the AM67 RAT, identity mapping elsewhere -- splitting
copies that straddle it.

Also gives DRIVERS_VHOST a prompt; it was promptless and so unselectable
without a driver forcing it.

Verified on t3-gem-o1 against an unmodified Linux virtio_net: eth0 registers,
ifup brings it to RUNNING, and the peer pings it 5/5 at 0.27 ms and 60/60 with
0% loss.

Assisted-by: Claude Code:claude-fable-5
Signed-off-by: Ulaş Sertan Kemeç <sertan.usk@gmail.com>
2026-09-21 10:40:13 -03:00
Royyan Zahir
72928d5dec arch/arm64: AES using the Armv8 Cryptography Extension.
NuttX emits no AES instruction on any arm64 core. There is no runtime
feature dispatch in arch/arm64, so every AES goes through crypto/rijndael.c
or crypto/aes.c, and the table-driven one indexes memory with key-dependent
values, so its timing follows the cache.

Provide aes_cypher() for ECB, CBC and CTR built on AESE, AESD and the
MixColumns pair, and register it with /dev/crypto as a hardware driver
alongside the existing stm32h7, sam34 and esp32 modules.

ID_AA64ISAR0_EL1.AES is read on every call, which returns -ENOTSUP rather
than trapping on a core without the extension.

Verified against the NIST SP 800-38A appendix F vectors for ECB-128,
ECB-256, CBC-128, CBC-192 and CTR-128, encrypt and decrypt, in place and
out of place.

Signed-off-by: Royyan Zahir <royzah@gmail.com>
2026-09-21 18:43:36 +08:00
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