Skip to content

Conversation

@nordic-krch
Copy link
Contributor

Cherry-pick fixes for DEPRECATED_UART_NRFX_UARTE_LEGACY_SHIM kconfig option. Without this there is a warning when UART is disabled.

tomi-font and others added 30 commits March 24, 2025 07:32
…ples/tests

Explicitly enable CONFIG_ENTROPY_GENERATOR instead of relying on the
build system's defaults.

This:
- Makes sure the filtering works properly between entropy_driver and
entropy_not_secure test scenarios for the samples.
- Helps with TF-M builds in certain scenarios where key generation (via
`psa_generate_key()`) would fail due to the RNG functionality being
disabled.

Signed-off-by: Tomi Fontanilles <[email protected]>
(cherry picked from commit 25ad578)
Signed-off-by: Tomi Fontanilles <[email protected]>
Use dynamic allocation for key material for
better compatibility as a fully static key store is a new
feature that not all PSA Crypto implementations support.

Explicitly enable CONFIG_MBEDTLS_ENABLE_HEAP to ensure that Mbed TLS uses
heap for the PSA keys' data (instead of failing at runtime).
This will turn off CONFIG_MBEDTLS_PSA_STATIC_KEY_SLOTS, making the
implementation default to dynamic key slots.

Signed-off-by: Tomi Fontanilles <[email protected]>
(cherry picked from commit eb1ed12)
Signed-off-by: Tomi Fontanilles <[email protected]>
…YPTO_STORAGE_C

Add a Kconfig option to match the Mbed TLS define
instead of defining it based on CONFIG_SECURE_STORAGE.

This gives more flexibility regarding the potential re-definition of the
CONFIG_MBEDTLS_PSA_CRYPTO_STORAGE_C Kconfig option.

Signed-off-by: Tomi Fontanilles <[email protected]>
(cherry picked from commit 8627250)
Signed-off-by: Tomi Fontanilles <[email protected]>
Some implementations require more stack than others.
Increase the Ztest and main stack sizes to accommodate them.

Signed-off-by: Tomi Fontanilles <[email protected]>
(cherry picked from commit f50c3d9)
Signed-off-by: Tomi Fontanilles <[email protected]>
On top of enabling and allowing test entropy sources, enable
CONFIG_ENTROPY_GENERATOR so that a real driver and entropy source gets
used if available.
This is needed for some PSA Crypto implementations that have random number
generation conditionally compiled in.

Signed-off-by: Tomi Fontanilles <[email protected]>
(cherry picked from commit b920686)
Signed-off-by: Tomi Fontanilles <[email protected]>
…eration fails

When `bt_le_oob_get_local` or `bt_le_ext_adv_oob_get_local` is called
and SMP is enabled, `bt_smp_le_oob_generate_sc_data` is called to
generate a Random Number and a Confirmation Value needed for OOB data.
These values are based on the device's public key.

The public key is generated only once when `bt_smp_init` is called.
If public key generation fails, the callback passed to `bt_pub_key_get`
is called with `pkey` set to NULL. The `bt_smp_pkey_ready` callback
gets called, but it doesn't release the `sc_local_pkey_ready` semaphore
thus leaving `bt_smp_le_oob_generate_sc_data` wait for semaphore with
`K_FOREVER`.

This commit replaces the semaphore with a conditional variable and
requests a public key again if the key is NULL thus solving 2 issues:
- handling the case where the callback was triggered notifying about the
  completion of the public key request, but the key was not generated,
- handling the case where multiple threads trying to acquire the same
  sempahore.

The timeout is used instead of K_FOREVER to avoid cases when callback
has never been triggered.

Signed-off-by: Pavel Vasilyev <[email protected]>
(cherry picked from commit 9757ffa)
…_WHITELIST macro

Macro has been deprecated since 2.7 LTS(!) and is using non-inclusive
terminology. Drop it.

