Commit graph

21541 commits

Author SHA1 Message Date
Seppo Takalo
4d6372be93 net: lwm2m: Fix Notify response handling
As the CoAP library was refactored to handle response
messages as stated by RFC, the LwM2M message handling was
untouched.
LwM2M Notify handling is relying on response callback
to be called, but as per CoAP RFC an empty Ack is not
actually a response and the callback was not called anymore.

Fix the issue by calling the response callback when
we receive an empty ack for any confirmable response
messages.
This should not affect any handling of CoAP requests.

Signed-off-by: Seppo Takalo <seppo.takalo@nordicsemi.no>
2025-01-30 14:08:39 +01:00
Andrzej Głąbek
dff78b4813 bluetooth: host: Add select PSA_WANT_ALG_ECB_NO_PADDING
This is a follow-up to commit 12eee61533.

Explicitly enable "PSA_WANT_ALG_ECB_NO_PADDING" to select the AES ECB
mode that it is used in CMAC operation.

This is done because CMAC uses AES-ECB, so both AES and ECB must
be explicitly enabled. Previously it worked because Mbed TLS is
not currently performing any check internally on this and it's
just enabling ECB automatically.

Signed-off-by: Andrzej Głąbek <andrzej.glabek@nordicsemi.no>
2025-01-30 11:15:24 +01:00
Théo Battrel
972d4c7369 Bluetooth: Host: GAP Device Name write now add null char at the end
The function used to write the value of the GAP Device Name
characteristic now ensure that the string passed to `bt_set_name` is
null terminated.

Also fix a wrong offset calculation.

The function used to write the value of the GAP Device Name
characteristic was returning an error when the offset + the length of
data to write was superior **or equal** to the maximum size of the
device name.

This caused the actual maximum device name size to be reduced by 1 byte.

Signed-off-by: Théo Battrel <theo.battrel@nordicsemi.no>
2025-01-30 11:15:03 +01:00
Jukka Rissanen
d243bc1fdb net: Fix inet_pton IPv4 implementation
The conversion from IPv4 string presentation to numeric value
did not check if the individual address value was between 0 and 255
inclusive.

Add also test case for this.

Fixes #84593

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2025-01-29 17:56:09 +01:00
Emil Gydesen
21be69f172 Bluetooth: PACS: Fix issue with PACS flags
The PACS flags were incorrectly defined without
ATOMIC_DEFINE and then it treated the atomit_t as an
array with the atomic functions.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2025-01-29 15:13:29 +01:00
Jeremy Bettis
027e19fe1f ztest: Don't clear test stats before running suite
test_main can call ztest_run_all multiple times. For example
tests/bluetooth/host/keys/bt_keys_get_addr/src/main.c does so.  If the
first call skips some tests and then they run in the second call,
everything is fine. However if they passed or failed in the first run
and skipped in the second run, then the test output (json, xml, and
printed summary) show the test as skipped even though it ran.

The solution is to not clear the test stats.

__ztest_init_unit_test_result_for_suite was added in commit
996c8457d7 by nashif.

Signed-off-by: Jeremy Bettis <jbettis@google.com>
2025-01-29 15:12:51 +01:00
Fabio Baltieri
5a40e49cff usb: device_next: cdc_acm: move few constant data to flash
Add a config structure and move few pointers that don't need to change
into it, save few bytes of SRAM.

Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
2025-01-29 12:53:04 +01:00
Tim Sørensen
ff2605d23e Bluetooth: CTS: Incorrect assert in bt_cts_init()
Fixup for incorrect assert in CTS service
initialization function bt_cts_init().

Signed-off-by: Tim Sørensen <tims@demant.com>
2025-01-29 12:51:30 +01:00
Eric Holmberg
b952f613e7 net: wifi: shell: only process scan events during requested scan
The scan events are always enabled which means if another software
component requests a scan, then the WiFi shell scan printouts will
also be sent to the shell.

Only enable the network management scan events when a user has
requested a scan.

