Commit graph

63346 commits

Author SHA1 Message Date
Jukka Laitinen
fae67d1608 boards/arm/imxrt/imxrt1180-evk: Add imxrt1189 evaluation board configurations
This adds the initial board configurattions for building NuttX for imxrt1189-evk.
Also add a script building the NXP container image for bootloaders (m33 images)

The board boots on Cortex-M33 core, for which there are two m33 targets: nsh-m33 and bl.

- "bl" target does basic initialization of ELE and TRDC and just releases the M7 to run
  at 0x20080000.
- "nsh-m33" target just boots nuttx into nsh shell on m33

- The "nsh" target is for M7 core. It can be flashed at 0x20080000, and
  it boots to nsh shell with a proper bootloader on m33 (the bl target does this).

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
Liam Howatt
27d948a27f Documentation/stm32h5: board.h clock defines.
Document the board.h keep-HSI-running-in-stop-mode define
STM32_BOARD_HSIKERON_ENABLE and the USART clock source
selection defines.

Signed-off-by: Liam Howatt <liamhowatt@geotab.com>
2026-09-19 08:52:17 -03:00
Liam Howatt
fa1d52a64d arch/arm/stm32h5: Add USART wake from low power.
Support USART waking from low power modes, allow keeping
HSI running in STOP mode, allow specifying clock source
for USARTs, add some missing register and field definitions.

stm32 common Kconfigs:
Add common STM32 UART config options USARTx_WAKE_FROM_LOW_POWER and USARTx_WUS
for USART to cause wake up from low power modes.

stm32h5 board configs:
Allow board.h to choose the clock source of each USART.
Allow board.h to express that HSI should continue running
in low power modes.

stm32h5 RCC:
Set the clock source for each USART if specified in the
board configs (STM32_RCC_CCIPR1_USARTxSEL).
Keep HSI on in STOP mode if specified in the board configs
(STM32_BOARD_HSIKERON_ENABLE).

stm32h5 serial driver:
Use the new USARTx_WAKE_FROM_LOW_POWER and USARTx_WUS in
stm32h5 serial driver to wake from low power modes.
Use the USART clock source specified by board configs.
Enable FIFOs.
Clear UE bit before initialization.

Co-authored-by: Javier Casas <javiercasas@geotab.com>
Co-authored-by: daniellizewski <daniellizewski@geotab.com>
Signed-off-by: Liam Howatt <liamhowatt@geotab.com>
2026-09-19 08:52:17 -03:00
Liam Howatt
85441f47a8 arch/arm/stm32h5: Fix nxstyle issues in stm32_serial.c.
Fix nxstyle issues in arch/arm/src/stm32h5/stm32_serial.c

Signed-off-by: Liam Howatt <liamhowatt@geotab.com>
2026-09-19 08:52:17 -03:00
Liam Howatt
92376dbac4 arch/arm/stm32h5: Fix duplicate define STM32_OTP_BASE.
STM32_OTP_BASE was defined independently in two separate contributions.
Remove one.

Signed-off-by: Liam Howatt <liamhowatt@geotab.com>
2026-09-19 08:52:17 -03:00
Marcio Ribeiro
35e6c252f4 arch/risc-v/espressif: add line-fitting ADC calibration
Use the HAL line-fitting APIs when curve fitting is not available.

Assisted-by: Cursor:Grok 4.6
Signed-off-by: Marcio Ribeiro <marcio.ribeiro@espressif.com>
2026-09-18 14:18:55 -03:00
wenquan1
1532596f6a net: fix pre-existing coding style issues in timestamp-related files
Fix coding style issues flagged by nxstyle in files touched by the
SO_TIMESTAMPING series. These are pre-existing issues, not introduced
by the SO_TIMESTAMPING patches:

- inet_sockif.c: missing blank lines after declarations
- ipv4_input.c: missing blank line after declaration, bad comment alignment
- can_input.c: bad indentation inside #ifdef block
- getsockopt.c: bad comment block alignment, bad brace alignment
- setsockopt.c: wrong column position of comment
- sim_netdriver.c: missing blank lines after declarations

