23091 Commits

Author SHA1 Message Date
Jakub Rzeszutko
a04d8957c2 shell: fix race condition between prompt print and RX buffer flush
Move z_shell_backend_rx_buffer_flush() before state_set() in
shell_start() to prevent a race condition where incoming shell
commands could be lost.

Previously, the sequence was:
1. state_set() - prints the prompt
2. z_shell_backend_rx_buffer_flush() - flushes RX buffer

If the shell thread was preempted after printing the prompt,
the host could see the prompt and send commands. When the
thread resumed, z_shell_backend_rx_buffer_flush() would discard
those commands.

By flushing the RX buffer before printing the prompt, any
commands received after the prompt is visible will not be
affected by the flush operation.

Fixes #99674

Signed-off-by: Jakub Rzeszutko <jakub.rzeszutko@verkada.com>
2026-01-23 09:21:43 -06:00
Robert Lubos
10b9520cac net: lib: http_server: Prefer explicitly defined resources over FS ones
Do direct resource path comparison on all registered resources before
falling back to fnmatch() so that exact path matches get always
preference.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2026-01-23 13:52:47 +01:00
Johann Fischer
506a59396f usb: device_next: fix compilation if the user disables HWINFO
Make USBD_HWINFO_DEVID_LENGTH prompt optional so that the code compiles
even if HWINFO is disabled.

Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
2026-01-23 13:48:16 +01:00
Robert Lubos
ba04734220 net: sockets: tls: Optimze helper buffer for sendmsg and CID check
Both cases use a large static buffer, we can optimize here and use a
single mutex-protected buffer for both.

sendmsg() test case needed adjustments, as it was also testing a buffer
overflow scenario. This can only be properly tested however if CID
feature is disabled, as otherwise the common helper buffer size is
increased for the CID use case, preventing the overflow from taking
place.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2026-01-23 10:46:05 +01:00
Robert Lubos
8afc2af3c2 net: sockets: tls: Make socket options work with multi-client server
For options that return the handshake status, make sure they work in
multi-client DTLS server case, by returning the status for the session
that completed handshake most recently. For TLS and DTLS client cases
that should make no difference, as there should only be one session per
context.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2026-01-23 10:46:05 +01:00
Robert Lubos
ab07f69128 net: sockets: tls: DTLS server session timeout rework
With support for multiple client sessions for DTLS server socket, the
session timeout can no longer rely on built-in mbed TLS timing out
mechanism, as this only works for the session that is currently active.
Background sessions would never time out if the client just went silent.
Therefore, allocate a per-session timestamp, that keeps track of the
last activity on the session. Then, whenever poll() or recv() is called
loop over all sessions to identify those that timed and should be
released.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2026-01-23 10:46:05 +01:00
Robert Lubos
53be38d3f0 net: sockets: tls: Implement DTLS server session matching by CID
In case a client address changes, but a session uses Connection ID
extension, the server should verify if the packet belongs to any of the
established sessions based on the CID value.

Therefore, before attempting to allocate a new session in such case,
loop over sessions and try to match the packet to one of the existing
sessions based on CID. In case of success, update the corresponding peer
address.

