Commit graph

21541 commits

Author SHA1 Message Date
Vinayak Kariappa Chettimada
37bf99eee7 Bluetooth: Controller: Fix radio_tmr_start_us for single timer use
This commit addresses two bugs in use of single timer s/w
switch implementation, incorrect aux_offset in subsequent
ADV_EXT_IND and ISO receiver failing to receive second or
greater BIS subevents.

Fix radio_tmr_start_now implementation to consider the
initial latency in starting the event timer in single timer
use mode. This fixes the incorrect aux_offset in ADV_EXT_IND
PDUs.

Fix radio_tmr_start_us implementation for single timer use,
as the timer is reset on every radio end, and hence the
requested start_us has to be adjusted for the accumulated
last_end_pdu_us value. This fixes the BIS subevent
receptions.

Also, fix the maximum radio ISR latency value used in
radio_tmr_start_us to consider the maximum Rx chain delay
and maximum radio ramp up delays. 80 us + ~30 us + ~40 us
should be able to meet the 150 us tIFS duration.

Relates to commit bcd28e0a86 ("Bluetooth: Controller: Fix
sw switch single timer for spurious TXEN/RXEN").

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2025-01-18 10:03:41 +01:00
Måns Ansgariusson
c39291b7f0 net: socketpair to use ring_buffer instead of k_pipe
Replaced the k_pipe-based implementation in sockpair with ring_buffer
based implementation instead.
The move to ring_buffer is done to avoid overhead of k_pipe and to align
with the new k_pipe API.
This does not pose any added risk to concurrency as the read and write
functions are protected by semaphores for both spairs.

Signed-off-by: Måns Ansgariusson <Mansgariusson@gmail.com>
2025-01-17 19:43:44 +01:00
Måns Ansgariusson
efcc734b79 tracing: k_pipe: Add tracing support for reworked k_pipe API
Add tracing support for the reworked k_pipe API.

Signed-off-by: Måns Ansgariusson <Mansgariusson@gmail.com>
2025-01-17 19:43:44 +01:00
Lyle Zhu
40993fe507 Bluetooth: RFCOMM: Add a argument server to bt_rfcomm_server.accept
In current implementation, the `accept` cannot be identified if the
same one `accept` callback is passed by the upper layer.

Similar with `accept` of `bt_l2cap_server.accept`, add a parameter
`server` to the `bt_rfcomm_server.accept` callback.

Add a argument `server` to function bt_hfp_hf_accept() to avoid
building issue for HFP_HF.

Add a argument `server` to function rfcomm_accept() to avoid building
issue for shell/rfcomm.c.

Signed-off-by: Lyle Zhu <lyle.zhu@nxp.com>
2025-01-17 13:54:13 +01:00
Lyle Zhu
87b2a3006c Bluetooth: rfcomm: Support dynamic channel allocation
In the function `bt_rfcomm_server_register()`, the channel cannot be
dynamic allocated. And only pre-set channel is supported.

Improve the function `bt_rfcomm_server_register()` to support the
dynamic channel allocation if the passed channel is zero.

Signed-off-by: Lyle Zhu <lyle.zhu@nxp.com>
2025-01-17 13:54:00 +01:00
Lyle Zhu
c4090998d3 Bluetooth: RFCOMM: Move BT_RFCOMM_BUF_SIZE to rfcomm.h
The buffer `BT_RFCOMM_BUF_SIZE` is used to define the TX buffer size of
TX pool.

In current implementation, the TX buffer size of RFCOMM cannot be
calculated due to the macro `BT_RFCOMM_BUF_SIZE` is defined in internal
header file `rfcomm_internal.h`.

Move the macro `BT_RFCOMM_BUF_SIZE` form internal header file
`rfcomm_internal.h` to interface `rfcomm.h`.

Signed-off-by: Lyle Zhu <lyle.zhu@nxp.com>
2025-01-17 10:41:49 +01:00
Krzysztof Chruściński
8207a05304 shell: modules: kernel_service: deprecate log_level
Log_level command is a duplicate of 'log enable' command from
the logging command set (enabled by CONFIG_LOG_CMDS=y). Adding
warning about deprecation as 'log enable' is recommended since
it has more features (e.g. autocompletion).

Signed-off-by: Krzysztof Chruściński <krzysztof.chruscinski@nordicsemi.no>
2025-01-17 09:08:26 +01:00
Lars Knudsen
bc4a2f37f3 Bluetooth: BAP: Remove ISO limitation on BASE parsing
BASE is now parsed on-the-fly on sink sync, removing
unnecessary restriction in intermediate parsed storage
and without requiring an excessive amount of memory.

Signed-off-by: Lars Knudsen <LAKD@demant.com>
2025-01-17 09:08:16 +01:00
Fin Maaß
ca43888f54 mgmt: hawkbit: use flash_img_get_upload_slot()
don't assume, that the slot to upload is the second.

Signed-off-by: Fin Maaß <f.maass@vogl-electronic.com>
2025-01-17 09:07:45 +01:00
Fin Maaß
beffba6d87 dfu: flash_img: add flash_img_get_upload_slot()
add flash_img_get_upload_slot() to get current
upload slot.
when CONFIG_MCUBOOT_BOOTLOADER_MODE_RAM_LOAD
is enabled, it is not based on the DT.

Signed-off-by: Fin Maaß <f.maass@vogl-electronic.com>
2025-01-17 09:07:45 +01:00
Lingao Meng
6371080406 Bluetooth: Mesh: Fix Assert in bt_mesh_adv_unref when messages to a proxy
Fixes:https://github.com/zephyrproject-rtos/zephyr/issues/83904

This solution fix is to define a separate variable for the each proxy FIFO.

Signed-off-by: Lingao Meng <menglingao@xiaomi.com>
2025-01-17 06:43:08 +01:00
Piotr Radecki
e2ddac3715 net: lib: http: Added Content-Range to http client.
Content-Range functionality added in recent commits has been propagated
to http_client module. If "Content-Range" string is detected on header
field, Content-Range are returned via http_response structure.

Signed-off-by: Piotr Radecki <piotr.radecki@jrdltd.co.uk>
2025-01-16 22:55:51 +01:00
Piotr Radecki
d572ebb62b net: lib: http: Added Content-Range header parsing.
Content-Range hasn't been supported in zephyr. This change adds
Content-Range header parsing to http_parser module. Range start,
range end, and total size are supported. All units are currently
interpreted as bytes.
This is much needed change, because many applications responsible
for http data download are based on Content-Range approach.

Signed-off-by: Piotr Radecki <piotr.radecki@jrdltd.co.uk>
2025-01-16 22:55:51 +01:00
Ahmed Ahmed
6a45e17b4b bluetooth: host: fix connection reference before returning
As the connection was removed from the list, we now own its reference.
Keep this reference and return it to the TX processor.

Signed-off-by: Ahmed Ahmed <ahmed.ahmed@dewinelabs.com>
2025-01-16 22:45:39 +01:00
Ahmed Ahmed
2edddbddb5 bluetooth: host: add asserts to foreach in get_conn_ready
Assert that the previous connection in the list and the tmp element
in the loop are different to the current connection.
Otherwise, if the same connection was somehow added twice it
could result in an infinite loop.

Signed-off-by: Ahmed Ahmed <ahmed.ahmed@dewinelabs.com>
2025-01-16 22:45:39 +01:00
Ahmed Ahmed
099871622a bluetooth: host: iterate over connections in TX list
Iterate over the list of connections to find a connection
that is able to send data, instead of returning NULL if
the first connection can't send data.

This solves the problem with starvation of other connections.

Signed-off-by: Ahmed Ahmed <ahmed.ahmed@dewinelabs.com>
2025-01-16 22:45:39 +01:00
Dawid Niedzwiecki
4f772ebee9 mgmt: ec_host_cmd: uart: add timeout config
Use a config, instead of hardcode, to set timeout value.

It says how much time UART backend should wait for entire message sent
in chunks.

Signed-off-by: Dawid Niedzwiecki <dawidn@google.com>
2025-01-16 22:41:09 +01:00
Daniel Mangum
2ca82ea6c4 ipc: pbuf: fix idx_occupied comment
Fix typos in the comment on the idx_occupied function.

Signed-off-by: Daniel Mangum <georgedanielmangum@gmail.com>
2025-01-16 22:38:26 +01:00
Jukka Rissanen
2f10d7d816 net: ethernet: Set the ptype by the caller in send
Instead of setting the upper protocol type in ethernet_send()
by checking the protocol type bits, use the ptype that is already
set by the caller. This allows new protocol types to be supported
and makes the system extensible.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2025-01-16 22:37:28 +01:00
Pieter De Gendt
e7e6cb9def shell: shell_log_backend: Allow printing the thread ID or name
Add the LOG_OUTPUT_FLAG_THREAD to the default flags for the shell log
backend.

Signed-off-by: Pieter De Gendt <pieter.degendt@basalte.be>
2025-01-16 22:36:50 +01:00
Benjamin Cabé
5b09caa122 net: http_server: fix HTTP 1.0 500 response template format
Template string for HTTP 1.0 500 response expects content length as a %d
but was getting passed a 'long unsigned int' instead of an 'int'.

Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
2025-01-16 22:35:29 +01:00
Robert Lubos
e9bedccc2e net: http_server: Add support for generic HTTP2 500 response
In case of errors during HTTP2 request processing (or after the HTTP1
upgrade response was sent), send 500 Internal Server Error response
before shutting down the connection.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2025-01-16 14:52:10 +01:00
Robert Lubos
143c4e07d9 net: http_server: Add support for HTTP2 405 error
HTTP2 should reply with 405 Method Not Allowed error the same way as
HTTP1 does.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2025-01-16 14:52:10 +01:00
Robert Lubos
4063913960 net: http_server: Simplify HTTP2 headers_sent flag setting
Since there is a helper function to generate/send headers frame, the
flag can be set there instead of being set separately in various places.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2025-01-16 14:52:10 +01:00
Robert Lubos
4178ede259 net: http_server: Add support for generic HTTP1 500 response
In case of internal server errors during HTTP1 request processing,
send 500 Internal Server Error response before shutting down the
connection.

Make sure http1_headers_sent is set whenever sever starts replying, to
avoid duplicate response in case of errors, as that would be protocol
violation.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2025-01-16 14:52:10 +01:00
Robert Lubos
11eb0433f8 net: http_server: Support HTTP1 405 error reply for all resource types
Reply with 405 Method not allowed not only for static FS resource types,
but also for others. Also, the method checking for for static resources
was messed up - those resource types only support GET by design, so no
need to compare resource method bitmask - it should be checked that the
request was actually GET instead.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2025-01-16 14:52:10 +01:00
Robert Lubos
5688f58eac net: http_server: Add helper functions for HTTP1 error replies
Add helper functions for HTTP/1 error replies to reduce and avoid
further code duplication.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2025-01-16 14:52:10 +01:00
Jilay Pandya
f5a126e7ac shell: backends: shell_websocket remove deadcode
fix coverity issue about deadcode, there is no code path which would
lead to the code that is being deleted with this commit

Signed-off-by: Jilay Pandya <jilay.pandya@outlook.com>
2025-01-16 14:51:10 +01:00
Krzysztof Chruściński
f0cdaace22 shell: modules: kernel_service: Fix log_level command
Add missing return when input logging source argument is not valid.

Signed-off-by: Krzysztof Chruściński <krzysztof.chruscinski@nordicsemi.no>
2025-01-16 14:46:33 +01:00
Cla Mattia Galliard
35df867515 net: ethernet: remove unused family variable
Remove unused family variable from receive function in ethernet layer 2.
It is checked only once under such conditions, that do not allow the
variable to be different.

Signed-off-by: Cla Mattia Galliard <cla-mattia.galliard@zuehlke.com>
2025-01-16 14:39:58 +01:00
Johan Hedberg
c9647a55fe Bluetooth: Classic: Fix invalid comparison with int8_t
We can't use 0xff to compare with an int8_t since it'll trigger compiler
warnings/errors:

subsys/bluetooth/host/classic/br.c:397:11: error: result of comparison of
constant 255 with expression of type 'int8_t' (aka 'signed char') is
always false [-Werror,-Wtautological-constant-out-of-range-compare]
        if (rssi == 0xff) {
            ~~ ^  ~~
1 error generated.

Use 127 instead for situations where we don't know the RSSI value, like
when processing remote name events. This is fine since from a spec
perspective only -127 - +20 are valid values for the parameter.

Signed-off-by: Johan Hedberg <johan.hedberg@silabs.com>
2025-01-16 14:37:44 +01:00
Benjamin Cabé
4b06ace975 mctp: mark MCTP as experimental
MCTP was just introduced in Zephyr 4.1.
Mark the feature as experimental.

Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
2025-01-15 22:58:09 +01:00
Valerio Setti
11a8a39c63 Bluetooth: Host: imply MBEDTLS_PSA_P256M_DRIVER_ENABLED rather than select
Allow the user to disable the P256-M driver in case their version of
Mbed TLS does not support this driver.

Signed-off-by: Valerio Setti <vsetti@baylibre.com>
2025-01-15 22:57:20 +01:00
Valerio Setti
12eee61533 Bluetooth: crypto: add select PSA_WANT_ALG_ECB_NO_PADDING
Explicitly enable "PSA_WANT_ALG_ECB_NO_PADDING" to select the AES ECB
mode that it is used in CMAC operation.

Signed-off-by: Valerio Setti <vsetti@baylibre.com>
2025-01-15 22:57:20 +01:00
Valerio Setti
aaf463ca7b Bluetooth: make MBEDTLS_AES_ROM_TABLES implied not selected
MBEDTLS_AES_ROM_TABLES let Mbed TLS use precomputed AES tables instead
of generating them at runtime and placing in RAM. It clearly helps
reducing the RAM footprint, but at the same time it increases the ROM
one. In order to let the final user decide which kind of optimization
they prefer, we change the "select" statement with "imply".

Signed-off-by: Valerio Setti <vsetti@baylibre.com>
2025-01-15 22:57:20 +01:00
Pavel Vasilyev
6463d15a66 bluetooth: mesh: Remove assertion for Received List message PDU size
According to MshDFUv1.0, section 6.2.3.5, the Firmware Distribution
Receivers List message is not limited by the size of the receivers list:

```
The number of selected entries shall be limited by the following:
- The number of entries shall not exceed the value of the Entries Limit
  field from the Firmware Distribution Receivers Get message.
- The number of entries shall not cause the message payload to exceed
  the maximum Access PDU size.
```

Thus, this assertion is incorrect as it doesn't allow to have the
receivers list bigger than number of maximal Access PDU size.

Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
2025-01-15 22:57:01 +01:00
Emil Gydesen
eff93d268a Bluetooth: BAP: Add common capability check
Instead of having 2 separate and non-equal checks for
capabilities in ASCS and the Broadcast Sink, there is now
a single function in pacs.c that performs the
check.

This reduces code size and makes it easier to maintain.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2025-01-15 19:04:31 +01:00
Chen Shu
5a5f05ba4e fs: ext2: Fix nbytes_to_read calculation in ext2_inode_read()
Fix incorrect nbytes_to_read calculation in ext2_inode_read() function.
Previously nbytes_to_read was decremented by read value which caused
incorrect calculation of bytes to read in subsequent iterations.
Now nbytes_to_read is decremented by to_read value which represents
the actual number of bytes read in current iteration.

This fixes potential data corruption issues when reading files from
ext2 filesystem.

Signed-off-by: Chen Shu <751541594@qq.com>
2025-01-15 11:51:10 +01:00
Tom Burdick
5de7e415a0 logging: Add a log flush operation
Ensure all pending log messages are processed by the log processing
thread when log_flush is called, blocking the caller until done.

Signed-off-by: Tom Burdick <thomas.burdick@intel.com>
2025-01-15 09:33:28 +01:00
Emil Gydesen
ba5971e703 Bluetooth: ISO: Move contents of Kconfig.iso to common Kconfig
Move the contents of Kconfig.iso to the common Kconfig
file.

The main reason for this is that the Kconfig.iso filename
has caused issues for some, due to the .iso filename extension.

The contents have been moved to right after the Kconfig options
for BT_CONN which are quite similar.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2025-01-15 01:39:35 +01:00
Tom Burdick
4148512567 mctp: Add mctp subsystem with uart binding
libmctp provides interfaces for wiring up a MCTP bus it calls bus
bindings. The bindings provided in libmctp however are not directly
useful to Zephyr without some work. Provide an initial uart binding that
directly uses Zephyr's async uart interface.

Signed-off-by: Tom Burdick <thomas.burdick@intel.com>
2025-01-14 22:55:41 +01:00
Vinayak Kariappa Chettimada
363c1431dd Bluetooth: controller: Fixup Broadcast ISO pre-transmission groups > 1
Fixup payload_index to be uint16_t to avoid index overflow.

Do not remember why ptc is 4 bits, where as it must be 5 bit
value similar to nse; added an assertion check until it is
fixed.

Fix ISO Broadcaster and ISO Sync Receiver for PTO > 1 and
use of Pre-Transmission Group Counts.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2025-01-14 15:37:53 +01:00
Vinayak Kariappa Chettimada
9cd9f4150d Bluetooth: Controller: Add back the use of pre-transmissions
Add back the implementation in the Controller that tries to
enable pre-transmissions to improve time diversity to aid a
remote ISO Sync Receiver role device.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2025-01-14 15:37:53 +01:00
Morten Priess
d58724d7d7 Bluetooth: controller: Fix ISO broadcaster pre-transmission groups > 1
For pre-transmission groups > 1, the broadcaster link layer would fetch
incorrect payloads from the TX node queue.

Update payload index calculation to reference correct TX payload. Fix
PTO FIXMEs and range checks.

Signed-off-by: Morten Priess <mtpr@oticon.com>
2025-01-14 15:37:53 +01:00
Marcin Szymczyk
94589b784b modules: hal_nordic: nrfx: cleanup
* Move all KConfig configuration from CMake to `nrfx_kconfig.h`
* Move macro utils from `nrfx_kconfig.h` to `nrfx_zephyr_utils.h`
* Move GRTC channels allocation from `nrfx_kconfig.h` to
  `nrfx_reserved_resources.h`

Signed-off-by: Marcin Szymczyk <marcin.szymczyk@nordicsemi.no>
2025-01-14 13:38:03 +01:00
Aleksandr Khromykh
967b096ad9 Bluetooth: Mesh: use secure storage in ble mesh
Commit:
 - adds dependency of the mbedtls psa usage on secure storage
 - removes PSA ITS emulator and enables usage of
   the secure storage in ble mesh bsim tests
 - enables secure storage in all ble mesh and related samples

Signed-off-by: Aleksandr Khromykh <aleksandr.khromykh@nordicsemi.no>
2025-01-14 13:23:47 +01:00
Pisit Sawangvonganan
bd9249457a bluetooth: shell: completely eliminate the dependency on ctx_shell
This commit removes the `ctx_shell` declaration from the Bluetooth shell,
marking a milestone in eliminating this dependency.

Signed-off-by: Pisit Sawangvonganan <pisit@ndrsolution.com>
2025-01-14 10:56:16 +01:00
Pisit Sawangvonganan
2ea23cec7c bluetooth: classic: shell: eliminate ctx_shell usage
This change aims to eliminate the dependency on `ctx_shell` in
the Bluetooth `classic/shell/*`, making the code more maintainable.
Replaced `shell_*` functions that depended on `ctx_shell` with
the appropriate `bt_shell_*` functions.

Signed-off-by: Pisit Sawangvonganan <pisit@ndrsolution.com>
2025-01-14 10:56:16 +01:00
Pisit Sawangvonganan
f70359bc7c bluetooth: mesh: shell: eliminate ctx_shell usage
This change aims to eliminate the dependency on `ctx_shell` in
the Bluetooth `mesh/shell/*`, making the code more maintainable.
Replaced `shell_*` functions that depended on `ctx_shell` with
the appropriate `bt_shell_*` functions.

Signed-off-by: Pisit Sawangvonganan <pisit@ndrsolution.com>
2025-01-14 10:56:16 +01:00
Pisit Sawangvonganan
f1516c960a bluetooth: audio: shell: eliminate ctx_shell usage
This change aims to eliminate the dependency on `ctx_shell` in
the Bluetooth `audio/shell/*`, making the code more maintainable.
Replaced `shell_*` functions that depended on `ctx_shell` with
the appropriate `bt_shell_*` functions.

Signed-off-by: Pisit Sawangvonganan <pisit@ndrsolution.com>
2025-01-14 10:56:16 +01:00