Signed-off-by: wenquan1 <wenquan1@xiaomi.com>
2026-09-18 20:00:49 +08:00
wenquan1
95f8c54836 arch/sim: support SO_TIMESTAMPING TX in sim netdriver
Add TX timestamp loopback support to the simulator network driver.
When a packet tagged with io_conn (SO_TIMESTAMPING TX) is sent,
the driver clones the packet, generates a software timestamp, and
queues it for loopback through the RX path. The protocol layer
(UDP/PKT) then delivers the timestamp via MSG_ERRQUEUE.

- Add tstampq IOB queue to sim_netdev_s for loopback packets.
- In netdriver_send(), clone timestamped packets with realtime
  clock and notify RX ready.
- In netdriver_recv(), return loopback packets before reading
  from the tap device.

Signed-off-by: wenquan1 <wenquan1@xiaomi.com>
2026-09-18 20:00:49 +08:00
wenquan1
935f830e16 include/sys/socket.h: add SCM_TIMESTAMPNS and SCM_TIMESTAMPING macros
Add missing SCM_TIMESTAMPNS and SCM_TIMESTAMPING control message type
definitions mapped to their corresponding SO_TIMESTAMPNS and
SO_TIMESTAMPING socket options. Also align whitespace of existing
SCM_* definitions for consistency.

Signed-off-by: wenquan1 <wenquan1@xiaomi.com>
2026-09-18 20:00:49 +08:00
wenquan1
cf78962356 net/socket: merge CONFIG_NET_TIMESTAMPING into CONFIG_NET_TIMESTAMP
Consolidate the two separate timestamp Kconfig options into a single
CONFIG_NET_TIMESTAMP option that covers SO_TIMESTAMP, SO_TIMESTAMPNS
and SO_TIMESTAMPING socket options.

Previously CONFIG_NET_TIMESTAMPING was a separate option only used by
PKT sockets for hardware TX/RX timestamps and error queue support.
Since both options guard the same io_time field in iob_s and share
the s_options bitmask, merging them simplifies configuration without
functional impact.

Changes:
- Replace all CONFIG_NET_TIMESTAMPING with CONFIG_NET_TIMESTAMP in
  pkt_input.c, pkt_recvmsg.c, pkt_sendmsg_buffered.c,
  pkt_sendmsg_unbuffered.c, pkt_sockif.c, pkt_netpoll.c, pkt.h,
  setsockopt.c, getsockopt.c
- Simplify iob.h conditional from OR of both to single option
- Remove NET_TIMESTAMPING Kconfig entry, update NET_TIMESTAMP
  description to cover all three socket options

Signed-off-by: wenquan1 <wenquan1@xiaomi.com>
2026-09-18 20:00:49 +08:00
wenquan1
7c87b4586c net/socket: use s_options for SO_TIMESTAMP instead of per-conn field
Remove the redundant `timestamp` field from `udp_conn_s` and use the
existing `s_options` bitmask to track SO_TIMESTAMP/SO_TIMESTAMPNS state.

The socket-level setsockopt/getsockopt already handles SO_TIMESTAMP via
_SO_SETOPT/_SO_GETOPT on s_options. The protocol-level handlers in
inet_sockif.c were intercepting the option before the socket layer,
causing s_options to never be set. This also meant SO_TIMESTAMPNS was
broken since inet_sockif.c only handled SO_TIMESTAMP.

Changes:
- Remove udp_conn_s.timestamp field from udp.h
- Remove SO_TIMESTAMP get/set handlers from inet_sockif.c, letting
  them fall through to the socket-level handler
- Simplify udp_recvfrom.c to call cmsg_store_timestamp() directly,
  which already checks s_options internally
- Align pkt_input.c software timestamp generation with ipv4/can by
  removing per-socket SO_TIMESTAMP option check, only checking
  hardware timestamp capability