If no session is found based on CID, only then try to allocate a new
one.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2026-01-23 10:46:05 +01:00
Robert Lubos
4197720be8 net: sockets: tls: Free DTLS server active session on errors
In case of errors on an active session (in most cases peer closing the
session), the session should be freed. Note, that as mbed TLS needs some
session context to work with, the last session on a socket is not freed,
but only reset instead.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2026-01-23 10:46:05 +01:00
Robert Lubos
6f58b3f24f net: sockets: tls: DTLS server session matching on TX
For TX, the DTLS server needs to check the peer address before passing
the packet to mbed TLS. In case the peer address doesn't match the
active session, it needs to switch sessions.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2026-01-23 10:46:05 +01:00
Robert Lubos
cc6248d87c net: sockets: tls: Refactor RX part for DTLS server
Refactor RX side for DTLS server to allow session switching when a
datagram from a peer that does not match current session. The server
needs to loop over established sessions, and in case no session is
found allocate a new one.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2026-01-23 10:46:05 +01:00
Robert Lubos
9e544a9ec7 net: sockets: tls: Split DTLS BIO functions
Split DTLS BIO RX functions for client and server case, given the
functionality will differ heavily. DTLS server needs to peek packet
before passing it to mbed TLS to allow to switch DTLS sessions in case
peer address doesn't match.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2026-01-23 10:46:05 +01:00
Robert Lubos
779bfe2e5e net: sockets: tls: Split TLS session and context initialization
It has to be possible to initialize TLS sessions separately of the TLS
socket context.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2026-01-23 10:46:05 +01:00
Robert Lubos
42754f8f8d net: sockets: tls: Separate TLS session context from socket context
Separate TLS session context from the TLS socket context so that a
single DTLS server socket can support multiple client sessions.
Other socket types will only have a single session per TLS socket.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2026-01-23 10:46:05 +01:00
Ryan Wiebe
8135c56cf6 modbus: Fixed serial RX enablement for ASYNC and client mode
Modbus is failing to turn on RX when using serial ASYNC mode. This
causes modbus to never receive inbound requests, leaving it inoperable.
Additionally, modbus also enables RX when in client mode, leading to
issues when running as a client. These have been fixed by enabling rx
only when serial init is successful and modbus is in server mode during
initialisation.

Signed-off-by: Ryan Wiebe <ryan.wiebe@analog.com>
2026-01-23 10:43:59 +01:00
Lyle Zhu
cc18a23ec9 bluetooth: classic: GOEP: fix L2CAP MTU calculation
Correct the minimum MTU calculation for GOEP over L2CAP to account
for the L2CAP I-frame overhead.

- Update BT_BUF_ACL_RX_SIZE default from 264 to 265 bytes for GOEP
- Update BT_GOEP_L2CAP_MTU minimum range from 259 to 265 bytes
- Add detailed comment explaining L2CAP I-frame field length (6 bytes):
  * 4 bytes for extended control field
  * 2 bytes for FCS field

The previous calculation only accounted for the L2CAP header (4 bytes)
but missed the 6-byte L2CAP I-frame overhead (extended control field
and FCS), resulting in an incorrect minimum of 264 bytes instead
of the correct 265 bytes. And it causes the minimum MTU of L2CAP
to be incorrectly set to 254. The MTU cannot meet the minimum
requirement of GOEP MOPL.

The correct calculation for GOEP over L2CAP is:
255 bytes (GOEP minimum MTU) + 4 bytes (L2CAP header) + 6 bytes
(L2CAP I-frame) = 265 bytes total.

Set the default value of CONFIG_BT_BUF_ACL_RX_SIZE to 265 if GOEP is
enabled.

Signed-off-by: Lyle Zhu <lyle.zhu@nxp.com>
2026-01-23 10:41:38 +01:00
Victor Brzeski
6b31178272 uac2: disable active terminals when class is disabled
When the USB Bus is reset, the USBD stack will disable and re-enable
all Classes. If this occurs while streaming audio with UAC2, the
terminals remain active when re-enabled, yet the endpoints have
yet to be enabled (resulting in -ENODEV logspam). This change
disables all active terminals when the class is disabled.

Signed-off-by: Victor Brzeski <vbrzeski@gmail.com>
2026-01-22 13:01:30 -05:00
Vinayak Kariappa Chettimada
43dede5acc Bluetooth: Host: settings: Add early len check without strncpy/cmp use
Add early len check, remove use of strcpy, strncpy and
strncmp.

