Commit graph

21541 commits

Author SHA1 Message Date
Mariusz Skamra
6723625336 Bluetooth: Controller: Fix LE Create BIG Complete event parameter
This fixes uninitialized iso_interval parameter in
bt_hci_evt_le_big_complete.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2025-02-10 14:33:12 +01:00
Mariusz Skamra
27c18adf28 Bluetooth: monitor: Fix SEGGER RTT compilation error
This fixes out of scope IRQ lock key by using SEGGER_RTT_Write
version that locks the IRQ by itself.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2025-02-10 14:33:01 +01:00
Fengming Ye
54ef1b54d1 net: wifi: add SAE extended key security type support
Add WPA3 SAE extended key security type support in
L2 wifi mgmt and hostap.

Signed-off-by: Fengming Ye <frank.ye@nxp.com>
2025-02-10 14:32:38 +01:00
Jukka Rissanen
c1201792f0 net: shell: Print interface status for iface command
Print interface status information for "net iface" command.
This is useful information when debugging connectivity issues.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2025-02-10 11:30:47 +01:00
Johann Fischer
d22c0d2ec3 usb: usbip: add initial support for USBIP server
The server uses host support to export a USB device to a remote
USBIP client. It supports control and bulk transfers, interrupt
transfers may also work, but this depends on the host controller used.

Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
2025-02-10 09:02:45 +01:00
Johann Fischer
c8f3a2eb2d usb: host: allow dynamic allocation of USB devices
Allow dynamic allocation of USB devices on connected event.
Add very basic USB device validation and configuration.

Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
2025-02-10 09:02:45 +01:00
Johann Fischer
96f4f3ff14 usb: host: move bus event handling to a separate thread
Handle them in separate contexts so that the request completion callback
cannot be blocked, such as when a device connection is detected and
requires configuration.

Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
2025-02-10 09:02:45 +01:00
Johann Fischer
fa7752494d usb: host: rework usbh_xfer_alloc() parameters
The transfers require enpoint MPS for proper transaction handling,
assign it in the common place during transfer allsocation so that it can
be reused.
Some users, such as USBIP, may need to keep a reference to private data,
add a parameter for completion callback data.

Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
2025-02-10 09:02:45 +01:00
Johann Fischer
63bd9ac1d0 drivers: uhc: add opaque pointer to store upper layer private data
Add an opaque pointer to store upper layer private data and initialize
it with the USB host context during controller initialization. Use the
pointer in event processing to get the correct context.

Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
2025-02-10 09:02:45 +01:00
Johann Fischer
2ff20a8c66 usb: host: allow partially read device descriptor
To determine bMaxPacketSize0, which is unknown after the reset.

Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
2025-02-10 09:02:45 +01:00
Johann Fischer
a7c8a8d46d drivers: uhc: remove UHC transfer parameter addr and attrib
Address parameter/argument is no longer needed because we have a pointer
to the USB device. The Attrib parameter has never been used and will be
replaced by the interval and start-frame parameters in the future.

Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
2025-02-10 09:02:45 +01:00
Johann Fischer
60884cc326 usb: host: move representation of a USB device to UHC header
This will allow the controller driver to access information about the
device in the future.

Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
2025-02-10 09:02:45 +01:00
Johann Fischer
a91740e1cf drivers: uhc: implement the dequeue function
Implement the dequeue function and remove the timeout parameter as it is
no longer necessary and can be handled in the upper layer. The dequeue
function is required for the USBIP implementation.

Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
2025-02-10 09:02:45 +01:00
Johann Fischer
3fd7ea980e usb: host: fix callback parameter type
The parameter should not be a pointer to type usbh_udev_cb_t.

Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
2025-02-10 09:02:45 +01:00
Johann Fischer
6e6c816446 usb: device_next: lock scheduler in usbd_enable()
Lock the scheduler until the device is fully enabled, similar to
usbd_init();

Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
2025-02-10 09:02:45 +01:00
Maochen Wang
4174c957bf net: l2: wifi: add the check if dev is NULL
Add the check if dev is NULL (when iface is NULL, dev is NULL) when
setting Wi-Fi CMD, in case Wi-Fi driver init fails and shell crashes.

Signed-off-by: Maochen Wang <maochen.wang@nxp.com>
2025-02-10 07:25:43 +01:00
Maochen Wang
6cbb37dd4e net: l2: wifi: setting CMD only when net_if is up
Setting Wi-Fi cmd only when the net interface is up, avoid the case
that driver deinit and net interface is down, then the L2 APIs interact
with supplicant and driver, which may lead to CPU exception.

Signed-off-by: Maochen Wang <maochen.wang@nxp.com>
2025-02-10 07:25:43 +01:00
Jordan Yates
7365bcf133 bluetooth: host: hci_core: add missing NULL check
Add check that the command buffer claimed in `bt_le_create_conn_cancel`
is not `NULL`. Fixes a fault caused by providing the `NULL` buffer to
`bt_hci_cmd_state_set_init`.

