Commit graph

17,121 commits

Author SHA1 Message Date
Seppo Takalo
bc86bf20cb net: l2: ppp: Allow using zero asyncmap locally
The L2 PPP driver was not working for any other
Async-Control-Character-Map values than 0xffffffff.

This was caused by two issues:
* modem_ppp.c was expecting CONTROL field to be always escaped.
* lcp.c was decoding async_map values wrongly. Either as 16bit,
  or raw 32bit, instead of big-endian 32 bit.

Now it should be safe to default my_options.async_map to a zero.

Signed-off-by: Seppo Takalo <seppo.takalo@nordicsemi.no>
2026-03-13 16:33:05 +01:00
Seppo Takalo
412d48ef31 net: l2: ppp: Async-Control-Character-Map updated too early
When peer sends the Async-Control-Character-Map option on LCP
phase, Zephyr correctly responsed with Configure-Ack.
But the LCP negotiation phase have not been finnished yet,
so the remote end may not expect us to immediately
update the value.

This is seen when trying to use Zephyr's PPP stack against
PPPD from Linux, where default asyncmap option is zero.

However, if we delay the update of the asyncmap to the network phase,
it works just fine.

Fixes #105291

Signed-off-by: Seppo Takalo <seppo.takalo@nordicsemi.no>
2026-03-13 16:32:32 +01:00
Glenn Andrews
4cf56ae059 Lib: SMF: Add instrumentation for SMF
Add instrumentation hooks for transitions and actions, as well as
error states. This will allow us to track the state of the state
machine during testing, and also provide a way to debug issues
that may arise during execution.

Signed-off-by: Glenn Andrews <andrewsglenn@meta.com>
2026-03-13 16:29:57 +01:00
Jiafei Pan
41428ccbdf drivers: pm_cpu_ops: psci: add cpu suspend
Add PSCI API for CPU suspend.

Signed-off-by: Chenhui Zhao <chenhui.zhao@nxp.com>
Signed-off-by: Jiafei Pan <Jiafei.Pan@nxp.com>
2026-03-13 14:45:02 +01:00
Henrik Lindblom
8494c5bdcf drivers: dac: add emulator driver
For use in tests where the existing "vnd,dac" driver doesn't work as it
returns error codes for all API functions. The approach is mimicked from
the adc-emul driver.

Signed-off-by: Henrik Lindblom <henrik.lindblom@vaisala.com>
2026-03-13 14:43:00 +01:00
Adam BERLINGER
fa30a2f8fe drivers: clock: stm32-mco: Add support for STM32N6
STM32N6 requires enable bit in RCC_MISCENR register.

Signed-off-by: Adam BERLINGER <adam.berlinger@st.com>
2026-03-13 14:42:29 +01:00
Sylvio Alves
c64a74e711 espressif: adapt to hal_espressif IDF master sync
Adapt all Espressif SoC and driver code to the updated
hal_espressif module synced with IDF master branch.

Main changes:
- clock control: delegate peripheral clock gating to HAL
  layer using new clock/reset APIs
- SPI/GDMA: adapt to restructured DMA HAL with new channel
  allocation and configuration interfaces
- ethernet: add RMII clock configuration and PHY management
- GPIO: simplify using direct HAL function calls
- flash: adapt to updated SPI flash HAL interfaces
- linker scripts: update IRAM/DRAM mappings for new HAL
  object files
- DTS: fix ESP32-S2 PSRAM dcache1 address to match actual
  MMU mapping region (0x3f800000 DRAM1 instead of 0x3f500000
  DPORT which lacks 8-bit access capability)
- west.yml: update hal_espressif revision

Signed-off-by: Sylvio Alves <sylvio.alves@espressif.com>
2026-03-13 11:38:18 +01:00
Yongxu Wang
81f27d13d1 pm: device: clarify TURN_ON/TURN_OFF action semantics
Improve documentation for PM_DEVICE_ACTION_TURN_ON and
PM_DEVICE_ACTION_TURN_OFF to clarify

Signed-off-by: Yongxu Wang <yongxu.wang@nxp.com>
2026-03-13 09:13:58 +01:00
Pieter De Gendt
aad056a7bc net: lib: coap: observer: Use struct net_sockaddr_storage
Replace the incomplete struct net_sockaddr with net_sockaddr_storage for
CoAP observers.