Co-authored-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2026-01-22 13:01:07 -05:00
Vinayak Kariappa Chettimada
230453b6ea Bluetooth: Host: settings: Fix truncation detection after strncpy
Fix truncation detection after strncpy, as strlen cannot be
used if the src was truncated due to insufficient size of
dst.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2026-01-22 13:01:07 -05:00
Vinayak Kariappa Chettimada
d98c2cf0d8 Bluetooth: Host: Rework settings without snprintk to return error
Rework settings implementation for not reusing the OS
snprintk implementation with CONFIG_PRINTK=n and to return
error if path buffer is insufficient.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2026-01-22 13:01:07 -05:00
Vinayak Kariappa Chettimada
d8f3e43b20 Bluetooth: Host: Rework settings without snprintk use
Rework settings implementation for not reusing the OS
snprintk implementation with CONFIG_PRINTK=n.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2026-01-22 13:01:07 -05:00
Vinayak Kariappa Chettimada
2db3f7978f Bluetooth: Host: settings without snprintk use
Update settings implementation for not reusing the OS
snprintk implementation with CONFIG_PRINTK=n.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2026-01-22 13:01:07 -05:00
Vinayak Kariappa Chettimada
4a914bf281 Bluetooth: Host: ATT: Do not use bt_addr_le_to_str when CONFIG_LOG=n
Do not use bt_addr_le_to_str() when CONFIG_LOG=n.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2026-01-22 13:01:07 -05:00
Robert Lubos
5a0f33b31f net: sockets: tls: Enforce minimum TLS version
Enforce the minimum TLS version on mbed TLS, based on the protocol
version provided by the application when creating socket. This ensures
that when application creates a TLS 1.3 socket, mbed TLS won't downgrade
the session to TLS 1.2 for instance.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2026-01-22 12:56:12 -05:00
Flavio Ceolin
59a57722ae pm: Fix wrong type promotion
In pm_system_suspend there is a possible invalid type promotion
in sys_clock_set_timeout(MAX(0, ticks - exit_latency_ticks), true);

ticks is int32_t and exit_latency_ticks is uint32_t consequently
ticks is promoted to uint32_t resulting in a possible underflow and
setting a wrong value in sys_clock_set_timeout().

Fixes #100005
Coverity CID: 535628

Signed-off-by: Flavio Ceolin <flavio@hubblenetwork.com>
2026-01-22 12:54:52 -05:00
Lingao Meng
d845a2230e fs: nvs: prevent ATE writes at sector boundary
In NVS, allocation table entries (ATEs) are written backwards within
each sector. Under delete-only or delete-heavy workloads, a sector may
contain only delete ATEs, causing the ATE write pointer to approach the
sector boundary.

Without an explicit boundary check, ATE writes may occur at offset 0 of
the current sector, allowing the write pointer to underflow into the
previous sector and corrupt unrelated data or metadata.

Fix this by disallowing ATE writes when the write pointer is at the
sector boundary. This ensures that ATE writes remain confined to the
current sector and prevents pointer underflow across sectors.

Signed-off-by: Lingao Meng <menglingao@xiaomi.com>
2026-01-22 14:09:23 +00:00
Vinayak Kariappa Chettimada
73c182509c Bluetooth: Controller: LLL prepare at margin Kconfig
Introduce Kconfig option to enfore LLL prepare at margin
irrespective of whether there is an overlapping state/role.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2026-01-22 14:09:11 +00:00
Vinayak Kariappa Chettimada
5fe53aaa84 Bluetooth: Controller: Use PPI/DPPI to start s/w switch timer
Use PPI/DPPI to start s/w switch timer to reduce current
consumption.

Explicitly starting the s/w switch timer at prepare meant
current being consumed in the prepare margin duration. Use
of PPI/DPPI ensure s/w switch timer is start when event
timer is started after the prepare margin.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2026-01-22 14:09:11 +00:00
Vinayak Kariappa Chettimada
0b1b099196 Bluetooth: Controller: Fix PAST sync_offset_us calculation
Fix the missing use of remainder value in the sync_offset_us
calculations. Also, Periodic Sync reception is relative to
Peripheral event hence ticks_anchor does not require the
ticker margin and event jitter to be subtracted.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2026-01-22 14:09:11 +00:00
Valerio Setti
77d603a5e0 storage: flash_map: remove legacy Mbed TLS crypto for integrity check
Remove Kconfig and code related to legacy Mbed TLS crypto for SHA-256.
This was used for the integrity check functionality as alternative to
PSA Crypto API. This support was already deprecated and now it's removed
in order to prepare for the next Mbed TLS 4.0 release where legacy crypto
won't be available anymore.

Signed-off-by: Valerio Setti <vsetti@baylibre.com>
2026-01-22 14:03:06 +00:00
Yangbo Lu
05c1fecb5b drivers: ethernet: dsa: move dsa_tag_netc driver out of subsys
Moved dsa_tag_netc driver out of subsys. Maintained it in
drivers/ethernet/dsa as vendor driver.

