Commit graph

17102 commits

Author SHA1 Message Date
jsanchez-2g
4ebc8a7291 arm/stm32g0: Add USB device controller support
Some checks are pending
MemBrowse Memory Report / changes-filter (push) Waiting to run
MemBrowse Memory Report / load-targets (push) Waiting to run
MemBrowse Memory Report / identical (push) Blocked by required conditions
MemBrowse Memory Report / analyze (push) Blocked by required conditions
Add the STM32G0 USB interrupt, memory map, register layout, HSI48 clocking, power control, packet memory handling, and device-controller support.

Assisted-by: OpenAI Codex
Signed-off-by: jsanchez-2g <jsanchez@2g-eng.com>
2026-08-22 11:09:08 +08:00
jsanchez-2g
421bd04a95 boards/nucleo-l073rz: Add USB device support and a CDC/ACM configuration.
The STM32L073RZ provides a full speed USB device controller, but the
Nucleo-L073RZ board support did not enable it and no configuration
exercised it.

Add the pieces required to run USB device mode on this board:

- Add the USB device pin definitions to the STM32L0 pin map.
- Provide board level pull-up control using the embedded DP pull-up in
  USB_BCDR, and register the CDC/ACM class at boot when it is selected.
- Add a usb-cdc configuration that presents an NSH console on USART2 and
  a CDC/ACM serial device on USB.

The 48MHz clock for the controller is supplied by HSI48 trimmed from the
USB start of frame packet, which is the crystal-less USB configuration
already described by this board's board.h.

Assisted-by: GitHub Copilot:claude-opus-5
Signed-off-by: jsanchez-2g <jsanchez@2g-eng.com>
2026-08-22 01:23:12 +08:00
Liam Howatt
4b3116df4c arch/arm/stm32h5: Support non-DMA and DMA SPI instances together.
The stm32h5 SPI driver had some issues when both
non-DMA and DMA instances were present at the same time.
Modify the driver to allow them to correctly coexist.

Signed-off-by: Liam Howatt <liamhowatt@geotab.com>
2026-08-21 19:57:10 +08:00
Liam Howatt
e47b8a7298 arch/arm/stm32h5: Port DMA support to SPI driver.
The stm32h5 SPI driver is based on stm32h7's.
It does not build when DMA is enabled. Port
stm32h5 DMA to the stm32h5 SPI driver using the
H5-specific DMA API. Use equivalents.

Use correct cache line definition.

Signed-off-by: Liam Howatt <liamhowatt@geotab.com>
2026-08-21 19:57:10 +08:00
Liam Howatt
a308b20723 arch/arm/stm32h5: Use FIFO for spi exchange.
Use the SPI hardware FIFO to increase the throughput of
non-DMA SPI exchanges.

Signed-off-by: Liam Howatt <liamhowatt@geotab.com>
2026-08-21 19:57:10 +08:00
Liam Howatt
4d1dc6334a boards/stm32h5/nucleo-h563zi: Register SPI1 spidev.
Add board spi1 initialization and generic spi
chardev registration for nucleo-h563zi.

Specify the SPI1 clock source and frequency on
this board for the spi driver.
Define the SPI pins for this board. The SPI_A
CN7 header pins were used.

Include stm32_spi.h in stm32h5/stm32.h.

Signed-off-by: Liam Howatt <liamhowatt@geotab.com>
2026-08-21 19:57:10 +08:00
jsanchez-2g
407aeb4aff arm/stm32: Decode saved M0 USB setup requests.
Decode the saved setup request fields after processing the optional OUT data phase. This ensures the fields are initialized when the EP0 handler is entered again to complete an OUT control transfer.

This also fixes Clang builds that treat the resulting maybe-uninitialized diagnostics as errors.

Assisted-by: Codex:GPT-5
Signed-off-by: jsanchez-2g <jsanchez@2g-eng.com>
2026-08-21 19:39:13 +08:00
raiden00pl
0619816787 boards/arm/stm32h5: add Nucleo-H503RB board support
minimal bring-up for the ST Nucleo-H503RB

Signed-off-by: raiden00pl <raiden00@railab.me>
Assisted-by: Claude Code
2026-08-21 08:10:05 -03:00
raiden00pl
6086f09174 arch/arm/stm32h5: add support for STM32H503RB
Add the STM32H50XXX support

Signed-off-by: raiden00pl <raiden00@railab.me>
Assisted-by: Claude Code
2026-08-21 08:10:05 -03:00
Darryl Ring
5a16381540 arch/arm/stm32h5: Fix MCO clock pins and config
Add the correct pin map definitions for MCO1 and MCO2, and add the clock
division option to stm32_mco{1,2}config with a macro. This matches the
STM32H7 implementation.

