Commit graph

22,555 commits

Author SHA1 Message Date
Peter Mitsis
fedbe50b20 portability: cmsis: Base Event Flags on k_event
Updates the implementation of the osEventFlags APIs to use
Zephyr kernel events instead of polling.

Fixes #92899

Signed-off-by: Peter Mitsis <peter.mitsis@intel.com>
2025-08-21 20:11:57 +02:00
Vinayak Kariappa Chettimada
4ec8980022 Bluetooth: Controller: Fix BT_CTLR_ADV_ADI_IN_SCAN_RSP
Fix to rename BT_CTRL_ADV_ADI_IN_SCAN_RSP to
BT_CTLR_ADV_ADI_IN_SCAN_RSP.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2025-08-21 17:13:30 +02:00
Ayman Elfayoumi
48689343dc Bluetooth: Simplify le_adv_update() function
Closes #94549
Removed vestigial d and d_len variables from le_adv_update()
and replaced them with a single bt_ad wrapper. This simplifies
the function while maintaining identical functionality.

Signed-off-by: Ayman Elfayoumi <aelfayoumi2@gmail.com>
2025-08-21 17:05:51 +02:00
Pavel Vasilyev
bcdd74d815 bluetooth: host: gatt: destroy key after hash calc completes
To generate the GATT Database Hash characteristic, the function
`db_hash_setup` is called. It allocates an entry for the AES key that will
be used in the CMAC calculation. Next, `db_hash_update` is called to feed
all GATT database entries into the hash. Finally, `db_hash_finish`
produces the resulting hash.

However, the AES key entry allocated in `db_hash_setup` was not being
destroyed after the hash generation completed. This caused a memory
leak, eventually leading to the error `PSA_ERROR_INSUFFICIENT_MEMORY`
(`-134`).

This commit fixes the issue by destroying the allocated AES key after
the GATT Database Hash calculation is complete, by calling
`psa_destroy_key` in `db_hash_finish`.

Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
2025-08-21 15:46:48 +02:00
Vinayak Kariappa Chettimada
7f0ba00095 Bluetooth: Move BT_BUF_EVT_DISCARDABLE_ to Host Kconfig
Move BT_BUF_EVT_DISCARDABLE_ to Host Kconfig, as this is
not used by the Controller.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2025-08-21 13:07:20 +02:00
Vinayak Kariappa Chettimada
41505da49a Bluetooth: Missing Kconfig depends for BT_BUF_EVT_DISCARDABLE_
Missing depends on !BT_HCI_RAW for HCI Discardable Events
count and size.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2025-08-21 13:07:20 +02:00
Vinayak Kariappa Chettimada
3a8738179a Bluetooth: Controller: Fix assertion on BIG terminate sync
Fix assertion on BIG terminate sync and due to not receiving
terminate control procedure when there are no free buffers.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2025-08-21 13:07:20 +02:00
Emil Gydesen
8b6162aec3 Bluetooth: GMAP: Add requirement for Broadcast assitant for BGS
As per GMAP 1.0.1, the BGS role now requires support for the
BAP Broadcast Assistant.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2025-08-21 11:10:23 +02:00
Jordan Yates
3b7a797d2d lorawan: services: swap select to depends on
Switch the selects on `LORAWAN_FRAG_TRANSPORT` to `depends on`. `select`
should only be used for simple symbols without dependencies themselves.
Mixing `depends on X` and `select X` on different symbols is the primary
cause of Kconfig dependency loops.

Signed-off-by: Jordan Yates <jordan@embeint.com>
2025-08-21 06:52:11 +02:00
Charles Hardin
0fe091bc46 net: dns: fix the bounds conditions on the failures and error returns
The loop condition is not the count of the actual tries since the
continue or breaks can occur on the loop and thus a failure count
can falsely match a loop count even when a query is outstanding.

This can be seen when a dual stack resolve is used for IPv4 and IPv6
that has two fds to be used and the interface has only gotten an
IPv6 address. The failures on the IPv4 will indicate a 1 and the break
on the tried attempt on the IPv6 will break the loop on a 1.

Signed-off-by: Charles Hardin <ckhardin@gmail.com>
2025-08-21 01:43:59 +02:00
Olivier Lesage
90113e68ea bluetooth: host: Combine main and sub mode CS step options
Not all combinations of main mode and sub mode are valid, so to make it
harder to select incorrect parameters, the main mode and sub mode
enums are combined into one.

Now the user chooses any valid option in enum bt_conn_le_cs_mode.