Signed-off-by: Pieter De Gendt <pieter.degendt@basalte.be>
2026-03-12 14:06:27 -05:00
Jisheng Zhang
f0df349808 arch: arm: implement EHABI walk_stackframe
Implement walk_stackframe() according to EHABI(Exception Handling ABI) [1]
Then implement arch_stack_walk() and z_arm_unwind_stack() based on
walk_stackframe. After that, hook the z_arm_unwind_stack() to
z_arm_fatal_error() so that we can unwind the stack during fatal error.

Tested with tests/arch/common/stack_unwind and enabling SYMTAB and
EXTRA_EXCEPTION_INFO:

*** Booting Zephyr OS build v4.3.0-3078-g23892b038f6a ***
Hello World! xxx
1: func1
2: func2
3: func1
4: func2
5: func1
6: func2
E: r0/a1:  0x00000003  r1/a2:  0x300000e8  r2/a3:  0x300000e8
E: r3/a4:  0x00000003 r12/ip:  0x00000000 r14/lr:  0x100011eb
E:  xpsr:  0x21000000
E: r4/v1:  0x00000006  r5/v2:  0x10009250  r6/v3:  0x00000000
E: r7/v4:  0x00000000  r8/v5:  0x00000000  r9/v6:  0x00000000
E: r10/v7: 0x00000000  r11/v8: 0x00000000    psp:  0x30000f58
E: EXC_RETURN: 0x0
E: Faulting instruction address (r15/pc): 0x100011fe
E: call trace:
E:      0: lr: 0x100011fe [func2+0x21]
E:      1: lr: 0x10001233 [func1+0x16]
E:      2: lr: 0x10001205 [func2+0x28]
E:      3: lr: 0x10001233 [func1+0x16]
E:      4: lr: 0x10001205 [func2+0x28]
E:      5: lr: 0x10001233 [func1+0x16]
E:      6: lr: 0x1000125d [main+0x10]
E:      7: lr: 0x10002cb5 [bg_thread_main+0x20]
E:
E: >>> ZEPHYR FATAL ERROR 3: Kernel oops on CPU 0
E: Current thread: 0x300000e8 (main)
E: Halting system

NOTE: cortex_a_r's walk_stackframe() works too, but extra_info.callee
is NULL during oops because the z_arm_svc doesn't save it, see below
comment in swap_helper.S or switch.S:

/* Zero callee_regs and exc_return (only used on Cortex-M) */
    mov r1, #0
    mov r2, #0
    bl z_do_kernel_oops

So the cortex_a_r's k_oops() can't unwind the stack now. For safe
reason, let's enable ARCH_HAS_STACKWALK for only CPU_CORTEX_M now.

Link: https://github.com/ARM-software/abi-aa/blob/main/ehabi32/ehabi32.rst [1]
Signed-off-by: Jisheng Zhang <jszhang@kernel.org>
2026-03-12 13:59:45 -05:00
Phuc Hoang
55ddd34ce3 driver: crc: Fix crc macro in header file
Fix crc macros in header file:
include/zephyr/drivers/crc.h
include/zephyr/sys/crc.h

Signed-off-by: Phuc Hoang <donp172748@gmail.com>
2026-03-12 12:20:27 -04:00
Lyle Zhu
7e1757e4e1 bluetooth: Classic: l2cap: refactor I-frame retransmission logic
Refactor the I-frame retransmission mechanism to improve clarity and
correctness in L2CAP BR/EDR flow control.

The previous implementation used multiple flags (L2CAP_FLAG_PDU_RETRANS
and L2CAP_FLAG_REQ_SEQ_UPDATED) to track retransmission state, which
made the logic complex and error-prone. This change introduces a
per-window retransmit flag and dedicated helper functions to manage
retransmission of all unacknowledged I-frames.

Key changes:
- Replace L2CAP_FLAG_PDU_RETRANS with L2CAP_FLAG_RET_I_FRAME for
  timeout-triggered retransmission of the first unacked I-frame
- Replace L2CAP_FLAG_REQ_SEQ_UPDATED with L2CAP_FLAG_RET_I_FRAMES for
  retransmission of all unacked I-frames
- Add `retransmit` flag to `bt_l2cap_br_window` structure to track
  which I-frames need retransmission
- Add `l2cap_br_retransmit_i_frames()` to mark all outstanding I-frames
  for retransmission
- Add `l2cap_br_stop_retransmit_i_frames()` to clear retransmission
  state