Signed-off-by: Jordan Yates <jordan@embeint.com>
2025-02-10 03:41:16 +01:00
Flavio Ceolin
5e3f3ce3f5 pm: Remove deprecated function
z_pm_save_idle_exit was deprecated before 3.7, it is time to remove it.

Signed-off-by: Flavio Ceolin <flavio@hubblenetwork.com>
2025-02-10 03:41:06 +01:00
Tom Hughes
67e07b7a41 net: utils: Fix unused function warning
Building with clang warns:

subsys/net/ip/utils.c:600:24: error: unused function 'pkt_calc_chksum'
[-Werror,-Wunused-function]
static inline uint16_t pkt_calc_chksum(struct net_pkt *pkt, uint16_t sum)
                       ^

pkt_calc_chksum is called by net_calc_chksum, which only exists when
CONFIG_NET_NATIVE_IP is defined.

Signed-off-by: Tom Hughes <tomhughes@chromium.org>
2025-02-08 19:45:38 -05:00
Thomas Deppe
f3bdd2bc8c Bluetooth: Host: Add support for Advertising Coding Selection
Adds API for Advertising Coding Selection.

Introduces two new advertising options to configure the advertiser's
requirement concerning coding scheme when LE Coded PHY is configured.
While the Bluetooth v6.0 specification makes a distinction betweeen
preferred and required advertising PHY options, a simplification is
made to only expose the required PHY options. Inline with how LE Coded
PHY is implemented; this API will set both the primary and secondary
advertising PHY's to the same coding scheme.

The support is enabled by CONFIG_BT_EXT_ADV_CODING_SELECTION, and requires
a controller that selects CONFIG_BT_CTLR_ADV_EXT_CODING_SELECTION_SUPPORT.

Signed-off-by: Thomas Deppe <thomas.deppe@nordicsemi.no>
2025-02-08 10:09:41 +01:00
Emil Gydesen
4451cee955 Bluetooth: ISO: Shell: Fix underflow of count for TX
The cmd_broadcast and cmd_send both should not take a
count value less than 1.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2025-02-08 10:08:52 +01:00
Tom Hughes
14fe06e453 Bluetooth: ISO: Fix -Wsometimes-uninitialized warning
Building sample.bluetooth.tmap_central with clang warns:

subsys/bluetooth/host/iso.c:2194:6: error: variable 'rsp' is used
uninitialized whenever 'if' condition is false
[-Werror,-Wsometimes-uninitialized]
        if (!advanced) {
            ^~~~~~~~~
subsys/bluetooth/host/iso.c:2202:6: note: uninitialized use occurs here
        if (rsp == NULL) {
            ^~~
subsys/bluetooth/host/iso.c:2194:2: note: remove the 'if' if its
condition is always true
        if (!advanced) {
        ^~~~~~~~~~~~~~~
subsys/bluetooth/host/iso.c:2137:21: note: initialize the variable 'rsp'
to silence this warning
        struct net_buf *rsp;
                           ^
                            = NULL
subsys/bluetooth/host/iso.c:2295:6: error: variable 'rsp' is used
uninitialized whenever 'if' condition is false
[-Werror,-Wsometimes-uninitialized]
        if (!advanced) {
            ^~~~~~~~~
subsys/bluetooth/host/iso.c:2303:6: note: uninitialized use occurs here
        if (rsp == NULL) {
            ^~~
subsys/bluetooth/host/iso.c:2295:2: note: remove the 'if' if its
condition is always true
        if (!advanced) {
        ^~~~~~~~~~~~~~~
subsys/bluetooth/host/iso.c:2258:21: note: initialize the variable 'rsp'
to silence this warning
        struct net_buf *rsp;
                           ^
                            = NULL

Signed-off-by: Tom Hughes <tomhughes@chromium.org>
2025-02-08 08:14:26 +01:00
Martin Stumpf
8c82d00b6f fs: shell: Add cp command
Creates a copy of a given file.

Signed-off-by: Martin Stumpf <martin.stumpf@vected.de>
2025-02-08 08:14:16 +01:00
Emil Gydesen
4fc6f127e6 Bluetooth: TBS: Fix return value of handle_string_long_read
The function may return a BT_GATT_ERR which is a negative
value that cannot be returned as uint8_t. Change the function
to use int instead and document the return values.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2025-02-08 08:13:28 +01:00
Emil Gydesen
f53c4db874 Bluetooth: CSIP: Update documentation for CSIP crypto functions
The encryption functions should document the expect byte order of
inputs and the byte order of the outputs.

The sef and sdf functions were also using an older, and incorrect,
description of the input, as it only takes the LTK as per CSIP 1.0.0

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2025-02-08 08:13:17 +01:00
Flavio Ceolin
b8ce176109 pm: policy: Fix possible undefined reference
When PM_POLICY_DEVICE_CONSTRAINTS is enabled, we create a list of
devices with the property “zephyr,disabling-power-states” and their
respective states to lock. However, if a device is declared but not
built (e.g., due to a Kconfig option), we have an undefined reference.

This PR changes the code to use the device name instead of the
reference. This increases lookup time (which could be cached at
runtime), and we still have an entry for a non-existent device.

Signed-off-by: Flavio Ceolin <flavio@hubblenetwork.com>
2025-02-08 04:06:29 +01:00
Jukka Rissanen
c8f640a610 net: socket: service: Restart instead of bailing out when error
It might happen now after the commit 8519fa1627 ("net: socket service
resets its restart flag") that the event has disappeared before we
call the work, if that happens we must not bail out but restart
the service.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2025-02-07 17:48:14 +01:00
Jukka Rissanen
4b57f7ad2c net: mdns_responder: Not an error if dispatcher is already registered
Just ignore any EALREADY error returned when trying to register a
DNS dispatcher. This could happen if trying to init things when the
interface comes up and we have already initialized the dispatcher.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2025-02-07 17:47:12 +01:00
Jukka Rissanen
c832f3dd86 net: dns: Use DNS_EAI_SYSTEM error properly
The DNS_EAI_SYSTEM error value tells that the errno value
contains the actual system error value. So set the errno
properly when there is a system error.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2025-02-07 17:47:12 +01:00
Jukka Rissanen
7f3d140f25 net: dns: Set answer offset only when within DNS msg
Do not set answer_offset if the offset would be outside of
DNS message.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2025-02-07 17:47:12 +01:00
Jukka Rissanen
e98bf3e6d7 net: dns: Use dispatcher context in callbacks
Feed the dispatcher context to dispatcher callbacks instead of
resolver or responder context. The callback can then use the
proper context because the dispatcher context contains those
two context. This allows dispatcher callback to utilize all the
information (like interface etc) stored in dispatcher context.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2025-02-07 17:47:12 +01:00
Jukka Rissanen
3ed8151b00 net: mdns: No error if mcast address is already added to interface
Ignore any EALREADY return code as that is not really an error in
this case.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2025-02-07 17:47:12 +01:00
Jukka Rissanen
04242abb99 net: sockets: Remove inline from zsock_recv_dgram()
As the zsock_recv_dgram() is rather large, remove the inline
keyword from it and let compiler to decide what to do with it.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2025-02-07 17:46:55 +01:00
Jukka Rissanen
3fb1e11d5b net: mdns_responder: Add more debug prints
Print the socket descriptor and interface after bounding it
successfully in order to help to figure out what sockets are
bind to one specific interface.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2025-02-07 17:46:55 +01:00
Jukka Rissanen
0f858b24aa net: socket: services: Restore only the socket related to work
Restore only the socket descriptor that we marked as -1 after running
the work related to that socket. Earlier we tried to restore the whole
global array of descriptors which could go wrong and is not needed
as we only support synchronous work.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2025-02-07 17:46:55 +01:00
Tom Hughes
eff76caa17 ztest: mock: Fix typo
"Return value no used by mock" should be
"Return value not used by mock".

Signed-off-by: Tom Hughes <tomhughes@chromium.org>
2025-02-07 14:34:39 +01:00
Ingar Kulbrandstad
0330ff1ac0 Bluetooth: Host: Updated Kconfig description
Added warning to the BT_RECV_WORKQ_SYS description
to explain the dangers by using this option.

Signed-off-by: Ingar Kulbrandstad <ingar.kulbrandstad@nordicsemi.no>
2025-02-07 14:34:23 +01:00
Kamil Krzyzanowski
cd281ab40b logging: fs backend: simplify checking if file exists
In order to check if the desired log file exists, the backend would open
the directory, then go through all the files seeing if one of them matches
the correct filename. Simplify to just `fs_stat` the file instead.

This has the added side effect of lowering the time spent checking if the
file exists after every log. Some quick testing revealed the time spent
checking went down from ~150-300ms to ~10ms (on my specific board, with a
nRF9160 writing to a LittleFS on external flash).

Signed-off-by: Kamil Krzyzanowski <kamnxt@kamnxt.com>
2025-02-07 14:33:35 +01:00
Kamil Krzyzanowski
41f2c64e97 logging: fs backend: only fs_sync when done with a batch of logs
The previous behavior was to call `fs_sync` on the file after every log
item written. In many cases, log messages come in bursts, and `log_core`
already operates in batches, configurable using
`CONFIG_LOG_PROCESS_THREAD_SLEEP_MS` and
`CONFIG_LOG_PROCESS_TRIGGER_THRESHOLD`. Once the batch is done, the
backends get notified with `LOG_BACKEND_EVT_PROCESS_THREAD_DONE` if any
logs were processed. This is a nice time to `fs_sync` the written changes.

This change both speeds up the time spent writing logs and reduces the
amount of block erases done on the flash, as the previous implementation
erased blocks after each individual log message.

Signed-off-by: Kamil Krzyzanowski <kamnxt@kamnxt.com>
2025-02-07 14:32:06 +01:00
Joakim Andersson
dc97cc0cd5 tests: logging: Convert unit test to include the full FS backend
Convert testing of the logging backend for file-system to include the
full implementation.
Need to disable logging and just include the unit under test to make
this simpler.
The API functions for the backend can then be called on the backend
object.

Signed-off-by: Joakim Andersson <joerchan@gmail.com>
2025-02-07 14:32:06 +01:00
Jeremy Bettis
e1cfd098a2 shell: Fix Kconfig dependencies
PR #84651 introduced new shell commands that don't compile if
CONFIG_THREAD_MONITOR=n

Add THREAD_MONITOR to new shell commands.

Signed-off-by: Jeremy Bettis <jbettis@google.com>
2025-02-06 21:14:01 +01:00
Aleksandr Khromykh
a09fa5f7f3 Bluetooth: Mesh: remove deprecated field in cdb subnet
Commit removes deprecated filed in cdb subnetwork.

Signed-off-by: Aleksandr Khromykh <aleksandr.khromykh@nordicsemi.no>
2025-02-06 21:13:31 +01:00
Ludvig Jordet
5facb50fe9 Bluetooth: Mesh: add missing device key candidate PSA support
Commit adds PSA key support for device key candidate.

Signed-off-by: Ludvig Jordet <ludvig.jordet@nordicsemi.no>
2025-02-06 21:13:31 +01:00
Emil Gydesen
8e53592da8 Bluetooth: BAP: Fix issue with sink recv state notifications
There was a bug in pa_decode_base that would would spent time
parsing incoming BASEs and also update the receive
states, which caused some tests to fail.

This commit adds a simply check to verify that the BASE is
different before spending parsing the content and updating
the receive states.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2025-02-06 21:13:15 +01:00
Dave Lacerte
d9aab69fbf net: coap: Fix uninitialized variable warning
The variable block_len in function coap_next_block_for_option()
can be used uninitialized in case of empty packet in
coap_packet_get_payload(). Mute the compiler warning with
default value of 0.

Signed-off-by: Dave Lacerte <lacerte.dave@hydroquebec.com>
2025-02-06 17:49:42 +01:00
Chaitanya Tata
4cd6654b21 net: l2: Add a config option to allow mismatched L3/L2 address packets
The RFC1122 section 3.3.6 says we SHOULD drop the packets if L2 address
is brodcast but L3 address is unicast, but we had seen some Wi-Fi access
points in the field not conforming to that, and DHCP offer is dropped
due to this and causes Wi-Fi connectivity issues.

As the RFC saus it's SHOULD and not a MUST, add a config option to allow
such packets, disabled by default.

Signed-off-by: Chaitanya Tata <Chaitanya.Tata@nordicsemi.no>
2025-02-06 17:48:37 +01:00
Seppo Takalo
ac01879330 net: lwm2m: Tickless does not depend on SOCKETPAIR
Tickless mode is refactored to use zvfs_eventfd,
but the Kconfig dependencies were not updated.

Signed-off-by: Seppo Takalo <seppo.takalo@nordicsemi.no>
2025-02-06 14:46:55 +01:00
Emil Gydesen
a9279eef35 Bluetooth: Controller: Fix coverity issue for cis == NULL
Coverity was unhappy that
`struct ll_conn_iso_stream *cis = NULL;` was never assigned to
a non-NULL value, which is due to the assignment being
guarded by `#if defined(CONFIG_BT_CTLR_CONN_ISO)`.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2025-02-06 14:46:31 +01:00
Dominic Moffat
8519fa1627 net: socket service resets its restart flag
The socket service restarts whenever a new socket is registered.
This is triggered via zvfs_eventfd_write(ctx.events[0].fd, 1),
but the restart flag (ctx.events[0].revents) is not properly cleared,
causing unintended repeated restarts and skipped socket processing.

Detecting socket restart is done after the socket fd has processed its
data, so the socket doesn't lose its data. Ensure the socket service
clears its restart flag (ctx.events[0].revents = 0) immediately after
detecting a restart event, preventing unnecessary restarts.

Fixes #81813

Signed-off-by: Dominic Moffat <dom@illysky.com>
2025-02-05 23:49:28 +01:00