Commit graph

24,075 commits

Author SHA1 Message Date
Szymon Janc
d660d38fca Bluetooth: MPL: Fix NULL pointer dereference in on_obj_selected
Track may not have next track and thus this must be checked before
trying to match ID.

This was affecting following qualification test cases:
GMCS/SR/MCP/BV-38-C
GMCS/SR/MCP/BV-39-C
GMCS/SR/MCP/BV-40-C

Signed-off-by: Szymon Janc <szymon.janc@codecoup.pl>
2025-11-07 19:24:42 +02:00
Tomasz Chyrowicz
6a4af2486d mcumgr: img_mgmt: Fix minor issues
Fix a few typos inside img_mgmt.c file.

Signed-off-by: Tomasz Chyrowicz <tomasz.chyrowicz@nordicsemi.no>
2025-11-07 19:22:29 +02:00
Pavel Vasilyev
bb006dc971 bluetooth: mesh: Increase BT RX Stack Size for PB-GATT
Increase BT RX Thread Stack Size which is needed for successfull
provisioning over PB-GATT.

Output from `kernel thread stacks` shell command:
```
BT RX WQ (real size 4096): unused 1408 usage 2688 / 4096 (65 %)
```

Fixes #98521

Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
2025-11-07 08:25:22 -05:00
Vinayak Kariappa Chettimada
c102a8e30e Bluetooth: Controller: Add BT_HCI_VS_FATAL_ERROR_SUPPORT
Add BT_HCI_VS_FATAL_ERROR_SUPPORT Kconfig to allow
out-of-tree Controllers to control Zephyr HCI Vendor-
Specific Fatal Error event support.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2025-11-07 06:58:27 -05:00
Lyle Zhu
27c245a44d Bluetooth: Classic: RFCOMM: Fix NULL pointer access issue
When received the DLC disconnect request, after prime the DLC
disconnect response, the DLC will be cleared and the `dlc->session`
is cleared. If the no DLC is linked in current session, the idle
timer of the session will be scheduled.

In current implementation, the `dlc->session` is used to get the
session pointer, but it is invalid in this time. And the unexpected
fault occurs.

Fix the issue by getting the session pointer from parameter of the
function `rfcomm_handle_disc()` instead of `dlc->session`.

Fix issue #99035.

Signed-off-by: Lyle Zhu <lyle.zhu@nxp.com>
2025-11-07 06:50:42 -05:00
Anas Nashif
4e9a4e385a cpu_load: rename conflicting API
We have two places defining cpu_load_get() and trying to the same thing,
one is a core kernel feature supported on all architecture, the other is
part of debug, requires tracing and supported only on a subset of
architectures. Both deliver different results and accuracy.

While we figure our how to merge those into one API and with the
advanatges of both, rename the API so there is no confusion about what
is being used.

Fixes #97845

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2025-11-07 10:27:50 +02:00
Seppo Takalo
74bea00174 modem: cmux: Don't set flow-control too easily
Only track the available buffer space, if
CONFIG_MODEM_CMUX_MSC_FC_THRESHOLD is configured.
When less than required amount fit into the ringbuffer,
indicate the RX buffer is full.

Otherwise, only mark RX buffer full when incoming data is being
dropped.

When RX buffer is detected to be full, send Modem Status Command
with flow-controll bit set.

Flow control is released once the incoming buffer has at least
MODEM_CMUX_MTU bytes free again.

Fixes #98644

Signed-off-by: Seppo Takalo <seppo.takalo@nordicsemi.no>
2025-11-06 16:30:13 -05:00
Benjamin Cabé
bdb314d036 net: lib: ocpp: fix misnamed State of Charge (SoC) measurand
As per OCPP 1.6, "State of charge of charging vehicle in percentage" is
"Soc", not "SoCState".

Fixes: zephyrproject-rtos/zephyr#98870

Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
2025-11-06 13:53:53 -05:00
Aleksandar Stanoev
9d06fca87a Bluetooth: Decode Bluetooth 6.2 version number
Bluetooth 6.2 has version number 0x10 and was released in November 2025.
This commit ensures this version number is properly decoded.