Signed-off-by: Darryl Ring <darryl@bluerobotics.com>
2026-08-21 12:56:23 +02:00
Darryl Ring
0cbde9ebe4 arch/arm/stm32h5: Fix SPI4 macro verification
There was a duplicate check for SPI1 macros instead of SPI4.

Signed-off-by: Darryl Ring <darryl@bluerobotics.com>
2026-08-21 14:06:14 +08:00
raiden00pl
f01134b144 arch/arm/stm32h5: add support for STM32H533RE
Add the STM32H53XXX support.

Signed-off-by: raiden00pl <raiden00@railab.me>
Assisted-by: Claude Code
2026-08-20 22:54:41 +02:00
jsanchez-2g
8c8ae92530 boards/nucleo-f072rb: Add USB device support and a CDC/ACM configuration.
The STM32F072RB provides a full speed USB device controller, but the
Nucleo-F072RB board support did not enable it and no configuration
exercised it.

Add the pieces required to run USB device mode on this board:

- Select HSI48 as the 48MHz source and use the USB start of frame packet
  as the CRS synchronisation event, which is the intended crystal-less
  USB configuration for this part.
- Add the USB device pin definitions to the STM32F07x pin map.
- Provide board level pull-up control and register the CDC/ACM class at
  boot when it is selected.
- Add a usb-cdc-uart configuration that presents an NSH console on
  USART2 and a CDC/ACM serial device on USB.
- Enable the USB device pins in the nsh configuration so the two
  configurations stay consistent.

Assisted-by: GitHub Copilot:claude-opus-5
Signed-off-by: jsanchez-2g <jsanchez@2g-eng.com>
2026-08-20 15:16:33 -03:00
jsanchez-2g
a5477dc4dc stm32l0: Write back SYSCFG_CFGR3 when enabling the HSI48 reference.
Some checks are pending
MemBrowse Memory Report / changes-filter (push) Waiting to run
MemBrowse Memory Report / load-targets (push) Waiting to run
MemBrowse Memory Report / identical (push) Blocked by required conditions
MemBrowse Memory Report / analyze (push) Blocked by required conditions
vrefint_enable() sets SYSCFG_CFGR3_ENBUFVREFINTHSI48 in its local copy
of the register value but never writes that value back to the hardware.
The VREFINT reference for the HSI48 scaler is therefore never enabled.

Only the earlier ENVREFINT update reaches the register, so VREFINT
itself is enabled while the HSI48 reference is not.  HSI48 then runs
without its voltage reference and the 48MHz clock is not accurate enough
to be used by the USB device controller.

Write the register after applying the HSI48 reference bit.

Assisted-by: GitHub Copilot:claude-opus-5
Signed-off-by: jsanchez-2g <jsanchez@2g-eng.com>
2026-08-20 16:25:52 +08:00
jsanchez-2g
a266398a4f arm/stm32: Enable the CRS frequency error counter with autotrim.
stm32_enable_hsi48() set CRS_CR_AUTOTRIMEN but left CRS_CR_CEN clear.
AUTOTRIMEN only instructs the hardware to apply corrections derived from
the frequency error counter; the counter itself is enabled by CEN.  With
CEN clear no error measurement is ever produced and the HSI48 TRIM value
stays at its reset default, so the oscillator is never disciplined to the
synchronisation source.

Set both bits, matching the value the STM32 ROM bootloader programs when
it runs its own crystal-less USB stack (CRS_CR = 0x1a60, i.e.
CEN | AUTOTRIMEN with a trimmed TRIM field).

This file is shared by the M0 STM32 parts (F0, G0, C0, L0); all of them
require CEN for automatic trimming to function.

Assisted-by: GitHub Copilot:claude-opus-5
Signed-off-by: jsanchez-2g <jsanchez@2g-eng.com>
2026-08-20 16:25:52 +08:00
jsanchez-2g
16e3c8c6de stm32l0: Enable SYSCFG clock when VREFINT is enabled.
The SYSCFG peripheral clock was gated on CONFIG_STM32_SYSCFG, but that
symbol is not defined by the STM32L0 Kconfig (only stm32h7 declares it),
so RCC_APB2ENR_SYSCFGEN was never set on this chip.

With SYSCFG unclocked every write performed by vrefint_enable() is
discarded and SYSCFG_CFGR3 reads back as 0x00000000.  VREFINT and, in
particular, the ENBUFVREFINTHSI48 reference for the HSI48 oscillator are
therefore never enabled.  HSI48 still reports HSI48RDY, but it runs
without its voltage reference and the 48MHz clock supplied to the USB
device controller is unusable: the controller cannot sample the bus,
never latches a reset condition in USB_ISTR, and never raises its
interrupt.  The result is a USB device that is configured correctly in
every visible register yet never enumerates.

