Commit graph

18755 commits

Author SHA1 Message Date
Georges Oates_Larsen 875755fbb2 net: conn_mgr: Track ready count ephemerally
Instead of incrementing and decrementing global counter,
just recompute the ready-count from scratch every time
conn_mgr_mon_handle_update is called.

This will simplify the introduction of additional ready count types.

This should have no externally observable impact on the behavior of
conn_mgr.

Signed-off-by: Georges Oates_Larsen <georges.larsen@nordicsemi.no>
2024-06-10 00:59:34 -07:00
Robert Lubos 3501d6e6d4 net: shell: ipv4: Add information about ACD
Print information in IPv4 shell whether address conflict detection is
enabled or not.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2024-06-10 00:59:28 -07:00
Robert Lubos c0161c8052 net: l2: ethernet: arp: Simplify ACD case
In case of ACD Probe/Announcement, all we need is to generate ARP
packet, we don't really want any cache entries to be created or searched
for. There was a bug, that a cache entry was created for the
Announcement sent, resulting in skipped ARP packet generation and
malformed packet being sent by the ACD module.

Therefore, simplify all this, by simply returning early in case of
conflict detection packets.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2024-06-10 00:59:28 -07:00
Robert Lubos cc53826cc9 net: ipv4: autoconf: Integrate with the ACD module
The autoconf module can now reuse generic address conflict detection,
which was added for all address types.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2024-06-10 00:59:28 -07:00
Robert Lubos 80339ac4ee net: dhcpv4: Add support for conflict detection
In case a conflict was detected on a DHCP-assigned address, send a
Decline message to the server and start over.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2024-06-10 00:59:28 -07:00
Robert Lubos 7352aaa841 net: config: Add support for IPv4 ACD
In case IPv4 conflict detection is enabled, monitor network events to
determine whether IPv4 address is ready to use or not, so that the
library returns only after the network setup is fully complete.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2024-06-10 00:59:28 -07:00
Robert Lubos c281db0f7e net: conn_mgr: Add support for ACD events
Connection manager needs to monitor ACD events as well to determine
whether a preferred IPv4 address is available.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2024-06-10 00:59:28 -07:00
Robert Lubos a89dd1a6f6 net: shell: Add ACD events to the event monitor
Include new ACD events in the shell event monitor.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2024-06-10 00:59:28 -07:00
Robert Lubos 0a95423421 net: ipv4: Implement IPv4 address conflict detection
Add support for IPv4 conflict detection, as specified in RFC 5227.
The new feature is optional and disabled by default.

Address conflict detection was implemented as a part of the IPv4
autoconf feature can be generalized to be available for all address
types.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2024-06-10 00:59:28 -07:00
Rodrigo Peixoto 453ab8a9a3 zbus: vded: msg_sub: Improve channel ref copy
The VDED was adding the channel information per clone. But it could be
done in the original buffer. This commit fixes that by adding the
channel information to the original buffer and not for each clone. As a
result, we have a more straightforward VDED execution with fewer copies.

Signed-off-by: Rodrigo Peixoto <rodrigopex@gmail.com>
2024-06-09 09:07:21 -05:00
Flavio Ceolin 73b755d817 pm: Add a symbol for device power state constraints
Add a symbol to enable device power state constraints this
saves resources when this feature is not needed.

Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
2024-06-07 19:06:23 -04:00
Flavio Ceolin 02a14d75fc pm: Declare pm state constraints for a device
Declare power state constraints for a device in devicetree.
It allows a map between device instances and power states that disable
their power. This information is used by a new API
(pm_policy_device_power_lock_put/get) that automically set/release
pm state constraints.

Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
2024-06-07 19:06:23 -04:00
Daniel DeGrasse 7981ea0056 fs: fat_fs: make IOCTL call to de-initialize disk in fatfs_unmount()
Make call to de-initialize disk in fatfs_unmount(). This will permit the
disk to be reinitialized when it is mounted with fatfs_mount().

Signed-off-by: Daniel DeGrasse <daniel.degrasse@nxp.com>
2024-06-07 18:16:01 +01:00
Daniel DeGrasse d18cbb60b2 drivers: disk: add DISK_IOCTL_CTRL_DEINIT command to supported IOCTLs
Add DISK_IOCTL_CTRL_DEINIT ioctl command to disk subsystem. When
disk_access_ioctl() is called with this command, the disk will be
de-initialized. After this IOCTL completes, the disk can safely be
reinitialized.

Fixes #60628

Signed-off-by: Daniel DeGrasse <daniel.degrasse@nxp.com>
2024-06-07 18:16:01 +01:00
Daniel DeGrasse fb2d5c338b drivers: disk: add DISK_IOCTL_CTRL_INIT macro to initialize a disk
Add DISK_IOCTL_CTRL_INIT IOCTL to initialize a disk. This IOCTL is
intended to replace disk_access_init() for new applications, but
disk_access_init() is kept for legacy compatibility. The INIT IOCTL is
added to better match the path that will be used for disk
de-initialization. Like the disk_access_init() calls,
DISK_IOCTL_CTRL_INIT calls are reference counted

Signed-off-by: Daniel DeGrasse <daniel.degrasse@nxp.com>
2024-06-07 18:16:01 +01:00
Daniel DeGrasse 3386a43a51 disk_access: reference count initialization calls for disks
Reference count initialization calls for disks. This changes the
behavior of the disk_access_init() function, such that disks will no
longer be initialized again if the first disk access init call
succeeds.

Disk access is reference counted in preparation for supporting disk
de-initialization, where a balanced number of disk de-initialization
calls with disk initialization calls will de-initialize the disk.

Also, remove code in disk drivers that was already checking against
duplicate disk_access_init() calls.

Signed-off-by: Daniel DeGrasse <daniel.degrasse@nxp.com>
2024-06-07 18:16:01 +01:00
Krzysztof Chruściński 8f3989412f testsuite: ztest: ztress: Add missing static keywords
Add static to local timers definition.

Signed-off-by: Krzysztof Chruściński <krzysztof.chruscinski@nordicsemi.no>
2024-06-07 18:08:22 +01:00
Luca Burelli 1a2f6ae381 llext: refact: move ELF loading and linking to separate files
This commit moves ELF loading and linking code to separate files. This
is done to make the code more manageable and to make it easier to add
new features in the future.

No functional changes are introduced by this commit, except for a few
static functions now made public to allow this file split to occur.

Signed-off-by: Luca Burelli <l.burelli@arduino.cc>
2024-06-07 18:07:53 +01:00
Luca Burelli 9c5412f79e llext: refact: move memory code to llext_mem.c
Move all memory management code to a separate file, llext_mem.c, to
allow for better separation of concerns and to make the code more
readable.

No functional changes are introduced by this commit.

Signed-off-by: Luca Burelli <l.burelli@arduino.cc>
2024-06-07 18:07:53 +01:00
Luca Burelli 35ef089cb1 llext: move basic ELF checks to llext_load_elf_data()
This patch moves the initial checks performed on the ELF file, that were
split between llext_load() and do_llext_load(), to the newly defined
llext_load_elf_data() function.

This way:

- only one function deals with ELF internal data checks;
- do_llext_load() is reduced to a list of tasks;
- llext_load() only focuses on the extension management.

One totally misplaced line initializing the number of symbols has been
moved to llext_count_export_syms().

No functional change except that the `struct llext` allocation may be
performed unnecessarily if the ELF file is not valid.

Signed-off-by: Luca Burelli <l.burelli@arduino.cc>
2024-06-07 18:07:53 +01:00
Luca Burelli cefeae0048 llext: add llext heap management functions
Add llext_alloc(), llext_aligned_alloc() and llext_free() wrapper
functions to manage memory allocation and deallocation from the llext
heap. Also add a helper to free all memory regions allocated by an
extension.

Signed-off-by: Luca Burelli <l.burelli@arduino.cc>
2024-06-07 18:07:53 +01:00
Alberto Escolar Piedras 510e1ba6af Bluetooth: Controller: Treat nrf54l15bsim like a real platform
Use the compatible kconfig option so that for the simulated
nRF54L15 we build the same code as for the real platform.

Signed-off-by: Alberto Escolar Piedras <alberto.escolar.piedras@nordicsemi.no>
2024-06-07 18:07:48 +01:00
Alberto Escolar Piedras a3218b0de5 Bluetooth: Controller: Fix BT_CTLR_DATA_LEN_UPDATE_SUPPORT selection
For the Nordic HW, the BT_CTLR_DATA_LEN_UPDATE_SUPPORT
does not require CCM HW enabled, hence support Data Length
Update if Encryption Support is disabled.

Signed-off-by: Alberto Escolar Piedras <alberto.escolar.piedras@nordicsemi.no>
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2024-06-07 18:07:48 +01:00
Alberto Escolar Piedras 35773882c2 Bluetooth: Controller: Use HAL to modify renamed registers in nRF54
In some nRF54 devices, DATAWHITEIV was renamed to
DATAWHITE,
and the CRCCNF SKIADDR field was renamed OFFSET.
The nrf HAL hid this change internally,
so let's use it so we don't need to ifdef these
in the Bluetooth Controller HAL code.

Signed-off-by: Alberto Escolar Piedras <alberto.escolar.piedras@nordicsemi.no>
2024-06-07 18:07:48 +01:00
Vinayak Kariappa Chettimada f59c3fafe8 Bluetooth: Controller: Preliminary support for nRF54L15 SoC
Add preliminary support for nRF54L15 SoC. This commit does
not support Controller Random Number Generation and
Controller Cryptography (AES-128 encryption) commands, nor
does it support encrypted connections.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2024-06-07 18:07:48 +01:00
Vinayak Kariappa Chettimada 0bbbef3a8c Bluetooth: Controller: Use NRF_RTC and RADIO_SHORTS_TRX_END_DISABLE_Msk
Use NRF_RTC and NRF_RADIO_SHORTS_TRX_END_DISABLE_Msk instead
to prepare towards using configurable use of RTC and Radio
hardware defines.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2024-06-07 18:07:48 +01:00
Vinayak Kariappa Chettimada d6f2bc9669 Bluetooth: Controller: Add explicit LLCP error code check
Add unit tests to cover explicit LLCP error code check and
cover the same in the Controller implementation.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2024-06-07 18:07:48 +01:00
Vinayak Kariappa Chettimada 78466c8f52 Bluetooth: Controller: Use BT_HCI_ERR_UNSPECIFIED as needed
A Host shall consider any error code that it does not
explicitly understand equivalent to the error code
Unspecified Error (0x1F).

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2024-06-07 18:07:48 +01:00
Vinayak Kariappa Chettimada fe205a598e Bluetooth: Controller: Refactor BT_CTLR_LE_ENC implementation
Refactor reused function in BT_CTLR_LE_ENC feature.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2024-06-07 18:07:48 +01:00
Vinayak Kariappa Chettimada 2d49080cb8 Bluetooth: Controller: Fix BT_CTLR_LE_ENC conditional compilation
Fix BT_CTLR_LE_ENC conditional compilation when feature is
disabled.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2024-06-07 18:07:48 +01:00
Vinayak Kariappa Chettimada a66baa1101 Bluetooth: Controller: Introduce BT_CTLR_CRYPTO_SUPPORT
Introduce BT_CTLR_CRYPTO_SUPPORT so that preliminary port to
support nRF54L15 SoC can be upstreamed without encryption
support.

ENTROPY_GENERATOR now selected when BT_CTLR_CRYPTO enabled.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2024-06-07 18:07:48 +01:00
Vinayak Kariappa Chettimada 073e627e3b Bluetooth: Controller: Fix ENTROPY_NRF5_RNG conditional compile
Fix ENTROPY_NRF5_RNG conditional compile when not enabled.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2024-06-07 18:07:48 +01:00
Fin Maaß e1246ccb65 mgmt: hawkbit: some Kconfig improvements
some hawkbit Kconfig improvements.

Signed-off-by: Fin Maaß <f.maass@vogl-electronic.com>
2024-06-07 18:06:45 +01:00
Siddharth Chandrasekaran 45085ba647 mgmt/osdp: cp: disallow unexpected SC responses
When CP has a secure channel active, it should never receive a
REPLY_CCRYPT or REPLY_RMAC_I. Since these responses change the SC state,
let's also make sure that they are accepted only when they are
expected: in response to commands CMD_CHLNG and CMD_SCRYPT respectively.

Reported-by: Eran Jacob <eran.jacob@otorio.com>
Signed-off-by: Siddharth Chandrasekaran <sidcha.dev@gmail.com>
2024-06-07 16:47:55 +03:00
Sean Madigan 0b327db097 Bluetooth: Add support for Path Loss Monitoring feature
This commit adds host support for the Path Loss Monitoring
feature see Bluetooth Core specification, Version 5.4,
Vol 6, Part B, Section 4.6.32.