Signed-off-by: Yangbo Lu <yangbo.lu@nxp.com>
2026-01-22 08:41:00 +00:00
Yangbo Lu
1b14cb18a2 net: dsa: support dsa protocol registering with iterable section
Supported dsa protocol registering with iterable section.

Signed-off-by: Yangbo Lu <yangbo.lu@nxp.com>
2026-01-22 08:41:00 +00:00
Yangbo Lu
d9d46c0ce3 net: dsa: make dsa_tag.h as common header file
Moved dsa_tag.h to include folder as common header file.
And we will support iterable section for vendor dsa tag
protocol drivers registering.

Signed-off-by: Yangbo Lu <yangbo.lu@nxp.com>
2026-01-22 08:41:00 +00:00
Ibrahim Abdalkader
0c5e7a6a95 sensing: sensor_mgmt: Use kernel heap for allocations
Use the kernel heap instead of the libc heap, improving
security and consistency.

Signed-off-by: Ibrahim Abdalkader <i.abdalkader@gmail.com>
2026-01-22 08:38:34 +00:00
Ibrahim Abdalkader
afa47a2765 mgmt: mcumgr: grp: Use kernel heap for allocations
Use the kernel heap instead of the libc heap, improving
security and consistency.

Signed-off-by: Ibrahim Abdalkader <i.abdalkader@gmail.com>
2026-01-22 08:38:34 +00:00
Mark Wang
f66ce9c251 bluetooth: shell: a2dp: include error code in failure messages
Add error code parameter to all A2DP shell error messages to provide
more detailed diagnostic information when operations fail. This applies
to configure, establish, release, start, suspend, delay report, and
abort response handlers.

Signed-off-by: Mark Wang <yichang.wang@nxp.com>
2026-01-22 08:37:41 +00:00
Mark Wang
d8eb0ce5f4 bluetooth: shell: a2dp: use bt_shell_error for error messages
Replace bt_shell_print() calls with bt_shell_error() for all error
conditions and failure cases in the A2DP shell implementation to
properly distinguish error messages from informational output.

Signed-off-by: Mark Wang <yichang.wang@nxp.com>
2026-01-22 08:37:41 +00:00
Mark Wang
313478b026 bluetooth: shell: a2dp: use bt_shell_xxx instead of shell_xxx
Replace all shell_print() and shell_error() calls with bt_shell_print()
and bt_shell_error() respectively to use the common Bluetooth shell
printing functions throughout the A2DP shell implementation.

Signed-off-by: Mark Wang <yichang.wang@nxp.com>
2026-01-22 08:37:41 +00:00
Mark Wang
36ab1ba154 Bluetooth: shell: a2dp: Update a2dp sdp profile version
The newest a2dp spec set the profile version as 1.4.

Signed-off-by: Mark Wang <yichang.wang@nxp.com>
2026-01-22 08:37:41 +00:00
Mark Wang
6f0b31c709 bluetooth: shell: a2dp: improve a2dp shell cmds
add abort req and rsp callbacks, improve register_ep cmd to support delay
report, check buf tailroom for sending media, add get_conn cmd to test
bt_a2dp_get_conn.

Signed-off-by: Mark Wang <yichang.wang@nxp.com>
2026-01-22 08:37:41 +00:00
Mark Wang
c92d617855 bluetooth: shell: a2dp: use common function to check a2dp initialization
Before every cmd, call one common function to check whether a2dp is
initialized.

Signed-off-by: Mark Wang <yichang.wang@nxp.com>
2026-01-22 08:37:41 +00:00
Supper Thomas
bd9bf13a0e logging: Fix backoff calculation to use K_CYC instead of K_TICK
The backoff timeout calculation in z_log_msg_claim_oldest() was
incorrectly using K_TICK macro. Changed to K_CYC to properly convert
cycle-based timing differences to kernel timeouts for accurate backoff
in multi-domain message processing.