Signed-off-by: Olivier Lesage <olivier.lesage@nordicsemi.no>
2025-08-20 16:30:57 +02:00
Emil Gydesen
31a3315d61 Bluetooth: BAP: Replace bt_bap_iso with bt_iso_chan for streams
Modify the struct bt_bap_stream to have a direct reference to the
bt_iso_chan, rather than having a reference to the parent
bt_bap_iso.

This change will allow users to more easily and directly access
the bt_iso_chan, instead of getting the reference via
bt_bap_ep_get_info.
Additionally, this allows users to access the bt_iso_chan for
streams that are not codec configured, and thus not have a
bt_bap_ep reference.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2025-08-20 13:46:02 +02:00
Emil Gydesen
25247fa401 Bluetooth: ISO: Expose CIG_ID, CIS_ID, BIG_Handle and BIS_Number
Expose the IDs, handles and numbers of CIGs, BIGs, CISes and BISes
via the ISO info struct. This information may be needed by higher
layer (such as the Basic Audio Profile (BAP)) or used as indexes
for arrays in the application layer.

The location of the CIG_ID, CIS_ID, BIG_Handle and BIS_Number
are moved to the location struct inside of struct bt_conn_iso
instead of being stored directly in it.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2025-08-20 13:46:02 +02:00
Emil Gydesen
6b1fafb660 Bluetooth: ISO: Change bis_id to bis_number
Modify the bis_id in struct bt_conn_iso to be bis_number
and correctly initialize it for both the broadcaster and
the sync receiver.

The field is currently unused and the term bis_id does not
exist in the core spec. The BIS Index was renamed to BIS
Number in Core 6.1, and thus the Zephyr code base will
reflect that.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2025-08-20 13:46:02 +02:00
Jamie McCrae
db8f991c77 kconfig: Use $(...) instead of ${...} for getting variables
Updates this to comply with the Zephyr Kconfig recommendations

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2025-08-20 12:05:41 +02:00
Dmitrii Sharshakov
b98e7f501f pm: fix NULL pointer dereference with stats
Fix null pointer dereference in pm_system_suspend

Fixes #89228

Signed-off-by: Dmitrii Sharshakov <d3dx12.xx@gmail.com>
2025-08-20 02:17:20 +02:00
Tim Pambor
e3a99bd625 shell: backend: Default to poll mode for uart_native_pty
The interrupt-driven UART API is emulated via polling on native_sim,
which introduces additional overhead. Defaulting to poll mode improves
performance by avoiding this emulation cost.

Signed-off-by: Tim Pambor <tim.pambor@codewrights.de>
2025-08-19 19:14:21 +02:00
Seppo Takalo
6cdae490e3 net: lwm2m: Suppress many LOG_ERR() that are not fatal
Suppress many LOG_ERR() messages from LwM2M registry
that are not necessary runtime errors.

Libraries and applications should be able to do following
without causing LOG_ERR to be produced:

* Checking existence of object, resource or resource instance
  using lwm2m_engine_get_res(), lwm2m_engine_get_res_inst()
  or path_to_objs(). These are only exposed in internal header.
* Delete object instance or resource instance without checking
  if it exits.

As there is no public API to check existence of some path,
application is much easier to write in a way that it directly
calls just lwm2m_get...(), lwm2m_set...(), lwm2m_delete...()
and trust the return code of -ENOENT.

Signed-off-by: Seppo Takalo <seppo.takalo@nordicsemi.no>
2025-08-19 19:13:59 +02:00
Kapil Bhatt
f48a66121a net: zperf: Improve UDP multicast upload
UDP multicast uploads did not produce zperf-compatible server stats,
so the client waited for and tried to decode a non-existent reply,
causing “Unexpected response flags” and misleading
“LAST PACKET NOT RECEIVED!!!” output.

This change treats multicast as client-only: after sending
the negative-id FIN it does not wait for or decode server stats,
Instead transmits the FIN a few times to help receivers detect test end.
The shell prints a clear “Statistics (client only)” summary for multicast
and suppresses the error when client stats are valid.

Unicast behavior is unchanged.

Signed-off-by: Kapil Bhatt <kapil.bhatt@nordicsemi.no>
2025-08-19 14:16:05 +02:00
Emil Gydesen
e6d6578d96 Bluetooth: CAP: Add missing check for abort in the started cb
bt_cap_initiator_started did not have a check for aborted like
all the other callbacks, which could cause the procedure to
continue even if it was aborted.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2025-08-19 14:15:48 +02:00
Tamás Kiss
c9087bce75 logging: fix dictionary mode for dropped messages on rtt backend
With the dictionary feature enabled, the RTT backend would still print
the "messages dropped" message as a string instead of the binary format.
Fix that by calling the correct process function when dictionary mode
is enabled.