Signed-off-by: Benjamin Cabé <[email protected]>
(cherry picked from commit 110c49f)
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 <[email protected]>
(cherry picked from commit c443343)
…nd 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 <[email protected]>
(cherry picked from commit cc1b534)
The gatt docs are very sparce, this commit adds imrpovements for the
GATT server API part. Others will follow.

Signed-off-by: Kyra Lengfeld <[email protected]>
(cherry picked from commit 775cc35)
… 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 <[email protected]>
(cherry picked from commit 6464ffa)
…_uuid

bt_gatt_find_by_uuid used bt_gatt_attr_value_handle but that
function only works to get the value handle of a characteristic
declaration, i.e. if the UUID is not BT_UUID_GATT_CHRC then it
would always return handle = 0. This meant that
bt_gatt_find_by_uuid would always use handle = 0 as the starting
handle for non-BT_UUID_GATT_CHRC attributes, instead of the handle
of the provided attr.

This was not an issue for any UUIDs that may only exist once on a
GATT server, which is most UUIDs, but for UUIDs like the
BT_UUID_TBS_* UUIDs that may be multiple instances of, it would
always return the first attribute rather than the one starting
from the provided start attr.

This commit also ensures that we do not overflow the `end_handle`
when adding 2 uint16_t values.

Signed-off-by: Emil Gydesen <[email protected]>
(cherry picked from commit e4c5bb9)
Adds improvement to the GATT API documentation by providing examples of
where (and how) certain structs are used, and adds specification
references to the fields of bt_gatt_cpf to clarify their purpose.

Signed-off-by: Håvard Reierstad <[email protected]>
(cherry picked from commit c7a19da)
This commit adds improvements for the
GATT client API part.

Signed-off-by: Kyra Lengfeld <[email protected]>
(cherry picked from commit b136f6d)
…tures

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 <[email protected]>
(cherry picked from commit 44c5c1d)
When allocation fails in `hci_rx_cb`, we should return immediately
instead of continuing the execution of the function.

Also, we need to free the allocated buffer from the heap when sending
to the message queue fails to avoid memory leak.

Signed-off-by: Axel Le Bourhis <[email protected]>
(cherry picked from commit 0034e12)
…mplete event

As the previous version of the MCXW71 BLE Controller wasn't sending a
command complete event after setting the BD address, we used a
workaround to directly send the HCI command without using zephyr's API.
Now, on the latest version of MCXW72 and MCXW71, this issue is fixed,
so we need to use `bt_hci_cmd_send_sync` to properly expect the
command complete event.

Signed-off-by: Axel Le Bourhis <[email protected]>
(cherry picked from commit e5a1c0b)
…when bt disable

remove the power off BLE controller function since the hci_reset cmd
is enough, also for wifi-ble coex scenario, need to maintain BLE controller
for some info in SMU region

Signed-off-by: Ying Zhang <[email protected]>
(cherry picked from commit 6b16d10)
- added HCI command to send hci-reset in bt_disable() func, and
  remove its call from the driver close() call.
- remove rsp buf pass to 'hci_reset_complete()' func as status is
  already checked under 'bt_hci_cmd_send_sync()'.

Signed-off-by: Nirav Agrawal <[email protected]>
(cherry picked from commit 438701f)
Clarifying `bt_gatt_attr` docs.

Signed-off-by: Kyra Lengfeld <[email protected]>
(cherry picked from commit c31b962)
This commit adds more detailed description to the "Bluetooth APIs" and
"GAP" group within the bluetooth header.

Signed-off-by: Kyra Lengfeld <[email protected]>
(cherry picked from commit 3570783)
This commit changes log level for already registered callback from
warning to debug as this is cause unnecessary noise and doesn't indicate
actual issue. Caller gets a certain error code for this case which can
be handled properly.

Signed-off-by: Pavel Vasilyev <[email protected]>
(cherry picked from commit 886faba)
The api has not changed since its introduction some time ago,
mark it as stable.

Signed-off-by: Herman Berget <[email protected]>
(cherry picked from commit 8b909b4)
…ection Subrating