Signed-off-by: Aleksandar Stanoev <aleksandar.stanoev@nordicsemi.no>
2025-11-06 13:53:30 -05:00
Nicolas Pitre
408da59cc4 net: lwm2m: fix format specifiers for size_t in LOG_DBG
Fix incorrect format specifiers in lwm2m_read_cached_data() where
size_t variables were printed using %u and %d instead of %zu. This
caused CI failures on ARM64 platforms where size_t is long unsigned
int, triggering -Werror=format warnings.

Signed-off-by: Nicolas Pitre <npitre@baylibre.com>
2025-11-05 15:35:38 -05:00
Robert Lubos
587d9e6a4a net: icmp: Verify the address family before calling the callback
Check the address family of the packet before passing it to a ICMP
handler, to avoid scenarios where ICMPv4 packet is paseed to a ICMPv6
handler and vice versa.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2025-11-05 13:19:03 -05:00
Mahesh Mahadevan
11dbae8a32 pm: Fix warning with pm_policy_priv_device_find_device_constraints
pm_policy_priv_device_find_device_constraints() function
is available only when zephyr_power_state is defined.

Signed-off-by: Mahesh Mahadevan <mahesh.mahadevan@nxp.com>
2025-11-04 13:45:14 -05:00
Johan Hedberg
73b6f8bd4a Bluetooth: Host: Fix build error with observer-only config
When building an observer-only build the check_pending_conn label would
result in CI warnings/errors due to this only being a C23 feature:

scan.c:692:1: error: label at end of compound statement is a C23 extension

Turns out the #ifdefs are completely unnecessary, and the code can simply
take advantage of IS_ENABLED(), which should get rid of the warning.

Signed-off-by: Johan Hedberg <johan.hedberg@silabs.com>
2025-11-04 12:00:35 -05:00
Zhijie Zhong
87e351f8bc Bluetooth: Host: Fix handling of adv reports when scanning for connection
In some cases, the host starts scanning internally for establishing
connections (BT_LE_SCAN_USER_CONN), such as host-based resolving or
auto-connection. In this situation, even if the application does not
start explicit scan, the host still needs to handle the advertising
reports to continue the connection process.

Previously, both bt_hci_le_adv_report() and bt_hci_le_adv_ext_report()
will break or discard all reports when explicit scan is not active.
This causes the connection to stay in SCAN_BEFORE_INITIATING and never
move forward.

This patch adds checking of BT_LE_SCAN_USER_CONN to allow advertising
reports to be processed during connection-purpose scanning. When the
scan is started explicitly by application, the behavior remains the
same, only small comments are updated to describe this behavior and keep
the original code style unchanged.

Signed-off-by: Zhijie Zhong <zhongzhijie1@xiaomi.com>
2025-11-04 16:55:45 +02:00
Tim Pambor
a4d99f5de2 net: core: only set l2_processed flag for NET_CONTINUE
If verdict is NET_OK net_pkt may already be unreferenced and reutilized,
so that setting the `l2_processed` flag would be set on a different
packet, corrupting its state. Avoid this situation by only setting the
l2_processed flag for NET_CONTINUE.

Signed-off-by: Tim Pambor <tim.pambor@codewrights.de>
2025-11-04 16:54:14 +02:00
Stuart Alldritt
8af379516d mgmt: mcumgr: grp: img_mgmt: increment data_off after reading the SHA
Fix a bug where the image's SHA would be interpreted as TLV headers due
to missing a data_off increment.

Signed-off-by: Stuart Alldritt <s.k.alldritt@gmail.com>
2025-11-03 16:59:50 +02:00
Szymon Janc
4571485e16 Bluetooth: Mesh: Fix invalid write in private beacon server
There is no guarantess enum will be packed so passing uint8_t as
node_id to bt_mesh_subnet_priv_node_id_get() could (and likely will)
result in writing past stack variable.