Signed-off-by: Tamás Kiss <tmik@demant.com>
2025-08-19 13:03:03 +02:00
Keith Packard
302b192dd9 tests/kernel: Avoid C library calls from interrupt handlers
On arm64, GCC feels free to use floating point registers for essentially
anything unless we build with -mgeneral-regs-only. After the FPU gets used
in an interrupt handler, interrupts are disabled as there's no place to
save the registers during a nested exception. As the C library may be built
separately without this flag, we cannot use any of its functions or risk
having nested exceptions fail.

Switch printk usage to k_str_out and stick to (mostly) Zephyr internal
functions to ensure nested interrupts work correctly.

Signed-off-by: Keith Packard <keithp@keithp.com>
2025-08-18 22:01:08 +02:00
Pavel Vasilyev
818e18eacb bluetooth: host: Use critical section when making channel ready to send
A public API call that sends ACL data — for example, `bt_gatt_notify` —
can be invoked from a preemptive thread context. This API, in turn,
calls the `raise_data_ready` function, which adds an L2CAP channel to
the `l2cap_data_ready` list.

The atomic variable used to create a critical section around
`l2cap_data_ready` did not work, because a preemptive thread can be
pre-empted at any time. This means that regardless of the `atomic_set`
result, we cannot trust it — the thread could be preempted after the
call, and the atomic variable state could be changed (specifically by
the TX processor in this case). The same issue applies to
`bt_conn_data_ready`, which is called next.

When making an L2CAP channel ready for sending data, we need to use a
critical section when appending a channel to the `l2cap_data_ready`
list. The same applies to the `conn_ready` list.

Since cooperative threads can only be rescheduled explicitly, we must
ensure there are no rescheduling points when accessing either the
`l2cap_data_ready` or `conn_ready` lists.

For `l2cap_data_ready`, this occurs in `get_ready_chan`, which is called
from `l2cap_data_pull`, which in turn is called by the TX processor. For
`conn_ready`, it occurs in `get_conn_ready`, which is also called from
the TX processor. Both functions have no rescheduling points when
working with their respective lists, so they do not require a critical
section.

This change removes the atomic variables previously used to create a
critical section for both lists, as they were ineffective. Instead,
`k_sched_lock`/`k_sched_unlock` are used where code may be executed from
a preemptive thread context. The `sys_slist_find` function is used to
check whether a channel or connection is already in the corresponding
list.

Fixes #89705

Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
2025-08-18 16:05:48 +02:00
Henrik Brix Andersen
faecad66c7 retention: bootmode: remove unused log module
Remove unused log module from the bootmode retention module.

Signed-off-by: Henrik Brix Andersen <hebad@vestas.com>
2025-08-18 16:00:37 +02:00
Lyle Zhu
2df8578c7a Bluetooth: Classic: SDP: Improve SDP discovery response
In current implementation, the attribute of the registered SDP record
will not be included in responding packet if the attribute data length
is more than the MAX payload size(`MIN(SDP_MTU, sad->sdp->chan.tx.mtu)
- sizeof(struct bt_sdp_hdr)`). And it causes the failure of ssa or sa
discovery.

Improve the SDP server to support the case by extending the
continuation state length. A 4 bytes space is extended to store the
attribute offset.

In this way, the attribute can be transmitted in segments according
to the reaming space of the responding buffer.

Signed-off-by: Lyle Zhu <lyle.zhu@nxp.com>
2025-08-18 11:57:23 +02:00
Kai Cheng
99243afec0 Bluetooth: PNP: add pnp product id interface and tool
add pnp product id interface and tool for HID profile

Signed-off-by: Kai Cheng <chengkai@xiaomi.com>
2025-08-18 10:55:19 +02:00
Kai Cheng
82fd0b898a Bluetooth: PNP: add pnp vendor id interface and tool
add pnp vendor id interface for hid feature.

Signed-off-by: Kai Cheng <chengkai@xiaomi.com>
2025-08-18 10:55:19 +02:00
Kai Cheng
ff2503c002 Bluetooth: SDP: wrap sdp attr item into u16 common func
Wrap sdp attr item into u16 common function, and it would help
to add pnp etc info

Signed-off-by: Kai Cheng <chengkai@xiaomi.com>
2025-08-18 10:55:19 +02:00
Sean Kyer
a28925af31 net: ocpp: Fix cast warning
Fix warnings generated from casting pointers
of different sizes and string literals in ocpp

