Commit graph

22,555 commits

Author SHA1 Message Date
Emil Gydesen
4619611326 Bluetooth: Conn: Add const for conn in bt_conn_get_remote_info
The connection object is, and should not, be modified by the function.
Making it const makes it possible to do this simple operation
in functions that also won't change the conn object (i.e.
that uses `const`).

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2025-03-07 19:58:23 +01:00
Emil Gydesen
44c5c1da3d Bluetooth: Host: Add API for reading LE controller features
The function supports reading multiple controller-based values.
It is effectively a copy of struct bt_dev_le but in a more
application-oriented definition.

It was chosen to keep the features as an array rather than a
64-bit value, as the comparison macros work on arrays and that
there already exists new bits > 64 in the core spec which is not
yet supported by Zephyr.

It is being smoke tested in a generic GATT client test,
as the individual values may depend on several Kconfig options.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2025-03-07 19:58:23 +01:00
Aleksandr Khromykh
e075e08195 Bluetooth: Mesh: remove api prefix for static functions
Commit removes api prefix for static functions
in crypto psa.

Signed-off-by: Aleksandr Khromykh <aleksandr.khromykh@nordicsemi.no>
2025-03-07 19:58:10 +01:00
Povilas Selevicius
37ddeb459c net: coap_client: expose has_ongoing_exchange function
The coap_client has a static/internal function, has_ongoing_exchange(),
which can be an useful addition to the public API. This would provide
a mechanism to determine when it is safe to close a socket gracefully.

Signed-off-by: Povilas Selevicius <povilas.selevicius@quadigi.com>
2025-03-07 19:52:22 +01:00
Utsav Munendra
2b48ef62ba portability: cmsis: Implement osThreadJoin using Zephyr k_thread_join
Bugfix previous `osThreadJoin()` implementation where a thread which
exited with `osThreadExit()` could not be joined upon by other threads.

Signed-off-by: Utsav Munendra <utsavm@meta.com>
2025-03-07 19:51:50 +01:00
Jordan Yates
7ab8e27e26 net: lib: sntp: async query API
Add a variant of the SNTP API that does not block while waiting for a
response from the SNTP server. Instead it takes advantage of
`CONFIG_NET_SOCKETS_SERVICE` to read the response asynchronously when
the response is received.

Signed-off-by: Jordan Yates <jordan@embeint.com>
2025-03-07 19:51:40 +01:00
Jordan Yates
5178835677 net: lib: sntp: extract query send logic
Extract the SNTP query send logic out of `sntp_query` so that it can be
used by functions that don't synchronously wait for the response.

Signed-off-by: Jordan Yates <jordan@embeint.com>
2025-03-07 19:51:40 +01:00
Noah Olson
b2e29fe0d7 net: tcp: fix ECONNREFUSED not reported by zsock_connect
When a TCP connection is refused during zsock_connect, errno is set
to -ENOTCONN, but errno should be set to -ECONNREFUSED. This change
causes the ECONNREFUSED status to be propagated from tcp_in to
net_tcp_connect, which eventually causes errno to be set
to -ECONNREFUSED.

Signed-off-by: Noah Olson <noah@wavelynx.com>
2025-03-07 19:48:10 +01:00
Tom Hughes
6c79dab929 toolchain: Add indirection for compiler warnings
In order to support new toolchains that are not compatible with
gcc/clang (e.g., IAR), we need to add a level of indirection for
the name of warnings.

Signed-off-by: Tom Hughes <tomhughes@chromium.org>
2025-03-07 19:47:30 +01:00
Lyle Zhu
c0f7aefe55 Bluetooth: BR: Support limited discoverable mode
Add a Kconfig BT_LIMITED_DISCOVERABLE_DURATION to set the timeout for
limited discoverable mode.

Add a argument `limited` to function `bt_br_set_discoverable()` to
support the limited discoverable mode.
When enabling discoverable mode with `limited` is true, both write
LIAC and GIAC to controller and set the bit 13 of COD in function
`bt_br_set_discoverable()`. And start a delay worker with the timeout
CONFIG_BT_LIMITED_DISCOVERABLE_DURATION to disable the discoverable
mode.
When disabling discoverable mode, only set GIAC to controller and
clear bit 13 of COD.