Signed-off-by: Eric Holmberg <eric.holmberg@northriversystems.co.nz>
2025-01-29 12:51:16 +01:00
Luca Burelli
f0328ddc80 llext: add option to import all global symbols
The new CONFIG_LLEXT_IMPORT_ALL_GLOBALS option allows all global symbols
from extensions to be used by the main application. This is useful to
load basic extensions that have been compiled without the full Zephyr
EDK.

Signed-off-by: Luca Burelli <l.burelli@arduino.cc>
2025-01-29 11:04:33 +01:00
Luca Burelli
ec52ed2c5d llext: shell: fix buffer alignment
Make sure the buffer used to load the hex file is aligned to a sensible
value; at least word size is assumed by the LLEXT APIs.

Signed-off-by: Luca Burelli <l.burelli@arduino.cc>
2025-01-29 11:04:33 +01:00
Luca Burelli
a62dc99178 llext: fix list_symbols shell command
The shell command 'llext list_symbols' currently iterates over the
'sym_tab' table. This is valid only inside 'llext_load' and is freed
before returning, so it will always be empty in shell context.

Fix it to display 'exp_tab', which is the one used at runtime by LLEXT
to provide symbols to the main application.

Signed-off-by: Luca Burelli <l.burelli@arduino.cc>
2025-01-29 11:04:33 +01:00
Oleh Kravchenko
ed15ff14d4 fb: cfb: Fix print of ASCII chars from 128 to 255
Change the "c" variable type from char to uint8_t in get_glyph_ptr() and
draw_char_vtmono() to fix issues with the range check of the "c" value.

The easiest way to print localized text with Zephyr is
to ask GCC for compile-time conversion:

  INCLUDE(${ZEPHYR_BASE}/cmake/cfb.cmake NO_POLICY_SCOPE)
    GENERATE_CFB_FONT_FOR_TARGET(app
    "${CMAKE_CURRENT_SOURCE_DIR}/fonts/koi8-u.png"
    "${ZEPHYR_BINARY_DIR}/include/generated/cfb_font_dice.h"
    8 16 --first 0 --last 255)

  TARGET_COMPILE_OPTIONS(app PRIVATE
    -finput-charset=UTF-8
    -fexec-charset=KOI8-U)

Signed-off-by: Oleh Kravchenko <oleg@kaa.org.ua>
2025-01-29 04:18:02 +01:00
Fabio Baltieri
e4752e5e11 net: dhcpv4_server: skip the DNS option if not configured
Check if NET_DHCPV4_SERVER_OPTION_DNS_ADDRESS is set before using it to
set the DNS option in DHCP responses. This avoids sending a client a DNS
server of 0.0.0.0.

Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
2025-01-29 04:17:36 +01:00
Fabio Baltieri
68b63d023b net: dhcpv4_server: allow skipping the router option
Add a Kconfig option to skip the router DHCP server option. This can be
useful to avoid having the client trying to forward all its traffic to
the embedded device.

Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
2025-01-29 04:17:36 +01:00
Chaitanya Tata
2019b7ba86 net: l2: ethernet: Fix interface state check
Modifying MAC address is allowed only when the interface is not
administratively UP, as it typically involves conveying the MAC address
to the chip firmware, and accepting the MAC address when interface is
administratively UP will not reflect in the actual usage.

So, modify the check to reject MAC address change if the interface is
administratively UP.

Fixes #81486.

Signed-off-by: Chaitanya Tata <Chaitanya.Tata@nordicsemi.no>
2025-01-29 04:17:21 +01:00
Johann Fischer
81dc390115 usb: device_next: add bulk transfers to loopback function
This allows us to use the testusb Linux kernel tool again. All tests
involving control and bulk transfers should pass. Additionally, add a
shell command that allows the user to manually enqueue bulk transfers.

Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
2025-01-29 04:16:42 +01:00
Jukka Rissanen
535e70a298 net: socket: Release packets in accepted socket in close
If we have received data to the accepted socket, then release
those before removing the accepted socket. This is a rare event
as it requires that we get multiple simultaneous connections
and there is a failure before the socket accept is called by
the application.
For example one such scenario is when HTTP server receives multiple
connection attempts at the same time, and the server poll fails
before socket accept is called. This leads to buffer leak as the
socket close is not called for the accepted socket because the
accepted is not yet created from application point of view.
The solution is to flush the received queue of the accepted socket
before removing the actual accepted socket.