VREFINT is configured exclusively through SYSCFG_CFGR3, so enable the
SYSCFG clock whenever CONFIG_STM32_VREFINT is selected.

Observed on NUCLEO-L073RZ (STM32L073RZ):

  before: SYSCFG_CFGR3 = 0x00000000, no enumeration
  after:  SYSCFG_CFGR3 non-zero, device enumerates as CDC/ACM

Assisted-by: GitHub Copilot:claude-opus-5
Signed-off-by: jsanchez-2g <jsanchez@2g-eng.com>
2026-08-20 16:25:52 +08:00
jsanchez-2g
561da42812 stm32f0/l0: Gate the CRS clock on STM32_USE_HSI48.
The clock recovery system peripheral clock was enabled only when
CONFIG_STM32_CRS was selected.  The CRS is required by any board that
uses HSI48 as the 48MHz clock source, because HSI48 must be trimmed from
an external synchronisation event to stay within the tolerance demanded
by USB full speed operation.

STM32_USE_HSI48 is the condition under which the remaining HSI48 and CRS
setup is compiled in, see stm32_enable_hsi48(), so accept that condition
here as well.  Without the peripheral clock the CRS registers are
inaccessible and automatic trimming silently does nothing.

CONFIG_STM32_CRS is retained so that boards selecting the CRS directly
are unaffected.

Assisted-by: GitHub Copilot:claude-opus-5
Signed-off-by: jsanchez-2g <jsanchez@2g-eng.com>
2026-08-20 16:25:52 +08:00
jsanchez-2g
d70725e4e0 arm/stm32: Fix the USB reset sequence in arm_usbinitialize().
The code that claimed to "enable clocking to the USB peripheral" cleared
RCC_APB1ENR_USBEN inside RCC_APB1RSTR.  That is both the wrong register
and the wrong bit: USBEN belongs to RCC_APB1ENR, while APB1RSTR holds
RCC_APB1RSTR_USBRST.  The peripheral clock is enabled by the RCC setup
performed at boot, so the write had no useful effect and merely cleared
an unrelated reset bit.

Issue a proper reset pulse on RCC_APB1RSTR_USBRST instead, so the
controller starts from a known state.

On STM32L0 the D+/D- lines are connected to the USB transceiver
automatically once the peripheral is enabled and there is no alternate
function to select, so skip the GPIO configuration on that chip.  The
board GPIO_USB_DM/GPIO_USB_DP definitions do not exist there.

Assisted-by: GitHub Copilot:claude-opus-5
Signed-off-by: jsanchez-2g <jsanchez@2g-eng.com>
2026-08-20 16:25:35 +08:00
jsanchez-2g
fc05091e18 arm/stm32: Enable and acknowledge USB error interrupts on M0 parts.
The initial interrupt mask enabled only reset, suspend and correct
transfer.  Error conditions reported by the controller, USB_ISTR_ERR and
USB_ISTR_PMAOVRN, were neither enabled nor acknowledged.

Because the status bits are never cleared, an error condition latched in
USB_ISTR remains set and is re-evaluated on every subsequent interrupt,
which makes the reported status misleading when debugging transfer
problems.

Add ERRM and PMAOVRN to the initial mask and clear the corresponding
status bits when they are seen.

Assisted-by: GitHub Copilot:claude-opus-5
Signed-off-by: jsanchez-2g <jsanchez@2g-eng.com>
2026-08-20 16:25:35 +08:00
jsanchez-2g
432d21a116 arm/stm32: Route EP0 completions to the EP0 handler on M0 parts.
The correct transfer loop in stm32_usb_interrupt() dispatched every
completion to stm32_epdone(), including those for endpoint 0.

stm32_epdone() implements the generic bulk/interrupt endpoint completion
path.  It does not decode the SETUP stage, does not maintain the EP0
state machine, and does not apply the EP0 specific RX/TX status rules.
Control transfers therefore never completed correctly and the device
could not be enumerated.

Dispatch endpoint 0 to stm32_ep0done(), which is the control endpoint
handler and is already used for the same purpose by the low priority
transfer path in stm32_lptransfer().

Assisted-by: GitHub Copilot:claude-opus-5
Signed-off-by: jsanchez-2g <jsanchez@2g-eng.com>
2026-08-20 16:25:35 +08:00
jsanchez-2g
a271b641a5 arm/stm32: Fix USB packet memory addressing on M0 parts.
The packet memory area (PMA) accessors in the M0 USB device driver were
carried over from the STM32F1 implementation, where the PMA is seen by
the CPU as 16-bit values placed on 32-bit boundaries.  On the STM32F0,
STM32L0 and other M0 parts the PMA is a linear 16-bit memory, so the
F1 scaling is wrong:

- STM32_USB_BTABLE_RADDR() shifted the computed buffer descriptor offset
  left by one, addressing every second descriptor entry.
- The buffer descriptor accessors declared the descriptor entries as
  uint32_t and accessed them 32 bits at a time, so each write clobbered
  the adjacent entry.
- stm32_copytopma() and stm32_copyfrompma() scaled the PMA offset by two
  when computing the packet buffer address.

The result is that endpoint buffer descriptors and packet data are
written to the wrong offsets in packet memory, and no transfer completes
correctly.

Drop the F1 scaling and use 16-bit accesses throughout.  Note that the
sibling stm32_usbfs.h defines STM32_USB_BTABLE_RADDR() without the shift
already, so this brings the M0 header in line with it.

Assisted-by: GitHub Copilot:claude-opus-5
Signed-off-by: jsanchez-2g <jsanchez@2g-eng.com>
2026-08-20 16:25:35 +08:00
raiden00pl
a5f8fdaa2e arch/stm32: remove dead STM32 Cortex-M0 GPIO IRQ init
Some checks are pending
Build Documentation / build-html (push) Waiting to run
MemBrowse Memory Report / changes-filter (push) Waiting to run
MemBrowse Memory Report / load-targets (push) Waiting to run
MemBrowse Memory Report / identical (push) Blocked by required conditions
MemBrowse Memory Report / analyze (push) Blocked by required conditions
CONFIG_STM32_GPIOIRQ has never had a Kconfig definition, and the guarded
stm32_gpioirqinitialize function has no declaration or implementation.

Signed-off-by: raiden00pl <raiden00@railab.me>
Assisted-by: OpenAI Codex:gpt-5
2026-08-19 22:17:03 +02:00
raiden00pl
1144671164 arch/stm32: remove dead STM32F7/H7 GPIO IRQ code
CONFIG_STM32_GPIO_IRQ has no Kconfig definition, and the guarded stm32_gpioirq
functions have no declarations or implementations.

Signed-off-by: raiden00pl <raiden00@railab.me>
Assisted-by: OpenAI Codex:gpt-5
2026-08-19 22:17:03 +02:00
Lwazi Dube
ba6ce5ea32 boards/arm: Add support for the original BeagleBone
Add initial NuttX port for the original (white) BeagleBone board, which is
powered by the TI AM335x Sitara Cortex-A8 processor.

This commit includes:
- Board documentation
- Board support package files derived from BeagleBone black
- Architecture-specific page allocator for memory management in kernel build.
- Default configurations for both flat (`nsh`) and kernel (`knsh`) builds
  running via U-Boot from a microSD card.

Signed-off-by: Lwazi Dube <lwazeh@gmail.com>
2026-08-19 10:11:38 +08:00
Liam Howatt
b013f074f4 arch/arm/stm32h5: IWDG remove some ifdefs, extend prescaler.
Remove the feature #ifdef guard since the file
is conditionally compiled.

Remove the #ifdefs for other stm32 families that came from the
common stm32_wdg.h.

Add additional extended prescaler values for stm32h5 IWDG.

Change the WWDG_CFR_WDGTB shift value to match
what it should be on stm32h5. (WWDG not supported on stm32h5 yet.)

Signed-off-by: Liam Howatt <liamhowatt@geotab.com>
2026-08-18 15:18:08 -03:00
Liam Howatt
8983489b8b arch/arm/stm32h5: Add IWDG support.
Copy the common m3m4_v1 implementation. The only
difference is a debug log of the register which
contains the LSI enabled status bit. In the common
implementation the register is RCC_CSR. On stm32h5
it is RCC_BDCR.

The common implementation is _not_ used because it's
only built if CONFIG_STM32_COMMON_LEGACY which
stm32h5 currently is not. IWDG is added similarly to stm32l4.
STM32_HAVE_IP_WDG_M3M4_V1 is selected but a distinct
source file implements it.

Signed-off-by: Liam Howatt <liamhowatt@geotab.com>
Co-authored-by: Nathan Best <nathanbest@geotab.com>
2026-08-18 15:18:08 -03:00
raiden00pl
da74440a20 arch/arm: add stm32u0 support
add stm32u0 support

Signed-off-by: raiden00pl <raiden00@railab.me>
Assisted-by: Claude Code
2026-08-18 15:00:15 +02:00
raiden00pl
2ef5db01f0 arch/arm/stm32: use common SYSTICK_HCLKd8 symbol
The SysTick timer logic of stm32h5, stm32h7, stm32l4, stm32l5, stm32u5
and stm32wl5 tests a family specific SYSTICK_HCLKd8 symbol, while
common/stm32 and stm32wb already test CONFIG_STM32_SYSTICK_HCLKd8.  Use
the common name everywhere.

