Commit graph

21541 commits

Author SHA1 Message Date
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
Robert Lubos
565a489fa9 net: tc: Ensure TC queueing works from ISR
Queueing packets should be possible from the ISR context, recent changes
prevented that. Therefore add extra checks in
net_tc_submit_to_tx/rx_queue() to make them ISR friendly again.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2025-02-24 15:36:32 +00:00
Adib Taraben
96526796d9 ptp: clock.c: revise offset calculation
cast differences to signed int to allow
negative numbers

Signed-off-by: Adib Taraben <theadib@gmail.com>
2025-02-21 18:35:34 +00:00
Ludvig Jordet
0460c9fdae Bluetooth: Mesh: Update Kconfig help about Mesh on System WQ
This updates the help text for the Kconfig option BT_MESH_WORKQ_SYS to
take into account the change made in PR #84282 which causes the host to
no longer return -ENOBUFS. Since the mesh will now instead block the
work queue, a note has been added about a potential consequence of this.

Signed-off-by: Ludvig Jordet <ludvig.jordet@nordicsemi.no>
2025-02-21 18:02:50 +00:00
Vinayak Kariappa Chettimada
d382fca6ff Bluetooth: Controller: Fix HCI command buffer allocation failure
Fix HCI command buffer allocation failure, that can cause
loss of Host Number of Completed Packets command.

Fail by rejecting the HCI Host Buffer Size command if the
required number of HCI command buffers are not allocated in
the Controller implementation.

When Controller to Host data flow control is supported in
the Controller only build, ensure that BT_BUF_CMD_TX_COUNT
is greater than or equal to (BT_BUF_RX_COUNT + Ncmd),
where Ncmd is supported maximum Num_HCI_Command_Packets in
the Controller implementation.

Relates to commit 81614307e9 ("Bluetooth: Add workaround
for no command buffer available")'.

Relates to commit 297f4f481f ("Bluetooth: Split HCI
command & event buffers to two pools").

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2025-02-21 11:30:38 +00:00
Vinayak Kariappa Chettimada
cc1b53445c Bluetooth: Host: Remove nested allocation of HCI command buffer
Remove nested allocation of HCI command buffer so that one
less HCI command buffer is needed starting extended
advertising with privacy enabled.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2025-02-21 11:30:38 +00:00
Riadh Ghaddab
5f7cda5e06 fs: zms: multiple style fixes from previous PR review
This resolves some addressed comments in this PR zephyrproject-rtos#77930
as well as this PR zephyrproject-rtos#80407

Signed-off-by: Riadh Ghaddab <rghaddab@baylibre.com>
2025-02-21 11:29:50 +00:00
Tom Hughes
9838a03ad7 net: l2: ethernet: Fix unused function warning
Building with clang warns:

subsys/net/l2/ethernet/ethernet.c:178:18: error: unused function
'ethernet_check_ipv4_bcast_addr' [-Werror,-Wunused-function]
enum net_verdict ethernet_check_ipv4_bcast_addr(struct net_pkt *pkt,
                 ^

ethernet_check_ipv4_bcast_addr is called by ethernet_ip_recv, which only
exists when CONFIG_NET_IPV4 or CONFIG_NET_IPV6 is defined.

Signed-off-by: Tom Hughes <tomhughes@chromium.org>
2025-02-21 04:46:26 +01:00
Tom Hughes
4aefbbe3a9 debug: gdbstub: Re-enable warning
The warning no longer seems to be needed. CI passes without it.

Signed-off-by: Tom Hughes <tomhughes@chromium.org>
2025-02-21 04:46:12 +01:00
Jukka Rissanen
9ba79f009b net: arp: Fix ARP protocol handler to not use Ethernet hdr directly
The ARP protocol handler cannot directly access the Ethernet header
because the caller has removed the header already when the handler
is called. So change net_arp_input() and pass source and destination
MAC address there instead of bogus pointer that was pointing to ARP
header instead of Ethernet header. This requires changes to ARP tests.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2025-02-20 21:04:44 +01:00
Jens Rehhoff Thomsen
c44334374e Bluetooth: host: Fix bug in scan start
When scanning is started on bt_bap_broadcast_assistant_scan_start then
BAP_BA_FLAG_SCANNING flag for the broadcast assistant instance should
not be cleared.

Fixes #85937

Signed-off-by: Jens Rehhoff Thomsen <jthm@demant.com>
2025-02-20 14:55:56 +00:00
Zihao Gao
7e18f8060a Bluetooth: Shell: fix assert when print address.
This patch fix the assertion caused by null address pointer
that occurs when BR/EDR pairing completed.

Signed-off-by: Zihao Gao <gaozihao@xiaomi.com>
2025-02-20 11:47:39 +01:00
Tom Hughes
74f6f7f94c tests: kernel: interrupt: Remove MS_TO_US
No files use MS_TO_US except tests/kernel/interrupt/src/nested_irq.c.
While the macro is convenient, we should put it in a more central
location and use it everywhere if we want to use it rather than just in
interrupt_util.h. For now, remove it and replace the two usages to match
how code is written in the rest of Zephyr.

Signed-off-by: Tom Hughes <tomhughes@chromium.org>
2025-02-20 06:05:37 +01:00
Maochen Wang
2b2915bd98 net: ip: Fix low Zperf UDP throughput with -a
When run the Zperf UDP throughput with '-a' (Asynchronous call),
zperf_work_q thread will generate and send the packets to tx_q thread.
When zperf_work_q and tx_q threads have same priority, if zperf_work_q
fails to take the semaphore of fifo_slot, it will not wait and directly
drop the net_pkt. Then it will allocate new net_pkt, repeat, and always
occupy the CPU, which leads to extreme low throughput.
For TX, when take the semaphore of fifo_slot, setting a wait time of
K_FOREVER to let other thread to process and free these packets.
For RX, when failed to take the semaphore of fifo_slot, yield the CPU
to let the thread of data path with same priority to run to reduce
dropping packets.

Signed-off-by: Maochen Wang <maochen.wang@nxp.com>
2025-02-19 18:49:13 +01:00
Robert Lubos
008a7ca202 net: if: Setup DAD timer regardless of DAD query result
In rare occasions when sending DAD NS packet fails, we should still
setup the DAD timer, unless we implement some kind of more advanced
retry mechanism. If we don't do that, the IPv6 address added to the
interface will never be usable in such cases.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2025-02-19 18:48:52 +01:00