Signed-off-by: Sean Kyer <Sean.Kyer@analog.com>
2025-08-16 10:20:26 +02:00
Emil Gydesen
04dc211f64 Bluetooth: CAP: Fix bad return from bap_unicast_group_foreach_stream_cb
The function should stop iterating if the callback provided to
bt_cap_unicast_group_foreach_stream returns true.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2025-08-16 10:20:18 +02:00
Emil Gydesen
ddfc33a4e5 Bluetooth: BAP: Implement bt_bap_broadcast_source_foreach_stream
Implement the function bt_bap_broadcast_source_foreach_stream that
allows users to iterate on all BAP streams in a BAP broadcast source.
This can be used to easily get reference to other broadcast streams in
the same group as any other stream via the stream->group pointer
or a broadcast source pointer directly.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2025-08-16 10:20:10 +02:00
Johan Hedberg
30527e5403 Bluetooth: Host: Rename acl_data to bt_conn_rx
We already have bt_conn_tx for outgoing buffer user data, so name the
struct for incoming (rx) buffers similarly. Also, update ISO to use this
struct instead of a custom iso_data struct, since the content and purpose
is identical.

Signed-off-by: Johan Hedberg <johan.hedberg@silabs.com>
2025-08-16 10:18:50 +02:00
Håvard Reierstad
fbd7acec25 Bluetooth: Host: Remove deprecated device name API
Removes the BT_LE_ADV_OPT_USE_NAME and BT_LE_ADV_OPT_FORCE_NAME_IN_AD
advertiser options and related flags, macros and functions. The
application now needs to include the device name explicitly.

The API was deprecated in
https://github.com/zephyrproject-rtos/zephyr/pull/71700

Signed-off-by: Håvard Reierstad <haavard.reierstad@nordicsemi.no>
2025-08-15 15:34:58 +02:00
Vinayak Kariappa Chettimada
72dac165d8 Bluetooth: Controller: Use OVERHEAD_XTAL_US from devicetree
Use the external crystal high frequency clock settling value
from devicetree.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2025-08-15 15:34:00 +02:00
Johann Fischer
4bf0381592 usb: device_next: cdc_ncm: disable data interface when disconnected
Disable the data interface when the device is disconnected or when the
CDC-NCM and CDC-ECM instances are disabled for any reason.

Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
2025-08-15 10:11:16 +03:00
Cristian Bulacu
4f644d8441 net: socket: Fix recvmsg() pktinfo support.
Fix an issue where IPV6_RECVPKTINFO was used instead of IPV6_PKTINFO
when insert_pktinfo was called.

Signed-off-by: Cristian Bulacu <cristian.bulacu@nxp.com>
2025-08-15 10:10:59 +03:00
Cristian Bulacu
6c826efd5a net: context: Add support for setting hop limit from ancillary data
Add support to parse over msghdr and set pkt hop limit, if needed, when
sendmsg() is used.

Signed-off-by: Cristian Bulacu <cristian.bulacu@nxp.com>
2025-08-15 10:10:59 +03:00
Cristian Bulacu
05f8edfebc net: socket: Add support for setting hop limit options
Add IP_RECVTTL or IPV6_RECVHOPLIMIT BSD socket options
that can be used to extract ttl/hop limit from ancillary data
in recvmsg() call.

Signed-off-by: Cristian Bulacu <cristian.bulacu@nxp.com>
2025-08-15 10:10:59 +03:00
Cristian Bulacu
4388cb1438 net: context: Add support for setting receive hop limit option
Add support for setting IPV6_RECVHOPLIMIT or IP_RECVTTL socket option.

Signed-off-by: Cristian Bulacu <cristian.bulacu@nxp.com>
2025-08-15 10:10:59 +03:00
Adrien Lessard
c5229fcda6 pm: device_runtime: fix pm_device_runtime_get rollback
In a call to pm_device_runtime_get, if the power domain is taken but
action_cb fails, the power domain is not released.