No Kconfig defines the symbol and the timer logic undefines it
unconditionally, so this does not change the generated code.

Signed-off-by: raiden00pl <raiden00@railab.me>
Assisted-by: Claude Code
2026-08-18 09:34:58 +08:00
raiden00pl
968005810c arch/arm/stm32wb: use common Kconfig symbols
The flash header documents CONFIG_STM32WB_FLASH_CONFIG_x and the RCC
tests CONFIG_STM32WB_AES1/AES2, which no Kconfig defines.  Use the
common CONFIG_STM32_* names.

Signed-off-by: raiden00pl <raiden00@railab.me>
Assisted-by: Claude Code
2026-08-18 09:34:58 +08:00
raiden00pl
0ee1608bf0 arch/arm/stm32wl5: use common Kconfig symbols
CONFIG_STM32WL5_FLASHEN is not defined by any Kconfig, so the FLASH clock
enable is dead code.  Use CONFIG_STM32_FLASH.

Signed-off-by: raiden00pl <raiden00@railab.me>
Assisted-by: Claude Code
2026-08-18 09:34:58 +08:00
raiden00pl
8c23508510 arch/arm/stm32u5: use common Kconfig symbols
CONFIG_STM32U5_I2C3EN, SDMMC1EN, SDMMC2EN, the STM32U5xxXX family names
and STM32U5A5ZJT are not defined by any Kconfig, so the RCC clock enables
and the STM32U5A5ZJT block in chip.h are dead code.  Use the common
CONFIG_STM32_* symbols and CONFIG_ARCH_CHIP_STM32U5A5ZJT.

Signed-off-by: raiden00pl <raiden00@railab.me>
Assisted-by: Claude Code
2026-08-18 09:34:58 +08:00
raiden00pl
e68f9a7c85 arch/arm/stm32l5: use common Kconfig symbols
CONFIG_STM32L5_FLASHEN, OTFDEC1EN, PKAEN, SDMMC1EN, WWDGEN and GTZCEN
are not defined by any Kconfig, so the RCC clock enables are dead code.
Use the common CONFIG_STM32_* peripheral symbols.

Signed-off-by: raiden00pl <raiden00@railab.me>
Assisted-by: Claude Code
2026-08-18 09:34:58 +08:00
raiden00pl
b1df5ddfb8 arch/arm/stm32l4: use common Kconfig symbols
CONFIG_STM32L4_OTGFS_SOFOUTPUT is not defined by any Kconfig, so the SOF
output pin is never enabled.  Use CONFIG_STM32_OTG_SOFOUTPUT.

Signed-off-by: raiden00pl <raiden00@railab.me>
Assisted-by: Claude Code
2026-08-18 09:34:58 +08:00
raiden00pl
0de50ad42e arch/arm/stm32h7: use common Kconfig symbols
CONFIG_STM32H7_LCD_BACKLIGHT is not defined by any Kconfig, so the LTDC
backlight control is dead code.  Use CONFIG_STM32_LTDC_BACKLIGHT.

Signed-off-by: raiden00pl <raiden00@railab.me>
Assisted-by: Claude Code
2026-08-18 09:34:58 +08:00
raiden00pl
f15d609069 arch/arm/stm32h5: use common Kconfig symbols
The headers test CONFIG_STM32H5_* names that no Kconfig defines (the
STM32H5xXXX families, FLASHEN, OTFDEC1EN, DCACHE, STM32H2X/H3X/H7X), so
those branches are dead code.  Use the common CONFIG_STM32_* symbols.

Fix what this exposes: derive the SRAM2/SRAM3 bases from the family SRAM
sizes, since the boot ECC init would otherwise write past the end of RAM
on smaller parts, correct the H52x/H53x SPI count to SPI1-4 and drop the
STM32_STM32H5X3XX select, which names no symbol.

Signed-off-by: raiden00pl <raiden00@railab.me>
Assisted-by: Claude Code
2026-08-18 09:34:58 +08:00
raiden00pl
20f15ba2e3 arch/arm/stm32f7: use common Kconfig symbols
CONFIG_STM32F7_LCD_BACKLIGHT is not defined by any Kconfig, so the LTDC
backlight control is dead code.  CONFIG_STM32F7_PLLSAI and
CONFIG_STM32F7_PLLI2S are defined by the board.h files, and the common
SPI test helper names its mode macros CONFIG_STM32F7_SPIx_TEST_MODE.
Use the common CONFIG_STM32_* names everywhere.

Also drop the misspelled CONFIG_STM32F7_STM33F75XX from the DMA chip
check, which already tests CONFIG_STM32_STM32F75XX.

