Commit graph

21541 commits

Author SHA1 Message Date
Dominik Ermel
984be5eb65 storage: flash map: Add FIXED_PARTITION(label) macro
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>
2024-12-02 09:43:00 +01:00
Håvard Reierstad
5a02aaa47e Bluetooth: Mesh: Trim _USES_MBEDTLS_PSA selects
Removes legacy configuration options. The same coverage is provided by
existing PSA_WANT_... selects.

Signed-off-by: Håvard Reierstad <haavard.reierstad@nordicsemi.no>
2024-12-02 09:42:45 +01:00
Steve Boylan
48b70cf180 net: ipv6: Fix unaligned access to IPv6 address
Add UNALIGNED_GET() to prevent alignment fault when
reading parts of the IPv6 address.

Signed-off-by: Steve Boylan <stephen.boylan@beechwoods.com>
2024-12-02 01:33:45 +01:00
Tomasz Moń
c19d34c5d3 usb: device_next: uac2: Double buffering on IN data endpoints
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>
2024-11-30 09:36:17 +01:00
Pieter De Gendt
e9e64bab35 drivers: bluetooth: hci: Place API into iterable section
Add wrapper DEVICE_API macro to all bt_hci_driver_api instances.

Signed-off-by: Pieter De Gendt <pieter.degendt@basalte.be>
2024-11-29 14:49:53 +01:00
Fabio Baltieri
3146a5552f input: prevent the caller from sleeping in sysworkq
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>
2024-11-29 14:49:43 +01:00
Ludvig Jordet
88f62a1a5e Bluetooth: Mesh: Fix cfg_cli KRP not working for key_net_idx != 0
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>
2024-11-29 14:49:34 +01:00
Chaitanya Tata
619cdb64f4 wifi: Fix current PHY rate handling
Fix the name to include TX and also add units to the shell display.

Signed-off-by: Chaitanya Tata <Chaitanya.Tata@nordicsemi.no>
2024-11-29 11:45:58 +01:00
Robert Lubos
a32d339c34 net: ipv4: Specify default netmask for IPv4 addresses registered
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>
2024-11-29 11:44:39 +01:00
Robert Lubos
68241fb1e2 net: ipv4: Filter the subnet part of the IPv4 addr when choosing src
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>
2024-11-29 11:44:39 +01:00
Robert Lubos
a909b538dc net: ipv4: Rework source address matching for LL addresses
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>
2024-11-29 11:44:39 +01:00
Chaitanya Tata
9762c32115 wifi: Update help/notes for forcing regulatory domain
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>
2024-11-29 05:42:03 +01:00
Jukka Rissanen
6e7fcff579 net: dns: Check DNS answer properly
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>
2024-11-28 20:52:20 +01:00
Jukka Rissanen
43c2b9cfe8 net: dns: Validate source buffer length properly
Make sure that when copying the qname, the source buffer is large
enough for the data.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2024-11-28 20:52:20 +01:00
Jukka Rissanen
eb2550a441 net: dns: Check parsing error properly for response
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>
2024-11-28 20:52:20 +01:00
Jukka Rissanen
3c59bd4fb5 net: wifi_cred: Decrease flash usage for error print strings
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>
2024-11-28 20:52:06 +01:00
Jukka Rissanen
8deebcec21 net: wifi_cred: Remove extra empty lines
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>
2024-11-28 20:52:06 +01:00
Jukka Rissanen
b2056e0966 net: wifi_cred: Introduce variables at the start of function
Follow the net coding style and declare the variables at the start
of the function.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2024-11-28 20:52:06 +01:00
Jukka Rissanen
3aa0c8670e net: wifi_cred: Check null before access
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>
2024-11-28 20:52:06 +01:00
Johann Fischer
1a5ab2c16e usb: device_next: fix null pointer dereference in Get Interface
Respond with a Request Error in default and addressed states.

Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
2024-11-28 15:43:56 +00:00
Robert Lubos
df79f10513 net: lib: http_server: Verify fs_read result for filesystem resources
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>
2024-11-28 15:43:32 +00:00
Stig Bjørlykke
95333705e5 net: lwm2m: Reset server timestamps after bootstrap
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>
2024-11-28 15:43:18 +00:00
Robert Lubos
35820f23f6 net: lwm2m: Add missing NULL pointer check in shell
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>
2024-11-28 15:43:04 +00:00
Stig Bjørlykke
48de0fcd73 net: lwm2m: Fix index for default disabled_until
Use correct index to set disabled_until default value in
server_create().

Signed-off-by: Stig Bjørlykke <stig.bjorlykke@nordicsemi.no>
2024-11-28 15:42:54 +00:00
Stig Bjørlykke
633269a913 net: lwm2m: Accept OMA TLV in LwM2M 1.1
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>
2024-11-28 15:42:42 +00:00
Jukka Rissanen
3bd4000712 net: dns: mdns_responder: Interface name might miss terminating null
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>
2024-11-28 15:42:32 +00:00
Jukka Rissanen
bf091fc909 net: ipv6: Check return value from mbedtls_md_setup
Bail out if mbedtls_md_setup() returns an error.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2024-11-28 15:42:08 +00:00
Jukka Rissanen
26d033b790 net: ipv6_pe: Check return value from mbedtls_md_setup
Bail out if mbedtls_md_setup() returns an error.

Fixes #81950
Coverify-CID: 434626

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2024-11-28 15:42:08 +00:00
Stig Bjørlykke
7d20d3a28c net: lwm2m: Make BinaryAppDataContainer instances configurable
Add Kconfig variables for BinaryAppDataContainer instance count
and data instance count.

Signed-off-by: Stig Bjørlykke <stig.bjorlykke@nordicsemi.no>
2024-11-28 15:41:52 +00:00
Valerio Setti
3bf9a14f98 Bluetooth: Host: increase BT_LONG_WQ stack size when using ECC emulation
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>
2024-11-28 15:38:57 +00:00
Valerio Setti
5790de6d6a Bluetooth: Host: use P256-M in ECC emulation
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>
2024-11-28 15:38:57 +00:00
Ravi Dondaputi
11dae0e9eb net: l2: wifi: Add checks for cert header creation
Execute certificate headers creation rules only if Wi-Fi Enterprise mode
is enabled.

Signed-off-by: Ravi Dondaputi <ravi.dondaputi@nordicsemi.no>
2024-11-28 12:52:34 +01:00
Pavel Vasilyev
1eeee010bd bluetooth: mesh: cfg_cli: Update logs when pulling out CDP0 and 1
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>
2024-11-28 12:50:58 +01:00
Pavel Vasilyev
e2a0fafe42 bluetooth: mesh: cfg_cli: Check buf len when pulling out data
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>
2024-11-28 12:50:58 +01:00
Jukka Rissanen
c6a1af5c17 net: ethernet: bridge: Drop the cloned packet in error
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>
2024-11-28 12:50:36 +01:00
Jukka Rissanen
ed0dcca2fb net: ethernet: bridge: Avoid null pointer access
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>
2024-11-28 12:50:36 +01:00
Pavel Vasilyev
2041682900 bluetooth: mesh: brg_cfg_cli: Initialize prohibited value
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>
2024-11-28 09:43:48 +01:00
Jamie McCrae
5437ded36c mgmt: mcumgr: grp: img_mgmt: Fix misplaced #endif
Fixes a misplaced endif which wrongly excluded functions

Signed-off-by: Jamie McCrae <spam@helper3000.net>
2024-11-28 09:38:49 +01:00
Pavel Vasilyev
f5409bd3de bluetooth: mesh: proxy_msg: Fix extracting role from k_work
Fix extracting role from k_work.
Hot fix for #78914

Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
2024-11-27 22:51:40 -05:00
Pavel Vasilyev
684c94e469 bluetooth: mesh: gatt: Move generic GATT related defines to gatt.h
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>
2024-11-27 22:51:29 -05:00
Pavel Vasilyev
ab346a1dd0 bluetooth: mesh: Use bt_get_name to get device name
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>
2024-11-27 22:51:29 -05:00
Valerio Setti
1b672491f1 bt: change dependencies for BT_RPA
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>
2024-11-27 16:40:47 -05:00
Valerio Setti
0f4875b7d0 bt-mesh: deprecate BT_MESH_USES_TINYCRYPT
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>
2024-11-27 16:40:47 -05:00
Valerio Setti
f4592382bb bt: use PSA for HCI ECC and rename BT_TINYCRYPT_ECC
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>
2024-11-27 16:40:47 -05:00
Valerio Setti
da9ab6f593 bt: crypto/host: remove CONFIG_BT_USE_PSA_API symbol
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>
2024-11-27 16:40:47 -05:00
Rubin Gerritsen
56a22cbccb Bluetooth: Host: Log when connecting while scanning may give bad params
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>
2024-11-27 10:38:27 -05:00
Andy Ross
7cdf40541b kernel/sched: Eliminate PRESTART thread state
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>
2024-11-27 10:38:05 -05:00
Jamel Arbi
70add85f9f drivers: openthread: nxp: Add a HDLC RCP communication
Add a HDLC RCP communication with its hdlc_api interface APIs
and a NXP driver.

Signed-off-by: Jamel Arbi <jamel.arbi@nxp.com>
2024-11-27 10:37:21 -05:00
Dominik Ermel
69b3ccf061 Revert "storage: flash map: Add FIXED_PARTITION(label) macro"
This reverts commit 1f1dc372cd.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2024-11-27 10:36:55 -05:00
Dominik Ermel
75a881313f Revert "storage: flash map: Add flash_area_sectors"
This reverts commit b50dc43a26.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2024-11-27 10:36:55 -05:00