Limited logic is required, just adding a wrapper around the
HCI command and callback for HCI event.

Add new zone - BT_CONN_LE_PATH_LOSS_ZONE_UNAVAILABLE, to
convert 0xFF path loss to a useful zone.

Add new Kconfigs and functionality to the bt shell.

Signed-off-by: Sean Madigan <sean.madigan@nordicsemi.no>
2024-06-07 15:04:11 +02:00
Emil Gydesen 5c9032019c Bluetooth: CAP: Fix linker issue in cap_stream.c for x86
The existing code in the cap_stream.c that handled the
check before calling CAP initiator unicast functions
seemingly did not work for x86 targets such as native_sim
or native_posix.

Modified the check so that IS_ENABLED is used directly.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2024-06-07 13:01:13 +02:00
Pisit Sawangvonganan aca97a0bef fs: fcb: refactor fcb_get_len() for improved readability
Introduced temporary variables `buf0_xor` and `buf1_xor` to store
XOR results and added an explicit cast to `uint16_t` for
the `*len` variable.

Signed-off-by: Pisit Sawangvonganan <pisit@ndrsolution.com>
2024-06-07 09:53:56 +02:00
Pisit Sawangvonganan 06177833d8 fs: fcb: correct FCB_MAX_LEN boundary condition
Correct the boundary condition in `fcb_put_len` function to
properly include `FCB_MAX_LEN` and change the #define to address
the potential flaw where `CHAR_MAX` might be treated as unsigned by
the compiler flag `-funsigned-char`, which would yield `FCB_MAX_LEN`
to 0x7fff instead of 0x3fff.

Fixes #73868

Signed-off-by: Pisit Sawangvonganan <pisit@ndrsolution.com>
2024-06-07 09:53:56 +02:00
Tom Burdick 87fc25afc1 sensing: Fix build warning on invalid array index
The assert was verifying that the current sensor address was greater
or equal than the start of the iterable section - 1 which isn't quite
right as the start is inclusive.

Signed-off-by: Tom Burdick <thomas.burdick@intel.com>
2024-06-07 09:52:09 +02:00
Jordan Yates dc5f27395f testsuite: add dependency to COVERAGE_GCOV_HEAP_SIZE
Add missing dependency on `COVERAGE_GCOV` to prevent the symbol from
appearing in every application.

Signed-off-by: Jordan Yates <jordan@embeint.com>
2024-06-06 20:07:20 -04:00
Tom Burdick d95caa51a4 sys: Add a lockfree mpsc and spsc queues
Moves the rtio_ prefixed lockfree queues to sys alongside existing
mpsc/spsc pbuf, ringbuf, and similar queue-like data structures.

Signed-off-by: Tom Burdick <thomas.burdick@intel.com>
2024-06-06 00:42:29 -07:00
Balaji Srinivasan 16fc8f5295 task_wdt: Feed hardware watchdog only when its started
Previously the schedule_next_timeout() function was feeding the hardware
watchdog irrespective of whether or not it was started. This is now
fixed.

Signed-off-by: Balaji Srinivasan <balaji.srinivasan@nordicsemi.no>
2024-06-06 00:40:53 -07:00
Anas Nashif 584a99f6ab tracing: add missing calls for k_wakeup/k_thread_user_mode_enter
Add missing hooks for k_wakeup/k_thread_user_mode_enter to CTF backend.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2024-06-05 17:38:22 -05:00
Alberto Escolar Piedras c9491a818f Bluetooth: Controller: Correct power levels for bsim targets
The simulated targets support the same power levels as the
real targets. Let's correct the kconfig dependencies
accordingly.

Signed-off-by: Alberto Escolar Piedras <alberto.escolar.piedras@nordicsemi.no>
2024-06-05 17:36:57 -05:00
Seppo Takalo d3081e2f30 net: lwm2m: On write, use server selected block size
When we receive CoAP packets, it is in input buffer
that is size of NET_IPV6_MTU.
So in reality, we can handle bigger Block-Wise writes
than CONFIG_LWM2M_COAP_BLOCK_SIZE.

So if parsing of CoAP packet has passed, continue
with the same block-size instead of going to default.

Signed-off-by: Seppo Takalo <seppo.takalo@nordicsemi.no>
2024-06-05 14:43:14 +01:00
Yong Cong Sin 3cb2c04fc1 subsys/debug: relocate symtab Kconfig
Move the symtab Kcofig into the symtab folder.

Signed-off-by: Yong Cong Sin <ycsin@meta.com>
2024-06-04 22:36:51 -04:00
Yong Cong Sin 9d9576b442 subsys/debug: relocate gdbstub stuff into its folder
Move the gdbstub files into the gdbstub folder, and relocated
its Kconfig as well.

Signed-off-by: Yong Cong Sin <ycsin@meta.com>
2024-06-04 22:36:51 -04:00
Flavio Ceolin 1c2e988021 pm: device: De-couple device pm from system pm
PM_DEVICE is not attached to system managed device power management.
It is a very common use case targets with device runtime power
management that don't want system device power management enabled.

We introduce a new symbol (PM_DEVICE_SYSTEM_MANAGED) to explicit
control whether or not system device power management should be
globally enabled.

Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
2024-06-04 19:13:53 -04:00
Flavio Ceolin c65be0cfb9 pm: Exclude device pm path when it is not needed
Remove device pm path when there is no is no power state in DT with
device pm enabled. This basically does the same thing that was done
by PM_DEVICE_RUNTIME_EXCLUSIVE.

Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
2024-06-04 19:13:53 -04:00
Flavio Ceolin 2f99ff51cc pm: Disable device pm per power state
Make it possible to disble device power management individually per
power state.  This allows targets tuning which states should
(and which should not) trigger device power management.

Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
2024-06-04 19:13:53 -04:00
Flavio Ceolin 94af630b22 pm: Deprecate PM_DEVICE_RUNTIME_EXCLUSIVE
That is option has shown confusing on it is attempt to prevent
system pm doing device power management. Lets address this
problem properly.

Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
2024-06-04 19:13:53 -04:00
Chris Friedt 0fa97326c7 posix: create kconfig options for pse51, pse52, pse53
Create Kconfig "shortcuts" for PSE51, PSE52, and PSE53.

Signed-off-by: Chris Friedt <cfriedt@tenstorrent.com>
2024-06-04 16:27:12 -05:00
Chris Friedt 487a8756c3 posix: eventfd: fix dependency cycle between net and posix
Until recently, the posix api was purely a consumer of the
network subsystem. However, a dependency cycle was added as
a stop-gap solution for challenges with the native platform.

Specifically,

1. eventfd symbols conflict with those of the host
2. eventfd was excluded from native libc builds via cmake

If any part of the posix were then to select the network
subsystem (which is a legitimate use case, given that networking
is a part of the posix api), we would get a build error due to
the Kconfig dependency cycle.

As usual, with dependency cycles, the cycle can be broken
via a third, mutual dependency.

What is the third mutual dependency? Naturally, it is ZVFS
which was planned some time ago. ZVFS will be where we
collect file-descriptor and FILE-pointer APIs so that we can
ensure consistency for Zephyr users.

This change deprecates EVENTFD_MAX in favour of
ZVFS_EVENTFD_MAX.

Signed-off-by: Chris Friedt <cfriedt@tenstorrent.com>
2024-06-04 16:27:12 -05:00
Chris Friedt 2bc722a97e posix: deprecate POSIX_FNMATCH GETOPT GETENTROPY
The functions fnmatch(), getopt(), getentropy()
and others are grouped into the standard Option Group
POSIX_C_LIB_EXT.

The getentropy() function is currently in-draft for
Issue 8 as of 2021.

https://www.opengroup.org/austin/docs/austin_1110.pdf

Not surprisingly, the POSIX_C_LIB_EXT Option Group
also includes the highly debated strnlen() function.

Moving that function will be deferred until later.

Signed-off-by: Chris Friedt <cfriedt@tenstorrent.com>
2024-06-04 16:27:12 -05:00
Chris Friedt bc4374b5fe posix: deprecate POSIX_MAX_FDS and add POSIX_DEVICE_IO
The POSIX_MAX_FDS option does not correspond to any standard
POSIX option. It was used to define the size of the file
descriptor table, which is by no means exclusively used by
POSIX (also net, fs, ...).

POSIX_MAX_FDS is being deprecated in order to ensure that
Zephyr's POSIX Kconfig variables correspond to those defined in
the specification, as of IEEE 1003.1-2017. Namely,
POSIX_OPEN_MAX. CONFIG_POSIX_MAX_OPEN_FILES is being deprecated
for the same reason.

To mitigate any possible layering violations, that option is
not user selectable. It tracks the newly added
CONFIG_ZVFS_OPEN_MAX option, which is native to Zephyr.

With this deprecation, we introduce the following Kconfig
options that map directly to standard POSIX Option Groups by
simply removing "CONFIG_":

* CONFIG_POSIX_DEVICE_IO

Similarly, with this deprecation, we introduce the following
Kconfig options that map directly to standard POSIX Options by
simply removing "CONFIG":

* CONFIG_POSIX_OPEN_MAX

In order to maintain parity with the current feature set, we
introduce the following Kconfig options.

* CONFIG_POSIX_DEVICE_IO_ALIAS_CLOSE
* CONFIG_POSIX_DEVICE_IO_ALIAS_OPEN
* CONFIG_POSIX_DEVICE_IO_ALIAS_READ
* CONFIG_POSIX_DEVICE_IO_ALIAS_WRITE

Gate open(), close(), read(), and write() via the
CONFIG_POSIX_DEVICE_IO Kconfig option and move
implementations into device_io.c, to be conformant with the
spec.

Lastly, stage function names for upcoming ZVFS work, to be
completed as part of the LTSv3 Roadmap (e.g. zvfs_open(), ..).

Signed-off-by: Chris Friedt <cfriedt@tenstorrent.com>
2024-06-04 16:27:12 -05:00
Chris Friedt 4a5c4e5f73 posix: timers: deprecate CONFIG_POSIX_CLOCK and TIMER
The POSIX_CLOCK option does not correspond to any standard
option. It was used to active features of several distinct
POSIX Options and Option Groups, which complicated API and
application configuration as a result.

POSIX_CLOCK is being deprecated in order to ensure that Zephyr's
POSIX Kconfig variables correspond to those defined in the
specification, as of IEEE 1003.1-2017.

Additionally, CONFIG_TIMER is being deprecated because it does
not match the corresponding POSIX Option (_POSIX_TIMERS).

With this deprecation, we introduce the following Kconfig
options that map directly to standard POSIX Option Groups by
simply removing "CONFIG_":

* CONFIG_POSIX_TIMERS

Similarly, we introduce the following Kconfig options that
map directly to standard POSIX Options by simply removing
"CONFIG":

* CONFIG_POSIX_CLOCK_SELECTION
* CONFIG_POSIX_CPUTIME
* CONFIG_POSIX_DELAYTIMER_MAX
* CONFIG_POSIX_MONOTONIC_CLOCK
* CONFIG_POSIX_TIMEOUTS
* CONFIG_POSIX_TIMER_MAX

In order to maintain parity with the current feature set, we
introduce the following Kconfig options that map directly to
standard POSIX Option Groups by simply removing "CONFIG_":

* CONFIG_POSIX_MULTI_PROCESS - sleep()

Similarly, in order to maintain parity with the current feature
set, we introduce the following additional Kconfig options that
map directly to standard POSIX Options by simply removing
"CONFIG":

* CONFIG_XSI_SINGLE_PROCESS - gettimeofday()

Signed-off-by: Chris Friedt <cfriedt@tenstorrent.com>
2024-06-04 16:27:12 -05:00
Yong Cong Sin e54b27b967 arch: define struct arch_esf and deprecate z_arch_esf_t
Make `struct arch_esf` compulsory for all architectures by
declaring it in the `arch_interface.h` header.

After this commit, the named struct `z_arch_esf_t` is only used
internally to generate offsets, and is slated to be removed
from the `arch_interface.h` header in the future.

Signed-off-by: Yong Cong Sin <ycsin@meta.com>
2024-06-04 14:02:51 -05:00
Yong Cong Sin 3998e18ec4 arch: rename all esf struct to struct arch_esf
Rename every architecture's esf struct to `struct esf`.

Signed-off-by: Yong Cong Sin <ycsin@meta.com>
2024-06-04 14:02:51 -05:00
Anders Storrø cee8080117 Bluetooth: Mesh: Fix PB GATT adv name
Fixes issue where PB GATT Server will drop
advertising device name if optional provisioning
URI is not provided.

Signed-off-by: Anders Storrø <anders.storro@nordicsemi.no>
2024-06-04 05:18:28 -07:00
Vivekananda Uppunda ca19e6bbaa net: wifi_shell: Resolve filter settings mismatch
The control and data settings are set improperly for packet filter
operation for sniffer operation. The change sets them properly.

Signed-off-by: Vivekananda Uppunda <vivekananda.uppunda@nordicsemi.no>
2024-06-04 13:46:37 +02:00
Emil Gydesen ebadb11645 Bluetooth: Audio: Spring cleaning
Adds, removes and modifies includes in all LE audio
files.

Fixes any found spelling mistakes as well.

Fixes a few places where incorrect types were used.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2024-06-04 13:37:53 +02:00
Jens Rehhoff Thomsen 06bb9f258a Bluetooth: BAP: Shell: Add endpoint state info
The bap list command now also shows the states of each endpoint.

Fixes #70838

Signed-off-by: Jens Rehhoff Thomsen <jthm@demant.com>
2024-06-04 13:37:39 +02:00
Luca Burelli 709b2e44bf llext: automatically merge sections by type
This patch changes the way sections are mapped to memories. Instead of
looking at the section name, each section in the ELF file is mapped to
the llext_mem enum by looking at the section type and flags.

This allows for a more generic mapping that works for both the ARM and
Xtensa cases, and also allows for sections to be merged if they are
contiguous and non-overlapping in the ELF file.

This patch also fixes a number of corner cases, such as in the logging
test where a section with read-only data was being ignored (not copied
and not relinked).

Signed-off-by: Luca Burelli <l.burelli@arduino.cc>
2024-06-04 13:37:22 +02:00
Dominik Ermel c4c7e15ba1 dfu/mcuboot: Use flash_area_flatten instead of flash_area_erase
The invocation of flash_area_erase, in boot_erase_img_bank,
has been replaced by flash_area_flatten.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2024-06-04 08:00:46 +02:00
Dominik Ermel bce06a64c4 mgmt/mcumgr: Replace use of flash_area_erase with flash_area_flatten
The commit replaces flash_area_erase with flash_area_flatten.
The function is used in to places:
 1) in image management commands IMG_MGMT_ID_UPLOAD
    and IMG_MGMT_ID_ERASE: to erase an image in secondary slot
    or to scramble trailer part of image, which could be misunderstood
    by MCUboot as valid image operation request;
 2) in command ZEPHYR_MGMT_GRP_BASIC_CMD_ERASE_STORAGE to
    erase/scramble data partition.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2024-06-04 08:00:46 +02:00
Dominik Ermel 95dfd1210d storage/stream_flash: Support for devices without explicit erase
Support for devices not requiring erase with Stream Flash API.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2024-06-04 08:00:46 +02:00
Dominik Ermel bf7d25117a fs/nvs: Switch to use flash_flatten instead of flash_erase
The NVS currently requires explict erase capability of
a device to work, so usage of flash_erase has been replaced
with flash_flatten.
There has been additional LOG_WRN added to warn user that
NVS may not efficiently work with device that do not really
have erase.

Currently NVS relies on devices that require erase.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2024-06-04 08:00:46 +02:00
Dominik Ermel 64ccfb0479 fs/fcb: Replace flash_area_erase with flash_area_flatten
FCB depends on explicit erase characteristics of a device.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2024-06-04 08:00:46 +02:00
Dominik Ermel 9da26eda5e fs/littlefs: Use flash_area_flatten in lfs_api_erase
LittleFS is based on program-erase devices and require that
characteristics to work; the commit replaces flash_area_erase
with flash_area_flatten to allow LFS work on devices that
do not provide erase callback.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2024-06-04 08:00:46 +02:00
Dominik Ermel 743d66a7e5 debug/coredump/flash_backend: Switch to flash_area_flatten
Replace usage of flash_area_erase with flash_area_flatten to
allow code to work with devices that do not provide erase
callback.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2024-06-04 08:00:46 +02:00
Dominik Ermel def4f060c1 storage/settings: Replace flash_area_erase with flash_area_flatten
Replace flash_area_erase with flash_area_flatten to allow FCB
Settings backend to work on devices that do not provide erase
callback.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2024-06-04 08:00:46 +02:00
Dominik Ermel 5da7df4e7c Bluetooth: Mesh: Switch erase to flash_area_flatten
The flash_area_erase has been replaced with flash_area_flatten,
allowing code to work with devices that do not provide
erase callback.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2024-06-04 08:00:46 +02:00
Dominik Ermel a5f7ceff81 storage/flash_map: Add flash_area_flatten
Add equivalent of flash_erase, from Flash API, to Flash Map API;
idea is the same: function tries to erase area if driver provides
erase function, otherwise writes erase_value across the defined
area.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2024-06-04 08:00:46 +02:00
Johann Fischer af63e488f0 usb: device_next: hid: fix Get Report buffer handling
After the get_report() callback, we need to determine how many bytes the
HID device wrote to the report buffer. Use the callback return value to
do this, and modify the net_buf data length value if get_report was
successful.

Reported-by: Marek Pieta <Marek.Pieta@nordicsemi.no>
Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
2024-06-04 07:56:45 +02:00
alperen sener c93859c659 bluetooth: mesh: fix lpn receive window timing error
APIs for enabling and disabling the scanner may take larger time than
expected and scheduling of the lpn state machine is affected by it.
Since these type of latencies are factored into timeouts and scheduling
times, we need to call scan enable/disable APIs after scheduling the
next event time for LPN state machine to be more accurate.

Signed-off-by: alperen sener <alperen.sener@nordicsemi.no>
2024-06-04 07:55:59 +02:00
Marek Pieta 059643062c usb: device_next: Update remote wakeup log level
The `Remote wakeup feature not enabled or not suspended` log is not
related to an actual error (connected host might not enable USB remote
wakeup feature). Use warning log level.

Signed-off-by: Marek Pieta <Marek.Pieta@nordicsemi.no>
2024-06-04 07:55:22 +02:00
Valerio Setti 4fc6506a8a random: enable AES support CTR_DRBG CSPRNG when it relies on Mbed TLS
PR #72475 disabled default enabling of many Mbed TLS features
including AES. This means that now it must be explicitly added
when required.

Signed-off-by: Valerio Setti <vsetti@baylibre.com>
2024-06-03 16:13:05 -04:00
Hess Nathan aaec285cd5 coding guidelines: comply with MISRA Rule 12.1.
-added parentheses verifying lack of ambiguities

Signed-off-by: Hess Nathan <nhess@baumer.com>
2024-06-03 16:10:33 -04:00
Mathieu Choplain 8aa6ae43ce llext: add support for SLID-based linking
This commit introduces support for an alternate linking method in the
LLEXT subsystem, called "SLID" (short for Symbol Link Identifier),
enabled by the CONFIG_LLEXT_EXPORT_BUILTINS_BY_SLID Kconfig option.

SLID-based linking uses a unique identifier (integer) to identify
exported symbols, instead of using the symbol name as done currently.
This approach provides several benefits:
 * linking is faster because the comparison operation to determine
   whether we found the correct symbol in the export table is now an
   integer compare, instead of a string compare
 * binary size is reduced as symbol names can be dropped from the binary
 * confidentiality is improved as a side-effect, as symbol names are no
   longer present in the binary

Signed-off-by: Mathieu Choplain <mathieu.choplain@st.com>
2024-06-03 15:29:34 -04:00
Joel Guittet 05ad2565fa llext: add _POSIX_C_SOURCE definition to build shell
Fix implicit-function-declaration warning while building the llext shell.

Signed-off-by: Joel Guittet <joelguittet@gmail.com>
2024-06-03 15:28:33 -04:00
Emil Gydesen 92002b2dff Bluetooth: CAP: Implement bt_cap_initiator_unregister_cb
Implement function to unregisterd the CAP initiator callbacks.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2024-06-03 15:28:05 -04:00
Tomasz Moń 8d344cc9d8 usb: device_next: Rename usbd_contex to usbd_context
Add the missing "t" to struct usbd_contex. No functional changes.

Signed-off-by: Tomasz Moń <tomasz.mon@nordicsemi.no>
2024-06-03 06:43:20 -07:00
Emil Gydesen d2fbeffaa9 Bluetooth: BAP: Unicast client Split start and connect
Removes the CIS connection establishment from bt_bap_stream_start
and move the behavior to a new funciton bt_bap_stream_connect.

This has 2 advantages:
1) The behavior of bt_bap_stream_start is much more clear and more aligned
with the spec's behavior for the receiver start ready opcode.
2) It is possible to connect streams in both the enabling
and the QoS configured state with bt_bap_stream_connect as
per the spec. This allows us to pass additional PTS test cases.

To implement this new behavior, samples and tests have been updated.