Signed-off-by: wenquan1 <wenquan1@xiaomi.com>
2026-09-18 20:00:49 +08:00
wenquan1
238cfa4a31 net/pkt: fix scheduling when receiving MSG_ERRQUEUE
Fix a scheduling issue where MSG_ERRQUEUE readiness was
not properly waking poll waiters in pkt_netpoll.c.


Signed-off-by: wenquan1 <wenquan1@xiaomi.com>
2026-09-18 20:00:49 +08:00
wenquan1
be3446850a net/pkt: support SO_TIMESTAMPING and MSG_ERRQUEUE
Add SO_TIMESTAMPING TX path for PKT sockets. Tagged TX
packets loop back through the driver with io_conn set,
are routed into conn->errahead, and delivered to userspace
via recvmsg(MSG_ERRQUEUE) with SO_TIMESTAMPING cmsg.
Add poll(POLLPRI) notification when errahead is non-empty.


Signed-off-by: wenquan1 <wenquan1@xiaomi.com>
2026-09-18 20:00:49 +08:00
OceanfromXiaomi
28402b9b35 net: add NETDEV_RX_STAMP flag in d_features
Replace compile-time CONFIG_ARCH_HAVE_NETDEV_TIMESTAMP with
a runtime NETDEV_RX_STAMP bit in net_driver_s.d_features.
Drivers providing hardware RX timestamps set the flag at
probe time; the stack checks it at runtime.


Signed-off-by: OceanfromXiaomi <zhaohaiyang1@xiaomi.com>
2026-09-18 20:00:49 +08:00
OceanfromXiaomi
c6878db031 net/utils: extract cmsg_store_timestamp helper
Extract a common cmsg_store_timestamp() helper that checks
SO_TIMESTAMP/SO_TIMESTAMPNS via s_options and appends the
appropriate cmsg. Replaces per-protocol timestamp formatting
in CAN, PKT, and UDP receive paths.


Signed-off-by: OceanfromXiaomi <zhaohaiyang1@xiaomi.com>
2026-09-18 20:00:49 +08:00
OceanfromXiaomi
9a65ffc51d net: move rx timestamp from d_rxtime to iob_s.io_time
Move RX timestamp storage from net_driver_s.d_rxtime into
iob_s.io_time so each IOB carries its own timestamp through
the stack. Remove old iob_trycopyin/iob_copyout timestamp
packing in CAN/PKT/UDP paths. Fix iob_clone_partial to copy
io_time before source pointer advances to NULL.

Signed-off-by: OceanfromXiaomi <zhaohaiyang1@xiaomi.com>
Signed-off-by: wenquan1 <wenquan1@xiaomi.com>
2026-09-18 20:00:49 +08:00
wangjianyu3
f492f136c2 boards/rp2040: switch waveshare nsh/usbnsh configs to nxinit entrypoint
Switch CONFIG_INIT_ENTRYPOINT from nsh_main to nxinit's init_main for
the shell-capable configs (nsh, usbnsh) of waveshare-rp2040-zero and
waveshare-rp2040-lcd-1.28.  nsh now runs as a "console sh" service
started by init.rc instead of being the top-level init task.

Add etc/init.d/init.rc to the shared common/src RCSRCS, gated on
CONFIG_ETC_ROMFS && CONFIG_SYSTEM_NXINIT, so one copy covers both
boards, plus a .gitignore for the etctmp files Board.mk generates from
it.  The four defconfigs also set CONFIG_SYSTEM_NXINIT=y with its
Kconfig deps, CONFIG_ETC_ROMFS=y and CONFIG_FS_ROMFS=y.

nsh_main connected the CDC/ACM gadget itself via
boardctl(BOARDIOC_USBDEV_CDCACM); init_main does not, so the usbnsh
configs would otherwise come up with no USB console.  Run sercon from
init.rc and enable CONFIG_SYSTEM_CDCACM in those two defconfigs to keep
that step.