Signed-off-by: Szymon Janc <szymon.janc@codecoup.pl>
2025-11-03 16:59:32 +02:00
Zhaoxiang Jin
f1f39e6a9e cpu_freq: Avoid redundant cpu_freq_policy_reset()
The current code calls cpu_freq_policy_reset() once within
the SMP branch of the cpu_freq_timer_handler function, and
then calls it again at the beginning of cpu_freq_next_pstate().
This causes repeated resets of 'pstate_best' and
'num_unprocessed_cpus', which prevents the 'last core' from
being reached. The initiating core should perform a reset
before broadcasting, and other cores should not reset again.

Signed-off-by: Zhaoxiang Jin <Zhaoxiang.Jin_1@nxp.com>
2025-11-03 16:59:22 +02:00
Zhaoxiang Jin
c924d8ba15 cpu_freq: remove redundant XOR calculation in k_ipi_work_add
In the current code, 'target_cpus ^= (1U << _current_cpu->id)'
is first used to remove the current core. Then, k_ipi_work_add
performs 'target_cpus ^ (1U << _current_cpu->id)' again when
passing parameters. This will add the current core to the mask
again, causing the current core to receive IPI and directly call
cpu_freq_next_pstate() at the end, which may lead to duplicate
execution.

This commit changed 'target_cpus ^ (1U << _current_cpu->id)' to
'target_cpus' in k_ipi_work_add to avoid the second XOR.

Signed-off-by: Zhaoxiang Jin <Zhaoxiang.Jin_1@nxp.com>
2025-11-03 16:59:22 +02:00
Jordan Yates
25269118b5 net: lib: sockets: add socket service fd requirement
The net socket service implementation permanently opens a file
descriptor, which should be taken into account by the build system.

Signed-off-by: Jordan Yates <jordan@embeint.com>
2025-11-03 10:42:06 +02:00
Cristian Bulacu
c341838502 net: ip: route: Add support to search mcast route by iface
This commit adds the possibility to check for a multicast route on a
given interface

Signed-off-by: Cristian Bulacu <cristian.bulacu@nxp.com>
2025-10-31 20:01:55 -04:00
Tomasz Chyrowicz
1b50f08ee9 mgmt: Handle slot version equality
If slots have equal version, but a secondary slot is the active one, the
next boot will switch to the primary slot.
Expose this through SMP commands by marking the primary slot as pending.

Signed-off-by: Tomasz Chyrowicz <tomasz.chyrowicz@nordicsemi.no>
2025-10-31 22:41:16 +02:00
Jukka Rissanen
60f83dca7d net: Do not access possibly freed net_pkt
As the net_pkt might have already been sent by net_if_try_send_data()
function, the pkt might already contain garbage data. So do not try
to access if after that send call but remember the used iface and family
and use them to update the statistics.

The issue was seen with qemu_x86_64 and qemu_cortex_a53 when CONFIG_SMP
was enabled.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2025-10-31 22:41:07 +02:00
Lyle Zhu
d95358e934 Bluetooth: Classic: L2CAP: Reset rx.cid when channel is deleted
rootcause: The dynamic L2CAP channel rx.cid is not reset, it
will be intercepted by the judgment condition of the fixed channel,
directly using the last alloced cid may cause cid conflict.

Co-authored-by: zhenwei fang <fangzhenwei@bytedance.com>
Signed-off-by: Lyle Zhu <lyle.zhu@nxp.com>
2025-10-31 10:34:04 -04:00
Jukka Rissanen
73315dd73d net: shell: stats: Fix undefined function call
If CONFIG_NET_STATISTICS_PER_INTERFACE is not set, then the
net_shell_print_statistics_all() function was not found and
the compilation was failing.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2025-10-31 10:33:47 -04:00
Szymon Janc
973934c1e9 Bluetooth: Host: Fix crash on bt_disable() with limited advertising
When limited advertising is enabled there is pending deleyable work
for timing it out. If in such case struct bt_le_ext_adv is cleared by
memset system will crash on next tick.