Signed-off-by: Supper Thomas <78900636@qq.com>
2026-01-21 20:07:56 +01:00
Tahsin Mutlugun
2de323cd3e testsuite: Correct broken link to coverage documentation
The existing documentation link pointed to a non-existent page.
Update the link to use the current documentation URL.

Signed-off-by: Tahsin Mutlugun <Tahsin.Mutlugun@analog.com>
2026-01-21 17:09:07 +01:00
Jeroen Broersen
a10f7f3541 net: lwm2m: senml opaque base64 encoding fix
The SenML-JSON specification mentions base64-encoded data with the
URL-safe alphabet and padding omitted.
For sending data, zephyr used normal base64 with padding. Change the
base64 data to use the URL-safe format without padding when sending opaque
data via SenML-JSON.
Fixes #102390

Signed-off-by: Jeroen Broersen <jeroen.broersen@wioniq.com>
2026-01-21 17:08:41 +01:00
Robert Lubos
fbd9079148 net: dns: Implement CONFIG_DNS_RESOLVER_ADDITIONAL_QUERIES
There was a Kconfig option defined to limit the number of additional DNS
queries sent for aliases received in CNAME records (to avoid potential
query loops), however it was not implemented. This commit implements the
feature - the resolver will now only send up to
CONFIG_DNS_RESOLVER_ADDITIONAL_QUERIES follow-up queries after
receiving CNAME record with an alias w/o any IP addresses.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2026-01-21 17:08:29 +01:00
Robert Lubos
38d9c632d6 net: dns: Fix query redirection in case of CNAME result
In case CNAME record is received with no IP addresses, DNS resolver will
attempt to re-send the query for the name indicated by the CNAME record.
The logic for scheduling the new query was inconsistent though:
dispatcher_cb() assumes that it'll reuse the query context with the same
query id, while dns_read() cancelled the query, which shouldn't really
happen, as that would cause an error to be reported to the application
via callback.

Fix that by skipping the query cancel in case of DNS_EAI_AGAIN result.
The query context will be properly reused then, and freed either when
reply for another query arrives, or the query times out.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2026-01-21 17:08:29 +01:00
Robert Lubos
2a1b814f7b net: dns: Don't report CNAME records via callback
Don't report CNAME records via application callback (as it used to be
done). They don't carry any data in the info struct and are only used
internally to redirect DNS queries.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2026-01-21 17:08:29 +01:00
Evgenii Kosenko
7deab5e334 Bluetooth: Shell: Add per-bearer pool for GATT operations
The original implementation used a single global parameter structure for
GATT operations, preventing concurrent operations on different bearers. By
introducing a per-bearer context pool, each bearer can maintain its own
operation state, enabling simultaneous GATT operations.

Signed-off-by: Evgenii Kosenko <Evgenii.Kosenko@silabs.com>
2026-01-21 13:01:42 +00:00
Jamie McCrae
917404f5d7 mgmt: mcumgr: transport: uart: Change Kconfig to depends on
Changes CONFIG_MCUMGR_TRANSPORT_UART from selecting
CONFIG_UART_MCUMGR to instead of depending upon it, as it should
never have selected a driver Kconfig and instead always depended
upon it, and is needed for supporting different UART transports

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2026-01-21 11:21:46 +00:00
Tom Hughes
8ea64b7b33 bluetooth: audio: Fix redundant initialization
When building the bluetooth.general.tester_le_audio test with clang and
-Winitializer-overrides, it warns:

subsys/bluetooth/audio/mpl.c:318:2: error: initializer overrides prior
initialization of this subobject [-Werror,-Winitializer-overrides]
  318 |         .add_group = NULL,
      |         ^~~~~~~~~~~~~~~~~
subsys/bluetooth/audio/mpl.c:317:15: note: previous initialization is here
  317 |         .add_track = NULL,
      |                      ^~~~

Remove redundant initializer for add_group which overlaps with add_track
in an anonymous union.

Signed-off-by: Tom Hughes <tomhughes@chromium.org>
2026-01-20 20:09:06 -05:00
Benjamin Cabé
25448bc996 task_wdt: adopt SHELL_HELP in task watchdog shell
Use SHELL_HELP macro for help strings to ensure consistency across
various shell modules.

Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
2026-01-20 20:07:37 -05:00