As part of ongoing work to move away from TinyCrypt and towards PSA
(#43712), introduce a PSA option and remove the TinyCrypt one for the
SHA-256 implementation.
The Mbed TLS implementation is modified to use `mbedtls_sha256`
directly for smaller code size.
The reliance of mgmt/updatehub on storage/flash_map's configuration
(`FLASH_AREA_CHECK_INTEGRITY_BACKEND`) is removed.
The choice of which implementation to use is made automatically,
based on whether a PSA API provider is present (`PSA_CRYPTO_CLIENT`).
This commit also add a test case with PSA (based on Mbed TLS)
in samples/subsys/mgmt/updatehub/sample.yaml.
Signed-off-by: Tomi Fontanilles <tomi.fontanilles@nordicsemi.no>
Signed-off-by: Valerio Setti <vsetti@baylibre.com>
This API converts a HCI error code to a string.
This can be useful if application developers want to print them
in the applications.
Later we can also use them in the host to improve debuggability.
Signed-off-by: Rubin Gerritsen <rubin.gerritsen@nordicsemi.no>
Currently, the NRU algorithm always picks the lowest (and very often the
same) clean unaccessed page over and over when e.g. doing large anonymous
memory mappings. Spread the eviction selection more uniformly by by
starting the search right after the last victim instead of always
restarting from 0.
Signed-off-by: Nicolas Pitre <npitre@baylibre.com>
The integer return of sensor_submit should be void as the call is
asynchronous and the response is meant to be delivered using RTIO APIs
signaling that the submission completed with error or success.
Change the function signature to void and fix all uses of the submit
API, fixing some bugs in the process.
Signed-off-by: Tom Burdick <thomas.burdick@intel.com>
This commit adds CONFIG_BT_USE_PSA_API to allow the end
user to prefer PSA APIs over TinyCrypt for crypto operations
in bluetooth. Of course, this is possible only if
a PSA provider is available on the system, i.e.
CONFIG_PSA_CRYPTO_CLIENT is set.
This commit also extends
tests/bluetooth/mesh/basic/bluetooth.mesh.gatt adding a specific
case using PSA.
Signed-off-by: Valerio Setti <vsetti@baylibre.com>
By enabling CONFIG_BT_USE_PSA_API the user can specify to use
PSA APIs instead of TinyCrypt for crypto operations in bluetooth
host module.
This commit also extends tests/bluetooth/gatt in order to
add a PSA test.
Signed-off-by: Valerio Setti <vsetti@baylibre.com>
This commit adds CONFIG_BT_USE_PSA_API to allow the end
user to prefer PSA APIs over TinyCrypt for crypto operations
in bluetooth. Of course, this is possible only if
a PSA provider is available on the system, i.e.
CONFIG_PSA_CRYPTO_CLIENT is set.
This commit also extends tests/bluetooth/bt_crypto adding
a test case for PSA.
Signed-off-by: Valerio Setti <vsetti@baylibre.com>
Allow DTLS handshake to be retried before the engine
drops into bootstrap. Otherwise any termporary failure,
for example DNS failure might drop us into bootstrap
without retrying.
Now all the retry logic should be in sm_do_network_error().
sm_do_registration() should only fall back to bootstrap
if there is configuration error.
Signed-off-by: Seppo Takalo <seppo.takalo@nordicsemi.no>
Nordic devices are commonly used with the nRF Connect SDK.
There the SoftDevice Controller is set as the default
Bluetooth Controller. To avoid confusion when reading DTS
and Kconfig files, clarify this by adding a note.
Signed-off-by: Rubin Gerritsen <rubin.gerritsen@nordicsemi.no>
DAP SWD sequence command is a requirement to support CMSIS-DAPv2.
Raise supported version to "2.1.0".
Signed-off-by: Maximilian Deubel <maximilian.deubel@nordicsemi.no>
Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
Add ID_DAP_UART_* command definitions and react properly to
unsupported UART commands.
Signed-off-by: Maximilian Deubel <maximilian.deubel@nordicsemi.no>
Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
Add API to read count bits from SWDIO into data LSB first.
Signed-off-by: Maximilian Deubel <maximilian.deubel@nordicsemi.no>
Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
If a host client crashes or fails to disconnect, the probe will
hang. Allow a new connection without raising errors.
Signed-off-by: Johan Carlsson <johan.carlsson@teenage.engineering>
Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
Add CMSIS-DAP compatible controller which is a handler between
the host interface and SWD driver. The controller follows CMSIS-DAP
reference implementation. It expects a request buffer from the host
interface, splits it to simple transfers and forwards to the DP driver,
and finally returns a response buffer to the host.
Interface to the host can be implemented with USB HID device support.
Controller implements only SW-DP support and is tested
with pyOCD and ADIv5.x.
Signed-off-by: Johann Fischer <j.fischer@phytec.de>
The section headers are now available in the loader structure, so we can
use those directly instead of reading them from the ELF file every time.
This commit contains no logic changes; it removes all copies of the
header loading code and replaces them with direct access to the cached
section headers.
Signed-off-by: Luca Burelli <l.burelli@arduino.cc>
This change reads all section headers at once, instead of reading them
one by one. This is more efficient and allows to further simplify the
code downstream.
The section headers are directly accessed from the file buffer if the
llext_peek() function is supported by the loader. Otherwise, they are
read into a buffer allocated on the heap and used only during the
llext_load() function.
Signed-off-by: Luca Burelli <l.burelli@arduino.cc>
The do_llext_load function is responsible for loading an extension from a
file, and for this purpose it calls a number of functions that a) allocate
memory, and b) can fail. This creates the opportunity for memory leaks if
the error paths are not handled correctly.
This commit adds a comment at the beginning of the function to document
the memory management policy that has to be followed in this file:
cleanup is not performed in the error paths, and all memory is freed at
the end of the do_llext_load() function, both in the case of error and of
successful loading.
As an improvement, the symbol table is not freed if the LLEXT log level
is set to debug, so that it can be used, for example, to inspect the
symbols of the loaded extension.
Signed-off-by: Luca Burelli <l.burelli@arduino.cc>
The recent llext_map_sections() rework changed the way debug messages
are output so that the names of most skipped sections are not printed
at all. This makes debugging harder since the section names are useful
to identify the contents at a glance.
Also print a few additional fields from the section header, and use 0x
prefixes for hex numbers.
Signed-off-by: Luca Burelli <l.burelli@arduino.cc>
First, do align the buffer. The slab code puts pointers in there and it
does not like it if those are not properly aligned.
And return the actual error code from k_mem_slab_alloc() even if errors
shouldn't happen (it did happen to me because of the above ... with
assertions disabled).
Signed-off-by: Nicolas Pitre <npitre@baylibre.com>
An architecture can indicate that it has an implementation for
the `arch_stack_walk()` function by selecting
`ARCH_HAS_STACKWALK`.
Set the default value of `EXCEPTION_STACK_TRACE_MAX_FRAMES` to
`ARCH_STACKWALK_MAX_FRAMES` if the latter is available.
Signed-off-by: Yong Cong Sin <ycsin@meta.com>
The design of the pipe is overly complicated compared to the
in-tree and planned future use of the pipe module.
The pipe is currently designed to protect against multiple
threads calling any API simultaineously. This is not neccesary
as only one thread ever calls open/close/transmit/receive at
once, while the notification APIs are potentially called by a
different thread.
This commit removes the synchronization of calls to the open/
close/receive/transmit APIs. It also uses a k_event for thread
safe event and state handling instead of a k_mutex and k_condvar.
The callback is proteced by a k_sem as it modified using the
attach/release APIs, which can be called simultaneously to a
thread invoking the callback.
Signed-off-by: Bjarki Arge Andreasen <bjarki@arge-andreasen.me>
Fix regression due to use of HAL_RADIO_TMR_START_DELAY_US
introduced in commit 11bae5cfa9 ("Bluetooth: Controller:
Fix missing radio timer comp and range delay").
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
The current implementation of the BAP Broadcast Assistant only supports a
single connection. This PR makes broadcast assistant support multiple BAP
scan delegators.
Fixes: #67523
Signed-off-by: Ping Wang <pinw@demant.com>
In case no Renewal/Rebinding times have been provided the server via
DHCP options, we should reset their values on ACK, so that the client
can recalculate the defaults. This is important, as the lease time may
change, so we should recalculate default T1/T2 timeout based on the new
lease time value.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
DHCP Request retransmission in RENEW and REBIND states was not
compliant with RFC2131.
The retransmission interval should not be calculated as in REQUESTING
state in such case, but rather calculated based on the remaining T2
or lease time (depending on current state).
RFC doesn't also mention any retransmission count limit for those
states. The client should retransmit the REQUEST until T2 or lease
expiry time are reached.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
Trying to start a chat script using either modem_chat_run_script()
or modem_chat_run_script_async() should result in returning -EBUSY
without affecting the currently running script and thread waiting
on the current script to stop.
The current behavior causes the thread waiting for the current
script to stop to return with error -EAGAIN, and the thread trying
to start the new script to return with error -EBUSY.
This commit moves the reset of the sem the current thread is
waiting on, to after the check of whether a script is currently
running, leaving the current thread unaffected as is intended.
Signed-off-by: Bjarki Arge Andreasen <bjarki@arge-andreasen.me>
The HCI command LE Read Supported States command returns
if the controller supports running the scanner and initiator
roles in parallel.
This commit utilizes this information in the host:
- It does not prevent initiating a connection when the scanner is
running
- It does not prevent the host from restarting the background
scanner when there the host wants to auto-initiate a connection.
- It does not stop the scanner when the host wants to auto-initiate
a connection.
To support this feature, the scanner and initiator
always have to use the same address.
This because the HCI command LE Set Random Address
cannot be issued after the initiator or scanner has started.
1. When privacy is disabled, the scanner has to use its identity
address to ensure it uses the same address as the initiator.
2. Only one identity is supported.
To simplify the implementation, it is a requirement to use
extended advertising commands to avoid interfering with
the random address used by the advertiser(s).
Also, it is a requirement to never use time-limited scanning,
as RPA this feature does not work when privacy is being used.
See https://github.com/zephyrproject-rtos/zephyr/issues/73634.
The changes in this commit will be tested out of tree as the
Zephyr Bluetooth Controller does not support this functionality.
Signed-off-by: Rubin Gerritsen <rubin.gerritsen@nordicsemi.no>
When creating a BAP broadcast source with bt_bap_broadcast_source_create
only the subgroup information is stored in the streams and the remaining
BIS specific information is not stored in the stream->codec_cfg,
which it should.
Fix is to store bis specific information also in stream codec config.
Updated broadcast source BSIM test to verify above usecase.
Signed-off-by: Nithin Ramesh Myliattil <niym@demant.com>
The polling properties are a period in us but are named as "-rate" right
now, which would imply that that's a frequency. Rename them to
"period-us" to make that unambiguous.
Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
Returning a status code will allow the application developer
to detect logic issues.
We consider this as not breaking the API.
If `-Werror -Wunused-result` is enabled, the application developer needs
to validate the return code.
Signed-off-by: Rubin Gerritsen <rubin.gerritsen@nordicsemi.no>
Callbacks can only be registered once. Otherwise the slist
will become circular.
In this commit we have choosen to ignore the second registration
call if the callback has already been registed. The alternative
is to trigger an assertion. That doesn't work if the assertions
are turned off.
Signed-off-by: Rubin Gerritsen <rubin.gerritsen@nordicsemi.no>
This allows us to use functionality provided by slist.
First use case: Avoid adding an element twice.
Signed-off-by: Rubin Gerritsen <rubin.gerritsen@nordicsemi.no>
Allow to protect the data part of each NVS item with a 32-bit CRC.
This uses 4 more bytes per NVS item.
Signed-off-by: Adrien Ricciardi <aricciardi@baylibre.com>
While forwarding a multicast packet decrement hop limit in a common net
buffer. Also, packets with hop limit equal to 0 should not be forwarded.
Signed-off-by: Konrad Derda <konrad.derda@nordicsemi.no>
Added a fallback parameter to
bt_audio_codec_cfg_meta_get_pref_context
as absence of pref context in BAP implicitly means a unspecified
for LC3.
In the case that it is absent BT_AUDIO_CONTEXT_TYPE_UNSPECIFIED
is the returned value.
While the metadata for codec cfg and codec cap are similar,
this only applies for codec cfg as per BAP.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Added a fallback parameter to
bt_audio_codec_cap_get_max_codec_frames_per_sdu
as absence of max codec frames per SDU in BAP implicitly
means a single frame for LC3.
In the case that it is absent 1 is the returned value.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Added a fallback parameter to
bt_audio_codec_cap_get_supported_audio_chan_counts
as absence of channel count in BAP implicitly means a single channel
for Lc3.
In the case that it is absent 1 is the returned value.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Added a fallback parameter to
bt_audio_codec_cfg_get_chan_allocation as absence of
channel allocation in BAP implicitly means Mono.
In the case that it is absent,
BT_AUDIO_LOCATION_MONO_AUDIO is the returned value.
This commit also fixes the implementation of
bt_audio_codec_cfg_get_frame_blocks_per_sdu as it only applies to
LC3 (as per the BAP spec). It also adds additional testing of it
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Adding network interface status monitor function. Depending
on the interface operation state and change of the state
events are generated and handled by the function.
Signed-off-by: Adam Wojasinski <awojasinski@baylibre.com>
This commit adds implementation of the PTP thread that will
poll sockets descriptors and PTP Port's timeres for timeouts,
generate events and handle them and trigger STATE_DECISION_EVENT
handling when needed.
Signed-off-by: Adam Wojasinski <awojasinski@baylibre.com>