Fixes #84538

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2025-01-28 18:24:39 +01:00
Matt Rodgers
ea6ca4e8b7 net: http_server: allow specifying a fallback resource
A _res_fallback parameter to HTTP_SERVICE_DEFINE is added to optionally
specify a fallback resource detail, which will be served if no other
resource matches the URL.

Signed-off-by: Matt Rodgers <mrodgers@witekio.com>
2025-01-28 18:14:36 +01:00
Maciej Baczmanski
341359568f openthread: fix logging configuration
Currently, `CONFIG_OPENTHREAD_LOG_LEVEL` is used to set log level
in OT and register log modules in Zephyr. OpenThread allows 5
levels, causing issues when `OPENTHREAD_LOG_LEVEL_DEBG` is
selected ad we are trying to register modules with unknown lvl.

This commit adds `CONFIG_OPENTHREAD_MODULE_LOG_LEVEL` which is
aligned for Zephyr's log levels.

Signed-off-by: Maciej Baczmanski <maciej.baczmanski@nordicsemi.no>
2025-01-28 14:13:31 +01:00
Joakim Andersson
8457db52c7 net: tls_credentials: Do not free slot when cred buf is NULL
Do not free the slot when cred buf is NULL.
If the TLS credential storage backend does not have a buffer pointer
to the TLS credential, then the buffer pointer can be NULL.
This may happen with an out-of-tree TLS credential storage backend.

In this case where credential buffer is NULL find_ref_slot retrieves
a new slot, and then tries to free it, causing a crash.

Signed-off-by: Joakim Andersson <joerchan@gmail.com>
2025-01-28 09:51:43 +01:00
Emil Gydesen
9688c2d43f Bluetooth: CCP: Initial CCP Client implemenation
Added initial CCP client implementation that simply
does discovery of TBS on a remote CCP server.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2025-01-28 09:46:39 +01:00
Johan Hedberg
8b356fd9fb Bluetooth: Host: Fix overwriting ECC error value
Jump straight to the exit portion of the function in the case that
psa_destroy_key() failed and we set err to a non-zero value. This also
fixes Coverity CID 487701 "Code maintainability issues  (UNUSED_VALUE)".

Signed-off-by: Johan Hedberg <johan.hedberg@silabs.com>
2025-01-28 00:06:06 +01:00
Frank Audun Kvamtrø
202c2c41ab secure storage: Add missing include for mbedtls_platform_zeroize
-Adding explicit include for mbedtls/platform_util.h to get acces
 to mbedtls_platform_zeroize in ITS. Somehow not visibile in Zephyr but
 it caused build issues in nRF Connect SDK.

Signed-off-by: Frank Audun Kvamtrø <frank.kvamtro@nordicsemi.no>
2025-01-27 21:04:20 +01:00
Johan Hedberg
3ae8a9cfe1 Bluetooth: Host: Remove leftover HCI ECC command checks
The code shouldn't be checking for HCI command support anymore, rather in
the case of debug keys we can just start immediately using them.

Fixes commit 09e86f3b69.

Signed-off-by: Johan Hedberg <johan.hedberg@silabs.com>
2025-01-27 13:26:40 +01:00
Valerio Setti
222f8d87b5 Bluetooth: Host: add PSA_WANT_xxx_IMPORT/EXPORT to BT_ECC
The BT Host module also uses import/export PSA functions alongside the
generate one, so these PSA_WANT should be added as well.

Previously it happened to work only because Mbed TLS is enabling
IMPORT/EXPORT internally whenever GENERATE/DERIVE is set. However the
same might not be true for all PSA Crypto providers.