- Add `l2cap_br_get_ret_win()` to retrieve the next I-frame marked
  for retransmission
- Update `l2cap_br_ret_fc_data_pull()` to handle both single I-frame
  timeout retransmission and bulk retransmission separately
- Fix window memory management to only free newly allocated windows on
  error, not retransmitted ones
- Update S-frame handlers (RR, REJ, RNR) to use new retransmission
  helpers instead of setting flags directly
- Update comment for L2CAP_FLAG_RET_I_FRAME to clarify it handles
  timeout retransmission

These changes make the retransmission logic more explicit and easier
to maintain while ensuring proper flow control behavior.

Signed-off-by: Lyle Zhu <lyle.zhu@nxp.com>
2026-03-12 12:09:04 -04:00
Phi Bang Nguyen
d4aecd3b65 include: drivers: video: Add buffer alignment to caps
Add a field to video_caps to expose buffer alignment requirement.

Signed-off-by: Phi Bang Nguyen <phibang.nguyen@nxp.com>
2026-03-12 12:08:51 -04:00
Phi Bang Nguyen
6f8bfed789 include: drivers: video: Introduce transform_caps API
For m2m video device, the get_caps() API give the supported caps of
either input or output side. However, there is currently no guaranteed
way to know the relationship between input and output caps.

Introduce a new video_transform_caps() API that help to transform a video
format cap from one end to the other end of a m2m device.

Signed-off-by: Phi Bang Nguyen <phibang.nguyen@nxp.com>
2026-03-12 12:08:51 -04:00
Phi Bang Nguyen
304629ccb0 include: drivers: video: Returning errno instead of _ASSERT
Return an errno instead of _ASSERT because in some cases, the propram
needs to be continued even if a function failed. For example,
video_get_caps() could be failed if it is called in an init function
where the HW is not yet assigned.

Furthermore, _ASSERT will be dissappeared in production build.

Signed-off-by: Phi Bang Nguyen <phibang.nguyen@nxp.com>
2026-03-12 12:08:51 -04:00
Silesh C V
9013b63fa4 dts: bindings: pinctrl: add alif E1C pin definitions
Add Ensemble E1C series specific pin multiplexing definitions.

The E1C series has different hardware peripheral routing compared
to the existing E4/E6/E8 series. So separate pin definitions are
needed. But as the pinctrl register layout and control
logic are identical across all Ensemble series, the same driver
and encoding scheme can be reused.

Signed-off-by: Silesh C V <silesh@alifsemi.com>
2026-03-12 09:27:25 -05:00
Adam Kondraciuk
7b342e147d drivers: timer: nrf_grtc_timer: Introduce interval mode support
Add support for hardware-generated periodic compare events using
the GRTC interval feature. Once configured, the hardware generates
compare events at a fixed interval without CPU intervention.

The feature is available only on channels defined as
"extended-channels" in the devicetree.

Signed-off-by: Adam Kondraciuk <adam.kondraciuk@nordicsemi.no>
2026-03-12 09:24:59 -05:00
Amneesh Singh
abdfea826f clock_control: tisci: fix macro argument
TISCI_GET_CLOCK_DETAILS_BY_INST takes the instance number of the DT node,
this is supposed to be denoted by `inst`. However, due to a typo it is
currently DT_DRV_INST which makes no sense since that is a separate macro
of its own. Hence, fix this typo.

Signed-off-by: Amneesh Singh <amneesh@ti.com>
2026-03-12 11:35:43 +01:00
Jordan Yates
ca0815a856 net: lib: sntp: output response delay
Add a new field to the `sntp_time` struct which is an estimate of the
delay between the SNTP server sending the response and the SNTP client
(the application) receiving it. This information can then be used by
the caller to correct for the systemic bias introduced by non-zero
network latencies.

Includes internal variable naming to make it clearer which timestamps
are which.

Signed-off-by: Jordan Yates <jordan@embeint.com>
2026-03-12 11:34:52 +01:00
minyuan xue
d3a8a26ef6 drivers: clock: add ameba clock driver
Add realtek ameba clock driver.

Signed-off-by: minyuan xue <minyuan_xue@realsil.com.cn>
2026-03-12 09:04:02 +00:00
minyuan xue
1663712875 dts: arm: add rcc bingding and nodes
Add ameba series rcc binding and notes.