Assisted-by: Claude:claude-sonnet-5
Signed-off-by: wangjianyu3 <wangjianyu3@xiaomi.com>
2026-09-18 08:47:09 -03:00
Daniel P. Carvalho
9e93888220 stm32/adc: add support for differential mode (DIFSEL) and calibration
Add board-level configuration and driver support for differential input
channels and auto-calibration on STM32 ADC IPv2 and IPv2G4 (STM32F3,
STM32G4), following the STM32H5 architecture pattern requested in review:

- In hardware headers (stm32_adc_v2.h and stm32_adc_v2g4.h), fix register
  comments and define ADC_DIFSEL register shift and masks.
- In stm32_adc_m3m4_v1v2.c:
  - Add difsel field to struct stm32_dev_s initialized from
    BOARD_ADCx_DIFSEL if defined, falling back to ADC_DIFSEL_DEFAULT (0).
  - Configure DIFSEL before enabling the ADC in adc_configure().
  - Fix and enable adc_calibrate() for HAVE_IP_ADC_V2, supporting both
    single-ended calibration (ADCALDIF=0) and differential calibration
    (ADCALDIF=1) based on the channel selection.

Verified on Nucleo-G431KB (single-ended and differential channel 1).

Assisted-by: Gemini:gemini-2.5-pro
Signed-off-by: Daniel P. Carvalho <danieloak@gmail.com>
2026-09-18 08:46:18 -03:00
raiden00pl
ce3dbf6539 drivers/serial/serial.c: fix nxstyle
drivers/serial/serial.c: fix nxstyle

Signed-off-by: raiden00pl <raiden00@railab.me>
2026-09-18 08:36:25 -03:00
raiden00pl
96c5330ea6 drivers/serial: bulk-copy raw output into the TX buffer
uart_writev() queues output one byte at a time via uart_putxmitchar().
Add uart_putxmitbuf() that memcpy()s a whole run into the TX ring buffer
and use it when no per-byte processing is needed (OPOST and ECHO clear,
not a console).  On a full buffer fall back to uart_putxmitchar(), which
keeps the blocking and error handling unchanged.

8 MiB write() to /dev/ttyACM0 on nRF52840: 455 -> 573 KB/s.
Guarded by CONFIG_SERIAL_TXBULK, default !DEFAULT_SMALL.

Assisted-by: Claude Code
Signed-off-by: raiden00pl <raiden00@railab.me>
2026-09-18 08:36:25 -03:00
Liam Howatt
2c7cf5ab03 Documentation/stm32h5: OTP is supported.
Describe the OTP API in stm32h5 platform documentation.

Signed-off-by: Liam Howatt <liamhowatt@geotab.com>
2026-09-18 16:33:48 +08:00
Liam Howatt
65775f26a7 arch/arm/stm32h5: Add OTP support.
Add an API for OTP (one-time programmable) memory on stm32h5.
There are OTP APIs for non-STM32 platforms.
There is no other API for STM32 so far with these names.

Implement it in stm32h563xx_flash.c since the progmem abstraction
also lives there.

int stm32_otp_write(const uint16_t *data, uint16_t len, uint32_t offset);
int stm32_otp_read(uint16_t *data, uint16_t len, uint32_t offset);
The API allows cross-block reads/writes that don't necessarily
start/end at block boundaries.
The type of `data` is uint16_t * to express to the caller that the
pointer should be 2-aligned. The natural size of OTP words is 16 bits.
`len` is uint16_t for no strong reason. Preserve author's work.

uint32_t stm32_otp_getlockstatus(void);
Get a mask of blocks that are locked. A block being locked
is considered as being one-time programmed.

Co-authored-by: Mykhailo Sopiha <mykhailosopiha@geotab.com>
Signed-off-by: Liam Howatt <liamhowatt@geotab.com>
2026-09-18 16:33:48 +08:00
Ulaş Sertan Kemeç
0474b8d406 Documentation/am67: Document eCAP APWM support on t3-gem-o1.
Record the eCAP1 and eCAP2 APWM outputs in the board's Peripheral
Support list.