The API has not changed since it was introduced so should no longer be
considered experimental.

Signed-off-by: Timothy Keys <[email protected]>
(cherry picked from commit 7ef8116)
Fix the following warning
att.c:734:3: warning: label followed by a declaration is a C23 extension
[-Wc23-extensions]
  734 |                 k_tid_t current_thread = k_current_get();
      |                 ^
By wrapping that code as a compound statement

Signed-off-by: Alberto Escolar Piedras <[email protected]>
(cherry picked from commit 1dab77b)
…_amend()

Extend `zephyr_library_amend()` to support an optional directory
argument.
The current `zephyr_library_amend()` works well when used inside a
Zephyr module with same structure, but fails when the macro is called
from Zephyr module integration code is located in a Zephyr
`MODULE_EXT_ROOT` because in this case the CMake code being executed
is not present in the Zephyr module itself, in which case the dir name
creation based on relative to module dir give wrong result.

For this use-case then support a base directory.
This also allows for use-cases in Zephyr modules where the directory
structure matching Zephyr's own structure is placed in a sub-folder.

Upstream PR #: 87274

Signed-off-by: Torsten Rasmussen <[email protected]>
noup since this option does not exist upstream.

The Oberon PSA core has an option to manually set
the buffer size of the PSA key slots in bytes.

This option here:
MBEDTLS_PSA_STATIC_KEY_SLOT_BUFFER_SIZE

This option has a default value of 16 since it
directly affects the memory usage.

The crypto tests use a secp256r1 key and thus since
the public key for this key is 65 bytes long we need
to set the option in the sample.

Signed-off-by: Georgios Vasilakis <[email protected]>
…and MODE_QUAD_1_4_4"

This reverts commit dd02c86.

Signed-off-by: Marcin Szymczyk <[email protected]>
…_QUAD_1_4_4

Extend driver to support single lane and 1-4-4 IO modes.

Upstream PR #: 85520

Signed-off-by: Marcin Szymczyk <[email protected]>
Allow configuring MTU for CMUX.
Some AT manual and specification define this as a
frame size. Linux ldattach default to 127 bytes,
3GPP TS 27.010 defaults to 31.

We should limit our CMUX frames to a size that
remote end is capable of handling.
Linux silently drops oversized frames.

Also, remove MODEM_CELLULAR_CMUX_MAX_FRAME_SIZE as
this was only limiting a buffer sizes, and resulted
CMUX frames to be capped to same value.
Use MODEM_CMUX_WORK_BUFFER_SIZE and MODEM_CMUX_MTU instead.

Also rename CONFIG_MODEM_CELLULAR_CHAT_BUFFER_SIZES to
CONFIG_MODEM_CELLULAR_CHAT_BUFFER_SIZE as it is now
only used as a Chat module. DLCI pipes use
CONFIG_MODEM_CMUX_WORK_BUFFER_SIZE.

Signed-off-by: Seppo Takalo <[email protected]>
(cherry picked from commit c78081e)
nordic-krch and others added 23 commits April 7, 2025 08:09
…mer_get_ticks

Converting absolute system ticks to GRTC ticks is simple and algorithm
can be simplified. Legacy algorithm was copied from nrf_rtc_timer which
back then was working on 32 bits only.

Signed-off-by: Krzysztof Chruściński <[email protected]>
(cherry picked from commit 40ab30f)
When CONFIG_COVERAGE is enabled then performance is degraded.
In that case higher baudrates shall be avoided because CPU may
not have enough time to handle UART interrupts. Limit baudrate
to 115200 when CONFIG_COVERAGE=y.

Signed-off-by: Krzysztof Chruściński <[email protected]>
(cherry picked from commit 8d13b6b)
Adds a configuration file which is used with nrfutil to allow
programming QSPI on the device

Upstream PR #: 86985

Signed-off-by: Jamie McCrae <[email protected]>
Adds a configuration file which is used with nrfutil to allow
programming the SPI flash on the device