The CAN section of the STM32F7 documentation names the options
CONFIG_STM32F7F7_CANx, which has a duplicated family prefix and never
existed.  Use the common names there too.

Signed-off-by: raiden00pl <raiden00@railab.me>
Assisted-by: Claude Code
2026-08-18 09:34:58 +08:00
dechao_gong
eaaba5e0a1 arch/arm/rtl8721f: add PWM master driver support
Wire the shared Ameba PWM driver (arch/arm/src/common/ameba/ameba_pwm.c)
to RTL8721F (amebagreen2).  The chip spreads PWM across four four-channel
timers (TIM4..TIM7); this port drives TIM4 as the single time base with
four compare channels, matching the shared driver's model.  A new
ameba_pwm_chip.h supplies the RTL8721F specifics taken from the SDK
fwlib headers: TIM4 at the non-secure base 0x41000000, 40 MHz input
clock, IRQ 11 (TIMER4_IRQ), crossbar pad-mux codes 111..114
(PINMUX_FUNCTION_TIM4_PWM0..3) and the distinct function/clock enable
bits (APBPeriph_PWM0 / APBPeriph_PWM0_CLOCK).

The board registers one timer at /dev/pwm0 with channel 1 on PB18 and
channel 2 on PB19 for the pwm example; edit the table to match a board's
wiring.  The common driver is not touched.

Signed-off-by: dechao_gong <dechao_gong@realsil.com.cn>
Assisted-by: Claude <noreply@anthropic.com>
2026-08-17 09:34:22 -03:00
dechao_gong
2546802911 arch/arm/rtl8720f: add PWM master driver support
Wire the shared Ameba PWM driver (arch/arm/src/common/ameba/ameba_pwm.c)
to RTL8720F.  The chip spreads PWM across several four-channel timers
(TIM4/TIM5); this port drives TIM4 as the single time base with four
compare channels, matching the shared driver's model.  A new
ameba_pwm_chip.h supplies the RTL8720F specifics taken from the SDK
fwlib headers: TIM4 at the non-secure base 0x401c7000, 40 MHz input
clock, IRQ 9 (TIMER4_IRQ), crossbar pad-mux codes 45..48
(PINMUX_FUNCTION_TIM4_PWM0..3) and the distinct function/clock enable
bits (APBPeriph_PWM0 / APBPeriph_PWM0_CLOCK).

The board registers one timer at /dev/pwm0 with channel 1 on PB18 and
channel 2 on PB19 for the pwm example; edit the table to match a board's
wiring.  The common driver is not touched.

Signed-off-by: dechao_gong <dechao_gong@realsil.com.cn>
Assisted-by: Claude <noreply@anthropic.com>
2026-08-17 09:34:22 -03:00
dechao_gong
6f2e17c113 arch/arm/rtl8721dx: add shared Ameba PWM driver
Add a shared NuttX PWM lower-half for the Realtek Ameba PWM timer in
arch/arm/src/common/ameba, driven through the SDK fwlib.  TIM8 provides a
single time base feeding eight compare channels (CCR0..CCR7) that share one
frequency while each carries its own duty, so a single /dev/pwm0 exposes the
multichannel output via CONFIG_PWM_NCHANNELS.  The fwlib PWM routines are
split ROM/RAM: the time-base calls resolve from on-chip ROM, while the
capture/compare calls live in fwlib ram_common/ameba_tim.c, which the build
pulls into AMEBA_FWLIB_SRCS when CONFIG_AMEBA_PWM is set.

Per-chip wiring (timer index, channel count, register base, input clock,
IRQ, clock masks and the crossbar pad-mux code table) lives in
arch/arm/src/rtl8721dx/ameba_pwm_chip.h so a port to another Ameba chip only
supplies a same-named header; the pad-mux codes are a per-channel table
(AMEBA_PWM_PINMUX_FIDS) rather than a computed base, so chips with a single
shared code or codes grouped per timer are expressed by the header alone.

The timer registers as /dev/pwm0 from pke8721daf bring-up through the stock
PWM character driver; a dedicated `pwm` defconfig drives examples/pwm for
validation.

Signed-off-by: dechao_gong <dechao_gong@realsil.com.cn>
Assisted-by: Claude <noreply@anthropic.com>
2026-08-17 09:34:22 -03:00
Liam Howatt
b245cc1762 arch/arm/stm32h5: Add EXTI GPIO support.
Copy the stm32u5 implementation,
add necessary port configuration for the MUXs.

