Commit graph

22,555 commits

Author SHA1 Message Date
Krzysztof Chruściński
4cbafc6bd4 tracing: Add sys_trace_idle_exit call
Add new tracing API which is called when core is exiting from idle.
Current implementation is using it to track CPU load. Implementation
in tracing_none is now weak so it can be used if given backend does
not support new API call.

When CONFIG_CPU_LOAD is enabled then sys_trace_idle also calls a
hook which stores the timing information when CPU entered idle.

Signed-off-by: Krzysztof Chruściński <krzysztof.chruscinski@nordicsemi.no>
2025-03-12 14:03:48 +00:00
Krzysztof Chruściński
c7d7aac2bd debug: Add cpu_load module
Add module which can measure CPU idle time. Idle time is measured in
the pre/post CPU idle hooks but they are not provided by this module.

Signed-off-by: Krzysztof Chruściński <krzysztof.chruscinski@nordicsemi.no>
2025-03-12 14:03:48 +00:00
Maochen Wang
1dbe1dfa1f net: lib: sockets: fix socket_service thread stuck by mistake
Use Wi-Fi connecting to Qualcomm IPQ8074 AP, and run the UDP RX traffic
with Zperf, but zperf does not return the throughput number after
traffic completion nor any session started prints. After traffic
completion, ping from STA to AP and vice versa does not work. The
socket_service thread is found blocked forever at zsock_wait_data()
after dns_dispatcher_svc_handler() is called via trigger_work().
The root cause of this issue is:
STA received one DHCPv4 packet containing DHCPV4_OPTIONS_DNS_SERVER,
it will create DNS socket and registered to socket_service. Then STA
received another IPv6 router advertisement packet containing
NET_ICMPV6_ND_OPT_RDNSS, it will close socket and change the state of
poll_events to K_POLL_STATE_CANCELLED(8), then registered to
socket_service with same fd. In socket_service thread, zsock_poll()
called zsock_poll_update_ctx() when handled ZFD_IOCTL_POLL_UPDATE, and
it checked the state of poll_events was not K_POLL_STATE_NOT_READY(0),
then it will set pfd->revents to '|= ZSOCK_POLLIN'. Finally
trigger_work() can be called as 'ctx.events[i].revents > 0' is matched.

The fix of this issue is that, in zsock_poll_update_ctx(), it should
check the state of poll_events is neither K_POLL_STATE_NOT_READY nor
K_POLL_STATE_CANCELLED before setting revents as ZSOCK_POLLIN, to avoid
trigger_work be unexpectedly called.

Signed-off-by: Maochen Wang <maochen.wang@nxp.com>
2025-03-12 07:14:46 +01:00
Lyle Zhu
f349976937 Bluetooth: SSP: Fix MITM flag incorrect issue in pairing
There is a case that if the local is a peripheral and a L2CAP server
with the security level 3,the mitm should be set to make sure the
security level can reach level 3.

But in current implementation, the MITM is not set because the MITM
of `Authentication_Requirements` parameter of remote is not set. And
the security level will be level 2 after the security pairing
procedure complete.

