The commit adds FIXED_PARTITION(label) macro that allows to obtain
struct flash_area object for partition of given label.
The macro allows instantiation of partition at point of usage
and will be replacing need for defining flash map with all partition
entries.
Area obtained with the macro should not be passed to open, instead
flash_area_device_is_ready, basically equivalent of device_is_ready
should be called on the obtained pointer to check if area is ready
for use.
Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
Removes legacy configuration options. The same coverage is provided by
existing PSA_WANT_... selects.
Signed-off-by: Håvard Reierstad <haavard.reierstad@nordicsemi.no>
Application is expected to call usbd_uac2_send() on each enabled USB
Streaming Output Terminal (isochronous IN data endpoint) exactly once
every SOF. The class is bookkeeping queued transfers to make it easier
to determine component at fault when things go wrong. However, this
approach only works fine if the underlying USB device controller buffers
the data to be sent on next SOF and reports the transfer completion
immediately after data is buffered (e.g. nRF52 USBD).
While DWC2 otg also requires the SW to arm endpoint with data for the
next SOF, unlike nRF52 USBD the transfer is only considered complete
after either the IN token for isochronous endpoint is received or after
the Periodic Frame Interval elapses without IN token. This design
inevitably requires the application to be able to have at least two
buffers for isochronous IN endpoints.
Support dual buffering on IN data endpoints to facilitate sending
isochronous IN data on every SOF regardless of the underlying USB device
controller design.
Signed-off-by: Tomasz Moń <tomasz.mon@nordicsemi.no>
Sleeping in sysworkq is a very bad idea, it can trash any hope of
realtimeness at best, deadlock the whole system at worse.
Add a check to input_report to downgrade the event to K_NO_WAIT
automatically when called from the sysworkq, similarly to what's done by
other APIs (netbuf and bluetooth), though only log if messages are
actually dropped.
Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
Initializes the `net_idx` field of the ack context properly for KRP
functions in the Config Client.
This fixes a problem where `bt_mesh_cfg_cli_krp_get` and
`bt_mesh_cfg_cli_krp_set` would always fail the ack ctx comparison if
`key_net_idx` was != 0.
Signed-off-by: Ludvig Jordet <ludvig.jordet@nordicsemi.no>
When IPv4 address is added, currently the netmask remains empty. This
makes it impossible to use the address now that the netmask is
considered during address selection if the application does not
specify the netmask manually. Therefore specify a default netmask for
IPv4 addresses added to an interface with Kconfig.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
Bit-wise comparing of the entire IPv4 addresses doesn't make much sense
as when selecting the source address for communication, what really
matters is the subnet part.
Doing so may actually lead to unexpected results, i. e. two addresses
within the same subnet should be considered equally good for
communication within the subnet, yet comparing the unique part of
the address (beyond the netmask) may lead to different results.
This is a problem for the mechanism of preferring the default interface
for LL communication if two interfaces have LL addresses with the
default subnet mask.
Fix this by filtering out the subnet from the IPv4 address before
passing it to net_if_ipv4_get_best_match() function.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
Currently we blindly return the LL address found on the default
interface or else on the first interface that has a valid LL address
configured.
This doesn't work well, if different interfaces have LL addresses
configured with a different subnet mask. Therefore, instead of blindly
selecting the address based on the first LL address encountered, use
net_if_ipv4_get_best_match() function for LL addresses to find the best
match for the given interface.
The rework takes into account current behavior, i. e. default interface
still gets the preference if there is no better candidate.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
With recent changes the regulatory domain is handled via the hostap
rather than by passing and going through the driver and hostap doesn't
have any option for forcing the regulatory domain, so, add a note to
reflect that this is implementation dependent to cover both hostap as
well other offloaded implementations.
Signed-off-by: Chaitanya Tata <Chaitanya.Tata@nordicsemi.no>
The dns_unpack_answer() did not check the length of the message
properly which can cause out of bounds read.
Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
If the packet parsing fails in dns_unpack_response_query(), then
do not continue further but bail out early.
Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
As the error print strings are very similar, construct the final
output at runtime to save some flash space.
Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
Follow net coding style and remove extra new lines between
variable set and checking its value.
Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
We must do null check before trying to access the fields.
Fixes#81980
Coverify-CID: 434549
Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
Verify the result of the fs_read() operation when handling filesystem
resources, and abort processing the resource in case of errors.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
Reset the server timestamps after bootstrap to handle a case
where a new server instance has replaced the bootstrap server
instance.
Signed-off-by: Stig Bjørlykke <stig.bjorlykke@nordicsemi.no>
In case lwm2m_get_engine_obj_field() fails to find a corresponding
object field when iterating resource instances, simply skip that
resource instance when printing object instance contents.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
Support write OMA TLV resource instance in LwM2M 1.1.
Accept OMA TLV as default content format.
Signed-off-by: Stig Bjørlykke <stig.bjorlykke@nordicsemi.no>
The network interface name that is copied to if_req struct might
be missing terminating null for IPv4.
This is fixing the IPv4 issue which was missed in previous fix attempt.
Fixes#74795
Coverity-CID: 368797
Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
After the switch from TinyCrypt to PSA Crypto API as crypto
backend, runtime crashes might happen on some platform due
to BT_LONG_WQ's stack size not being large enough. This
commit fixes this issue.
Signed-off-by: Valerio Setti <vsetti@baylibre.com>
When BT_SEND_ECC_EMULATION and the platform uses Mbed TLS as PSA
Crypto provider, we select the Cortex-M software optimized
implementation of the secp256r1 curve algorithms. This is much
faster than the standard support provided by Mbed TLS and it
also reduces ROM footprint.
Signed-off-by: Valerio Setti <vsetti@baylibre.com>
This commits puts in order log messages when unpacking CDP0 and CDP1 so
that it a bit more clear where the error happens.
Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
This commit checks that config client doesn't pull out data outside of
the buffer.
Fixes#80012
Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
We need to drop the cloned packet that was fed to the bridge instead of
returning directly from the function. Without this change we have a
buffer leak.
Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
If the packet cloning failed, bail out in order to avoid
null pointer access.
Fixes#81992
Coverity-CID: 434493
Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
Coverity complains about uninitialized prohibited fields. Even though it
is not used because it is "prohibited", it is simpler to just
initialized it with the value received from a server.
Fixes#81939
Coverity-CID: 434649
Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
This moves GATT releated defines that are used by both Mesh Proxy
Service and Mesh Provisioning Service implementations to a common
header file.
Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
By default if CONFIG_BT_MESH_PROXY_USE_DEVICE_NAME
or CONFIG_BT_MESH_PB_GATT_USE_DEVICE_NAME is enabled, the mesh stack
will add BT_DATA_NAME_COMPLETE AD Type along with the Mesh Proxy Service
or Mesh Provisioning Service advertisements accordingly.
When BT_LE_ADV_OPT_USE_NAME was present and
CONFIG_BT_DEVICE_NAME_DYNAMIC is enabled, the advertised name was
automatically updated by the host. This turned out to be a side-effect
rather than expected behavior and after #71700 this behavior waa
changed.
But customers use dynamic name feature.
This commit makes the mesh stack use bt_get_name to get the device name,
which returns runtime name if CONFIG_BT_DEVICE_NAME_DYNAMIC is enabled.
Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
Since the TinyCrypt library is being deprecated in Zephyr, this
commit modified the dependencies of BT_RPA. Instead of selecting
TinyCrypt, it relies on BT_HOST_CRYPTO or BT_CTLR_CRYPTO. This
helps both in the deprecation process of TinyCrypt, but also this
is more correct dependency since these 2 symbols are extensively
used in the rpa.c source code.
Signed-off-by: Valerio Setti <vsetti@baylibre.com>
Since the TinyCrypt library is being deprecated in Zephyr, this
commit set TinyCrypt usage in BT mesh as deprecated and it sets
Mbed TLS PSA Crypto API as the default option (when TF-M is not
available).
Tests are also updated in this commit.
Signed-off-by: Valerio Setti <vsetti@baylibre.com>
This commit sets PSA Crypto API as the default library to perform
ECC-DH in HCI, replacing TinyCrypt (which is being deprecated).
Therefore the symbol BT_TINYCRYPT_ECC is renamed as BT_SEND_ECC_EMULATION.
References in samples/tests are also fixed.
Signed-off-by: Valerio Setti <vsetti@baylibre.com>
CONFIG_BT_USE_PSA_API was used in BT crypto/host modules to select
PSA crypto API over TinyCrypt (which was the default until now).
Since TinyCrypt is being deprecated and PSA crypto API is the new
standard library for crypto operations, CONFIG_BT_USE_PSA_API is
no more needed.
Signed-off-by: Valerio Setti <vsetti@baylibre.com>
The API documentation already states that the controller may require
the scan interval and window used for scanning and connection
establishment to be equal to obtain the best performance.
This commit prints out a warning when this is not the case. The code
size is unchanged when `CONFIG_BT_SCAN_AND_INITIATE_IN_PARALLEL=n`.
This makes application developers aware that using the parameters
`BT_LE_SCAN_ACTIVE_CONTINUOUS` with `BT_CONN_LE_CREATE_CONN` may not
give the best performance.
Signed-off-by: Rubin Gerritsen <rubin.gerritsen@nordicsemi.no>
Traditionally threads have been initialized with a PRESTART flag set,
which gets cleared when the thread runs for the first time via either
its timeout or the k_thread_start() API.
But if you think about it, this is no different, semantically, than
SUSPENDED: the thread is prevented from running until the flag is
cleared.
So unify the two. Start threads in the SUSPENDED state, point
everyone looking at the PRESTART bit to the SUSPENDED flag, and make
k_thread_start() be a synonym for k_thread_resume().
There is some mild code size savings from the eliminated duplication,
but the real win here is that we make space in the thread flags byte,
which had run out.
Signed-off-by: Andy Ross <andyross@google.com>