Signed-off-by: Valerio Setti <vsetti@baylibre.com>
2025-01-27 11:07:07 +01:00
Luca Burelli
7094eae111 llext: support multiple string and symbol tables
The ELF format allows for multiple string and symbol tables with
complex references between them. This is especially evident when
debugging information is included.

This patch fixes the issues that have been identified with multiple
string tables to allow LLEXT to properly parse those files:

* The symbol table used by LLEXT (LLEXT_MEM_SYMTAB) is now chosen
  depending on the loaded file type, and other tables are ignored.
  This change is also applied to the SLID injection script.

* The LLEXT string table (LLEXT_MEM_SYMTAB) is now correctly identified
  by the symbol table reference, instead of picking the first one.

* VMA range checks only make sense for allocated sections.

Signed-off-by: Luca Burelli <l.burelli@arduino.cc>
2025-01-27 08:54:44 +01:00
Luca Burelli
61c61a5528 llext: display section addresses in gdb-compatible format
This patch adds a debug log message to display the addresses of the
sections in a format that can be used with the gdb 'add-symbol-file'
command to properly inform the debugger about the final addresses for
the loaded sections.

Signed-off-by: Luca Burelli <l.burelli@arduino.cc>
2025-01-27 08:54:44 +01:00
Luca Burelli
cf11ab4b0f llext: ignore relocations on non-allocated sections
When building an ELF file with debugging information, the compiler
places this data in sections that do not need to be loaded in memory for
the program to run. These sections are marked as "not allocated" in the
ELF section header, and can be safely ignored when loading the file.

This patch adds a check to the relocation processing code to skip
relocations acting on those non-allocated sections, allowing to load ELF
files with debugging information.

Signed-off-by: Luca Burelli <l.burelli@arduino.cc>
2025-01-27 08:54:44 +01:00
Krzysztof Chruściński
9b2532ab43 logging: frontends: stmesp: Fix logging single argument log twice
Macro was missing a break when single argument with non 32 bit
word argument was detect. Because of that, there were two
logging messages created for a single log entry.

Signed-off-by: Krzysztof Chruściński <krzysztof.chruscinski@nordicsemi.no>
2025-01-24 15:43:19 +01:00
Kamil Kasperczyk
2534dc14b9 net: Added configuring child timeouts on openthread start
Some time ago three Kconfigs dedicated for the child timeouts
configuration were added, but changing them does not apply when
using OpenThread libraries. Added setting these values using
openthread API on openthread start.

Signed-off-by: Kamil Kasperczyk <kamil.kasperczyk@nordicsemi.no>
2025-01-24 08:39:05 +01:00
Jeremy Bettis
7ff7420668 boards: Allow llvm toolchain for unit tests
llvm is just as good as host for unit tests.

Signed-off-by: Jeremy Bettis <jbettis@google.com>
2025-01-24 08:38:55 +01:00
Fabio Baltieri
b0791400f6 usb: device_next: cdc_acm: allow setting the interface description
Add a interface-name string for the CDC-ACM node, this allow setting a
string that is then set as iInterface, which can then be used downstream
in an udev rule such as:

SUBSYSTEM=="tty", ACTION=="add",
ATTRS{interface}=="my interface descriptor",
SYMLINK+="tty-my-device"

To create known aliases for these ports.

Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
2025-01-24 01:14:28 +01:00
Dominik Ermel
49f5598835 Bluetooth: Mesh: Improve logic for serving devices erase capabilities
The commit fixes issue where flash_area_flatten has been used where
code was only supposed to erase devices by hardware requirement prior
to write, by replacing the call with flash_area_erase and supporting
logic to select proper path.
There have been following Kconfig options added:
 - CONFIG_BT_MESH_BLOB_IO_FLASH_WITHOUT_ERASE
 - CONFIG_BT_MESH_BLOB_IO_FLASH_WITH_ERASE