Signed-off-by: Liam Howatt <liamhowatt@geotab.com>
Co-authored-by: Nathan Best <nathanbest@geotab.com>
Co-authored-by: Randy Rossi <randyrossi@geotab.com>
2026-08-17 10:45:14 +02:00
raiden00pl
440be49862 arch/arm/src/common/stm32: read UID with 32-bit accesses
STM32H5 stores the UID in flash memory that supports only 16-bit or
32-bit read accesses. The 8-bit reads introduced with the stm32_uid
unification generate an AHB bus error and hard fault the chip when
the Ethernet driver reads the MAC address.

Read the UID as three 32-bit words into an aligned buffer and copy it
to the caller's buffer. On little-endian ARM the resulting byte order
is identical to byte reads, so behavior is unchanged for the other
STM32 families.

Fixes: https://github.com/apache/nuttx/issues/19771

Signed-off-by: raiden00pl <raiden00@railab.me>
Assisted-by: Claude Code
2026-08-16 08:42:20 -03:00
dechao_gong
36a971567a arch/arm/rtl8721f: add SPI master driver support
Some checks failed
MemBrowse Memory Report / changes-filter (push) Waiting to run
MemBrowse Memory Report / load-targets (push) Waiting to run
MemBrowse Memory Report / identical (push) Blocked by required conditions
MemBrowse Memory Report / analyze (push) Blocked by required conditions
Build Documentation / build-html (push) Has been cancelled
Wire the shared Ameba SPI (DesignWare SSI) driver
(arch/arm/src/common/ameba/ameba_spi.c) into the RTL8721F (amebagreen2)
build and expose the SPI0/SPI1 masters at /dev/spiN.

Add the per-chip ameba_spi_chip.h with the amebagreen2 controller bases
(0x40121000 / 0x40122000, non-secure aliases), the group-0 SPI clock masks
(bit14/bit15), and the per-signal crossbar pad-mux codes (SPI0 75/76/77/78,
SPI1 79/80/81/82).  The SSI ip_clk is the PERI_HCLK-domain clock, which the
amebagreen2 fwlib exposes directly through HPERI_ClkGet(), so AMEBA_SPI_IPCLK()
is a single ROM call rather than the register poking the other ICs need.

Compile the common driver and the SDK fwlib SSI RAM source under
CONFIG_AMEBA_SPI, register the bus in the board bring-up, and add an "spi"
board configuration exercising the system/spi spitool.

Assisted-by: Claude <noreply@anthropic.com>
Signed-off-by: dechao_gong <dechao_gong@realsil.com.cn>
2026-08-14 11:36:37 -03:00
dechao_gong
214d02f417 arch/arm/rtl8720f: add SPI master driver support
Wire the shared Ameba SPI (DesignWare SSI) driver
(arch/arm/src/common/ameba/ameba_spi.c) into the RTL8720F build and expose
the SPI0/SPI1 masters at /dev/spiN.

Add the per-chip ameba_spi_chip.h with the RTL8720F controller bases
(0x401C1000 / 0x401C2000, non-secure aliases), the group-0 SPI clock masks,
the per-signal crossbar pad-mux codes (RTL8720F has no generic
PINMUX_FUNCTION_SPI), and the SYS_PLL-based ip_clk computation
(REG_LSYS_CKD_SYS_PLL_GRP0 HPERI divider).  The chip header declares the
SYS_PLL_ClkGet() query its AMEBA_SPI_IPCLK() uses, since RTL8720F has no
PLL_ClkGet().

Compile the common driver and the SDK fwlib SSI RAM source under
CONFIG_AMEBA_SPI, register the bus in the board bring-up, and add an "spi"
board configuration exercising the system/spi spitool.

Assisted-by: Claude <noreply@anthropic.com>
Signed-off-by: dechao_gong <dechao_gong@realsil.com.cn>
2026-08-14 11:36:37 -03:00
dechao_gong
7dbf782e5b arch/arm/rtl8721dx: add shared Ameba SPI driver
Add a shared NuttX SPI master lower-half for the Realtek Ameba SPI
controllers (SPI0/SPI1) in arch/arm/src/common/ameba, driven through the
SDK fwlib in polling mode with full-duplex exchange and a software chip
select.  Per-chip wiring (controller count, register bases, clock masks,
crossbar pad-mux codes and the fwlib SSI_InitTypeDef layout) lives in
arch/arm/src/rtl8721dx/ameba_spi_chip.h so a port to the other Ameba
chips only supplies a same-named header.

Each controller registers as /dev/spiN from pke8721daf bring-up through
the stock SPI character driver; a dedicated `spi` defconfig drives the
spitool for validation.

Assisted-by: Claude <noreply@anthropic.com>
Signed-off-by: dechao_gong <dechao_gong@realsil.com.cn>
2026-08-14 11:36:37 -03:00
raiden00pl
45657b976b arch/nrf53: fix HFXO trim field extraction
fix HFXO trim field extraction

