Skip to content

Conversation

@rghaddab
Copy link
Contributor

@rghaddab rghaddab commented Apr 8, 2025

Optimize the Settings subtree load

tejlmand and others added 30 commits March 24, 2025 09:48
…_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)
If we end up writing zero bytes to cmux output, we can return
zero instead of -ENOMEM as it would break various modules when
using small buffers. For example modem_chat.c does not tolerate
-ENOMEM but handles zero OK.

Signed-off-by: Seppo Takalo <[email protected]>
(cherry picked from commit 15b0f90)
…` folder

Relocated `bt_shell_private.c` to the `common` folder to enable
independent use between `BT_SHELL` and `BT_MESH_SHELL`.

Signed-off-by: Pisit Sawangvonganan <[email protected]>
(cherry picked from commit eeda631)
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 <[email protected]>
(cherry picked from commit f1516c9)
…ests

Instead of using rs=1,2,3 and 4 we make it 10, 20, 30, 40 as the
other values could cause some connection issues.

Signed-off-by: Emil Gydesen <[email protected]>
(cherry picked from commit 7d24771)
…BAP broadcast sink

Workaround by using `-start_offset` to ensure that the ACL
established does not overlap the sink being established.

The behavior between nrf52_bsim and nrf54l15bsim is
different where in the two device are starting to
advertising at the same time in nrf54l15bsim where as
there is an offset already in nrf52_bsim test.

Signed-off-by: Vinayak Kariappa Chettimada <[email protected]>
(cherry picked from commit 490da9e)
…te for the BA

The broadcast assistant will now validate the content of the
received receive states.

Some modifications were done to the tests to properly
pass these new validations.

Signed-off-by: Emil Gydesen <[email protected]>
(cherry picked from commit b361c95)
…le adv

Most specs require the use of extended advertising, and most
tests used legacy advertising.

Implement a common function to create and start an extended
advertising set to reduce code duplication.

Signed-off-by: Emil Gydesen <[email protected]>
(cherry picked from commit 0e9a3e0)
…e 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 <[email protected]>
(cherry picked from commit 9d4cc4b)
Renamed BT_CSIP_SET_MEMBER_NOTIFIABLE to
BT_CSIP_SET_MEMBER_SIRK_NOTIFIABLE to be more specific.

Signed-off-by: Emil Gydesen <[email protected]>
(cherry picked from commit 501b95f)
…et size

The set size can now be dynamically set and notified.
The rank is added as a argument in the case that changing
the set size, also affects the device's rank, as ranks
in a coordinated set needs to be continuous.

The set coordinator implementation has been updated
to support receiving the new set size, and providing
this information to the upper layers.

This commit adds a babblesim test for the new API,
as well as a shell command.

Signed-off-by: Emil Gydesen <[email protected]>
(cherry picked from commit d19abff)
The commit exports control of MBEDTLS_ASN1_PARSE_C, in mbedTLS
module, via Kconfig.
This allows applications to use ASN1 parser independently from
other functions.

Signed-off-by: Dominik Ermel <[email protected]>
(cherry picked from commit e8589d2)
…IONS

The commit adds Kconfig options that allows users to select
 - MBEDTLS_PLATFORM_NO_STD_FUNCTIONS
 - MBEDTLS_PLATFORM_SNPRINTF_ALT
allowing Mbed TLS to use alternative definitions of STD functions.

Upstream PR #: 87135

Signed-off-by: Dominik Ermel <[email protected]>
`CI-zigbee-test` not to be triggered anymore.

nrf-squash! [nrf noup] ci: add .github/test-spec.yml

Signed-off-by: Eduardo Montoya <[email protected]>
…config to int pin

Add possibility to configure open drain and pull up on nPM2100's
interrupt output through DTS flags.

Signed-off-by: Sergei Ovchinnikov <[email protected]>
(cherry picked from commit 32b79cf)
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 <[email protected]>
(cherry picked from commit 27c18ad)
…allow

Enable test execution on nRF54L20pdk.
Overlay was already added.

Signed-off-by: Sebastian Głąb <[email protected]>
(cherry picked from commit 0d7f6d1)
added function to calculate antenna path
based on the antenna permutation index and
total number of antenna paths

Signed-off-by: Ivan Iushkov <[email protected]>
(cherry picked from commit ded9c1f)
… nRF54L20

Added missing nodes, configurations and filters in
testcase.yaml.

Signed-off-by: Michał Stasiak <[email protected]>
(cherry picked from commit 1e97295)
Implement PM device runtime in nrx spis device driver.

Signed-off-by: Bjarki Arge Andreasen <[email protected]>
(cherry picked from commit 7e93016)
Add a new function to check if a nodelabel exists in devicetree.

Signed-off-by: Gerard Marull-Paretas <[email protected]>
(cherry picked from commit b99ae6c)
As of today, nrfx components are selectable depending if devicetree has
a certain compatible or not, and in case of IP that can operate in
multiple modes, nodelabel+compatible. An example of the later is:

```
config NRFX_SPI0
    bool "SPI0 driver instance"
    depends on $(dt_nodelabel_has_compat,spi0,$(DT_COMPAT_NORDIC_NRF_SPI))
    select NRFX_SPI