Signed-off-by: minyuan xue <minyuan_xue@realsil.com.cn>
2026-03-12 09:04:02 +00:00
Kai Cheng
d9cdc215fc Bluetooth: SPP: Add rfcomm server unregister interface
Add bt_rfcomm_server_unregister() to support unregistering an
RFCOMM server for a channel.

Signed-off-by: Kai Cheng <chengkai@xiaomi.com>
2026-03-12 09:02:56 +00:00
Kai Cheng
5574ababa2 Bluetooth: RFCOMM: Use sys_slist_t for server list
Replace the manual linked list (using _next pointer) for RFCOMM
servers with sys_slist_t. This enables use of slist utility functions
like sys_slist_find_and_remove(), which is needed to support server
unregistration in a subsequent commit.

Signed-off-by: Kai Cheng <chengkai@xiaomi.com>
2026-03-12 09:02:56 +00:00
Peter Marheine
2221500305 arch: riscv: correct signature of __soc_handle_irq
When __soc_handle_irq is called inside _isr_wrapper, it actually expects
the function to return an IRQ number but the declaration of
__soc_handle_irq in the header has it returning `void` instead. Fix the
declaration to reflect that it actually returns an XLEN-length integer.

All existing implementations of __soc_handle_irq already follow this
behavior by either not modifying the a0 register or setting it to the
correct IRQ number, and follow the calling convention in all other
respects:

 * soc/ite/ec/common/soc_irq.S: trampoline to
   `uint8_t get_irq(void* unused)`
 * soc/adi/max32/soc_irq_rv32.S: internally calls
   `uint32_t max32_rv32_intc_get_next_source(void)` and doesn't modify
   a0 afterwards
 * soc/openisa/rv32m1/soc_irq.S: does not modify a0, and obliquely
   refers to this issue in a comment explaining why the function isn't
   implemented in C
 * soc/common/riscv-privileged/soc_irq.S: does not modify a0
 * all others: stub (just `ret`), which is a valid implementation of the
   integer identity function

Signed-off-by: Peter Marheine <pmarheine@chromium.org>
2026-03-11 23:17:21 -04:00
Albort Xue
95399aed4f drivers: wuc: add NXP LLWU (Low-Leakage Wakeup Unit) driver
Add a Wakeup Controller driver for NXP's LLWU
peripheral found on MCX-C series MCUs.

Signed-off-by: Albort Xue <yao.xue@nxp.com>
2026-03-11 20:55:25 -04:00
Albort Xue
0cab5de544 drivers: wuc: introduce Wakeup Controller (WUC) driver API
Introduce a new Wakeup Controller (WUC) driver API to manage wakeup
sources in low-power scenarios. The WUC API provides a standardized
interface for enabling, disabling, checking, recording and clearing
wakeup sources that can bring a device out of low-power states.

Signed-off-by: Albort Xue <yao.xue@nxp.com>
2026-03-11 20:55:25 -04:00
Isabelle OGER
fe0f2cb897 drivers: modem: st87mxx: add services APIs (GNSS, WIFI scan, RSSI)
Added some application services APIs to handle the GNSS, WIFI scan
and to retrieve the RSSI on the st87mxx modem driver.

Signed-off-by: Isabelle OGER <isabelle.oger@st.com>
2026-03-11 20:53:28 -04:00
Zafer SEN
07ab65c612 drivers: modem: hl78xx: optimize GNSS for low-power (PSM/eDRX)
Add a configurable GNSS processing mode for low-power operation and
teach the GNSS/LTE state machine to run GNSS without unnecessary CFUN
toggling when the RF path is already free in PSM. Improves energy
usage and reduces wake latency.

Kconfig:
- New choice HL78XX_GNSS_REQUEST_PROCESSING_MODE (depends on PSM):
  * HL78XX_GNSS_PROCESS_POST_PSM (default).
  * HL78XX_GNSS_PROCESS_PRE_PSM.
- Document PRE vs POST behavior and constraints.

Core (hl78xx.c):
- When GNSS is requested in low-power mode, defer to PSM-aware flow:
  * PRE‑PSM: start GNSS on PSM entry.
  * POST‑PSM: start GNSS after user wake.
- Avoid CFUN=4 when the RF path is already free due to PSM.
- Log intent and return early to skip legacy airplane path.

GNSS TU (hl78xx_gnss.c/.h):
- If PSM is active or just exited, skip CFUN=4 and start GNSS
  immediately (RF path free).
- Start GNSS on timeout when RF is free (airplane or PSM), otherwise
  queue until free.