Signed-off-by: raiden00pl <raiden00@railab.me>
2026-08-13 21:52:30 +08:00
Javier Alonso
f8cf5f9d4e arch/s32k3xx: initializers clobbering rx_pin instead of enable_high
The `rx_pin` configuration when `CONFIG_S32K3XX_FLEXCAN2` is defined is
overwritten if `PIN_CAN2_ENABLE` is defined, breaking the flexcan config
for S32K3 MCU.

Signed-off-by: Javier Alonso <javieralonso@geotab.com>
2026-08-13 12:29:11 +02:00
Javier Alonso
2a777381d6 arch/kinetis: initializers clobbering rx_pin instead of enable_high
The `rx_pin` configuration when `CONFIG_KINETIS_FLEXCAN2` is defined is
overwritten if `PIN_CAN2_ENABLE` is defined, breaking the flexcan config
for Kinetis MCU. Additionally, the `.enable_high` configuration points to
a non-defined constant/macro (looks like a legacy from the first driver
definition). Based on regularly maintained drivers (such as s32k3), this
was changed to `CAN2_ENABLE_OUT`

Signed-off-by: Javier Alonso <javieralonso@geotab.com>
2026-08-13 12:29:11 +02:00
Javier Alonso
8730a75687 arch/s32k1xx: initializers clobbering rx_pin instead of enable_high
The `rx_pin` configuration when `CONFIG_S32K1XX_FLEXCAN2` is defined is
overwritten if `PIN_CAN2_ENABLE` is defined, breaking the flexcan config
for S32K1 MCU. Additionally, the `.enable_high` configuration points to
a non-defined constant/macro (looks like a legacy from the first driver
definition). Based on regularly maintained drivers (such as s32k3), this
was changed to `CAN2_ENABLE_OUT`

Signed-off-by: Javier Alonso <javieralonso@geotab.com>
2026-08-13 12:29:11 +02:00
dechao_gong
af49db4483 arch/arm/rtl8720f: add I2C master driver support
Wire the RTL8720F to the shared Ameba I2C master driver
(arch/arm/src/common/ameba/ameba_i2c.c), reusing it unchanged.

Add the per-chip header arch/arm/src/rtl8720f/ameba_i2c_chip.h supplying
the chip's I2C wiring: two controllers (I2C0/I2C1) on their non-secure
register aliases (0x401c8000 / 0x401c9000), the APBPeriph function/clock
masks, the crossbar SCL/SDA pad-mux codes (59/60 and 61/62), and
AMEBA_I2C_HAS_DMA_FIELDS=1 (the chip's I2C_InitTypeDef carries the DMA
request-level fields).

Add the board glue: rtl8720f_i2c.c registers I2C0 at /dev/i2c0
(PA22/PA23) and I2C1 at /dev/i2c1 (PA24/PA25), plus the build wiring
(Make.defs / CMakeLists.txt / ameba_board.mk pull in the common driver
and the fwlib ram_common/ameba_i2c.c data-table source), the bringup
registration hook and the board header declaration.

Add the i2c defconfig (minimal NSH with the i2ctool) and document the
config in the board index.

Signed-off-by: dechao_gong <dechao_gong@realsil.com.cn>
Assisted-by: Claude <noreply@anthropic.com>
2026-08-12 08:46:16 -03:00
dechao_gong
18d2ae253c arch/arm/rtl8720f: add UART master driver support
Wire the shared common UART driver
(arch/arm/src/common/ameba/ameba_uart.c) into RTL8720F.  Add an
ameba_uart_chip.h supplying the per-chip UART parameters: two
general-purpose controllers (UART0/UART1), their non-secure register
bases (0x401C3000 / 0x401C4000 -- the fwlib UART_DEV_TABLE points at
the non-secure alias), NVIC vectors, APBPeriph function/clock masks
and the crossbar TX/RX pad-mux function codes.

The fwlib ROM UART routines index data tables (UART_DEV_TABLE,
APBPeriph_UARTx) that live in fwlib ram_common/ameba_uart.c, so that
source is compiled in when CONFIG_AMEBA_UART is set.  Wire
CONFIG_AMEBA_UART into Make.defs/CMakeLists/ameba_board.mk, add the
board port table (UART0 at /dev/ttyS1, PA22 TX / PA23 RX, 115200 8N1)
with bringup registration, a uart config and board documentation.

Hardware-verified on rtl8720f_evb: serialrx/serialblaster over a
PA22-to-PA23 TX/RX loopback transferred all 2600 bytes intact.

Assisted-by: Claude <noreply@anthropic.com>
Signed-off-by: dechao_gong <dechao_gong@realsil.com.cn>
2026-08-12 08:46:16 -03:00