Assisted-by: Claude Code:claude-opus-5
Signed-off-by: Ulaş Sertan Kemeç <sertan.usk@gmail.com>
2026-09-18 16:25:31 +08:00
Ulaş Sertan Kemeç
986394a56d arch/arm/am67: Add eCAP APWM lower-half driver.
Adds a PWM lower-half using the eCAP modules in APWM mode as single-channel
generators rather than capture units.

start() reprograms the time base only when the frequency changes, so a
duty-only update does not stop or zero a live counter.

t3-gem-o1 registers /dev/ecap1 and /dev/ecap2; output pad selection is left to
the board, as the candidates collide with I2C0.

Verified on t3-gem-o1: examples/pwm runs a 1 kHz, 50% duty train on both
instances and accepts a duty-only change (25% then 75%).  The output pins have
not been measured on copper, as no pad is assigned to them on this board.

Assisted-by: Claude Code:claude-opus-4-8
Signed-off-by: Ulaş Sertan Kemeç <sertan.usk@gmail.com>
2026-09-18 16:25:31 +08:00
Aurora-QIU0
637a53c136 risc-v/espressif: Fix I2C SCL/SDA pin attribute masks.
esp_i2c.c composes the pin attribute masks handed to esp_configgpio()
using the logical OR operator instead of the bitwise OR operator:

    #define SCL_PIN_ATTR (FUNCTION_2 || INPUT_PULLUP || OUTPUT_OPEN_DRAIN)
    #define SDA_PIN_ATTR (FUNCTION_2 || INPUT_PULLUP || OUTPUT_OPEN_DRAIN)

Every operand is a non-zero bit field, so the expression collapses to 1
rather than to the intended combination.  With the encodings defined in
esp_gpio.h the mask must be 171 (0xab):

    FUNCTION_2        (2 << FUNCTION_SHIFT) = 128
    INPUT_PULLUP      (INPUT | PULLUP)      = 9
    OUTPUT_OPEN_DRAIN (OUTPUT | OPEN_DRAIN) = 34

Passing 1 to esp_configgpio() selects input mode only: output and
open-drain remain disabled, the pull-up is not enabled and the function
field does not match, so the pin falls back to plain GPIO function.  The
I2C peripheral signal then never reaches the pads; the bus is left
floating while the transfer state machine still reports completion.

Every other pin attribute mask in this directory (esp_i2c_slave.c,
esp_i2c_bitbang.c, esp_spi.c, esp_twai.c) already uses the bitwise
operator for the same encodings, so esp_i2c.c was the only outlier.

Since this file is modified by this commit, the pre-existing nxstyle
violations reported by the check job are fixed as well, as asked in
CONTRIBUTING.md section 2.1 (adapt all modified files even if you did
not introduce the problem yourself):

* esp_i2c.c:1267      - statement over-indented inside its enclosing
                        block (8 spaces where the block body is at 6)
* esp_i2c.c:1303      - missing blank line after declarations
* esp_i2c.c:1592      - missing blank line after declarations
* esp_i2c.c:1710-1725 - 'case'/'default' labels inside switch(port)
                        sat at the same indent as the brace opening
                        the switch body; they belong one level further
                        in, with the case logic one more level in from
                        the label

Assisted-by: WorkBuddy:DeepSeek-V4.1-Flash
Signed-off-by: Aurora-QIU0 <2170685247@qq.com>
2026-09-18 16:15:14 +08:00
Daniel P. Carvalho
1b172fb8d2 drivers/sensors: add Microchip TC74 temperature sensor driver
Add support for the Microchip TC74 digital temperature sensor using the
Sensor Driver Framework (uORB). The TC74 is an 8-bit I2C temperature
sensor with a measurement range from -40C to +125C and a resolution
of 1C.

The driver registers as a uORB topic (/dev/uorb/sensor_temp<n>) and
polls on the low-priority work queue. It supports dynamic interval
configuration and automatically enters low-power standby mode when
the topic is deactivated.