- Cancel scheduled power‑down when GNSS actually starts.
- Handle LTE REGISTERED and DEVICE_AWAKE while GNSS is active:
  * If LTE reclaims RF, modem auto‑stops GNSS; return to LTE flow.
  * If GNSS exit occurs while CFUN=1 (PSM path), auto‑resume LTE
    registration; in airplane mode, user restores CFUN=1.
- Clarify state doc: waiting for “RF free (airplane or PSM)” instead of
  only airplane.
- Emit HL78XX_GNSS_EVENT_MODE_EXITED with status=false when auto‑stopped
  by LTE.

Public API docs (hl78xx_apis.h):
- Document low‑power GNSS paths:
  * ENTER: queued, start pre‑ or post‑PSM depending on Kconfig.
  * EXIT: auto‑resume LTE in PSM path; airplane path still user‑driven.

Why:
- GNSS can operate while LTE hibernates in PSM; avoiding CFUN toggles
  saves energy and time.
- PRE‑PSM maximizes GNSS acquisition window; POST‑PSM delivers fixes at
  wake before LTE work.
- Clearer eventing for auto‑stop cases simplifies app logic.

Impact / migration:
- Behavior change for queued GNSS in PSM: CFUN=4 is no longer forced if
  PSM already frees the RF path.
- Apps that assumed CFUN=4 during GNSS should rely on events instead.
- Consumers of MODE_EXITED should handle status=false (auto‑stop).
- New Kconfig choice requires MODEM_HL78XX_PSM=y to be effective.

Testing notes:
- Verified PRE‑PSM starts GNSS on PSM entry and cancels power‑down.
- Verified POST‑PSM defers GNSS until wake, then runs before LTE regs.
- Confirmed LTE REGISTERED during GNSS causes clean abort and return to
  LTE path.
- Confirmed no CFUN changes when PSM already frees the RF path.

Signed-off-by: Zafer SEN <zafersn93@gmail.com>
2026-03-11 20:53:19 -04:00
Zafer SEN
d78304f027 drivers: modem: hl78xx: add low-power states, events, and APIs
Introduce a low-power framework for HL78xx: new states, events, Kconfig
options, URC handlers, GPIO control, and an optional power-down timer.
Includes DTS pins for WAKE/GPIO6/VGPIO and a public wake API.

Board/DTS:
- swir_hl78xx_ev_kit.overlay:
  - Add mdm-vgpio, mdm-gpio6, and mdm-wake GPIOs.

Kconfig:
- Add MODEM_HL78XX_POWER_DOWN when eDRX/PSM are both disabled.
- Add choice for power-down policy:
  - MODEM_HL78XX_USE_DELAY_BASED_POWER_DOWN (+ delay seconds).
  - MODEM_HL78XX_USE_ACTIVE_TIME_BASED_POWER_DOWN (+ active time).
- Tune eDRX defaults and add PTW value knob.
- Adjust PSM defaults (e.g., TAU default 15 minutes).
- Gate legacy sleep-delay settings when power-down is disabled.

Driver core (hl78xx.c/.h):
- New states:
  - RUN_PMC_CONFIG_SCRIPT (apply PSM/eDRX/power-down).
  - SLEEP (bus closed, UART suspended, wake via RESUME).
- New events (when low-power enabled):
  - DEVICE_ASLEEP, DEVICE_AWAKE, LTE_PSMEV_UPDATE.
- +CEREG handler:
  - Feed power timers, handle GNSS interplay, release socket comms
    after register when low-power is active.
- +PSMEV handler:
  - Track ENTER/EXIT, toggle WAKE pin, dispatch sleep/awake events.
- +KCELLMEAS handler:
  - Update RSRP, mark registered on valid signal, release comms.
- Carrier-on / await-registered:
  - Distinguish PSM entry vs coverage loss, route to SLEEP or retry.
  - Avoid iface status run during initial PSM edge cases.
- Sleep state handlers:
  - On enter: WAKE=0, release chat, close pipe, suspend UART, give sem.
  - On bus closed: decide GNSS pre/post-PSM behavior.
  - On resume: WAKE=1, resume UART, reopen pipe, proceed to GNSS or LTE.
- State-table safety:
  - Use MODEM_HL78XX_STATE_COUNT for bounds checks.
- Log improvements and explicit state transition trace.

APIs (hl78xx_apis.c / include):
- Add hl78xx_wakeup_modem() to resume from SLEEP (PSM).