Upstream PR #: 86985

Signed-off-by: Jamie McCrae <[email protected]>
Adds a configuration file which is used with nrfutil to allow
programming QSPI on the device

Upstream PR #: 86985

Signed-off-by: Jamie McCrae <[email protected]>
Adds a configuration file which is used with nrfutil to allow
programming QSPI on the device

Upstream PR #: 86985

Signed-off-by: Jamie McCrae <[email protected]>
Non-secure variants for nRF7002 DK were removed from upstream
in commit 10d4973. Revert these
changes downstream, so that the NS variants are still available.

Signed-off-by: Andrzej Głąbek <[email protected]>
…lue."

This reverts commit 1e69738.

Upstream PR #: 88121

Ref: NCSDK-32650

Signed-off-by: Tomasz Chyrowicz <[email protected]>

This reverts commit 1e69738
This reverts commit a53cb73.

Upstream PR #: 88121

Ref: NCSDK-32650

Signed-off-by: Tomasz Chyrowicz <[email protected]>

This reverts commit a53cb73.
UDC API passes struct udc_ep_config to all functions. Some UDC functions
were using endpoint config structure while some were using device and
endpoint number. This API inconsistency led to completely unnecessary
endpoint structure lookups. Remove unnecessary lookups by using endpoint
config structure pointer where it makes sense.

Signed-off-by: Tomasz Moń <[email protected]>
(cherry picked from commit 1cccf28)
… hibernated

When endpoint is disabled while hibernated, the UDC endpoint state has
to be reset. Set the busy to false to keep UDC endpoint state in sync
with peripheral register state.

Upstream PR #: 88236

Fixes: 2be960a ("drivers: udc_dwc2: Disable endpoint while
hibernated")

Signed-off-by: Tomasz Moń <[email protected]>
…aly 30.

Applied fix for nRF54L anomaly 30, which requires a periodic
calibration of high-frequency clock.

Upstream PR #: 88112

Signed-off-by: Michał Stasiak <[email protected]>
…and MODE_QUAD_1_4_4"

This reverts commit 999e700.

Signed-off-by: Marcin Szymczyk <[email protected]>
…nable bit"

This reverts commit a7e820a.

Signed-off-by: Marcin Szymczyk <[email protected]>
Separate compatible is required for Flash MSPI quirks.

Upstream PR #: 85520

Signed-off-by: Marcin Szymczyk <[email protected]>
…_QUAD_1_4_4

Extend driver to support single lane and 1-4-4 IO modes.
Move flash chip quirks to a separate file.

Upstream PR #: 85520

Signed-off-by: Marcin Szymczyk <[email protected]>
Upstream PR #: 88166

Some OpenThread functions were called without verifying the return
value, which not only is not the best practice, but also could lead to
build warnings with llvm. This commit fixes it.

Signed-off-by: Robert Lubos <[email protected]>
Commit fixes bug when corresponding group ID was never
incremented for independent corresponding relationships.

Signed-off-by: Aleksandr Khromykh <[email protected]>
(cherry picked from commit 69c5c6f)
Signed-off-by: alperen sener <[email protected]>
…hen UART is unused

This hides the deprecation warning when UART_NRFX_UARTE_LEGACY_SHIM is
false because UART is not used.

Signed-off-by: Xudong Zheng <[email protected]>
(cherry picked from commit fac7c86)
…_UARTE_LEGACY_SHIM

The Kconfig option should be defined alongside
UART_NRFX_UARTE_LEGACY_SHIM for clarity.

Signed-off-by: Xudong Zheng <[email protected]>
(cherry picked from commit 020cb79)
@nordic-krch nordic-krch force-pushed the ncs/uart_legacy_shim_deprecated_fix branch from 2802d9a to fba1fa1 Compare April 9, 2025 05:42
@sonarqubecloud
Copy link

sonarqubecloud bot commented Apr 9, 2025

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet