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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
Updated the MAX31790 header file to improve documentation for custom
sensor channels and attributes.
Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
Updated the MAX30210 header file to improve documentation for custom
sensor channels and attributes.
Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
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>
Updated the MCP9600 header file to improve documentation for custom
sensor channels and attributes.
Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
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>
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>
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>
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>