Add a function `bt_l2cap_br_get_max_sec_level` to
get the max level of the registered servers.
`
Force set the MITM bit if the max level is bigger than level 2 and
pairing method is not `just works`.

Signed-off-by: Lyle Zhu <lyle.zhu@nxp.com>
2025-03-12 07:14:25 +01:00
Andrej Butok
8473928db4 zms: fix the zms_mount() sector_size check
Adds the return -EINVAL, if the fix zms_mount() sector_size
check is failed.

Signed-off-by: Andrej Butok <andrey.butok@nxp.com>
2025-03-12 02:29:31 +01:00
Christoph Seitz
5992208605 net: ethernet: Refactor length check to accommodate VLAN header size
The ethernet header size with VLAN tag is 18 bytes,
so the length check should accommodate this.

Signed-off-by: Christoph Seitz <christoph.seitz@infineon.com>
2025-03-12 02:29:02 +01:00
Christoph Seitz
e43246b756 net: ethernet: Fix length update for unsupported packet families
Do not update packet length for unsupported packet families.
AF_PACKET family used the IPv6 length update, which breaks the
packet length if there is a payload with bytes resembling a
IPv6 length field less then 6 or a IPv4 length field less
then 46.

Signed-off-by: Christoph Seitz <christoph.seitz@infineon.com>
2025-03-12 02:29:02 +01:00
Etienne de Maricourt
16c6504ee0 net: lwm2m: Fix ifdef nesting for data cache config
Avoid a "defined but not used" warning on
`init_next_pending_timeseries_data` when
LWM2M_RESOURCE_DATA_CACHE_SUPPORT is enabled but not LWM2M_VERSION_1_1.

Signed-off-by: Etienne de Maricourt <edmecomemail@gmail.com>
2025-03-12 02:27:59 +01:00
Alberto Escolar Piedras
c1a40abc6d subsys/bluetooth: Misc native_posix cleanup
Remove a kconfig dependency on BOARD_NATIVE_POSIX which
does not really exist anymore.
Replace a comment mention of native_posix with native_posix.

Signed-off-by: Alberto Escolar Piedras <alberto.escolar.piedras@nordicsemi.no>
2025-03-12 02:27:36 +01:00
Lars-Ove Karlsson
8d3dcd79f4 logging: Added config to disable vla in statements
The config LOG_USE_VLA depends on that MISRA_SANE is not set.
Unfortunately the IAR toolchain can't handle vla:s inside a
statement, which the LOG_USE_VLA macro does.

I've added a new, hidden config to check if vla is ok inside
statements, SUPPORT_VLA_IN_STATEMENTS. Default is always y, but
a toolchain can override it so that VLA is not used by
Z_LOG_MSG_ON_STACK_ALLOC.

Signed-off-by: Lars-Ove Karlsson <lars-ove.karlsson@iar.com>
2025-03-11 18:55:08 +01:00
Johann Fischer
53c33ab9b5 dap: add DAP backend USB
The backend uses a new USB device stack and bulk endpoints. Only a
single instance of the backend function is currently supported. Both DAP
packet processing and the new backend are prepared to support multiple
instances, but require a user interface and minor modifications.

New backen has similar functionality to what is provided by the function
in the sample samples/subsys/dap.

Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
2025-03-11 18:54:24 +01:00
Johann Fischer
6fbd63b733 cmsis_dap: remove Kconfig option CMSIS_DAP_PACKET_SIZE
We need a way to update the value configured by option
CMSIS_DAP_PACKET_SIZE at runtime. For example, the USB backend may have
different values depending on the speed at which the device is being
enumerated.

Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
2025-03-11 18:54:24 +01:00
Lyle Zhu
d811f6921c Bluetooth: L2CAP_BR: Reject the conn req if sec levels do not match
If the ACL link has been encrypted and it has a authenticated link key,
it means the pairing procedure has been done. And the security level of
the link key can not be upgraded. In this case, if `conn->sec_level` is
less than the required security level of the L2CAP channel, reject the
L2CAP conn request.

Signed-off-by: Lyle Zhu <lyle.zhu@nxp.com>
2025-03-11 18:53:50 +01:00
Olivier Lesage
6f33793b41 bluetooth: Host: Rename CS tone antenna configurations
Improves readability by removing the need to check the table
to figure out how many antennas devices A and B are using.

Signed-off-by: Olivier Lesage <olivier.lesage@nordicsemi.no>
2025-03-11 08:59:19 +01:00
Nicolas Pitre
c7467f0c65 ring_buffer: constify some arguments
Functions that don't modify content should have pointers to it marked
const.

Signed-off-by: Nicolas Pitre <npitre@baylibre.com>
2025-03-11 08:59:05 +01:00
Emil Gydesen
9d4cc4b49b Bluetooth: BAP: Add a set of suggested intervals to use with BAP
Add a selection of interval values that are suitable for BAP,
which will allow better coexistence between ISO and ACL,
for both broadcast and unicast. Some of these are defined
by the BAP spec, and some are defined by Zephyr, since they
do have a suggested value from BAP.

Samples and tests have been updated to use these new values.
Peripheral samples have also been updated with
CONFIG_BT_GAP_AUTO_UPDATE_CONN_PARAMS so that the connection
parameters from the centrals aren't updated to something else
shortly after.

The shell has also been updated to use the LE Audio (BAP) values
if audio is enabled, and the audio.conf file has disabled automatic
updating of the connection parameters as the peripheral, as we rarely
(if ever) want to do that.

Due to the connection interval change, CI hit an issue
with test_bass_broadcast_code in test_main_client_sync, where
the reading of the long receive state did not finish before we
attempted to do another procedure, so the function was updated to have
a retry.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2025-03-11 08:58:51 +01:00
Lyle Zhu
1cfd624b3d Bluetooth: SDP: Notify upper layer if the response data len is 0
In current implementation, the SDP discovery complete event is not
notified when the response data length is 0.

Notify the discovery complete event if the response length is 0.

Signed-off-by: Lyle Zhu <lyle.zhu@nxp.com>
2025-03-10 21:49:41 +01:00
Thomas Deppe
4161ba2103 Bluetooth: Host: Fix Advertising Coding Selection as peripheral
Fix mistake in host implementation of Advertising Coding Selection.

The host should only try set the BT_LE_FEAT_BIT_ADV_CODING_SEL_HOST
when the observer role is enabled. If a broadcaster enables the
CONFIG_BT_EXT_ADV_CODING_SELECTION Kconfig option bluetooth will
fail to initialise.

Signed-off-by: Thomas Deppe <thomas.deppe@nordicsemi.no>
2025-03-10 21:31:12 +01:00
Lyle Zhu
ed45960870 Bluetooth: SDP: Fix the issue of not handling the next discovery req
The pending discovery request will not be handled in some cases.
The cases include,
- The received data length is not aligned with frame length
- The continuation status length is more than maximum value
- Total length of the response is less than the frame length
- Unknown operation code is received

There is also a case where the current discovery result was not
notified when processing the pending discovery request.
The cases include,
- Fail to send SDP request
- No tail room of received buffer to save the response data

Fix the issue by using the following steps,
- Notify the application that the discovery is done
- Process the pending discovery request

Signed-off-by: Lyle Zhu <lyle.zhu@nxp.com>
2025-03-10 15:20:40 +01:00
Lyle Zhu
dcd8bcb88d Bluetooth: SSP: Reply a negative rsp if binding flags are mismatched
If the remote is in bondable mode, but the local is in non-bondable
mode, the local host shall respond to an IO capability request with
a negative response.

In current implementation, it does not check the bonding flags of the
both sides are consistent.

Fix the issue by checking the consistency of bonding flags of the both
sides. If they are not consistent, send a negative IO capability
response with the reason pairing not allowed.

Signed-off-by: Lyle Zhu <lyle.zhu@nxp.com>
2025-03-10 15:03:04 +01:00
Lyle Zhu
1408614fd2 Bluetooth: SSP: bt_conn_unref is missing if pairing is not accepted
The `conn` is found by using function `bt_conn_lookup_addr_br()`, it
should be released by calling `bt_conn_unref()`. But `bt_conn_unref()`
is missing in the case that the pairing is not accepted.

Release the `conn` by calling `bt_conn_unref()` before exiting the
function `bt_hci_io_capa_req`.

Signed-off-by: Lyle Zhu <lyle.zhu@nxp.com>
2025-03-10 15:02:48 +01:00
Christoph Seitz
0e4cf09b55 net: sockets: Fix AF_PACKET sll_protocol in recvfrom
Convert the protocol value in return in recvfrom to
network byte order as expected.

Signed-off-by: Christoph Seitz <christoph.seitz@infineon.com>
2025-03-10 15:02:38 +01:00
Lyle Zhu
0d36361b5d Bluetooth: SDP: Check data len consistency between total and received
Add fields `total_len` and `recv_len` to `struct bt_sdp_client`.

Save the total length of the response to `total_len`.
Save the received data length of the response to the `recv_len`.

Check the consistency between `total_len` and `recv_len` after all of
the response packets are received.

Signed-off-by: Lyle Zhu <lyle.zhu@nxp.com>
2025-03-10 08:58:38 +01:00
Alberto Escolar Piedras
ac24d2277e native FUSE FS access: Support any libC and fix random crashes
Split the fuse FS driver into 2 parts: A top built in the embedded side,
with the embedded libC, and a bottom built in the runner side with the
host libC.
The error returns are converted to match the host libC.

Also, before the host FUSE thread, which is asynchronous to Zephyr was
calling directly into the Zephyr filesystem code, which resulted quite
often if catastrophic failures or corruption of the Zephyr state.
This is now fixed by having the FUSE thread queue requests to a Zephyr
thread, which will be handled in the embedded side in a coherent way.
This adds a slightly noticeable overhead, but the performance is still
acceptable.

Signed-off-by: Alberto Escolar Piedras <alberto.escolar.piedras@nordicsemi.no>
2025-03-08 15:26:29 +01:00
Rubin Gerritsen
65c7f1f269 Bluetooth: Controller: Kconfig: Add dependencies to ISO configs
The ISO configs set defaults based upon BT_ISO_MAX_CHAN and other
configs defined in `bluetooth/Kconfig.iso`.

By adding these dependencies the error messages resulting from
adding `CONFIG_BT_CTLR_PERIPHERAL_ISO=y` to a project configuration
file will become less confusing.

Now the build will output:
```
warning: BT_CTLR_PERIPHERAL_ISO (
defined at subsys/bluetooth/controller/Kconfig:976,
subsys/bluetooth/controller/Kconfig:984) was assigned the value 'y' but
got the value 'n'. See ...
```

Previously we would get:
```
warning: default value 0 on BT_CTLR_CONN_ISO_STREAMS
(defined at subsys/bluetooth/controller/Kconfig:993)
clamped to 1 due to being outside the active range ([1, 64])
```

Signed-off-by: Rubin Gerritsen <rubin.gerritsen@nordicsemi.no>
2025-03-07 20:35:45 +01:00
Jukka Rissanen
d955af4e62 net: dns: Join mDNS multicast group for resolving
If mDNS resolver is enabled but mDNS responder is not, then
mDNS multicast address group is not joined. This would prevent
the mDNS resolver to receive the responses. Fix this by
joining the mDNS multicast group if mDNS responder is not
enabled (because the responder will join the group itself).

Fixes #86477

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2025-03-07 20:28:03 +01:00
Mathieu Anquetin
7282ea08e9 net: dhcpv4: fix deadlock issue
There is a deadlock issue when calling stop using address conflict
detection. This is due to the fact that some net_mgmt events are fired
and trigger the dhcpv4_acd_event_handler() with lock held even if they
are of no interest for this callback.

Therefore, before acquiring the lock, make sure the event we received
is one we are expecting.

Also, do the same for dhcpv4_iface_event_handler().

Signed-off-by: Mathieu Anquetin <mathieu.anquetin@groupe-cahors.com>
2025-03-07 20:22:58 +01:00
Kiara Navarro
737133a6df mgmt: ec_host_cmd: remove response leftovers
Remove `res` variable since it was not used in any part of `rx_timeout`
function.

Signed-off-by: Kiara Navarro <knavarro@paltatech.com>
2025-03-07 20:21:02 +01:00
Guennadi Liakhovetski
57e8d5ecfb log: fix log_flush()
The logging thread is usually woken up by a timer, if the timer
period is longer than 10ms, log_flush() can iterate multiple times
needlessly, while waiting for the next timer. Instead wake up the
logging thread to let it flush the queue immediately. Besides a
hard-coded polling period of 10ms is too long for some applications,
make it a Kconfig parameter.

Signed-off-by: Guennadi Liakhovetski <guennadi.liakhovetski@linux.intel.com>
2025-03-07 20:20:00 +01:00
Carlo Kirchmeier
3d1370f094 net: http: Add compression support in HTTP server
Add compression support using the accept-encoding
header to the http server static filesystem resource.

Signed-off-by: Carlo Kirchmeier <carlo.kirchmeier@zuehlke.com>
2025-03-07 20:19:44 +01:00
Lyle Zhu
1aa88f86b8 Bluetooth: SDP: Ignore the unexpected response
The response should not be handled if there is not a request has been
sent.

Ignore the response if the `session->param` is `NULL`.

Signed-off-by: Lyle Zhu <lyle.zhu@nxp.com>
2025-03-07 20:18:51 +01:00
Lyle Zhu
86b765c0a9 Bluetooth: SDP: Ignore unsupported UUID
In current implementation, if the UUID of request is unknown, the
local variable `u` will not be updated, and the unknown UUID `u`
is used as the target to search it in the SDP record list. It may
result in irrelevant record being replied to the requester.

Ignore the unsupported UUID to fix the issue.

Signed-off-by: Lyle Zhu <lyle.zhu@nxp.com>
2025-03-07 20:18:31 +01:00
bac phan
7026f113d6 net: http: Add #ifdef guard file system in HTTP server
http_server_http2.c does not guard check if file system is available
or not before using file system api. This PR will add guard for that

Signed-off-by: bac phan <phanhaibac98@gmail.com>
2025-03-07 20:18:04 +01:00
Lyle Zhu
7ec9f58b66 Bluetooth: SDP: Fix the error if continuation length is not 0
When the continuation length is not 0, there is a reported error.

In current implementation, the total length is only valid only when
the frame is the first block of the SDP response. For following
continuous frame, the total length is 0.

So, change the condition to `(total != 0 && frame_len > total)`.

Signed-off-by: Lyle Zhu <lyle.zhu@nxp.com>
2025-03-07 20:16:38 +01:00
Alberto Escolar Piedras
78f800642a drivers/ethernet/eth_native_posix: Rename to eth_native_tap
Rename this driver to eth_native_tap, including renaming all its
options.
The old options remain until v4.4, but as deprecated.

Signed-off-by: Alberto Escolar Piedras <alberto.escolar.piedras@nordicsemi.no>
2025-03-07 20:10:38 +01:00
Jukka Rissanen
0f90affcdf net: http: server: Select POSIX_C_LIB_EXT instead of FNMATCH
The CONFIG_POSIX_C_LIB_EXT will get support for fnmatch() function.
The old CONFIG_FNMATCH is deprecated.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2025-03-07 20:03:27 +01:00
Jukka Rissanen
33cf7dc78a net: http: server: The detail length of wildcard detail was wrong
The path length of the detail resource was not set properly.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2025-03-07 20:03:27 +01:00
Troels Nilsson
8373f19bc2 Bluetooth: Controller: Add tests covering ticker without remainder support
Update Kconfig to not select BT_TICKER_REMAINDER_SUPPORT for nrf54L

Add BSim tests to cover using a ticker without BT_TICKER_REMAINDER_SUPPORT
and expire info enabled

Signed-off-by: Troels Nilsson <trnn@demant.com>
2025-03-07 20:02:49 +01:00
Troels Nilsson
df67f4ec13 Bluetooth: Controller: Fix building ticker without remainder support
A few things were not flagged by CONFIG_BT_TICKER_REMAINDER_SUPPORT
that should have been; This caused building without it to fail

Initialize remainder to 0 where used with ticker_next_slot_get_ext(),
since it may not get set if remainder support is off

Signed-off-by: Troels Nilsson <trnn@demant.com>
2025-03-07 20:02:49 +01:00
Seppo Takalo
334b32d9f5 net: coap_client: Stop lifetime on piggybacked Ack
When we receive piggybacked Ack, it means that we have
received all information for this request.
There is no need to track exchange lifetime anymore.

Once we reset the internal request, it is free to be used
for the application. So if we only have few requests allocated,
it would be slow to send those as get_free_request() only
gives request structures that don't have a lifetime left.

Signed-off-by: Seppo Takalo <seppo.takalo@nordicsemi.no>
2025-03-07 20:01:26 +01:00
Michal Piekos
81bf6e746e shell: fixes shell dead code issue
Move z_transport_buffer_flush(sh) to the scope of the while loop.

Coverity-CID: 399568

Signed-off-by: Michal Piekos <michal.piekos@wp.pl>
2025-03-07 20:00:27 +01:00
Luis Ubieda
c66d0d81c2 rtio: workq: Default workqueue to two threads with SPI/I2C/I3C
As to facilitate work items preemption, common for sensor read ops.

e.g:
- Sensor read (submitted through workqueue).
- SPI read (submitted through workqueue using default handler).

This requires at least 2 thread pools to allow SPI read to complete,
to then come back and complete sensor reading.

Signed-off-by: Luis Ubieda <luisf@croxel.com>
2025-03-07 20:00:18 +01:00
Théo Battrel
158870ec64 Bluetooth: Host: Use memset to initialize psa_mac_operation_t
In `db_hash_setup()` the state object for MAC operations was initialized
using `psa_mac_operation_init()`. This function was not always optimized
or inlined.

A way to reduce stack usage is to use `memset()` and set the object to
0. This is one of the option documented to initialize
`psa_mac_operation_t` object.

Signed-off-by: Théo Battrel <theo.battrel@nordicsemi.no>
2025-03-07 19:59:24 +01:00
Maciej Baczmanski
6636adc706 openthread: Rework L2 configuration
- Add possibility to choose implementation of OpenThread L2 and
set it to Zephyr's by default
- Remove unused `OPENTHREAD_SECURITY_INTERNAL` Kconfig
- Add missing choice names for logging and coprocessor

Signed-off-by: Maciej Baczmanski <maciej.baczmanski@nordicsemi.no>
2025-03-07 19:59:07 +01:00
Cla Mattia Galliard
7d721ce63a net: icmp: Send replies with timeout K_NO_WAIT
This ensure system stays operational in icmp flood situation.

Signed-off-by: Cla Mattia Galliard <cla-mattia.galliard@zuehlke.com>
2025-03-07 19:58:45 +01:00
Cla Mattia Galliard
647ca57234 net: lldp: Send replies with timeout K_NO_WAIT
This ensures system stays operation in lldp-flood situation.

Signed-off-by: Cla Mattia Galliard <cla-mattia.galliard@zuehlke.com>
2025-03-07 19:58:45 +01:00
Cla Mattia Galliard
353e314fbf net: arp: Send replies with timeout K_NO_WAIT
This ensures system stays operational in arp-flood situation.

Signed-off-by: Cla Mattia Galliard <cla-mattia.galliard@zuehlke.com>
2025-03-07 19:58:45 +01:00
Cla Mattia Galliard
19f192cfb5 net: net_context: Make use of timeout for sending
Use the newly added timeout in various send functions from within
net_context_sendto.

Signed-off-by: Cla Mattia Galliard <cla-mattia.galliard@zuehlke.com>
2025-03-07 19:58:45 +01:00
Cla Mattia Galliard
5b89a5c4b8 net: add try variant with timeout for various send functions
Allows to send with different timeouts to not block caller in some
situations. Stable API is kept and just calls `try`-variant with a timeout
of `K_FOREVER`.

Signed-off-by: Cla Mattia Galliard <cla-mattia.galliard@zuehlke.com>
2025-03-07 19:58:45 +01:00
Emil Gydesen
1a6af2bfa6 Bluetooth: Audio: Modifed PAST checks to use public API
Use the recently added bt_le_get_local_features function as well
as bt_conn_get_remote_info to avoid using internal APIs to
check for PAST supported.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2025-03-07 19:58:23 +01:00