config NRFX_SPIM0
    bool "SPIM0 driver instance"
    depends on $(dt_nodelabel_has_compat,spi0,$(DT_COMPAT_NORDIC_NRF_SPIM))
    select NRFX_SPIM

config NRFX_SPIS0
    bool "SPIS0 driver instance"
    depends on $(dt_nodelabel_has_compat,spi0,$(DT_COMPAT_NORDIC_NRF_SPIS))
    select NRFX_SPIS
```

These symbols are later selected by e.g. SPI driver if `spi0` node is
enabled. While this works in the Zephyr context, it can be a problem in
applications using nrfx directly in the application layer, unless they
tweak devicetree. For example, if devicetree `spi0` node defaults to
`compatible = "nordic,nrf-spim"`, NRFX_SPI0 or NRFX_SPIS0 won't be
selectable, but an application using nrfx directly doesn't really care
about what is defined in devicetree as it is effectively bypassing it.
It just wants to select e.g. `CONFIG_NRFX_SPI0=y` and forget about the
rest.

This patch fixes this problem by just checking for the existence of
certain nodelabels.

Signed-off-by: Gerard Marull-Paretas <[email protected]>
(cherry picked from commit f23b4fd)
It is defined as spis120 rather than spi120,
because spi120 is already used for SPIM120 hardware instance,
but their base address is different.

Signed-off-by: Nikodem Kastelik <[email protected]>
(cherry picked from commit d8506af)
…time PM

Extend runtime PM to support fast instance (spis120) which requires
additional action in suspend/resume phase.

Signed-off-by: Krzysztof Chruściński <[email protected]>
(cherry picked from commit 125e5d8)
SPIS120 is a SPI slave device with >8 MHz SCK compatibility.

Signed-off-by: Nikodem Kastelik <[email protected]>
(cherry picked from commit f13c8a5)
New test case is for building an application simultaneously
utilizing SPIM120, SPIM120, SPIS120 and SPIS13x.

Signed-off-by: Nikodem Kastelik <[email protected]>
(cherry picked from commit 8b77098)
rghaddab and others added 26 commits April 7, 2025 20:52
…orage)

This adds the initial backend support for the ZMS storage system.

Signed-off-by: Riadh Ghaddab <[email protected]>
(cherry picked from commit ef4e8dd)
This adds a on target performance test for Settings SS. Using this test
performance of the Setting SS + NVS/ZMS backend can be benchmarked.

The test repeatedly write 128 settings entries. Each setting entry
has a size of 4 bytes, and path length of 16 bytes (excluding the
null-terminator).

The test has two variants, with and without Bluetooth scan running.
This is useful to benchmark performance along with some component
of BT subsystem activated.

The test could be enhanced in future to include or create combinations
of different functionalities running, when agreesive store operations
are happening.

Signed-off-by: Omkar Kulkarni <[email protected]>
(cherry picked from commit 97166a5)
This resolves some addressed comments in this PR zephyrproject-rtos#77930
as well as this PR zephyrproject-rtos#80407

Signed-off-by: Riadh Ghaddab <[email protected]>
(cherry picked from commit 5f7cda5)
…tive_posix

native_posix is deprecated and will be removed in 4.2
Run this sample in native_sim instead.

Signed-off-by: Alberto Escolar Piedras <[email protected]>
(cherry picked from commit 4a91a55)
This sample could not run on any target as it depedend on zms
which is set by no board.
But it seems to run just fine in both allowed platforms,
so let's add a trivial twister check (so it actually passes instead
of waiting for ever), and remove that `depends on`.

Signed-off-by: Alberto Escolar Piedras <[email protected]>
(cherry picked from commit cc2d31f)
- adds ability to change the ZMS sample MAX_ITERATIONS
  and DELETE_ITERATION parameters via Kconfig without manually
  modifying the source code.
- adds ability to reduce flash memory wear on real devices
  by reducing the number of write iterations.

Signed-off-by: Andrej Butok <[email protected]>
(cherry picked from commit c887d5e)
- fix unwanted "Error: Something went wrong at iteration 0".
- the loop_cnt check has no sense for iteration 0,
  comparing with wrong -1.

Signed-off-by: Andrej Butok <[email protected]>
(cherry picked from commit 2766c78)
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 <[email protected]>
(cherry picked from commit 333fadd)
Add reference to the new settings backend ZMS and add more details about
how it works.

Signed-off-by: Riadh Ghaddab <[email protected]>
(cherry picked from commit f363015)
- Allows to build and run ZMS tests on real platforms.
- Enables ZMS tests designed for a flash-simulator only when
  built for qemu_x86 or native_sim targets.

Signed-off-by: Andrej Butok <[email protected]>
(cherry picked from commit b826d46)
- Sets CONFIG_LOG_BLOCK_IN_THREAD for the zms sample.
- Fixes "--- 9999 messages dropped ---".

Signed-off-by: Andrej Butok <[email protected]>
(cherry picked from commit ac7790e)
When deleting a settings entry the linked list is updated by removing
the deleted node. This operation is time consuming and add some delays.
For applications that use almost the same set of Setting entries, add an
option to make this operation faster at a cost of having some empty
nodes in the linked list.
These empty nodes can be used later when the deleted entry is written
again.
Each empty node occupies 16B of storage.

Upstream PR #: 87792

Signed-off-by: Riadh Ghaddab <[email protected]>
(cherry picked from commit 02ab54e077e090e4c9364e4d4954a8c3508e513e)
When the CONFIG_ZMS_NO_DOUBLE_WRITE is not enabled there is no need to
search in the cache for matching ID

Upstream PR #: 87792

Signed-off-by: Riadh Ghaddab <[email protected]>
(cherry picked from commit 546ed2dbe817794bedb16bae0c81fd4af22675ea)
Settings subsystem is storing the name ID and the linked list node ID
with only one bit difference at BIT(0).
Settings subsystem is also storing the name ID and the data ID in two
different ZMS entries at an exact offset of ZMS_DATA_ID_OFFSET.
Using the regular lookup function could result in many cache misses.

Therefore, to assure the least number of collisions in the lookup cache,
the BIT(0) of the hash indicates whether the given ZMS ID represents a
linked list entry or not, the BIT(1) indicates whether the ZMS ID is a
name or data and the remaining bits of the hash are set to a truncated
part of the original hash generated by Settings.

Upstream PR #: 87792

Signed-off-by: Riadh Ghaddab <[email protected]>
(cherry picked from commit ad2581fede5f6efa570e3e8157ff37290d2dbe21)
If the subtree argument is not NULL in the settings_load function, load
only the setting entry that corresponds to that subtree.
If the subtree argument is NULL or it is not found in the storage, load
all the existing entries in the storage.

Upstream PR #: 87792

Signed-off-by: Riadh Ghaddab <[email protected]>
(cherry picked from commit 86132feb5c59e8a071d9782c5482ab346cfbf6f3)
Increase the load performance by adding an optional cache for the linked
list hashes.
This is used only when the settings_load is called with NULL parameter
and we need to load all Settings that exist in the persistent storage.
Cache is enabled using SETTINGS_ZMS_LL_CACHE and the size of the cache
is set using SETTINGS_ZMS_LL_CACHE_SIZE.
Each cache entry will add 8 bytes of RAM usage.

Upstream PR #: 87792

Signed-off-by: Riadh Ghaddab <[email protected]>
(cherry picked from commit 50c099243557a49b53d793c839299e0a55370f42)
…s entry

Add a a function settings_load_one that allows to load only one settings
entry instead of a complete subtree.
Add as well its implementation for ZMS backend.
This will allow a faster return if the Settings entry doesn't exist in
the persistent storage.

Upstream PR #: 87792

Signed-off-by: Riadh Ghaddab <[email protected]>
(cherry picked from commit 98e544b4b838cd96012bb4bd5adfb584e67a52f1)
…ad_one

Add a test for the new API settings_load_one that loads only one path
from the persistent storage.

Upstream PR #: 87792

Signed-off-by: Riadh Ghaddab <[email protected]>
(cherry picked from commit 168ae245bdce756fd5db22dd391469ad17eeb9b2)
Add the functional test for the new backend of ZMS

Upstream PR #: 87792

Signed-off-by: Riadh Ghaddab <[email protected]>
(cherry picked from commit 18f7736ce3c73f6f10e037aa627293104dc55b9d)
When a power off happens after writing the settings name and before
writing the linked list node we cannot write the settings name again in
the future.
Fix this by writing the linked list node before writing the name.
When loading all settings, we already delete linked list node that do
not have any name or value written.
Adds as well a recover path if a power down happens in the middle of
unlinking an LL node after a delete.

Upstream PR #: 87792

Signed-off-by: Riadh Ghaddab <[email protected]>
(cherry picked from commit bf4d15316b1a3bd9239ddbe179b11006eea1e3b1)
When the linked list is broken, recover it instead of reinitializing it.

Upstream PR #: 87792

Signed-off-by: Riadh Ghaddab <[email protected]>
(cherry picked from commit 057c1d65fa5822d9145330c87183d0b652707ab2)
Add a function to get the value's length of a Key. If it doesn't exist
returns 0.
Add ZMS implementation for csi_get_val_len() and a default implementation
for the other storage systems.
Add some functional tests to verify it.

Upstream PR #: 87792

Signed-off-by: Riadh Ghaddab <[email protected]>
(cherry picked from commit 5a730f71f49e87fb4da35120826e8d45bc62fef6)
…f strlen

if the provided name in argument is not null this could lead to un
undefined behavior.
Use strnlen to make this safe

Upstream PR #: 87792

Signed-off-by: Riadh Ghaddab <[email protected]>
(cherry picked from commit e9ac2ef95bd34a8c4756e46e8f2ddf66e0964dbc)
Add references to the new API functions that were added
"csi_load_one" and "csi_get_val_len"

Upstream PR #: 87792

Signed-off-by: Riadh Ghaddab <[email protected]>
(cherry picked from commit b26ed3a3ec5dae5017ecd4e40164e3b38ca88235)
Clean some parts of the code and refactor it to avoid multiple nested
conditions.

Upstream PR #: 87792

Signed-off-by: Riadh Ghaddab <[email protected]>
(cherry picked from commit 1699785ff3fd7d7e260133898729afff634eea73)
@sonarqubecloud
Copy link

sonarqubecloud bot commented Apr 8, 2025

Quality Gate Failed Quality Gate failed

Failed conditions
C Reliability Rating on New Code (required ≥ A)

See analysis details on SonarQube Cloud

Catch issues before they fail your Quality Gate with our IDE extension SonarQube for IDE

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

Labels

None yet