Chat/URC (hl78xx_chat.c/.h):
- Enable +KPSMEV URC and +KCELLMEAS URC when low-power is on.
- Provide disable-PMC script when low-power is off.

Config helpers (hl78xx_cfg.c/.h):
- Add PMC enabling and settings application:
  - hl78xx_enable_pmc(), hl78xx_psm_settings(), hl78xx_edrx_settings().
- Power-down timer (when enabled):
  - Init/cancel/query and feed functions via k_work_delayable.
  - Feed timer on dynamic TX path to extend on activity.
- Add hl78xx_is_rsrp_valid() helper.
- Respect CONFIG_MODEM_LOG_LEVEL in cfg TU logging.

Misc:
- Expose hl78xx_release_socket_comms() for post-register gating.
- Guard init-fail path to require WAKE pin when low-power is on.
- Add RUN_PMC_CONFIG_SCRIPT transitions after RAT config.

Why:
- Reduce energy by using PSM/eDRX and a clean SLEEP state with bus and
  UART suspended. Optionally power down the modem when DRX features are
  disabled. Provide explicit wake and robust PSM detection.

Impact / migration:
- DTS must define WAKE/GPIO6/VGPIO if low-power is enabled.
- New state/event enums added; state table now uses *_STATE_COUNT.
- +KCELLMEAS URC is enabled unless GNSS blocks it (see comments).
- External users can call hl78xx_wakeup_modem() to resume from PSM.
- Power-down policy and delays are configurable via Kconfig.

Testing notes:
- Verified PSMENTER drives WAKE low and transitions to SLEEP.
- Verified RESUME re-opens UART, waits settle time, then proceeds.
- Confirmed GNSS pre/post-PSM flows per config.
- Checked power-down timer feeds on data activity and triggers OFF.

Signed-off-by: Zafer SEN <zafersn93@gmail.com>
2026-03-11 20:53:19 -04:00
Benjamin Cabé
2214d51f3a include: haptics: document driver operations of the haptics API
This uses the newly introduced Doxygen tags for exposing driver operations
documentation in the public docs.

As haptics_error_callback_t typedef is effectively also used for the
public API of the driver, it's moved outside of the "backend" group.

Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
2026-03-11 20:52:41 -04:00
Nicolas Pitre
30c07c0ff7 lib: heap: validate canaries on free chunk removal
At FULL hardening, trailer canaries on used chunks implicitly guard
adjacent free chunk headers: a sequential buffer overflow must corrupt
the used chunk's trailer before reaching the next header.  However,
when a free neighbor's metadata is needed for merging during free(),
the neighbor's header could already have been corrupted by an overflow
from its left used chunk that hasn't been freed yet.  For example:

  [hdr_U1] [data_U1] [trailer_U1] [hdr_F] [...] [hdr_U2] [trailer_U2]

If data_U1 overflows past trailer_U1 and corrupts hdr_F, freeing U2
would use hdr_F's corrupted size and free-list pointers for merging,
potentially leading to heap structure corruption or arbitrary writes.

Additionally, a corrupted LEFT_SIZE in a used chunk being freed can
point to a fake header crafted inside the left neighbor's data area:

  [hdr_U1] [data_U1 ..fake_hdr.. trailer_U1'] [hdr_U2'] [data_U2] ...
                       |           corrupted   LEFT_SIZE points
                       |           by overflow  to fake_hdr
                       +<--------------------------+

A determined attacker can make fake_hdr's size field self-consistent
with the corrupted LEFT_SIZE so that the structural round-trip checks
pass.  If fake_hdr is marked "used", free_chunk() skips the left
merge and the corruption goes undetected.  If marked "free", it
triggers a bogus merge with attacker-controlled free-list pointers.

Both cases are caught by verifying the left used neighbor's canary:
any overflow from the left must pass through trailer_U1 to reach
hdr_U2's LEFT_SIZE field, so the corrupted canary acts as a tripwire
regardless of whether the resulting fake header is marked used or free.

Address this by introducing free_chunk_check() which validates a free
chunk's structural integrity before trusting its header fields.  It
consolidates the existing MODERATE-level structural checks (chunk
linkage, used-bit consistency) with a new FULL-level canary
verification of the left used neighbor.  Factoring these checks into
a dedicated function lets callers specify @left_trusted according to
context (e.g. the chunk being freed is the left neighbor of the right
merge candidate, so its canary need not be rechecked).

In inplace_realloc()'s shrink path, the freed suffix's left neighbor
is always the chunk being reallocated (used, just validated).  This
path inlines only the right merge to avoid the unnecessary left canary
check.

The check is called before every free list removal: in free_chunk()
for left/right merge candidates, in alloc_chunk() when pulling from
a bucket, and in inplace_realloc() before consuming the right
neighbor.

Also give chunk0 a canary trailer so that the left-neighbor canary
check works uniformly for the first free chunk in the heap.

Signed-off-by: Nicolas Pitre <npitre@baylibre.com>
2026-03-11 20:52:01 -04:00
Nicolas Pitre
c3c404af96 lib: heap: add CONFIG_SYS_HEAP_CANARIES for corruption detection
Add optional canary values at the end of each heap allocation to detect
memory corruption. The canary is validated when memory is freed, catching
buffer overflows (writing past allocation) and double-free errors.

The canary is computed from the chunk address and size, XORed with a
magic value. On free, it is checked and then poisoned to detect
double-free attempts.

The canary is stored as trailer data at the end of the chunk rather than
in the header to avoid complicating aligned allocation processing, and
because buffer overflows are most likely to overwrite past the buffer end
anyway.

This adds 8 bytes of memory overhead per allocation and a canary
computation on alloc and validation on free. It is useful for hardening
against memory corruption as well as for chasing bugs during
development. The trailer structure can be readily extended to carry
additional per-allocation metadata if so desired.

Signed-off-by: Nicolas Pitre <npitre@baylibre.com>
2026-03-11 20:52:01 -04:00
Nicolas Pitre
dee349919b lib: heap: compute heap sizing constants from actual struct layouts
Z_HEAP_MIN_SIZE and Z_HEAP_MIN_SIZE_FOR were defined in kernel.h as
hardcoded magic numbers gated by a growing tower of #ifdefs — one
per Kconfig option that happened to affect the heap struct layout.
Every internal change required manually recomputing the constants,
duplicating layout knowledge across files, and praying nobody forgot
to update the #ifdef matrix.  This is fragile and unscalable: adding
a single new heap feature (e.g. a chunk canary trailer) would add yet
another dimension to the combinatorial explosion.

Replace this with build-time computation from the actual C structures.
A new lib/heap/heap_constants.c uses GEN_ABSOLUTE_SYM to emit the
correct values into a generated heap_constants.h header via the
zephyr_constants_library() infrastructure.  Z_HEAP_MIN_SIZE is
derived through an iterative fixed-point expansion (3 rounds, always
convergent) that mirrors the runtime logic in sys_heap_init().

Big vs small heap determination uses CONFIG_SYS_HEAP_SMALL_ONLY,
CONFIG_SYS_HEAP_BIG_ONLY, and sizeof(void *), mirroring the
big_heap_chunks() logic in heap.h.

Signed-off-by: Nicolas Pitre <npitre@baylibre.com>
2026-03-11 20:52:01 -04:00
Jilay Pandya
43b74864ab drivers: stepper: trinamic: introduce version info
put stepper_trinamic in stepper_ctrl group
add version info

Signed-off-by: Jilay Pandya <jilay.pandya@outlook.com>
2026-03-11 20:48:19 -04:00
Fin Maaß
52c254af76 net: add Kconfig option for checksum offloading
Adds a Kconfig option to detect if checksum offloading
is supported by any driver and one to activate it.

Main benefit is that `net_if_need_calc_rx_checksum()` and
`net_if_need_calc_tx_checksum()` are now inline and therefore the
compiler can optimize more, when checksum offloading is not supported.

Signed-off-by: Fin Maaß <f.maass@vogl-electronic.com>
2026-03-11 17:52:13 +00:00
Vincent Surkijn
311a841620 drivers: pwm: add support for enabling DMA requests
Extend the PWM API with optional API functions for enabling DMA requests

Possible solution for #88670

Signed-off-by: Vincent Surkijn <vincent.surkijn@siemens.com>
2026-03-11 11:38:01 +01:00
Benjamin Cabé
2dc5de7b4f include: drivers: opamp: document driver operations using Doxygen
Use doxygen driver_ops commands to properly document the opamp driver
operations and other symbols useful to driver implementers
(e.g. opamp_functional_mode).

Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
2026-03-10 17:57:29 -07:00
Benjamin Cabé
42b31ab5a0 include: drivers: sensor: enhance Doxygen documentation for MAX31790 sensor
Updated the MAX31790 header file to improve documentation for custom
sensor channels and attributes.

Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
2026-03-10 17:57:10 -07:00
Benjamin Cabé
86a6f7d627 include: drivers: sensor: enhance Doxygen documentation for MAX30210 sensor
Updated the MAX30210 header file to improve documentation for custom
sensor channels and attributes.

Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
2026-03-10 17:57:10 -07:00
Benjamin Cabé
eb2a3794ec include: drivers: sensor: remove unused MAX30210 upper threshold attribute
Removed the SENSOR_ATTR_MAX30210_UPPER_THRESH attribute as it's likely
a leftover and driver code actually uses SENSOR_ATTR_UPPER_THRESH.

Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
2026-03-10 17:57:10 -07:00
Benjamin Cabé
d56720da1d include: drivers: sensor: enhance Doxygen documentation for MCP9600 sensor
Updated the MCP9600 header file to improve documentation for custom
sensor channels and attributes.

Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
2026-03-10 17:57:10 -07:00
Camille BAUD
0fdda30623 drivers: gpio: Introduce BFLB BL61x GPIO FIFO / Wire Out
Introduce a fast GPIO output system with pulse width modifications

Signed-off-by: Camille BAUD <mail@massdriver.space>
2026-03-10 22:20:46 +01:00
Zhaoxiang Jin
790411ab48 dt-bindings: clock: syscon: correct FLEXSPI clock identifiers
Move MCUX_FLEXSPI_CLK and MCUX_FLEXSPI2_CLK definitions
to use correct clock ID 0x24 instead of 0x0A, which
conflicts with MCUX_DMIC_CLK. This ensures each
peripheral has a unique clock identifier.

Signed-off-by: Zhaoxiang Jin <Zhaoxiang.Jin_1@nxp.com>
2026-03-10 14:21:46 -05:00
Keith Packard
ded265f3e7 toolchain/gcc: Add __volatile__ in GEN_ABSOLUTE_SYM macros
This should prevent GCC from eliding these otherwise-unused asm statements.

Signed-off-by: Keith Packard <keithp@keithp.com>
2026-03-10 14:18:47 -05:00
Duy Dang
925d652d10 driver: pinctrl: Add support R-Car V4H SoC
Add pin definition for R-Car V4H SoC.

Signed-off-by: Duy Dang <duy.dang.yw@renesas.com>
2026-03-10 14:15:49 -05:00
Duy Dang
3d68ed92d5 driver: clock_control: Add V4H clock control driver
Support Clock Pulse Generator driver for V4H

Signed-off-by: Duy Dang <duy.dang.yw@renesas.com>
2026-03-10 14:15:49 -05:00
Tim Pambor
b78d3c346c soc: stm32: stm32_iocell: add support for STM32H5 series
For STM32H5 series, only the cell compensation can be configured,
as the HSLV configuration is controlled on a per pin basis and
not on a per domain basis as for other STM32 series.

Signed-off-by: Tim Pambor <tim.pambor@codewrights.de>
2026-03-10 17:24:44 +01:00
Sudan Landge
076a21c30a arch: arm: fix USE_SWITCH for armclang
Fix below issues when trying to build hello world with armclang:
```
Error: L6218E: Undefined symbol z_arm_exc_exit (referred from reset.o).
Error: L6218E: Undefined symbol z_arm_int_exit (referred from reset.o).
Error: L6218E: Undefined symbol z_arm_pendsv (referred from reset.o).
```

Signed-off-by: Sudan Landge <sudan.landge@arm.com>
2026-03-10 17:24:10 +01:00
Sudan Landge
51480990a6 arch: arm: fix USE_SWITCH for IAR
orr fix is as reported in review:
```
The add causes a crash with IAR tools as the address loaded to r8
already has the lowest bit set, and the add causes it to be set to ARM
mode. The orr instruction works fine with both scenarios
```

`UDF 0` seems to break on IAR but `UDF #0` works for all.

Signed-off-by: Sudan Landge <sudan.landge@arm.com>
2026-03-10 17:24:10 +01:00
Sudan Landge
97e9caeda4 arch: arm: document arm-m-switch for Doxygen
Documented Cortex-M switch helper interfaces in arm-m-switch.h with
Doxygen blocks.

Signed-off-by: Sudan Landge <sudan.landge@arm.com>
2026-03-10 17:24:10 +01:00