that are available for user depending on devices in the system and allow
to turn off paths that are not used by BLOB IO; for example if user
never writes to device with erase CONFIG_BT_MESH_BLOB_IO_FLASH_WITH_ERASE
will disable the path.
Both Kconfig options are y by default and enable all paths.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2025-01-23 19:25:27 +01:00
Yong Cong Sin
085df8bd1e arch: remove z_arch_esf_t
The exception stack frame type `z_arch_esf_t` had been deprecated
since #73593 for 2 releases, it is not used in the kernel since, and
applications/drivers should have been updated to use the
`struct arch_esf` now, remove it.

Signed-off-by: Yong Cong Sin <ycsin@meta.com>
Signed-off-by: Yong Cong Sin <yongcong.sin@gmail.com>
2025-01-23 16:32:36 +01:00
Robert Lubos
21b71224ac net: ethernet: Remove L2 header stripping after TX
It seems that this change was solely added to address issues with old
TCP stack, which blindly queued packets intended for TX for potential
further retransmission, expecting that the packet would remain intact
during transmission.

I think this assumption was wrong, as it's natural that lower layers
append respective headers to the packet, and this "header stripping"
behavior was specific for Ethernet L2 only. If an upper layer expects
that the packet would need to be retransmitted at some point, it should
clone it instead.

Therefore, remove the L2 header stripping from the Ethernet L2 to avoid
any potential issues in zero-copy case.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2025-01-23 16:31:41 +01:00
Robert Lubos
78c3996b59 net: ethernet: Allow drivers to reserve net_pkt headroom
Add new Ethernet driver config option,
ETHERNET_CONFIG_TYPE_EXTRA_TX_PKT_HEADROOM, which allows Ethernet
drivers to inform L2 about the extra net_pkt headroom they need to be
allocated.
This is only supported when CONFIG_NET_L2_ETHERNET_RESERVE_HEADER is
enabled, so that it's possible to fit entire packet into a single
net_buf, which is needed for zero-copy transmission.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2025-01-23 16:31:41 +01:00
Robert Lubos
ea191bddaf net: pkt: Fix fixed buffer allocation with headroom bug
The size calculation for the first buffer, in case extra headroom is
requested, had a bug which could result in a size variable underflow
followed by net_buf exhaustion.

In case the net_buf size was larger than requested size, but smaller
than requested size + headroom, the whole buffer size was subtracted
from the requested size. This however did not take the extra headroom
into account and in effect could result in underflow.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2025-01-23 16:31:03 +01:00
Jakub Rzeszutko
b0a0febe58 shell: fix unsafe API calls and add configurable autoflush behavior
Fixes an issue where the shell API could block indefinitely when called
from threads other than the shell's processing thread, especially when
the transport (e.g. USB CDC ACM) was unavailable or inactive.

Replaced `k_mutex_lock` calls with an indefinite timeout (`K_FOREVER`)
by using a fixed timeout (`K_MSEC(SHELL_TX_MTX_TIMEOUT_MS)`) in shell
API functions to prevent indefinite blocking.

Link: https://github.com/zephyrproject-rtos/zephyr/issues/84274

Signed-off-by: Jakub Rzeszutko <jakub.rzeszutko@verkada.com>
2025-01-23 13:45:20 +01:00
Jakub Rzeszutko
8991b954bc shell: add Kconfig option for configurable autoflush behavior
Introduced a new Kconfig option `SHELL_PRINTF_AUTOFLUSH` to allow
configuring the autoflush behavior of shell printing functions.

Updated `Z_SHELL_FPRINTF_DEFINE` to use the
`CONFIG_SHELL_PRINTF_AUTOFLUSH` setting instead of hardcoding
the autoflush behavior to `true`.

Signed-off-by: Jakub Rzeszutko <jakub.rzeszutko@verkada.com>
2025-01-23 13:45:20 +01:00
Johan Hedberg
d3c8cb4b79 Bluetooth: Host: Remove prompt from BT_ECC
This option only exposes internal APIs, so there should be no need to allow
applications to set an explicit value. Instead, users of the API should
select it through Kconfig.