Validated against a real TC74A5-3.3 on a custom STM32H743BI board.

Assisted-by: Gemini:gemini-3.8-pro
Signed-off-by: Daniel P. Carvalho <danieloak@gmail.com>
2026-09-18 16:04:32 +08:00
Aurora-QIU0
86159f3353 risc-v/espressif: Fix I2C polling wait timeout comparison.
clock_t is an unsigned type unless CONFIG_SYSTEM_TIME64 is selected, as
documented in sys/types.h.  The difference in

    while (current - timeout < 0 && priv->error == 0)

therefore underflows to a large positive value instead of being
negative, the comparison is always false, and the loop body never runs.
status keeps its initial value of zero and the function returns OK
without having waited for the transfer at all.

Because the polling path reports completion immediately, every transfer
looks successful: no timeout is ever raised and register reads return
whatever the RX FIFO happens to contain.  The function is compiled in
under CONFIG_I2C_POLLED, which boards use when the I2C interrupt is not
wired up.

Cast the difference to int32_t to get the intended signed comparison.
The result also stays correct across the counter wrap, as long as the
timeout is shorter than the counter range, which SEC2TICK(10) satisfies.

Since this file is modified by this commit, the pre-existing nxstyle
violations reported by the check job are fixed as well, as asked in
CONTRIBUTING.md section 2.1 (adapt all modified files even if you did
not introduce the problem yourself):

* esp_i2c.c:1267      - statement over-indented inside its enclosing
                        block (8 spaces where the block body is at 6)
* esp_i2c.c:1303      - missing blank line after declarations
* esp_i2c.c:1592      - missing blank line after declarations
* esp_i2c.c:1710-1725 - 'case'/'default' labels inside switch(port)
                        sat at the same indent as the brace opening
                        the switch body; they belong one level further
                        in, with the case logic one more level in from
                        the label

Assisted-by: WorkBuddy:DeepSeek-V4.1-Flash
Signed-off-by: Aurora-QIU0 <2170685247@qq.com>
2026-09-18 15:59:11 +08:00
Felipe Moura
d656cfa930 xtensa/espressif: fix lock-order deadlock in esp_wifi_event_handler()
esp_wifi_event_handler() held esp_wifi_lock() across the whole event
switch, including the esp_wlan_*_hook() calls
(WIFI_EVENT_STA_CONNECTED/_DISCONNECTED, WIFI_EVENT_AP_START/_STOP).
Those hooks reach netdev_lower_carrier_on()/_off(), which take the
per-device netdev_lock().

Every other path into esp_wifi_lock() acquires the two locks in the
opposite order -- the netdev ifdown path holds netdev_lock() around
its own call into esp_wifi_api_stop(), which calls esp_wifi_lock().
An application that disconnects Wi-Fi (wpa_driver_wext_disconnect()
immediately followed by wapi_set_ifdown()) races the resulting
WIFI_EVENT_STA_DISCONNECTED callback against its own ifdown call, and
the two lock orders wedge each other permanently.

Confirmed on real ESP32-S3 hardware (XIAO ESP32-S3,
CONFIG_ESPRESSIF_WIFI + CONFIG_PM + CONFIG_SCHED_TICKLESS): the
disconnecting task and the low-priority work-queue thread each waited
on a mutex held by the other (checked live via JTAG/GDB, not inferred
from code reading alone). Reproduced 4/4 times before this fix, 0/2
after.

Fix: esp_wifi_lock() is now taken only around the specific calls that
reach into the Wi-Fi driver API (esp_wifi_scan_event_parse(),
esp_wifi_set_ps()), never spanning a esp_wlan_*_hook() call --
netdev_lock() first (or absent), esp_wifi_lock() last, on every path.

Signed-off-by: Felipe Moura <moura.fmo@gmail.com>
Assisted-by: Claude:claude-sonnet-5
2026-09-18 15:57:44 +08:00