Fix this by ensuring work is cancelled before clearing struct
bt_le_ext_adv. Using bt_le_ext_adv_foreach() ensures that this will
be correctly handled with and without extended advertising enabled.

Signed-off-by: Szymon Janc <szymon.janc@codecoup.pl>
2025-10-30 18:37:07 -04:00
William Tambe
611f381ed9 xtensa: properly compute irq number
This is a miss from:
abeccfec28 xtensa: support for more than 32 interrupts

Signed-off-by: William Tambe <williamt@cadence.com>
2025-10-30 18:36:41 -04:00
Tomasz Leman
45bfe066c7 ipc: intel_adsp_host_ipc: clear tx_ack_pending on PM resume
Fix IPC driver becoming non-operational after power management resume
due to stale tx_ack_pending state from before suspend.

After the IPC service backend refactor (commit cf7e2e63c1), the
intel_adsp_ipc_data structure contains function pointers for
suspend/resume handlers. This prevents using `memset` to clear the
entire structure during initialization, which was previously done in
intel_adsp_ipc_init.

Without clearing tx_ack_pending on resume, if the device enters D3 state
while still waiting for an IPC acknowledgment (e.g., from a previous
test iteration), the driver remains stuck in the waiting state after
resume. This prevents sending any new IPC messages, including the
FW_READY notification after D3 exit.

The fix explicitly clears tx_ack_pending during PM_DEVICE_ACTION_RESUME
to ensure the driver starts in a clean operational state after resume,
regardless of the state before suspend.

Fixes regression introduced in commit cf7e2e63c1

Signed-off-by: Tomasz Leman <tomasz.m.leman@intel.com>
2025-10-29 20:18:41 +02:00
Simon Walz
fd780ae34e net: lwm2m: fix missing name entries for time-serialized resource instances
The LwM2M SENML JSON/CBOR decoder expects a name entry for every
time-serialized record. While this was already the case for resources,
resource instances were missing their corresponding name entries. This
change ensures consistency by adding name entries for resource instances
as well.

Signed-off-by: Simon Walz <simon.walz@autosen.com>
2025-10-29 20:18:30 +02:00
Jamie McCrae
20be667f16 mgmt: mcumgr: grp: settings_mgmt: Part revert settings save change
Partially reverts commit 7d2fb6c013,
it was originally thought that this commit added a method of saving
one specific key using the value that the device already has set,
but has been found to actually save the value that the user has
provided, bypassing the current value that the device has, which is
not compliant with the settings mgmt protocol, therefore remove
this change and it will need to be reworked in future to function
properly by saving one specific value from the device's current
configuration, not a user-specified value

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2025-10-29 20:18:20 +02:00
Chaitanya Tata
05899583fd ipc: icmsg: Increase default stack size
For nRF71 Wi-Fi a higher stack size is needed.

Signed-off-by: Chaitanya Tata <Chaitanya.Tata@nordicsemi.no>
2025-10-29 13:48:33 +02:00
Jukka Rissanen
a02414a9bc net: zperf: Use %zd when printing size_t variable
Wrong printf format was using for size_t variable which caused
compiler warning and a failure.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2025-10-29 13:47:21 +02:00
Lyle Zhu
354a63f401 bluetooth: classic: HFP_AG: Fix early SCO connection req sending
When creating the audio connection, the SCO connection request will be
sent before the response "OK" to AT command "AT+BCS" is issued.

It causes the issue that the HFP HF cannot response the SCO connection
request with the correct codec. Then the SCO connection cannot be
established properly.

Put all processing into the same context, thus avoiding non-sequential
execution caused by the different priorities of different threads.

Add a flag `BT_HFP_AG_AT_PROCESS` to flag the AT command is being
processed.

When the flag `BT_HFP_AG_AT_PROCESS` is set, put the pending
executions into temp list `tx_submit_pending`. After the AT response
`OK` or `ERROR` has been sent, move the pending executions from
`tx_submit_pending` to `tx_pending`.