Signed-off-by: Johan Hedberg <johan.hedberg@silabs.com>
2025-01-23 10:14:46 +01:00
Johan Hedberg
09e86f3b69 Bluetooth: Host: Remove HCI ECC emulation
Remove the HCI command & event emulation layer for ECDH commands and
events. This means that we always do the necessary operations in the host.
The existing BT_ECC Kconfig option stays, but now gets automatically
enabled when necessary (e.g. based on the BT_SMP option), which is why this
commit removes so many explicit assignments in prj.conf files.

Signed-off-by: Johan Hedberg <johan.hedberg@silabs.com>
2025-01-23 10:14:46 +01:00
Vinayak Kariappa Chettimada
7573ac521d Bluetooth: Controller: Fix regression in Code PHY S2 Rx to any PHY Tx
Fix regression in Coded PHY S2 reception to any other PHY Tx
in the s/w switch implementation.

Regression in commit 55b7dba8ec ("Bluetooth: Controller:
Refactor sw_switch hal interface use").

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2025-01-23 05:23:39 +01:00
Chew Zeh Yang
d770a4c584 usbd: device_next: cdc: add option to enable short packet terminate
For usbser.sys driver, which is the default USB host driver for CDC
devices in windows, it is expected that USB device always indicate
completion of transmission by short packet. In case where the last
packet length is multiple of max packet size of the BULK IN endpoint,
the USB device shall indicate completion of transmission by sending a
zero length packet. This commit adds the sending of the short packet
termination mentioned above, ensuring condition of short packet
terminate is fulfilled.

Signed-off-by: Chew Zeh Yang <zeon.chew@ambiq.com>
2025-01-23 00:12:24 +01:00
Aleksandr Khromykh
a8e540c371 Bluetooth: Mesh: remove experimental flag from mbedtls support
Commit removes experimental flag from mbedtls psa
crypto library support.

Signed-off-by: Aleksandr Khromykh <aleksandr.khromykh@nordicsemi.no>
2025-01-22 18:32:51 +01:00
Alberto Escolar Piedras
196062580f Bluetooth: Controller: Use cracen entropy driver for 54L devices
Use the new entropy driver for 54L devices and therefore
claim BT_CTLR_ENTROPY_SUPPORT is always supported
(note 54H remains unsuported)

Signed-off-by: Alberto Escolar Piedras <alberto.escolar.piedras@nordicsemi.no>
2025-01-22 18:32:35 +01:00
Alberto Escolar Piedras
f4cdb0f07e boards nrf54l15bsim: Default to new cracen rng driver
Let's default to this new driver.
And therefore change the conditions in the BT controller kconfig
which were selecting the native_posix fake entropy driver

Signed-off-by: Alberto Escolar Piedras <alberto.escolar.piedras@nordicsemi.no>
2025-01-22 18:32:35 +01:00
Fredrik Danebjer
21b5f0c4fe Bluetooth: pacs: Add dynamic PACS registration
Added option to set the PACS Characteristics through the bap API,
making PACS configuration runtime available. Source and Sink PAC, as
well as Source/Sink PAC Location is can be set through a register
function in the PACS api.

Signed-off-by: Fredrik Danebjer <frdn@demant.com>
2025-01-22 15:49:50 +01:00
Luca Burelli
b0dbbb7782 device: add CONFIG_LLEXT_EXPORT_DEV_IDS_BY_HASH option
This new option allows to export devices using identifiers generated
from the hash of the devicetree node path, instead of the device's
ordinal number. Identifiers generated this way are stable across
rebuilds.

Add new test cases to test this new option.

Signed-off-by: Luca Burelli <l.burelli@arduino.cc>
2025-01-22 15:49:10 +01:00
Matt Rodgers
d1d85fa40b net: http_server: fix URL matching with '?' character in resource
Fixes #84198.

If a '?' character is used as part of a wildcard resource, do not treat
this as the end of the string when comparing with a path from the HTTP
request. Only the path from the HTTP request may be terminated by '?'
(in the case of a request with query parameters).

Signed-off-by: Matt Rodgers <mrodgers@witekio.com>
2025-01-22 13:44:01 +01:00