Signed-off-by: Lyle Zhu <lyle.zhu@nxp.com>
2025-03-07 19:46:53 +01:00
Mark Wang
37ae587b64 bluetooth: avdtp: move the buf as callback parameter
if saving buf to another variable, usually the ref/unref
needs to be used. change to pass the buf as one parameter
of callback

Signed-off-by: Mark Wang <yichang.wang@nxp.com>
2025-03-07 19:45:20 +01:00
Mark Wang
0d253c5b45 bluetooth: a2dp: clean few unused codes lines
memset already clean the `buf`, don't need to set as NULL.
`avdtp_set_status` already set `req->status` based on `msg_type`,
don't need to check `msg_type` again.

Signed-off-by: Mark Wang <yichang.wang@nxp.com>
2025-03-07 19:45:20 +01:00
Mark Wang
935fdd2147 bluetooth: a2dp: improve the readability
add more blank lines before or after the code block {}

Signed-off-by: Mark Wang <yichang.wang@nxp.com>
2025-03-07 19:45:20 +01:00
Mark Wang
e531295515 bluetooth: a2dp: optimize bt_a2dp_ep_info
bt_a2dp_ep_info is used in bt_a2dp_discover, and the max
discovered endpoints' info are already given in seps_info
of bt_a2dp_discover_param, so use pointer to point to the
seps_info of bt_a2dp_discover_param.

Signed-off-by: Mark Wang <yichang.wang@nxp.com>
2025-03-07 19:45:20 +01:00
Mark Wang
8b1b79bf3c bluetooth: avdtp: handle the unsupported signal identifier
reject the cmd if the signal identifier is not supported

Signed-off-by: Mark Wang <yichang.wang@nxp.com>
2025-03-07 19:45:20 +01:00
Mark Wang
11c1ccbbc7 bluetooth: avdtp: split packet handler as cmd_handler and rsp_handler
use two handler array to process cmd and response separately,
make the functions shorter and codes more readable.

Signed-off-by: Mark Wang <yichang.wang@nxp.com>
2025-03-07 19:45:20 +01:00
Mark Wang
1a4de907c8 bluetooth: a2dp: check the invalid avdtp packet
When the packet is invalid, reply the right error code or call
back error code to upper layer.

Signed-off-by: Mark Wang <yichang.wang@nxp.com>
2025-03-07 19:45:20 +01:00
Eric Ackermann
3466dab804 llext: Add parameters to arch_elf_relocate
The RISC-V port of llext requires additional parameters for
handling non-adjacent HI20/LO12 relocations in arch_elf_relocate():
the current extension (struct llext), the current extension loader
(struct llext_loader), the current section header (elf_shdr_t) and
the current symbol (elf_sym_t).
This changes the signature of arch_elf_relocate accordingly.

Signed-off-by: Eric Ackermann <eric.ackermann@cispa.de>
2025-03-07 19:44:54 +01:00
Eric Ackermann
2255b63846 llext: Refactor symbol lookup logic into function
This commit refactors logic in llext_link.c that resolves
a symbol to be imported by an llext into a utility function.
Thereby, the logic can be re-used in other functions if
needed, e.g., when resolving symbols for indirect relocations.

Signed-off-by: Eric Ackermann <eric.ackermann@cispa.de>
2025-03-07 19:44:54 +01:00
Kiara Navarro
6b2a476c66 lorawan: add callback for descriptor changes
allow the application to decide whether to keep going with the fuota
process by setting a callback that exposes the descriptor field
whenever `FragSessionSetupReq` is sent to the device.

Signed-off-by: Kiara Navarro <sophiekovalevsky@fedoraproject.org>
2025-03-07 19:42:56 +01:00
Etienne de Maricourt
7bc2a1bb47 net: lwm2m: Fix data cache rollback logic compilation
The root cause of this issue is a modification of `struct ring_buf` in
3075a7d9. Even though all the fields of the struct are marked as
internal, the LwM2M code is using some of them to roll back the state of
the ring buffer on failure.

Signed-off-by: Etienne de Maricourt <edmecomemail@gmail.com>
2025-03-06 11:38:09 +00:00
Riadh Ghaddab
333faddd43 settings: zms: fix some bugs related to the name's ID
To avoid collisions between IDs used by settings and IDs used directly
by subsystems using ZMS API, the MSB is always set to 1 for Setting's
name ID written to ZMS backend

Add as well a recovery path if the hash linked list is broken.

Signed-off-by: Riadh Ghaddab <rghaddab@baylibre.com>
2025-03-06 11:37:58 +00:00
Jukka Rissanen
1a5e13a79b net: if: Release the interface lock early when starting IPv4 ACD
In order to avoid any mutex deadlocks between iface->lock and
TX lock, release the interface lock before calling a function
that will acquire TX lock. See previous commit for similar issue
in RS timer handling. So here we create a separate list of ACD
addresses that are to be started when network interface comes up
without iface->lock held.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2025-03-05 16:40:29 +00:00
Jukka Rissanen
196782ed91 net: if: Release the interface lock early when rejoining mcast groups
In order to avoid any mutex deadlocks between iface->lock and
TX lock, release the interface lock before calling a function
that will acquire TX lock. See previous commit for similar issue
in RS timer handling. So here we create a separate list of multicast
addresses that are to be rejoined when network interface comes up
and then rejoin the groups without iface->lock held.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2025-03-05 16:40:29 +00:00
Jukka Rissanen
1e88c62b4e net: if: Release the interface lock early when starting IPv6 DAD
In order to avoid any mutex deadlocks between iface->lock and
TX lock, release the interface lock before calling a function
that will acquire TX lock. See previous commit for similar issue
in RS timer handling.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2025-03-05 16:40:29 +00:00
Jukka Rissanen
4926698b1c net: if: Release the interface lock early in IPv6 RS timeout handler
The net_if.c:rs_timeout() is sending a new IPv6 router solicitation
message to network by calling net_if_start_rs(). That function will
then acquire iface->lock and call net_ipv6_start_rs() which will try
to send the RS message and acquire TX send lock.
During this RS send, we might receive TCP data that could try to
send an ack to peer. This will then in turn cause also TX lock
to be acquired. Depending on timing, the lock ordering between
rx thread and system workq might mix which could lead to deadlock.
Fix this issue by releasing the iface->lock before starting the
RS sending process. The net_if_start_rs() does not really need to
keep the interface lock for a long time as it is the only one sending
the RS message.

Fixes #86499

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2025-03-05 16:40:29 +00:00
Ying Zhang
90c6eb1da7 random: Correct Mutex define
Correct Mutex ctr_lock defination as the wrong defination lead to
sysworkq task not acquiring this mutex during bt init, which lead to
BLE didn't work as described in issue https://github.com/zephyrproject-rtos/zephyr/issues/86444

Signed-off-by: Ying Zhang <ying.zhang_2@nxp.com>
2025-03-04 21:55:45 +01:00
Riadh Ghaddab
f020720a80 fs: zms: fix Copyright notice
Add missing Copyright from derived files and fix the Copyright year for
some files to keep the original Copyright notice

Signed-off-by: Riadh Ghaddab <rghaddab@baylibre.com>
2025-03-04 12:17:02 +00:00
Vinayak Kariappa Chettimada
ec69ccb681 Bluetooth: Controller: Fix single timer direction finding support
Fix use of single timer software tIFS switching to support
direction finding.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2025-02-28 14:55:11 +01:00
Vinayak Kariappa Chettimada
7520742671 Bluetooth: Controller: Fix single timer clear event define name
Rename the single timer clear event define name based on
direction finding support.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2025-02-28 14:55:11 +01:00
Vinayak Kariappa Chettimada
23d321d679 Bluetooth: Controller: Fix end time capture be on radio event end
Fix end time capture be on radio event end irrespective of
direction finding support. Let the timer clear use radio
end or radio phy end, for no direction finding or direction
finding support, respectively.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2025-02-28 14:55:11 +01:00
Vinayak Kariappa Chettimada
f67a94f47a Bluetooth: Controller: Fix single timer end time capture
Fix single timer use end time capture from being disabled
as end time and timer clear use the same PPI.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2025-02-28 14:55:11 +01:00
Vinayak Kariappa Chettimada
65d69ec176 Bluetooth: Controller: Fix active mode extended scanning assert
Fix active mode extended scanning assert raised when calling
radio_tmr_start_us() due to stale radio_tmr_end_get() value.
Active mode extended scanning did not drop reception of
ADV_EXT_IND PDU when setup to receive ADV_SCAN_RSP PDUs.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2025-02-28 14:55:11 +01:00
Vinayak Kariappa Chettimada
3a996c570b Bluetooth: Controller: Fix BT_CTLR_LOW_LAT_ULL dependency
Fix BT_CTLR_LOW_LAT_ULL dependency after changes in
commit 5119896c7d ("Bluetooth: Controller: Fix
BT_CTLR_LOW_LAT_ULL conditional code").

BT_CTLR_LOW_LAT_ULL is independent of BT_CTLR_LOW_LAT, where
the later prevents any ULL execution inside a radio event.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2025-02-28 14:53:27 +01:00
Johann Fischer
9cb0fbf80d usb: device_next: fix Get Status request response
We need to track the self-powered status of the device independently of
the D6 bit in the bmAttributes value of the configuration descriptor
because the Get Status request about the self-powered status is valid in
address state and we support multiple configurations.

Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
2025-02-28 14:51:53 +01:00
Kyra Lengfeld
6464ffa3f9 Bluetooth: Host: Fix deadlock when failing to alloc on BT RX thread
This commit alignes the timeout value for allocating buffers within att
on the BT RX thread, making it consistent within att.c, see
bt_att_req_alloc.

We are inferring in many bt_gatt_* functions that if called from a BT RX
thread (which is inherently the case if called from a callback when
running a Bluetooth application), we don't block and instead return
-ENOMEM when the ATT request queue is full, avoiding a deadlock.
This promise is fulfilled within bt_att_req_alloc, where the timeout for
allocation of the request slab is set to K_NO_WAIT if we are on the BT
RX thread. Unfortunately, we break this promise in
bt_att_chan_create_pdu, where the timeout for allocation of the att pool
is still K_FOREVER and deadlocks can (and do) occur when too many
requests are sent yet the pool is depleted.

Note: Both req_slab and att_pool sizes are defined by
CONFIG_BT_ATT_TX_COUNT. If applications start getting -ENOMEM with this
change, they were at risk of such a deadlock, and may increase
CONFIG_BT_ATT_TX_COUNT to allocate the att pool for their requests.

Note: This possible deadlock has been flying under the radar, as
att_pools are freed when the HCI driver has sent it to the controller
(instead of when receiving the response, as it happens with req_slabs)
and due to the att_pool and the req_slab being both sized by
CONFIG_BT_ATT_TX_COUNT, and req_slab being allocated before and
returning -ENOMEM already if there is no space, it takes a more specific
situation to deplete the att_pool but not the req_slab pool at this
point.

Note: Ideally, we don't want functions to behave differently depending
on which thread they are running, and while this commit makes it more
consistent, it should be considered a workaround solution.

Signed-off-by: Kyra Lengfeld <kyra.lengfeld@nordicsemi.no>
2025-02-28 10:10:01 +01:00
Joakim Andersson
d082c7dc46 net: http_client: Fix handling of poll error revents
Fix handling of poll setting socket error flag.
In this case errno is no set, so should not be the return value either.
Instead retrieve the socket error for SOCKERR and return EBADF for
SOCKNVAL.

Signed-off-by: Joakim Andersson <joerchan@gmail.com>
2025-02-27 13:27:28 +00:00
Jordan Yates
5ad76de07f secure_storage: swap select to depends on
Mixing `select` and `depends on` is a common source of Kconfig
dependency loops and should be avoided. Both `ZMS` and `SETTINGS` are
more commonly used with `depends on` rather than `select`.

The usage here also contradicts the Zephyr best practices guide for
`select`:
 * Avoid selecting symbols with prompts or dependencies.
   Prefer depends on.

Signed-off-by: Jordan Yates <jordan@embeint.com>
2025-02-27 09:07:56 +00:00
Jordan Yates
8f36307329 secure_storage: remove incorrect imply symbols
`SECURE_STORAGE_ITS_STORE_IMPLEMENTATION_SETTINGS` does not use either
the `FLASH_MAP` or `NVS` APIs, only `SETTINGS`.

Similarly, `SECURE_STORAGE_ITS_STORE_MODULE` does not consist of any
code itself and therefore should not select or imply any options.

Signed-off-by: Jordan Yates <jordan@embeint.com>
2025-02-27 09:07:56 +00:00
Jordan Yates
76c526a035 fs: nvs: move FLASH_PAGE_LAYOUT to depends on
`FLASH_PAGE_LAYOUT` has a hardware dependency on `FLASH_HAS_PAGE_LAYOUT`
which is not present for all boards. Forcing this symbol to `y` when
the hardware doesn't support it results in build errors at the Kconfig
stage.

`FLASH_PAGE_LAYOUT` is enabled by default when `FLASH_HAS_PAGE_LAYOUT`
is true, so this change will not require any user changes.

Signed-off-by: Jordan Yates <jordan@embeint.com>
2025-02-27 09:07:56 +00:00
Paul Alvin
c897adb1c6 sd: mmc: Remove unwanted request to card for reading OCR content
As part of the MMC card initialization sequence, CMD1 command send
multiple times to the card, first time to identify the card type and
second time to check the requested voltage window is supported or not.
There is a chance that after issuing the CMD1 for first time, card will
move to the ready state before issuing the CMD1 for second time. In this
case, card will not respond to the CMD1 send for the second time as card
is already moved to ready state and this leads to failures. Hence remove
the separate card identification logic and call mmc_send_op_cond only
once to check both supported voltage window and card type
identification.

Signed-off-by: Paul Alvin <alvin.paulp@amd.com>
2025-02-26 22:03:23 +00:00
Jordan Yates
2824a28871 mgmt: hawkbit: remove imply HWINFO
`imply` should only be used if the code can still operate without the
symbol, which is not the case. Move the ID source to a choice symbol,
which depends on `HWINFO` when required.

Signed-off-by: Jordan Yates <jordan@embeint.com>
2025-02-26 10:10:42 +00:00
Martin Gysel
9cc8301dfa usb: device_next: prevent CDC ACM notifications from being blocked forever
Reset semaphore if USB transfer failed or was canceled and prevent
cdc_acm_send_notification() from blocking forever.

Signed-off-by: Martin Gysel <me@bearsh.org>
2025-02-25 15:33:25 +00:00
Johan Hedberg
05b16b971b Bluetoth: Host: Fix buffer allocation warnings in system workqueue
The buffer allocation in conn.c will trigger warnings if we try to use
anything else than K_NO_WAIT for the timeout when called from within the
system workqueue.

The calls in l2cap.c and att.c which may pass non-zero timeouts already
have proper handling for failed allocations, so make sure we use K_NO_WAIT
to avoid unnecessary warnings from conn.c.

Signed-off-by: Johan Hedberg <johan.hedberg@silabs.com>
2025-02-25 15:14:08 +00:00
Vinayak Kariappa Chettimada
17d695a535 Bluetooth: Controller: Simplify required ISO PDU length and buffer count
Simplify the defines calculating the minimum required ISO
PDU length and the buffer count.

Co-authored-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2025-02-24 20:18:37 +00:00
Vinayak Kariappa Chettimada
662acab1ae Bluetooth: Controller: Fix ISO Tx PDU buffer counts for fragmentation
Fix ISO Tx PDU buffer count required when SDU fragmentation
is used.

Rename BT_CTLR_CONN_ISO_SDU_LEN_MAX to
BT_CTLR_ISO_TX_SDU_LEN_MAX so the value is common to both
Broadcast and Connected ISO transmissions.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2025-02-24 20:18:37 +00:00
Vinayak Kariappa Chettimada
4161db72cd Bluetooth: Controller: Rename to BT_CTLR_ISO_TX_PDU_BUFFERS
Rename the internal BT_CTLR_ISO_TX_BUFFERS to
BT_CTLR_ISO_TX_PDU_BUFFERS correct represent the number
of actual ISO PDU buffers allocated in the Controller.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2025-02-24 20:18:37 +00:00
Yago Fontoura do Rosario
ee8266797c bluetooth: id: Fix logging
* Logging module already adds a new line, no need to add it

Signed-off-by: Yago Fontoura do Rosario <yafo@demant.com>
2025-02-24 15:37:41 +00:00
Yago Fontoura do Rosario
f0af67afa0 bluetooth: id: Fix uninitialized variable
* This variable default value has to be true, so that the
application can return false in the expired callback

Signed-off-by: Yago Fontoura do Rosario <yafo@demant.com>
2025-02-24 15:37:41 +00:00
Luis Ubieda
f1be8afc46 bluetooth: Guard gatt_prepare_write against calls while disconnected
Fixes #84752.

Signed-off-by: Luis Ubieda <luisf@croxel.com>
2025-02-24 15:37:18 +00:00