Signed-off-by: Lyle Zhu <lyle.zhu@nxp.com>
2025-10-29 11:44:52 +02:00
Anas Nashif
303af992e5 style: fix 'if (' usage in cmake files
Replace with 'if(' and 'else(' per the cmake style guidelines.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2025-10-29 11:44:13 +02:00
Cristian Bulacu
ecb5db6c92 samples: net: openthread: border_router: Fix packet forwarding bug
This commit fixes an issue introduced in #97531. Multicast routes added
by application are now set to have a prefix length of 16 bits instead of
128. This will allow multicast routing to all IPv6 addresses from those
groups.

For the OpenThread multicast listener callback, route length will be set
to 128 bits, as a MLD event is expected when an address is subscribed.
Route lookup has been removed since one will always be found as the
application registers multicast routes with same scope, but with a
smaller prefix length.

Fixed issue regarding packet forwarding and BBR state. Previously, code
was covering only the case wehn BBR was secondary and packet was
received from backbone interface. A secondary BBR should not forward a
multicast packet from OT interface to backbone interface and vice versa.

Improved unicast forwarding function to return from the beginning if the
packet has a multicast destination.

Signed-off-by: Cristian Bulacu <cristian.bulacu@nxp.com>
2025-10-29 10:32:42 +02:00
Rob Barnes
5ce408b647 kernel: assert if k_current_get is called pre-kernel
k_current_get is not valid pre-kernel. It will return an invalid dummy
thread or invalid memory. The invalid memory case can occur when
CURRENT_THREAD_USE_TLS is enabled.

Assert in k_current_get when called pre-kernel so offending code may be
identified.

k_is_pre_kernel is moved up in kernel.h to avoid needing a prototype for
k_is_pre_kernel.

Signed-off-by: Rob Barnes <robbarnes@google.com>
2025-10-28 11:52:34 +02:00
Jakub Rzeszutko
3ae4dfe490 shell: fix deadlock in the bypass function
Previously, the bypass() function was called while the shell mutex
was still held, preventing the use of shell APIs (e.g. shell_print())
inside the bypass context.

This change unlocks the shell mutex before invoking bypass() and
locks it again afterwards, restoring proper shell context handling
and preventing potential deadlocks.

Issue fixed by: roni1234321

Fixes #97722

Signed-off-by: Jakub Rzeszutko <jakub.rzeszutko@verkada.com>
2025-10-28 11:51:18 +02:00
Pan Gao
40256a919d net: l2: wifi: Fix btwt_setup command parameter count
command btwt_setup maximum support max 12 optional parameters.

Signed-off-by: Pan Gao <pan.gao@nxp.com>
2025-10-28 11:50:02 +02:00
Chris Friedt
b6d45e1def testsuite: coverage: use correct path to fnmatch.h
The minimal libc does not include `fnmatch.h` in its default search path.

This causes an issue when running coverage in CI as shown here.
https://github.com/zephyrproject-rtos/zephyr/actions/runs/18839500380/\
job/53748166725

That would technically be fixed with #97855 as well.

Testing Done:
```
west twister -c -p qemu_x86/atom -s kernel.pending.minimallibc --coverage\
 --coverage-tool gcovr
```

Signed-off-by: Chris Friedt <cfriedt@tenstorrent.com>
2025-10-28 11:47:31 +02:00
Vinayak Kariappa Chettimada
533ef58157 Bluetooth: Controller: Fix use-after-release in lll_scan/lll_scan_aux
Fix use-after-release in lll_scan/lll_scan_aux when using
mayfly_enqueue to defer execution of the offset calculation
using ull_sched_mfy_after_cen_offset_get().

Apply suggestion from @Copilot

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2025-10-27 16:18:48 -04:00
Alberto Escolar Piedras
8fb6cb7537 tracing: ctf: Fix arguments for socket tracing functions (again)
Zephyr's socklen_t was changed in
c546c1cad1
to be uint32_t instea of size_t.
Let's fix accordingly the prototypes which expect it.