Signed-off-by: Adrien Lessard <adrien.lessard@rbr-global.com>
2025-08-14 15:11:13 -04:00
Emil Gydesen
f149118e7c Bluetooth: BAP: Source: Remove LOG_WRN for started/stopped
Removed the LOG_WRN if the started or stopped callback
for streams are not set. The reasoning is that there is also
the group-wide started and stopped callbacks, and an application
may want to use those instead of the per-stream callbacks.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2025-08-14 18:04:01 +02:00
Emil Gydesen
cb7965a1a9 Bluetooth: BAP: Sink: Remove LOG_WRN for started/stopped
Removed the LOG_WRN if the started or stopped callback
for streams are not set. The reasoning is that there is also
the group-wide started and stopped callbacks, and an application
may want to use those instead of the per-stream callbacks.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2025-08-14 18:04:01 +02:00
Emil Gydesen
e6da768edc Bluetooth: BAP: Add missing ep->iso checks
The bt_bap_unicast_client_ep_qos function attempts to access
ep->iso->chan.iso->iso, but where some of the pointers may be
invalid. Add an additional check for these.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2025-08-14 18:03:41 +02:00
Emil Gydesen
6dffbf88f9 Bluetooth: BAP: Broadcast Source: Fix missing group relations
Adds missing assignments to stream->group and
cleanup of ep->broadcast_source.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2025-08-14 18:03:32 +02:00
Emil Gydesen
aac06ba84f Bluetooth: BAP: Broadcast Sink: Fix missing group relations
Adds missing assignments to stream->group and
cleanup of ep->broadcast_sink.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2025-08-14 18:03:32 +02:00
Emil Gydesen
ff7de521c2 Bluetooth: BAP: Fix missing endian conversions for codec_cfgs
Adds a few missing endian conversions when handling codec_cfgs.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2025-08-14 18:03:25 +02:00
Pavel Vasilyev
a18811857b bluetooth: host: smp: Update bt_keys addr when receiving identity addr
In addition to aligning the destination address of all connection
objects during the identity resolution phase, we also need to update the
corresponding address field in the `struct bt_keys` structure for each
of these connection objects.

If we don't do this, `bt_keys_get_type` for that connection won't find
the `bt_keys` structure in the pool and will allocate a new one. This
will result in orphaned `bt_keys` structures in the pool.

This completes the change done in https://github.com/zephyrproject-rtos/zephyr/pull/61030/commits/637dabc3c9b018f47dee656d2ca0fe8f2fa21984

Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
2025-08-14 15:49:09 +02:00
Pavel Vasilyev
1a61ba5316 bluetooth: host: Increase BT_MAX_PAIRED to 250
This is done to align with BT_MAX_CONN max value.

Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
2025-08-14 15:49:09 +02:00
Pavel Vasilyev
c3edbac5cb bluetooth: host: hci_core: Move event length check to bt_recv_unsafe
The event header is already accessed in `bt_recv_unsafe`. If length is
valid there, no point in checking it again in `hci_event` or
`hci_event_prio`.

Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
2025-08-14 15:49:09 +02:00
Pavel Vasilyev
9e5e23d1e9 bluetooth: host: hci_core: prioritize LE Conn Complete event handling
During debugging multiple.sh test, a race condition was observed where
advertiser state on Host and Controler was desynchronized.

Below is the sequence of actions led to this issue:

0. Host has queued few priority events at this moment.
1. Controller establishes a connection and stops the advertiser.
2. Controller sends to Host BT_HCI_EVT_LE_ENH_CONN_COMPLETE.
3. Host deprioritizes BT_HCI_EVT_LE_ENH_CONN_COMPLETE event and doesn't
   process it immediately.
4. Controller sends to Host other priority events which are processed
   immediately.
5. Host wants to disable the advertiser in order to update the Resolving
   List (see `bt_id_add`).
6. Host sends to Controller BT_HCI_OP_LE_SET_ADV_ENABLE(Disable)
   command.
7. Controller sends to Host BT_HCI_EVT_CMD_COMPLETE event on
   BT_HCI_OP_LE_SET_ADV_ENABLE command.
8. Host prioritizes this BT_HCI_EVT_CMD_COMPLETE event, processes it
   immediately and clears `BT_ADV_ENABLED` flag for the advertiser.
   Note that Controller already has the advertiser disabled after
   establishing connection on step 1.
9. Host sends few commands in a row and Controller sends
   BT_HCI_EVT_CMD_COMPLETE events that are prioritized (see
   `bt_id_add`).
10. Host wants to re-enable the advertiser after updating the Resolving
    List.
11. Host sends to Controller BT_HCI_OP_LE_SET_ADV_ENABLE(Enable)
    command.
12. Controller sends to Host BT_HCI_EVT_CMD_COMPLETE event on
    BT_HCI_OP_LE_SET_ADV_ENABLE.
13. Host prioritizes this BT_HCI_EVT_CMD_COMPLETE, processes it
    immediately and sets `BT_ADV_ENABLED` flag for the advertiser.
14. Controller has the advertiser enabled.
15. Host now processes the delayed BT_HCI_EVT_LE_ENH_CONN_COMPLETE
    event.
16. Host resets the advertiser state, thinking the Controller's
    advertiser is also stopped.

This commit prioritizes LE Connection Complete and LE Enhanced
Connection Complete events to drop advertiser state on Host immediately
once the corresponding event was received.

Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
2025-08-14 15:49:09 +02:00