The CAP Initiator implementation has also been updated
to accomodate for the change in BAP, but the CAP
initiator implementation should work the same for application, except
that it's now possible to do unicast start on ASEs in any order
(https://github.com/zephyrproject-rtos/zephyr/issues/72138).

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2024-06-03 15:42:33 +02:00
Rubin Gerritsen 3609d97c95 Bluetooth: Document reasons for HCI command timeouts
When reading the error message:
"ASSERTION_FAIL: command opcode 0x0c03 timeout with err -11" it may not be
obvious what is wrong with their setup unless you are very familiar
with HCI.

This commit adds some more documentation to make this more obvious.

Signed-off-by: Rubin Gerritsen <rubin.gerritsen@nordicsemi.no>
2024-06-03 15:39:23 +02:00
Jukka Rissanen a124dd2596 net: http_server: Send chunked response correctly
The chunked response was not sent properly. There were extra
"\r\n" before the chunk lenght and the length of the string
to be sent was calculated incorrectly.

Fixes #72887

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2024-06-03 15:39:09 +02:00
Tomasz Moń a1afd349a1 usb: device_next: initialize BOS device caps number
Explicitly initialize bNumDeviceCaps to 0 because the bos descriptor is
stored on stack.

Fixes: b0d7d70834 ("usb: device_next: add initial BOS support")
Coverity-CID: 368798

Signed-off-by: Tomasz Moń <tomasz.mon@nordicsemi.no>
2024-06-03 15:38:23 +02:00
Seppo Takalo 9e615429d5 net: lwm2m: Block-Wise response NUM field fix
When calculating the offset for blockwise writes,
we should not advance the block_ctx->current field
past the block boundary.
It causes CoAP layer to reply with the next NUM field
instead of the current one being processed.

Signed-off-by: Seppo Takalo <seppo.takalo@nordicsemi.no>
2024-06-03 15:37:21 +02:00
Jordan Yates 924db97724 usb: cdc_acm: add locks around ring_buf_put
The ring buffer API is explicitly not thread safe, with users needing to
implement their own locking. As `poll_out` and `fifo_fill` are operating
on the same ringbuffer, these locks are needed.

Signed-off-by: Jordan Yates <jordan@embeint.com>
2024-06-03 03:44:45 -07:00
Emil Gydesen 1af717430a Bluetooth: CAP: Do not require CAS unless necessary
Removes the requirement that CAS is found on the remove
device for ad-hoc sets. This makes the CAP API more
versatile as it allows applications to use it with
remote non-CAP devices.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2024-06-03 03:39:07 -07:00
Yong Cong Sin 02770ad963 debug: EXCEPTION_STACK_TRACE should depend on arch Kconfigs
Fix the dependencies of `CONFIG_EXCEPTION_STACK_TRACE`:
- Architecture-specific Kconfig, i.e.
  `X86_EXCEPTION_STACK_TRACE`, will be enabled automatically
  when all the dependencies are met.
- `EXCEPTION_STACK_TRACE` depends on architecture-specific
  Kconfig to be enabled.
- The stack trace implementations should be compiled only if
  user enables `CONFIG_EXCEPTION_STACK_TRACE`.

Signed-off-by: Yong Cong Sin <ycsin@meta.com>
2024-06-03 03:02:04 -07:00
Yong Cong Sin 8a5823b474 debug: remove !OMIT_FRAME_POINTER from EXCEPTION_STACK_TRACE
Not all stack trace implementation requires frame pointer, move
that dependency to architecture Kconfig.

Signed-off-by: Yong Cong Sin <ycsin@meta.com>
2024-06-03 03:02:04 -07:00
Yong Cong Sin 413b1cf409 debug: remove DEBUG_INFO from EXCEPTION_STACK_TRACE
The `DEBUG_INFO` in the `EXCEPTION_STACK_TRACE` is only
required by x86. Move that to `X86_EXCEPTION_STACK_TRACE`
instead.

Signed-off-by: Yong Cong Sin <ycsin@meta.com>
2024-06-03 03:02:04 -07:00
Yong Cong Sin 1570ef2863 debug: remove PRINTK from EXCEPTION_STACK_TRACE
The `PRINTK` was required for `EXCEPTION_STACK_TRACE` because
it's initial implementation for x86 in #6653 uses `printk()`.
We are using `LOG_ERR()` now, so this is not required anymore.

Signed-off-by: Yong Cong Sin <ycsin@meta.com>
2024-06-03 03:02:04 -07:00
Valerio Setti a15af0be9f mbedtls: fix Mbed TLS Kconfig options
PR #72475 disabled default enabling of most Mbed TLS features.
This means that:

- CONFIG_MBEDTLS_CIPHER_AES_ENABLED needs to be manually enabled
  when required;
- CONFIG_PSA_WANT_KEY_TYPE_RSA_KEY_PAIR_BASIC does not need to
  be (almost) always added because there is no default RSA
  key-exchange enabled, so PSA can be built without RSA support.

Signed-off-by: Valerio Setti <vsetti@baylibre.com>
2024-06-03 09:55:58 +02:00
Jukka Rissanen b95821f809 net: dns: llmnr_responder: Print query type properly
Instead of printing either A or AAAA resource query type,
print the correct query type value.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2024-06-03 09:49:01 +02:00
Jukka Rissanen b305be037c net: Start socket service thread by net core init
Do not depend on init level but start the socket service
already in net core init because DNS init code depends on
socket service API to be ready to serve. And we call DNS
init at the net core init.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2024-06-03 09:49:01 +02:00
Jukka Rissanen 1eb4a709e8 net: dns: Allow using resolver and responder at the same time
Allow mDNS resolver and responder to to be used at the same
time so that both can use the port 5353. This requires
a DNS traffic dispatcher which affects also the normal DNS
resolver.

Fixes #72553

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2024-06-03 09:49:01 +02:00
Jukka Rissanen 63e6a83510 net: dns: Add helper for figuring out the query type
Add helper function that returns the name of the query type
so that we can print it.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2024-06-03 09:49:01 +02:00
Jukka Rissanen 434e290649 net: dns: Add ANY query resource type
Don't give an error for ANY type record.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2024-06-03 09:49:01 +02:00
Emil Gydesen f93b9dee5c Bluetooth: CSIP: Make set_member_by_conn a public function
The function is useful for application to lookup set
members from bt_conn pointers, e.g. when iterating on
connected devices.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2024-06-03 09:48:48 +02:00
Fengming Ye 4f8c2e8f58 net: conn: fix supplicant l2 recv unexpected frame
Supplicant create AF_PACKET proto ETH_P_PAE socket but receive other
frames like ICMP, UDP and causes following issues.
1. When frame len exceeds MTU, net_pkt_clone cannot clone pkt.
   Thus dropped it and print warning log.
2. It will lower throughput performance as every packet is cloned.

Fix it by conn_raw_socket does not deliver pkts protocol not macted,
after l2 processed, unless conn is all packets.

Signed-off-by: Fengming Ye <frank.ye@nxp.com>
2024-06-03 09:48:32 +02:00
Mathieu Choplain a07d493c9d llext: relocate all symbols regardless of type
In the current implementation, the LLEXT linker will only apply
relocations targeting a given symbol if it has a specfic symbol type.
This is overzealous and causes issues on some platforms, as some symbols
that need to be relocated are skipped due to being of a "bad" type.

Ignore the symbol type when performing relocation to solve this problem,
but also add checks to ensure we don't attempt to relocate symbols with
an invalid section index. If such a relocation is found, return an error
instead of ignoring the relocation entry to ensure that it is impossible
to execute code from a (partially) unrelocated LLEXT.

Also remove all hacks added to circumvent this issue:
* qemu_cortex_r5 exclusion from test cases
* unnecessary exclusion of some flags when building with LLEXT EDK

Fixes #72832.

Signed-off-by: Mathieu Choplain <mathieu.choplain@st.com>
2024-05-31 16:38:09 -05:00
Tomi Fontanilles c1342b3aa9 modules: mbedtls: remove the default enabling of features
In an effort to shave off code size, remove out-of-the-box
enabling of crypto features (except SHA-256).

Configurations are adjusted to enable what they need.

Bonuses:

- When enabled, AES now defaults to using a smaller version
(`CONFIG_MBEDTLS_AES_ROM_TABLES` isn't default enabled anymore,
and if enabled, `CONFIG_MBEDTLS_AES_FEWER_TABLES` defaults to y).

- Conditions around Mbed TLS Kconfig options have been improved
to reflect the reality of the dependencies.

Signed-off-by: Tomi Fontanilles <tomi.fontanilles@nordicsemi.no>
2024-05-31 16:33:06 -05:00
Robert Lubos 8a808c40cc net: if: Remove redundant ifdef slicing
Some IPv4/IPv6 functions were ifdef-sliced internally, despite being
compiled in conditionally in top-level #ifdef block under the same
condition.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2024-05-31 09:58:59 -05:00
Robert Lubos c84444b681 net: if: Improve ifdef blocks matching
In some cases the comment after #endif did not match the opening #if, in
some cases it was missing.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2024-05-31 09:58:59 -05:00
Jukka Rissanen 08dc8f93fe net: http_server: Add wildcard support to resource strings
Allow user to specify resource string using wildcard characters
so that multiple URL paths can be served with just one handler.

Fixes #73367

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2024-05-31 09:57:22 -05:00
Patrick Patel 131a0fad04 Bluetooth: host: Update id.c to support id rst/del for CONFIG_BT_SMP=n
Currently calls to these two functions fail unnecessarily when
CONFIG_BT_SMP is disabled. This fix allows identity resets
without having the BT_SMP stack enabled. The primary use case
is enabling random mac address rotation for privacy in memory
constrained SOCs. Fixes #73313

Signed-off-by: Patrick Patel <ppatel@micro-design.com>
2024-05-31 09:55:06 -05:00
Vinayak Kariappa Chettimada 4b6d3f1e16 Bluetooth: Controller: Fix missing conn update ind PDU validation
Fix missing validation of Connection Update Ind PDU. Ignore
invalid connection update parameters and force a silent
local connection termination.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2024-05-31 04:39:34 -07:00
Kai Vehmanen 6509b8199b shell: add shell backend for audio DSP using shared memory window
Add a new shell backend implemented over a shared memory window
on the Intel audio DSPs. The implementation uses the Zephyr winstream
to manage the data streaming.

Signed-off-by: Kai Vehmanen <kai.vehmanen@linux.intel.com>
2024-05-31 08:07:03 +02:00
RAJAGOPALAN GANGADHARAN 65c4ca1f05 fs: open: Add Truncate flag to zfs open
This commit has added new flag FS_O_TRUNC to support truncation
during file open. Modified fs_open to handle truncation based on
provided flags. Included unit tests for flag behavior with common
filesystems.

Signed-off-by: RAJAGOPALAN GANGADHARAN <g.raju2000@gmail.com>
2024-05-31 08:06:05 +02:00
Emil Gydesen 6b6107ccd1 Bluetooth: Audio: Rename set_sirk to just sirk
The S in SIRK is for set, so set_sirk was effectively
"set set".

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2024-05-31 08:05:24 +02:00
Yong Cong Sin 13a5c8aad7 debug: symtab: fix linking issue due to variable redefinition
Employs the same linkonce magic of sw_isr_table to fix the
multiple definition of the symtab variables issue that I
get in my application build that doesn't use `west`.

Signed-off-by: Yong Cong Sin <ycsin@meta.com>
2024-05-30 16:52:01 -05:00
Yong Cong Sin 043f595279 debug: symtab: rename start_addr to first_addr
`start_addr` is the address of the first symbol, rename it to
`first_addr` instead as it seems more intuitive and relatable
to the comments.

Signed-off-by: Yong Cong Sin <ycsin@meta.com>
2024-05-30 16:52:01 -05:00
Yong Cong Sin f5934de8e5 build: symtab: Add a dummy entry at the end for the binary search
The `symtab_find_symbol_name()` is using an adapted binary
search function to get the entry between 2 addresses, we need
to add a dummy entry at the end so that the search function
can remain simple and straightforward without doing
out-of-bound checks:

   20  \
       |
       |
   50  x
       |
       |
   90  x
    .  |
    .  |
    .  |
dummy  /

Signed-off-by: Yong Cong Sin <ycsin@meta.com>
2024-05-30 16:52:01 -05:00
Emil Gydesen 6ed90f65a5 Bluetooth: Audio: Remove empty Kconfig.bass
The kconfig file is empty.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2024-05-30 16:49:06 -05:00
Emil Gydesen c57c857f9b Bluetooth: CAP: Add check for member in common_get_client
The function did not check if `member` was NULL before
dereferencing it.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2024-05-30 16:47:04 -05:00
Andries Kruithof b5ecb21447 Bluetooth: CAP: shell: add command for broadcast reception start
A shell command has been added for the new CAP procedure
'broadcast_reception_start'

Signed-off-by: Andries Kruithof <andries.kruithof@nordicsemi.no>
2024-05-30 16:44:17 -05:00
Guennadi Liakhovetski 518a712db0 llext: zero is a valid relocation offset
Zero offset in a relocation entry is valid, shouldn't ignore it.

Signed-off-by: Guennadi Liakhovetski <guennadi.liakhovetski@linux.intel.com>
2024-05-30 09:50:17 -05:00
Guennadi Liakhovetski 946fd3fda2 llext: (cosmetic) fix a misplaced space and re-use a variable
Use an existing variable instead of re-calculating and fix swapped
space and a paranthesis.

Signed-off-by: Guennadi Liakhovetski <guennadi.liakhovetski@linux.intel.com>
2024-05-30 09:50:17 -05:00
Guennadi Liakhovetski ebde53904d llext: fix handling of non-standard sections in relocatable case
When building partially linked / relocatable objects no ELF segments
are created and it becomes more difficult to predict which sections
the compiler will build and use. In this case a .data.rel.local
section is created by the compiler and it is needed to link .rodata
strings in a twister test. We can handle arbitrary sections at run-
time if .peek() is supported. If it isn't we need to allocate and
copy the section. For now we simply error out in such cases. Fixing
that would represent a larger change and can be done incrementally.

This also fixes the relocation calculation to point to the correct
symbol address instead of the memory location, where it's currently
residing, because that can be a temporary buffer as is the case with
SOF.

Signed-off-by: Guennadi Liakhovetski <guennadi.liakhovetski@linux.intel.com>
2024-05-30 09:50:17 -05:00
Emil Gydesen 3537c4614b Bluetooth: CAP: Shell: Fix minors bugs with unicast_stop
The cap_initiator unicast_stop shell command had the wrong
minimum parameter count (as it defaults to all).

Some indentation had also gone wrong for it in the
documentation.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2024-05-30 04:08:37 -07:00
Kapil Bhatt 8a52b64875 net: shell: Add random MAC address generation
Add option for setting a random MAC address to
the net iface set_mac command. With random option
a random MAC address can be assigned to an interface.

Signed-off-by: Kapil Bhatt <kapil.bhatt@nordicsemi.no>
2024-05-30 11:55:27 +01:00
Yong Cong Sin c87dc641bc arch: generalize frame pointer via CONFIG_FRAME_POINTER introduction
Enabling `CONFIG_FRAME_POINTER` allows the users to build the
kernel with frame-pointer.

Signed-off-by: Yong Cong Sin <ycsin@meta.com>
2024-05-30 03:00:40 -07:00
Tom Burdick d2ccc91d7d sensors: Add a blocking sensor_read call
Rename the current sensor_read to sensor_read_async_pool and create a
new blocking sensor_read helper.

Signed-off-by: Tom Burdick <thomas.burdick@intel.com>
2024-05-30 09:00:43 +02:00
Johan Hedberg f48a57b2a8 Bluetooth: drivers: Remove unmaintained B91 HCI driver
The driver isn't currently buildable due to "west blobs" support never
having been added for hal_telink. Furthermore, even if the blob
dependency is manually made available it turns out the code has
bitrotten to the point where it doesn't build anymore. This situation
has continued for several years without anyone taking action, so I think
it's safe to assume this is unmaintained and should be removed.

Signed-off-by: Johan Hedberg <johan.hedberg@gmail.com>
2024-05-30 09:00:22 +02:00
Jukka Rissanen 99693bee5f net: socket: Change the protocol field for AF_PACKET sockets
In order to be compatible with Linux AF_PACKET socket calls, the
protocol field needs to be in network byte order.
So for example, if user wants to receive all packets, then the
protocol field needs to be set as "htons(ETH_P_ALL)".
See Linux manual page at
https://www.man7.org/linux/man-pages/man7/packet.7.html
for details.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2024-05-29 10:48:34 -07:00
Seppo Takalo b76683e4cb net: lwm2m: Allow setting RD context without starting
When tests control the LwM2M client entirely through
shell, we should be able to set the RD client context
from the application without causing RD client to
start registration.

Signed-off-by: Seppo Takalo <seppo.takalo@nordicsemi.no>
2024-05-29 10:47:57 -07:00
Ajay Parida 91054be051 net: wifi: shell: Correction to connect command default case
For default case it should print the option character provided by user.
Extra shell_help removed as it's being called in the caller function.

Signed-off-by: Ajay Parida <ajay.parida@nordicsemi.no>
2024-05-29 14:09:59 +02:00
Ajay Parida d4b22cd10e net: wifi_mgmt: Support to configure AP parameter max_num_sta
Support to set BSS parameter "max_num_sta" at compile and run time

Added support to configure `max_num_sta` BSS parameter.
Maximum number of stations allowed in station table. New stations will be
rejected after the station table is full.

Signed-off-by: Ajay Parida <ajay.parida@nordicsemi.no>
2024-05-29 14:09:59 +02:00
Ajay Parida bedd38ce65 net: wifi_mgmt: Support AP parameter configuration "Skip inactivity poll"
Support for configuration of AP parameter "Skip inactivity poll".
Only build time setting is supported.

Signed-off-by: Ajay Parida <ajay.parida@nordicsemi.no>
2024-05-29 14:09:59 +02:00
Ajay Parida c6d1a91372 net: wifi_mgmt: Support to configure AP mode parameter
Support to set BSS parameter at compile and run time.

Added support to configure `max_inactivity` BSS parameter.
Station inactivity timeout is the period for which AP may keep a client
in associated state while there is no traffic from that particular client.
If a non-zero value is set, AP may choose to disassociate the
client after the timeout.

Signed-off-by: Ajay Parida <ajay.parida@nordicsemi.no>
2024-05-29 14:09:59 +02:00
Ajay Parida 180c22a4fc net: wifi: shell: Support to print name
Support to print name of the argument along with the value.

Signed-off-by: Ajay Parida <ajay.parida@nordicsemi.no>
2024-05-29 14:09:59 +02:00
Johann Fischer 2f272b2d79 usb: device_next: fix BOS descriptor request
Return protocol error if bcdUSB is less than 0x0201. Fix typo in number
of capabilities.

Fixes: b0d7d70834 ("usb: device_next: add initial BOS support")

Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
2024-05-29 12:03:12 +02:00
Tom Burdick 054f453ea7 rtio: Callback chaining and testing
Callbacks were a bit neglected in terms of test coverage, especially
when used in chains. It was clear from the code that chained callbacks
may not actually work, and callback ordering then was hard to verify.
Test callbacks chained to transactions work as expected.

The test iodev had built up some cruft over time and in the process
showed a few bugs once callback chaining was fixed so the test iodev now
better matches typical iodev implementations at this point.

Cancellation testing now includes an added case for cancelling a the
second submission in the chain prior to calling submit noting that no
completions notifications should be given back for those.

Signed-off-by: Tom Burdick <thomas.burdick@intel.com>
2024-05-29 08:41:12 +02:00
Tomi Fontanilles 3efdbe6c0c modules: mbedtls: rename CONFIG_MBEDTLS_MAC_*_ENABLED and rm duplicates
Remove the `_MAC` part because those Kconfig options enable only hash
algorithms, nothing MAC-related, and the `_ENABLED` part to align the
naming to the Mbed TLS defines (plus we don't need such a part).

As a bonus, enabling SHA-256 does not automatically enable SHA-224
anymore.

See the migration guide entries for more details on the practical
changes.

Signed-off-by: Tomi Fontanilles <tomi.fontanilles@nordicsemi.no>
2024-05-29 08:39:26 +02:00
Dominik Ermel 25138ff99c storeage/stream_flash: Cache write_block_size to ctx on init
The commit caches write_block_size and erase_value to stream flash
context, at init, to avoid calling Flash API multiple times
to get these values at various stages of code exectuion,
at run-time.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2024-05-29 07:35:19 +02:00
Ravi Dondaputi 9e38bcc173 wifi: utils: Get correct channel count
When channel range is configured in scan params, get the
channel count from `chan_idx` instead of taking a difference
of start and end of the channel range. The `difference` method
fails in case of 5GHz band since channels may not be consecutive
numbers.

Signed-off-by: Ravi Dondaputi <ravi.dondaputi@nordicsemi.no>
2024-05-29 07:32:09 +02:00
Daniel DeGrasse 0767fd97f8 sd: sd_ops: fix DISK_IOCTL_CTRL_SYNC return code
SD IOCTL handling for DISK_IOCTL_CTRL_SYNC was falling through to the
default return statement, and returning an error when disk sync
succeeded. Fix this issue by properly breaking in IOCTL handler.

Signed-off-by: Daniel DeGrasse <daniel.degrasse@nxp.com>
2024-05-29 07:31:39 +02:00
Yong Cong Sin 3570408db5 build: namespace syscall sources to zephyr/
Namespace the `syscall_dispatch.c` & `syscall_export_llext.c`
to `zephyr/` as well

Signed-off-by: Yong Cong Sin <ycsin@meta.com>
2024-05-28 22:03:55 +02:00
Yong Cong Sin bbe5e1e6eb build: namespace the generated headers with zephyr/
Namespaced the generated headers with `zephyr` to prevent
potential conflict with other headers.

Introduce a temporary Kconfig `LEGACY_GENERATED_INCLUDE_PATH`
that is enabled by default. This allows the developers to
continue the use of the old include paths for the time being
until it is deprecated and eventually removed. The Kconfig will
generate a build-time warning message, similar to the
`CONFIG_TIMER_RANDOM_GENERATOR`.

Updated the includes path of in-tree sources accordingly.

Most of the changes here are scripted, check the PR for more
info.

Signed-off-by: Yong Cong Sin <ycsin@meta.com>
2024-05-28 22:03:55 +02:00
Tomasz Moń d034106b40 usb: device: cdc_acm: Warn once about full ring buffer
Generating separate log entry at INFO level for every single character
dropped is excessive and leads to log flood. Logging dropped character
in no way helps end user and is really a delayed performance killer that
triggers when CDC ACM buffer gets full.

If user does not want to lose outgoing characters then the solution is
to enable hardware flow control which properly blocks in the case the
output buffer is full.

Signed-off-by: Tomasz Moń <tomasz.mon@nordicsemi.no>
2024-05-28 18:58:55 +02:00
Tomasz Moń 20983c7ced usb: device_next: uac2: Fix integer handling issues
Fix integer handling issues found out by Coverity Scan.

Coverity-CID: 363729
Coverity-CID: 363737

Signed-off-by: Tomasz Moń <tomasz.mon@nordicsemi.no>
2024-05-28 18:58:25 +02:00
Alexander Kozhinov bf77d74e91 usb: device: usb_descriptor.c
fix cbprintf_package warning.
cbprintf_package complains about char usage for %p
string argument and suggests void * usage.

Signed-off-by: Alexander Kozhinov <ak.alexander.kozhinov@gmail.com>
2024-05-28 18:57:22 +02:00
Seppo Takalo 4049e17c62 net: lwm2m: Fix null dereference when post-write cb is set
When opaque resources have post-write callback set, but
the write is not a Block-Wise write, there is no block_ctx
and the code causes null pointer dereference when calculating
the offset of the data.

Signed-off-by: Seppo Takalo <seppo.takalo@nordicsemi.no>
2024-05-28 18:54:31 +02:00
Rubin Gerritsen ff80c0b926 Bluetooth: Host: Fix connection establishment upon RPA timeout
Before this commit, the following bugs were present:
- When `CONFIG_BT_FILTER_ACCEPT_LIST` was set, connection establishment
  was cancelled upon RPA timeout. This required the application
  to restart the initiator every RPA timeout.
- When `CONFIG_BT_FILTER_ACCEPT_LIST` was not set, the RPA was not updated
  while the initiator was running.

This commit unifies the RPA timeout handling for both these cases.
Upon RPA timeout the initiator is cancelled and restarted when
the controller raises the LE Connection Complete event.
The workqueue state is checked when restarting the initiator to prevent
it being restarted when the timeout is hit.

Corresponding test cases have been added to ensure that this
feature works.

Signed-off-by: Rubin Gerritsen <rubin.gerritsen@nordicsemi.no>
2024-05-28 09:12:05 -07:00
Rubin Gerritsen 3ce106c620 Bluetooth: Host: Fix not clearing IDs and keys upon bt_disable()
Expectation: After calling `bt_disable()` it is possible to
use the Bluetooth APIs as if `bt_enable()` was never called.

This was not the case for `bt_id_create()`, it was not possible
to set the default identity. This prevented an application
developer to restart the stack as a different identity.

Keys also need to be cleared to avoid the following pattern:
1. Pair two devices
2. Central calls `bt_disable()` and `bt_enable()`.
   The central will now generate a new identity address.
3. Connect the two devices.
4. Re-establish encryption. Now the central will try to use
   the previously used keys. The procedure will fail
   because the peripheral does not have any keys associated
   with the new central address.

The API documentation is updated accordingly.

Signed-off-by: Rubin Gerritsen <rubin.gerritsen@nordicsemi.no>
2024-05-28 09:11:52 -07:00
Fin Maaß 8c37f14b98 tracing: add k_realloc trace
For `k_realloc` add tracing feature.

Signed-off-by: Fin Maaß <f.maass@vogl-electronic.com>
2024-05-28 17:55:12 +02:00
Jukka Rissanen 96c26c2268 shell: backend: telnet: Rename write and read functions
Rename write() to telnet_write(), and read() to telnet_read() so
that if we enable CONFIG_POSIX_API, the compiler will not complain
about those two functions as they conflict with POSIX API ones.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2024-05-28 17:49:59 +02:00
Jukka Rissanen 3f96a87d1c net: dns: Fix resolver debug print
Make sure that we are not trying to print NULL pointer string.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2024-05-28 17:49:59 +02:00
Jukka Rissanen 74f9a1c482 net: sockets_service: Add build check for using zephyr libc
Add checks to make sure that we are not trying to use the socket
service library with eventfd if CONFIG_POSIX_API is not set and if
using native_sim based board. The reason is that we should always
use zephyr libc based eventfd implementation instead of host libc one.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2024-05-28 17:49:59 +02:00
Jukka Rissanen aa458a279a Revert "net: sockets: Check eventfd errors better"
This reverts commit b56297bf16
because it is causing problems when using native_sim and not
having CONFIG_POSIX_API set.

The proper fix is to set CONFIG_POSIX_API when using eventfd
and native_sim so that picolibc is used instead of host libc.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2024-05-28 17:49:59 +02:00
Robert Lubos 87bacf378d net: l2: ethernet: arp: Fix ARP probe target HW address matching
According to RFC3927 and RFC5227, an ARP probe target HW address should
be set to all-zeroes:

"The 'target hardware address' field is ignored and
SHOULD be set to all zeroes."

Hence, we should allow the ARP probes to have all-zeroes target HW
address as well.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2024-05-28 17:49:03 +02:00
Mark Wang c56183529c tests: bluetooth: shell: add a2dp shell test
implement the current a2dp APIs test.
update the document.

Signed-off-by: Mark Wang <yichang.wang@nxp.com>
2024-05-28 12:56:42 +02:00
Mark Wang bdca41d0bf Bluetooth: A2DP: Implement the a2dp and avdtp
implement a2dp.c and avdtp.c
add a2dp related Kconfig:
BT_AVDTP_RTP_VERSION, BT_A2DP_SOURCE and BT_A2DP_SINK
a2dp_codec_sbc.c/h are used to provide some APIs to get
A2DP SBC codec information. (like: channel num).

Signed-off-by: Mark Wang <yichang.wang@nxp.com>
2024-05-28 12:56:42 +02:00
Emil Gydesen 0b654c1502 Bluetooth: BAP: Fix conn checks for bcast assistant notifications
The notify handle in the BAP broadcast assistant did not handle
conn == NULL properly, and neither did delayed_bap_read_handler.

Add better NULL checks, which also fixes a coverity issue.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2024-05-28 12:53:48 +02:00
alperen sener 0b220dd6a6 bluetooth: mesh: increase the friend adv latency range
Increasing the adv latency range to the minimum valid
ReceiveDelay value, 10ms. 4ms might be small for some
target systems.

Signed-off-by: alperen sener <alperen.sener@nordicsemi.no>
2024-05-28 10:08:47 +02:00
Bjarki Arge Andreasen 000784b91d modem: chat: Add runtime APIs for chat scripts
Add runtime APIs for chat scripts.

Signed-off-by: Bjarki Arge Andreasen <bjarki@arge-andreasen.me>
2024-05-28 10:02:06 +02:00
Bjarki Arge Andreasen 2a575a6bf5 modem: chat: Add runtime API to modem_chat_script_chat
Add APIs allowing for modifying the modem_chat_script_chat
safely at runtime.

Signed-off-by: Bjarki Arge Andreasen <bjarki@arge-andreasen.me>
2024-05-28 10:02:06 +02:00
Bjarki Arge Andreasen 8b4822861b modem: chat: Add runtime API to modem chat matches
Add APIs for changing the contents of modem chat matches
safely at runtime.

This allows for reusing a single modem_chat_match at the cost
of placing the match and its buffers in RAM.

Signed-off-by: Bjarki Arge Andreasen <bjarki@arge-andreasen.me>
2024-05-28 10:02:06 +02:00
Jungo Lin fa716d9842 shell: fix index out bound issue
In order to prevent index out of bounds access of the sh->ctx->cmd_buff
array when sh->ctx->cmd_buff_pos is 0, it has been added a check for the
value of sh->ctx->cmd_buff_pos.

This ensures that the array will not be accessed beyond its boundaries.

Signed-off-by: Jungo Lin <jungolin.tw@gmail.com>
2024-05-27 08:16:36 -07:00
Jordan Yates 251ddf0ab5 net: l2: ethernet: arp: improve debug output
Improve the ARP debug output by printing:
 * Sending ARP query
 * Queuing packets due to pending ARP query
 * Receiving ARP query response

Signed-off-by: Jordan Yates <jordan@embeint.com>
2024-05-27 08:16:22 -07:00
Tomasz Moń c30ac4dfd8 usb: device_next: CDC ACM: Process TX on configuration enable
If CDC ACM uart side has TX enabled when the configuration gets enabled,
depending on fifo state following has to happen:
  * if the fifo is empty - trigger TX ready interrupt
  * if the fifo is not empty - queue TX data on IN endpoint

Signed-off-by: Tomasz Moń <tomasz.mon@nordicsemi.no>
2024-05-27 14:04:35 +01:00
Tomasz Moń 1784446c8d usb: device_next: Fix string descriptors response
Commit 2f31ee63b5 ("usb: device_next: convert ASCII7 strings to
UTF16LE on the fly") made string descriptors respond with twice as much
of the actual string data.

Fix the issue by taking into account that USB string descriptor length
is already multiplied by two. Additionally, make it possible to return
odd number of bytes if host requested so.

Signed-off-by: Tomasz Moń <tomasz.mon@nordicsemi.no>
2024-05-27 14:04:26 +01:00
Andries Kruithof 3122296e1c Bluetooth: CAP: fix bug in reception start
The wrong number of subgroups was used in copying subgroups

Signed-off-by: Andries Kruithof <andries.kruithof@nordicsemi.no>
2024-05-27 05:01:49 -07:00
Jukka Rissanen 2a16f4d2bc net: dns: responder: No need to double the socket count
The socket allocation count was incorrectly calculated as
we have only one socket per listened port.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2024-05-27 05:01:28 -07:00
Jukka Rissanen ecda6b190f net: dns: The DNS_EAI_ALLDONE is not an error
If DNS_EAI_ALLDONE is returned, it indicates that the request
was done and should not be considered an error.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2024-05-27 05:01:28 -07:00
Emil Gydesen f5fd2cf49e Bluetooth: ISO: Avoid bt_iso_chan_disconnected in bt_iso_reset
The bt_iso_chan_disconnected function will attempt to
remote ISO data paths as the central.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2024-05-27 03:27:15 -07:00
Flavio Ceolin 4c5ee9b2db pm: system: Restore clock after sleep
sys_clock_idle_exits was being called *only* when the system
was resumed from interruption.

Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
2024-05-27 02:10:03 -07:00
Flavio Ceolin 1860dd9153 pm: system: Resume devices in pm_system_resume
pm_system_resume() can be called directly from ISR and because of this
devices should be resumed before calling pm_state_exit_post_ops().

Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
2024-05-27 02:10:03 -07:00
Flavio Ceolin f7437ac3b1 pm: Move z_pm_save_idle_exit to pm subsys
There is no need to this function be defined inside the kernel since
all places using it are protecting the call under ifdef PM guards.

This way we can also remove the ifdef condition inside the implementation.

Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
2024-05-27 02:10:03 -07:00
Younghyun Park ea29ef36bb debug: coredump: Move COREDUMP_*_STR strings to the public header
This allows a customized coredump_backend_other API to re-use the
COREDUMP_*_STR without re-defining the same strings.

Signed-off-by: Younghyun Park <younghyunpark@google.com>
2024-05-25 14:39:18 -04:00
Lyle Zhu 2d665c1c14 bluetooth: keys_br: Improve bt_foreach_bond
The BR Keys cannot be scanned by function
bt_foreach_bond.

Add function bt_foreach_bond_br for br.

The function bt_foreach_bond_br will be
called by bt_foreach_bond if the BR is
enabled.

Signed-off-by: Lyle Zhu <lyle.zhu@nxp.com>
2024-05-25 14:39:06 -04:00
Fin Maaß f9819dc010 mgmt: hawkbit: option for cold reboot
add option for cold reboot.

Signed-off-by: Fin Maaß <f.maass@vogl-electronic.com>
2024-05-24 18:04:13 -04:00
Babak Arisian b0dceffacc Bluetooth: Audio: add bt_audio_get_chan_count
Implement a function bt_audio_get_chan_count that takes an enum
bt_audio_location and returns the number of channels in that value.

This PR fixes #69617
(https://github.com/zephyrproject-rtos/zephyr/issues/69617)

Signed-off-by: Babak Arisian <bbaa@demant.com>
2024-05-24 09:55:37 -05:00
Ping Wang 1339ce4bf0 Bluetooth: Audio: Get function for bt_audio_codec_qos_pref.
Get the preferred QoS settings via bt_bap_ep_get_info()
Therefore no need to use the internal header file to get it.

This PR fixes https://github.com/zephyrproject-rtos/zephyr/issues/72359

Signed-off-by: Ping Wang <pinw@demant.com>
2024-05-24 08:04:45 -04:00
Marcin Niestroj c6fd2a1ddf net: dns: don't request address in recvfrom()
Source address is not used anywhere, so don't request it with recvfrom()
API.

Signed-off-by: Marcin Niestroj <m.niestroj@emb.dev>
2024-05-24 07:48:17 -04:00
Aurelien Jarno 44f86dd67d usb: dfu: fix detach happening too fast
In some relatively rare conditions, the DFU detach/attach happens to
fast, which cause the host to not notice it. It seems to to be the case
for instance on STM32 when no endpoint are being used.

Adding a 1 ms delay (i.e. one SOF period) between the detach and the
attach fixes the issue.

Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
2024-05-24 07:48:03 -04:00
Andrzej Głąbek e9256135d6 Bluetooth: Controller: nrf5: Allocate GPIOTE channels
Allocate the GPIOTE channels that the Bluetooth Controller needs to use
with the dedicated function provided by the nrfx_gpiote driver instead
of using hard-coded indexes of these channels, as now, when the driver
supports multiple GPIOTE instances, it would be much more difficult to
properly inform the driver which channels should be reserved.

Signed-off-by: Andrzej Głąbek <andrzej.glabek@nordicsemi.no>
2024-05-24 07:47:15 -04:00
Morten Priess 06870146e6 Bluetooth: controller: Allow any valid ISO sync receiver BIG handle
The BIG handle for an ISO sync receiver is provided by the host. The
valid range is [0x00..0xEF], and this requires the controller to allow
non-consecutive handle numbering. This means that even if only one sync
set is supported, a BIG handle of ex. value 2 must be supported.

As the code uses indexing and range checking directly by handle, this
needs to be changed. Introducing the handle index, which sequnces the
handles such that index = 0 is always the "first handle", regardless
of value.

Signed-off-by: Morten Priess <mtpr@oticon.com>
2024-05-23 11:53:22 -04:00
Valerio Setti 210e08be5d bluetooth: mesh: update BT_MESH_USES_MBEDTLS_PSA selected symbols
Instead of selecting legacy MBEDTLS symbols, use corresponding
PSA_WANT ones when possible (note: some legacy symbols do not
have a PSA correspondance).

Signed-off-by: Valerio Setti <vsetti@baylibre.com>
2024-05-23 11:53:02 -04:00
Valerio Setti 2adb4cac17 mbedtls: default enable USE_PSA_CRYPTO when CRYPTO_C
Now that support for all PSA_WANT symbols is in place, we can
enable MBEDTLS_USE_PSA_CRYPTO when MBEDTLS_PSA_CRYPTO_C is
enabled as well.

Note: this commit also moves USE_PSA_CRYPTO out of CRYPTO_C
dependency in config-tls-generic.h because TLS/DTLS/X509 modules
of MbedTLS can rely on *any* implementation of PSA crypto APIs
not only the MbedTLS one. TFM is for example an alternative
to this.

Signed-off-by: Valerio Setti <vsetti@baylibre.com>
2024-05-23 11:53:02 -04:00
Yong Cong Sin c118cd5a13 arch: make the max stack frames configurable
Current on x86 & risc-v that implement stack trace, the
maximum depth of the stack trace is defined by a macro.

Introduce a new Kconfig:EXCEPTION_STACK_TRACE_MAX_FRAMES
so that this is configurable in software.

Signed-off-by: Yong Cong Sin <ycsin@meta.com>
2024-05-23 11:52:08 -04:00
Yong Cong Sin c1a925de98 arch: riscv: use symtab to print function name in stack trace
Selecting `CONFIG_EXCEPTION_STACK_TRACE_SYMTAB` will
enable the symtab generation which will be used in the
stack trace to print the function name of the return
address.

Updated the `stack_unwind` test to test the symbols in a
stack trace.

Signed-off-by: Yong Cong Sin <ycsin@meta.com>
2024-05-23 11:52:08 -04:00
Yong Cong Sin e1ce0aefff debug: implement symtab generation
Use pyelftools to extract the symbol table from the
link stage executable. Then, filter out the function names
and sort them based on their offsets before writing into the
`symtab.c`, this is similar to how the `isr_tables` works.

To access the structure, simply include the new header:
```c
#include <zephyr/debug/symtab.h>
```

Signed-off-by: Yong Cong Sin <ycsin@meta.com>
2024-05-23 11:52:08 -04:00
Roger Wang e79f7135af logging: backend: uart: fix coverity warning
This commit is to fix a warning which is reported in Coverity scan
after device runtime pm is enabled.

Signed-off-by: Roger Wang <roger1.wang@intel.com>
2024-05-23 08:22:32 -04:00
Robert Lubos 1e3f14476b net: tls_credentials: Add missing base64.h header inclusion
base64_encode() was used w/o including the base64.h header. This commit
fixes it.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2024-05-23 07:47:41 -04:00
Jordan Yates 0f56974c9d net: lib: dhcpv4: goto INIT on IF down, not RENEWING
When the interface goes down, the safest thing to do is to return to
the INIT state, as there is no guarantee that any state is preserved
upon the interface coming back up again.

This is particularly the case with WiFi.

Signed-off-by: Jordan Yates <jordan@embeint.com>
2024-05-22 21:34:44 -04:00
Flavio Ceolin 6569ae1798 pm: device_runtime: Fix usage API
Fix pm_device_runtime_usage() API for isr safe devices.

Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
2024-05-22 15:08:39 -05:00
Ravi Dondaputi d8c89f2b08 wifi: shell: Support configuration of timeout in connect command
Add support for configuring timeout in `wifi connect` command.

Signed-off-by: Ravi Dondaputi <ravi.dondaputi@nordicsemi.no>
2024-05-22 13:46:40 -05:00
Vinayak Kariappa Chettimada 1b7fe792e0 Bluetooth: Controller: Support Link Time Optimizations (LTO)
Support for using Link Time Optimization (LTO) when
building application with open source Bluetooth Low
Energy Controller. This reduces code space usage.

Current Memory Usage at the time of this PR (hci_ipc):

BT_CTLR_OPTIMIZE_FOR_SPEED:
Memory region         Used Size  Region Size  %age Used
           FLASH:      260112 B       256 KB     99.22%
             RAM:       60136 B        64 KB     91.76%
           SRAM1:           0 B        64 KB      0.00%
        IDT_LIST:           0 B        32 KB      0.00%

BT_CTLR_OPTIMIZE_FOR_SIZE:
Memory region         Used Size  Region Size  %age Used
           FLASH:      232292 B       256 KB     88.61%
             RAM:       60128 B        64 KB     91.75%
           SRAM1:           0 B        64 KB      0.00%
        IDT_LIST:           0 B        32 KB      0.00%

BT_CTLR_OPTIMIZE_FOR_APP_DEFAULT:
Memory region         Used Size  Region Size  %age Used
           FLASH:      232292 B       256 KB     88.61%
             RAM:       60128 B        64 KB     91.75%
           SRAM1:           0 B        64 KB      0.00%
        IDT_LIST:           0 B        32 KB      0.00%

BT_CTLR_LTO:
Memory region         Used Size  Region Size  %age Used
           FLASH:      221484 B       256 KB     84.49%
             RAM:       60120 B        64 KB     91.74%
           SRAM1:           0 B        64 KB      0.00%
        IDT_LIST:           0 B        32 KB      0.00%

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2024-05-22 13:38:14 -05:00
Vinayak Kariappa Chettimada 31c048f4e3 Bluetooth: Controller: Remove legacy LL optimize for speed dependency
Remove legacy LL optimize for speed dependency required to
support encryption feature in Controller where crypto was
performed in highest priority ISRs to setup encryption in 3
radio events (this now requires 5 radio events in split LL).

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2024-05-22 13:38:14 -05:00
Dong Wang ea288283a3 logging: log_output: Prevent redundant flush with zero-length data
There's such a case captured. When log immediate mode is enabled, each log
message is output per character. However, "log_output_flush()" function is
still called with zero data length at the end of "log_output_process()".
Better to make "buffer_write()" returns immediatley if buffer data
length is zero.

Signed-off-by: Dong Wang <dong.d.wang@intel.com>
2024-05-21 20:54:29 -04:00
Jean-Nicolas Graux c2f65cddfc net: gptp: fix race condition on timestamp callback
If time aware system has more than 1 gptp port, because there is only
one boolean to handle callback registering, a race condition can occur
for instance in case 2 master ports are waiting for a timestamp following
sending of sync message. More in details, callback may be unregistered
by port 1 while port 2 is waiting for timestamp event.

The issue is solved by declaring as much as boolean and struct
net_if_timestamp_cb as the number of declared ports
(=CONFIG_NET_GPTP_NUM_PORTS).

Signed-off-by: Jean-Nicolas Graux <jean-nicolas.graux@st.com>
2024-05-21 16:49:05 -04:00
Jean-Nicolas Graux 64aa577c92 net: gptp: fix rate_ratio in gptp_mi_set_ps_sync_cmss()
Setting a ration of 0 breaks the computation of scaled_rate_offset
in gptp_md_follow_up_prepare().

According to IEEE802.1AS 10.2.2.3.9, when sent by clock master
entity, rate_ratio shall be equal to gmRateRatio. But since
in gptp_md_follow_up_prepare(), in case we are the grand master
clock, we take the assumption that clock source is the local clock,
we may set this ratio to 1.0.

Signed-off-by: Jean-Nicolas Graux <jean-nicolas.graux@st.com>
2024-05-21 16:49:05 -04:00
Jean-Nicolas Graux cec4818fde net: gptp: do not run clock master sync send SM if we are not the GM clock
Without this patch, in case time aware system is grand master capable
but is not the grand master clock and behave as a bridge so that it
shall ONLY relay SYNC and FUP messages from slave port to master port(s),
SYNC and FUP are mistakenly generated by ClockMasterSyncSend state
machine.

This patch only call ClockMasterSyncSend state machine in case a Grand
Master clock is present and is this time aware system.
This check is not described by IEEE802.1AS. Instead, according to
10.2.9.3, the SiteSyncSync state machine shall not take into account
information from ClockMasterSyncSend in case this time aware system is
not grand-master capable. Current implementation of ClockMasterSyncSend
state machine sends sync indication to the PortSync entities, instead of
sending it to the SiteSyncSync entity. And the SiteSyncSync state machine
does not make any check.

Signed-off-by: Jean-Nicolas Graux <jean-nicolas.graux@st.com>
2024-05-21 16:49:05 -04:00
Jean-Nicolas Graux c2cd0fe3ed net: gptp: fix again computation of follow up correction field
Commit 413eceeddb ("net: gptp: fix follow_up message correction_field")
breaks computation of follow up correction field in case time aware system
is not the grand master clock but behave as a transparent clock which relay
sync and follow-up messages from one slave port to one or several master
port(s). In this case, according to IEEE802.AS 11.1.3 and 11.2.14.2.3,
md sync send state machine shall compute the sum of link propagation delay
and residence time, expressed in grand master time base. Then this quantity
shall be added to last received fup correction field to build value of
correction field. This patch checks whether time aware system is the grand
master clock or not, and computes value correction field accordingly.

Signed-off-by: Jean-Nicolas Graux <jean-nicolas.graux@st.com>
2024-05-21 16:49:05 -04:00
Krzysztof Chruściński 299b52d1a7 debug: Add MIPI STPv2 data stream decoder
Add a decoder of STPv2 stream.

Signed-off-by: Krzysztof Chruściński <krzysztof.chruscinski@nordicsemi.no>
2024-05-21 16:48:28 -04:00
Benjamin Lindqvist ed025b2f04 net: lib: coap_client: observe-related fixes
An earlier pull request implementing observe support was merged too
hastily. It had a few issues:

1. The predicate for whether a request should be marked not ongoing was
wrong (it checked ret != 0 instead of ret < 0)
2. Without observes in mind, MID-based deduplication is not a required
feature. Deduplication was handled implicitly - the exchange would get
dropped after the first response anyway, so duplicate responses would
not get matched to anything. But with observes, there are several
responses in an exchange. This commit adds this.
3. Using coap_request_is_observe(&internal_req->request) in the response
handler requires the whole request to stay in scope for the lifetime of
the observation, which I observed was not always the case. Adding an
is_observe bool to the internal struct improved stability significantly.

With these fixes, GETs with observe option works very well.

Signed-off-by: Benjamin Lindqvist <benjamin@eub.se>
2024-05-21 16:42:38 -04:00
Aleksander Wasaznik 93d0eac834 Bluetooth: Host: Forbid holding on to buf given to stack
These are safety checks to guard against silent data corruption. The
implementation currently does not clobber bufs, but soon it will. The
bufs will be zero-copy segmented and fragmented, which involves
overwriting already-sent contents with headers for the next fragment.

Signed-off-by: Aleksander Wasaznik <aleksander.wasaznik@nordicsemi.no>
2024-05-21 11:51:20 +01:00
Anders Storrø 261b358dc3 Bluetooth: Mesh: Shell: Update DFD start bool parse
Changes the parsing of boolean input parameter "PolicyApply"
to DFD start command to use shell boolean parse library.

Signed-off-by: Anders Storrø <anders.storro@nordicsemi.no>
2024-05-21 11:51:10 +01:00
Jamie McCrae b3ffe0aede mgmt: mcumgr: transport: Add missing net include file
Adds a missing network include file which was causing an undefined
function build failure, likely caused by a recent change affecting
includes in other header files

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2024-05-21 09:36:24 +02:00
Johan Hedberg 274507fc52 Bluetooth: Controller: Add BT_CTLR_HCI Kconfig option
Add a new option to split off the building of the HCI layer of the
controller. This layer is not needed by the controller unit tests, and
becomes problematic with the planned change to use devicetree for HCI
drivers.

Signed-off-by: Johan Hedberg <johan.hedberg@gmail.com>
2024-05-20 15:16:54 +01:00
Bjarki Arge Andreasen 5e193edbc3 modem: chat: implement buffer stats
implement buffer statistics for modem_chat module.

Signed-off-by: Bjarki Arge Andreasen <bjarki@arge-andreasen.me>
2024-05-20 14:40:06 +03:00
Bjarki Arge Andreasen 88bb45082a modem: ppp: implement modem_statistics
Implement modem buffer statistics for ppp module.

Signed-off-by: Bjarki Arge Andreasen <bjarki@arge-andreasen.me>
2024-05-20 14:40:06 +03:00
Bjarki Arge Andreasen b636327601 modem: cmux: Implement modem backend statistics
Implement modem backend statistics into modem CMUX DLCI
channel receive buffer and CMUX transmit and receive buffers.

Signed-off-by: Bjarki Arge Andreasen <bjarki@arge-andreasen.me>
2024-05-20 14:40:06 +03:00
Bjarki Arge Andreasen 9f45102299 modem: backend: uart: async: Implement modem backend stat
Implement modem backend statistics in async uart modem backend.

Signed-off-by: Bjarki Arge Andreasen <bjarki@arge-andreasen.me>
2024-05-20 14:40:06 +03:00
Bjarki Arge Andreasen beeb769bb1 modem: backend: uart: isr: Implement modem backend stat
Implement modem backend statistics into isr uart modem backend.

Signed-off-by: Bjarki Arge Andreasen <bjarki@arge-andreasen.me>
2024-05-20 14:40:06 +03:00
Bjarki Arge Andreasen aba5580af3 modem: backend: Add statistics module
Add statistics module which tracks the usage of modem backend
transmit/receive buffers if implemented by a backend.

A modem backend may register itself to the modem backend
stat module, and advertise its transmit and receive buffer
sizes and momentary usage (length).

The modem backend module tracks the maximum usage, which can be
output to the shell using the "modem_stats buffer" shell command.

Signed-off-by: Bjarki Arge Andreasen <bjarki@arge-andreasen.me>
2024-05-20 14:40:06 +03:00
Anders Storrø f8bbf753fc Bluetooth: Mesh: Change log lvl for element_model_recv
Changes the log level from ERR to DBG for element_model_recv for the
following cases:
- Element does not have the appkey for incoming message.
- Element does not have destination address for incoming meesage.

When the received message is for a group address, element_model_recv
is called for all elements on the device. One or more elements may contain
a model that is subscribing to this address. If more than one element
contains the same model. but they do not all share the same application
key as the incoming message is encrypted with, or they do not all
subscribe to the same group address, then the log will show error
message for these elements, which is misleading.

Signed-off-by: Anders Storrø <anders.storro@nordicsemi.no>
2024-05-20 14:37:46 +03:00
Robert Lubos 0874f609f1 net: ipv6: Fix DAD conflict detection
Filtering out received packets which source address matches one of our
own addresses has broken the duplicate address detection conflict
reporting.

In case Neighbor Advertisement is sent during DAD collision, the source
address of such packet might be set to the address that triggered the
collision. This address would also be set on our interface, marked as
tentative. Therefore in order to make duplicate address detection work,
we cannot filter out packets in case our own address is still in
tentative state.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2024-05-20 14:26:24 +03:00
Robert Lubos 62a55d03af net: ipv6: Fix RA RDNSS and DNS_RESOLVER interdependencies
A support for RDNSS option should not force DNS subsystem being enabled
in the system, especially that the option is enabled by default. It
should work the other way around - the option is supported only if DNS
was enabled by the user.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2024-05-20 14:25:44 +03:00
Jukka Rissanen b042c5796a logging: Fix network backend compilation
Because of include file changes, we now need to include both
hostname.h and net_if.h in the syslog logging module directly.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2024-05-20 14:25:44 +03:00
Jukka Rissanen b56297bf16 net: sockets: Check eventfd errors better
With native_sim, this error is seen a lot when socket
service API is used.

  <dbg> net_sock: get_sock_vtable: (net_socket_service):
    Invalid access on sock 3 by thread 0x807a8e0 (net_socket_service)

If we just ignore the error, then we might get into forever
loop which is not good. So if this happens, mark the eventfd
fd as not pollable to basically ignore the eventfd support in
this case.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2024-05-20 14:25:44 +03:00
Jukka Rissanen 3f1bd6b29e net: sockets: Add extra debug print for invalid socket access
Print also thread name when printing socket access error.
This helps debugging what thread caused it.
Lowering the Error to Debug as we could be missing vtable
for example for eventfd descriptors, this is easily seen when using
socket service API.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2024-05-20 14:25:44 +03:00
Jukka Rissanen d5cd41a0fe net: llmnr_responder: Convert LLMNR responder to use socket service API
Instead of using net_context API directly, the LLMNR responder is
changed to use the socket service API. This allows DNS access
for offloaded sockets and can lower overall memory consumption.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2024-05-20 14:25:44 +03:00
Jukka Rissanen 94433b9ce2 net: mdns_responder: Convert mDNS responder to use socket service API
Instead of using net_context API directly, the mDNS responder is
changed to use the socket service API. This allows DNS access
for offloaded sockets and can lower overall memory consumption.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2024-05-20 14:25:44 +03:00
Jukka Rissanen 9a40066b4f net: dns: Convert resolver to use socket service API
Instead of using net_context API directly, the DNS resolver is
changed to use the socket service API. This allows DNS access
for offloaded sockets and can lower overall memory consumption.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2024-05-20 14:25:44 +03:00
Erik Brockhoff 9d8059b6e5 Bluetooth: controller: minor cleanup and a fix-up re. LLCP
Only perform retention if not already done.
Ensure 'sched' is performed on phy ntf even if dle is not.

Signed-off-by: Erik Brockhoff <erbr@oticon.com>
2024-05-20 10:56:17 +03:00
Erik Brockhoff 806a4fcf92 Bluetooth: controller: fix node_rx retention mechanism
Ensure that in LLCP reference to node_rx is cleared when
retention is NOT used, to avoid corruption of node_rx later
re-allocated

Signed-off-by: Erik Brockhoff <erbr@oticon.com>
2024-05-20 10:56:17 +03:00
Erik Brockhoff edef1b7cf4 Bluetooth: controller: fixing rx node leak on CPR reject of parallel CPR
In case a CPR is intiated but rejected due to CPR active on
other connection, rx nodes are leaked due to retained node not
being properly released.

Signed-off-by: Erik Brockhoff <erbr@oticon.com>
2024-05-20 10:56:17 +03:00
Emil Gydesen 7c96743fae Bluetooth: ISO: Upgrade from experimental to unstable
The ISO API and implementation have existed in Zephyr
for several years, and while not fully qualified, stable
or tested yet, it's not experimental anymore (and have
not been for a long time).

This commit removes any references to it being experimental
and instead defines it as unstable by setting the version to
> 0.1.0. 0.8.0 is being used as the initial version, as that
is what other unstable modules was defined to have as their
initial version if they were not stable (>= 1.0.0).

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2024-05-18 15:54:31 +03:00
Emil Gydesen 4a97746312 Bluetooth: Host: Guard set state in conn_destroy
If bt_conn_set_state(conn, BT_CONN_DISCONNECTED) is called
while the connection is already disconnected, this triggers
a warning. This is likely to happen when bt_conn_cleanup_all
is called as part of bt_disable.

Added the state check to avoid unnecessary warnings in the log.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2024-05-18 15:54:19 +03:00
Emil Gydesen c40856e5aa Bluetooth: ISO: Support bt_disable
Add support for bt_disable in the ISO implementation.
This involves clearing all information related to states
in the controller, such as the BIGs and CIGs.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2024-05-18 15:54:19 +03:00
Emil Gydesen f58ac3476f Bluetooth: CAP: Add reference to the set member for CAP discover
Since the CSIP API expects a set member struct for nearly all
functionality, the reference to the full set member (along with
the CAS specific CSIS) should be given to the application.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2024-05-18 15:51:26 +03:00
Taras Zaporozhets a20e962340 net: if: Fix potential unaligned word access
The input address originates from an RX net_buf which may
be unaligned. Consequently, word access to this unaligned buffer
can trigger an unaligned access exception on certain platforms,
such as the ARMv7 Cortex-A9.

Signed-off-by: Taras Zaporozhets <zaporozhets.taras@gmail.com>
2024-05-18 15:50:37 +03:00
Dominik Ermel cda52f80b5 mgmt/MCUmgr/img: Fix img_mgmt_get_unused_slot_area_id checks
Remove image == -1 check that can not happen anymore.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2024-05-17 14:48:24 -05:00
Johann Fischer b0d7d70834 usb: device_next: add initial BOS support
Use the same scheme as for string descriptors. Descriptors can be added
or removed using the existend interface.

Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
2024-05-17 16:25:02 +01:00
Johann Fischer 29003ff264 usb: bos: cleanup Binary Device Object Store header
We could reuse the BOS header, but there are parts that are only needed
in the legacy device support or used internally and the tests. Move this
parts to the appropriate places.

Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
2024-05-17 16:25:02 +01:00
Johann Fischer 4f17bc6051 usb: device_next: store bDescriptorType and bLength in descriptor node
It simplifies the macros to create the string descriptors. We also no
longer need placeholders for the SerialNumber descriptor when it is
generated from hwid. In the future, we can store other descriptor types
in the same list.

Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
2024-05-17 16:25:02 +01:00
Johann Fischer 9b8796400a usb: device_next: rework SerialNumber generation from HWINFO
Do not use application-provided placeholder buffers. Generate
SerialNumber just before ASCII string is converted to UTF16LE. Make
dependency on HWINFO optional, but enabled by default.

Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
2024-05-17 16:25:02 +01:00
Johann Fischer 48ca72326b usb: device_next: move string descriptor data to a separate structure
Move and rework string descriptor data to a separate structure so we can
share memory with another type. Also add description to the
USBD_DESC_STRING_DEFINE macro.

Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
2024-05-17 16:25:02 +01:00
Johann Fischer 2f31ee63b5 usb: device_next: convert ASCII7 strings to UTF16LE on the fly
This is slower but should have no real effect. In the future we can
support more than ASCII7 format and store it in other memory areas.

Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
2024-05-17 16:25:02 +01:00
Johann Fischer f110766072 usb: device_next: add few more string descriptor helpers
Add function to get string descriptor index and function
to remove linked descriptor from a device. This abstracts
it a bit so that the user does not need to know how it is
handled internally.

Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
2024-05-17 16:25:02 +01:00
Ederson de Souza 967168a536 subsys/llext: Generate syscalls stubs for EDK exclusively for userspace
A new Kconfig option which generates syscall stubs assuming that
extensions will always run on userspace, thus simplifying linking
them, as there's no need for z_impl_ stubs (used for direct syscalls),
CONFIG_LLEXT_EDK_USERSPACE_ONLY.

While defining __ZEPHYR_USER__ could have the same effect for optmised
builds, people building extensions on debug environments - thus
non-optimised - would suffer, as they'd need to somehow make the stubs
available (by either exporting the symbol or implementing dummy stubs).

Signed-off-by: Ederson de Souza <ederson.desouza@intel.com>
2024-05-17 16:21:48 +01:00
Ederson de Souza d156a03074 cmake: New target which generates a sort of development kit for llext
Loadable extensions need access to Zephyr (and Zephyr application)
includes and some CFLAGS to be properly built. This patch adds a new
target, `llext-edk`, which generates a tar file with those includes and
flags that can be loaded from cmake and make files.

A Zephyr application willing to expose some API to extensions it loads
only need to add the include directories describing such APIs to the
Zephyr ones via zephyr_include_directories() CMake call.

A new Kconfig option, CONFIG_LLEXT_EDK_NAME allows one to control some
aspects of the generated file, which enables some customization - think
of an application called ACME, willing to have a ACME_EXTENSION_KIT or
something.

All EDK Kconfig options are behind CONFIG_LLEXT_EDK, which doesn't
depend on LLEXT directly - so that EDK features can be leveraged by
downstream variations of loadable extensions.

Also, each arch may need different compiler flags for extensions: those
are handled by the `LLEXT_CFLAGS` cmake flag. An example is set for GCC
ARM.

Finally, EDK throughout this patch means Extension Development Kit,
which is a bad name, but at least doesn't conflict with SDK.

Signed-off-by: Ederson de Souza <ederson.desouza@intel.com>
2024-05-17 16:21:48 +01:00
Krzysztof Chruściński 24082d582f arch: arm: cortex_m: pm_s2ram: Add option for custom marking
s2ram procedure used RAM magic word for marking suspend-to-RAM. This
method may not work in some cases, e.g. when global reset does not
reset RAM content. In that case resuming from s2ram is detected when
global reset occurred.

RAM magic word method is the default but with
CONFIG_PM_S2RAM_CUSTOM_MARKING a custom implementation can be provided.

Signed-off-by: Krzysztof Chruściński <krzysztof.chruscinski@nordicsemi.no>
2024-05-17 14:33:47 +02:00
Emil Gydesen c547079cc2 Bluetooth: Audio: Upgrade from experimental to unstable
This commit upgrades the LE audio API and implementation
from experimental to unstable.

LE Audio have existing for quite a few years in Zephyr
and is not going anywhere, but at the same time it still
has significant effort remaining before it can be
considered stable.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2024-05-17 14:33:39 +02:00
Pete Skeggs f04f8b2422 net: lib: coap_client: Improve cancel function
Improve coap_client_cancel_requests(). Ensure it can be
called from a callback. Report error to waiting callbacks.
Clear active flag.

This is useful when the network becomes unavailable
or prior to disconnecting in order to save power.

Signed-off-by: Pete Skeggs <peter.skeggs@nordicsemi.no>
2024-05-17 10:34:12 +02:00
Daniel DeGrasse 05c84ccb2d sd: sd_ops: take card lock when issuing IOCTL command
Take card lock when running IOCTL command, to avoid race conditions that
could occur within the lower SDHC transfer implementations (as these
will be called by sdmmc_wait_ready)

Fixes #72368

Signed-off-by: Daniel DeGrasse <daniel.degrasse@nxp.com>
2024-05-16 18:54:21 -04:00
Johann Fischer 4c4ff20383 usb: device_next: prevent recursive logging loop
Apply the commit 21975231e2
("usb: device: cdc_acm: Prevent recursive logging loop")
to the new CDC ACM implementation.

Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
2024-05-16 16:23:07 +01:00
Emil Gydesen f573c3eb01 Bluetooth: Audio: Shell: Fix build errors for USB=n
When CONFIG_USB_DEVICE_STACK=n then the sine wave
generator was enabled, which caused build errors.

This commit fixes those errors and also adds the
nRF5340 as a build target for the USB tests.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2024-05-16 15:51:45 +02:00
Emil Gydesen 0a89ce0bf5 Bluetooth: Controller: Add missing guard for mic_state in ull_conn_iso
The mic_state is a guarded field in event_done_extra where it was
accessed outside of its guard.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2024-05-16 11:00:15 +02:00
Daniel DeGrasse 6d7a6ea8a8 sd: sd_ops: remove additional unlock call within card_read()
SD ops card_read() implementation does not need to unlock mutex, as this
is managed by the calling function card_write_blocks. Remove this stray
k_mutex_unlock() call.

Fixes #72287

Signed-off-by: Daniel DeGrasse <daniel.degrasse@nxp.com>
2024-05-16 09:21:18 +02:00
Daniel DeGrasse ed64818565 sd: sdio: rework frequency and timing selection logic
Reword frequency and timing selection logic for SDIO framework so that
the maximum supported timing mode between the card and host will be
selected, even if the maximum frequency supported by the host is not
equal to the maximum frequency for that mode.

Also, resolve an issue where a host and card combo only supporting HS
mode or worse would still use legacy timing mode, because the CCCR flags
were not being checked when checking if HS bus speed could be used.

Signed-off-by: Daniel DeGrasse <daniel.degrasse@nxp.com>
2024-05-16 09:21:03 +02:00
Daniel DeGrasse 82ce2b412d sd: sdmmc: rework frequency and timing selection logic
SDMMC framework frequency and timing selection logic has several
longstanding issues, including:
- requiring that SD hosts support the maximum frequency possible for a
  given UHS mode in order to apply that timing
- selecting SDHC_TIMING_SDR25 for high speed mode, when SDHC_TIMING_HS
  would be correct

Rework the frequency and timing selection logic within the SD framework
to resolve these issues.

Fixes #52589
Fixes #67943

Signed-off-by: Daniel DeGrasse <daniel.degrasse@nxp.com>
2024-05-16 09:21:03 +02:00
Lyle Zhu fa6df6a51a Bluetooth: HFP_AG: Protect the consistency of AG state/value
Use hfp_ag_lock/hfp_ag_unlock to protect the consistency
of AG state or value.

Signed-off-by: Lyle Zhu <lyle.zhu@nxp.com>
2024-05-16 09:15:49 +02:00
Lyle Zhu 5da8916ad5 Bluetooth: classic: Kconfig: Move Kconfig of classic to classic/Kconfig
Create classic/Kconfig, and move all of classic from Kconfig to
classic/Kconfig.

Signed-off-by: Lyle Zhu <lyle.zhu@nxp.com>
2024-05-16 09:15:49 +02:00
Lyle Zhu 615fe2466b Bluetooth: RFCOMM: Kconfig: Add configure BT_RFCOMM_DLC_STACK_SIZE
The default stack size of RFCOMM DLC is 256.
The default value is sufficient for basic operation.

If more stack space is used (such as call function printk)
in context of callback disconnected of RFCOMM DLC, the
default stack size is not sufficient.

Add a configuration BT_RFCOMM_DLC_STACK_SIZE to configure
the RFCOMM DLC stack size.

Signed-off-by: Lyle Zhu <lyle.zhu@nxp.com>
2024-05-16 09:15:49 +02:00
Lyle Zhu 804dbdd43c Bluetooth: host: Kconfig: Change default value of BT_RFCOMM_TX_MAX
To avoid the case that CONN_TX is available but RFCOMM_TX is
unavailable, set the default value of BT_RFCOMM_TX_MAX to
BT_CONN_TX_MAX.

Signed-off-by: Lyle Zhu <lyle.zhu@nxp.com>
2024-05-16 09:15:49 +02:00
Lyle Zhu c3ac857438 Bluetooth: Kconfig: Set BT_BUF_EVT_RX_SIZE to 255 for BR/EDR
The maximum data length of event packet is 255 for BR/EDR.
Such as the data length of event Remote Name Request
Complete is 255.

Set BT_BUF_EVT_RX_SIZE to 255 to avoid error "Not enough
space in buffer" from bt_hci driver.

Signed-off-by: Lyle Zhu <lyle.zhu@nxp.com>
2024-05-16 09:15:49 +02:00