Note this was already fixed in
37ff1b254f
But it was reverted in
d849ab1263

Signed-off-by: Alberto Escolar Piedras <alberto.escolar.piedras@nordicsemi.no>
2025-10-27 16:14:50 -04:00
Jukka Rissanen
ec3bcd3930 net: tcp: Close all connections when interface goes down
If the network interface goes down, close all TCP connections
that are bound to that interface. The reasoning here is that we
need a way to remove IP address from the interface and it might
not be possible if there is a TCP socket that is bound to that address.
If the interface comes back on, we might get the same IP address in
which case the socket closure was not really needed but it is not
possible to know in advance.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2025-10-27 07:32:28 -04:00
Jukka Rissanen
1f5c285279 net: tcp: Allow immediate connection tear down
If the network interface goes down, then we do not have any time
to tear down TCP connection gracefully because there is no more
a connection to send data to. In this case the TCP connection is
forcefully closed without going into FIN_WAIT_1 state.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2025-10-27 07:32:28 -04:00
Lars Segerlund
fc813d9556 Bluetooth: Controller: Handle overlapping CIG and ACL
If the CIG and ACL overlap each other when the CIS is starting
zephyr will assert on negative time, so fit this special case.

Signed-off-by: Lars Segerlund <lrsu@demant.com>
2025-10-27 10:59:38 +02:00
Pavel Vasilyev
1a4f113d14 bluetooth: mesh: adv_ext: Fix scheduling with multiple relay adv sets
When multiple relay adv sets are used, the bt_mesh_adv_send function
calls bt_mesh_adv_relay_ready which should distribute relayed
advertisements across all relay adv sets.

Until the submitted relay adv set work is started, the ADV_FLAG_ACTIVE
is not set. Therefore, next call to bt_mesh_adv_send will try to
re-submit the same relay adv set work, instead of picking up another
relay set which is actually free and ready to send an advertisement.

This commit adds a check that checks if the adv set work is already
pending to be executed. And if so, schedule_send returns false to make
bt_mesh_adv_relay_ready pick next relay adv set.

This shouldn't brake advertising because once adv set is done
transmitting advertisment, it will pick up a next one.

The ADV_FLAG_PROXY check is added to do re-submit for adv set which was
used for proxy advertisement since we need to prioritize mesh messages
over proxy advertisements when those are running on the same adv set.

Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
2025-10-27 10:59:23 +02:00
Lingao Meng
bed07a5ebf tests: bluetooth: audio: fix bsim timing
move extending advertising start after periodic adv.

Signed-off-by: Lingao Meng <menglingao@xiaomi.com>
2025-10-27 10:59:23 +02:00
Lingao Meng
d59cd2e368 Bluetooth: Host: Fix Periodic Advertising random address update
update random address when periodic adv enabled.

Signed-off-by: Lingao Meng <menglingao@xiaomi.com>
2025-10-27 10:59:23 +02:00
Lingao Meng
f902f2ab0d Bluetooth: Host: Fix unnecessary random address update
The `bt_le_ext_adv_update_param` will set new random address when option
not select `BT_LE_ADV_OPT_USE_IDENTITY`, But `bt_le_ext_adv_start` will
also set random address again.

This will be affect bluetooth mesh, after this change, will ensure address
only change once for every advertising.

Signed-off-by: Lingao Meng <menglingao@xiaomi.com>
2025-10-27 10:59:23 +02:00
Emil Gydesen
02d0e96bf1 Bluetooth: BAP: Add bt_bap_unicast_client_unregister_cb
Add bt_bap_unicast_client_unregister_cb to unregister BAP
unicast client callbacks. This is required for unittests
to clean up between runs.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2025-10-25 15:59:40 +03:00
Anas Nashif
d849ab1263 tracing: fix various style issues
run clang-format and fix various checkpatch issues.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2025-10-25 15:59:19 +03:00