Commit graph

18700 commits

Author SHA1 Message Date
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
Lyle Zhu 84144c6833 Bluetooth: HFP_AG: Initialize HFP AG
Implement basic functions for HFP AG.

Signed-off-by: Lyle Zhu <lyle.zhu@nxp.com>
2024-05-16 09:15:49 +02:00
Johann Fischer eb9b46c118 usb: device_next: lock scheduler in usbd_init()
Lock the scheduler to ensure that the context is not preempted before it
is fully initialized.

Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
2024-05-15 17:29:24 +01:00
Johann Fischer c3ec41bdf8 usb: device_next: remove unused API function
Remove unused and not required usbd_ep_ctrl_buf_alloc().

Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
2024-05-15 17:29:24 +01:00
Johann Fischer 4c360f38d1 usb: device_next: add controller can detect VBUS state change capability
There are controllers with capability to detect VBUS state change. This
can be used in a generic application to explicitly handle the VBUS
detected event after usbd_init() and for example allow the PMIC to
detect to what type of port device controller is connected.

Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
2024-05-15 17:29:24 +01:00
Johann Fischer 48f2a4bc1a usb: device_next: remove initialized state checks in event processing
For the simple events, do not check whether the device driver and stack
are marked as initialized. USB device notification will reschedule
delivery if the stack is not yet marked initialized.

Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
2024-05-15 17:29:24 +01:00
Johann Fischer 693191467d usb: device_next: add USB device context to message delivery callback
Add USB device context argument to message delivery callback.

Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
2024-05-15 17:29:24 +01:00
Johann Fischer 22d574cb3c usb: device_next: tweak USB device notification support
Since no threads are waiting for the FIFO and we do not need any k_fifo
features, we can just use slist.

Some notifications (caused by interrupts), especially "VBUS ready", can
be triggered very quickly right after UDC initialization if the USB
controller is already connected. Depending on the global thread
configuration, messsage publishing work can be executed before the
context is marked as initialized. Use delayed work to reschedule
publishing when the context is not initialized.

Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
2024-05-15 17:29:24 +01:00
Ayush Singh 56882e2d91 net: zperf: Fix upload ping timeout error
Fixes remote address for ping before upload. This caused the ping in zperf
upload to timeout as shown in the following output:

```
uart:~$ zperf udp upload 2001:db8::2 5001 10 50 1M
Remote port is 5001
Connecting to 2001:db8::2
Duration:       10.00 s
Packet size:    50 bytes
Rate:           1000 kbps
Starting...
ping 2001:db8::2 timeout
Rate:           1.00 Mbps
Packet duration 390 us
```

Fixes: https://github.com/zephyrproject-rtos/zephyr/issues/68674

Signed-off-by: Ayush Singh <ayushdevel1325@gmail.com>
2024-05-15 17:07:58 +02:00
Seppo Takalo 37f6803833 net: lwm2m: Allow Block-Wise write without callbacks
Allow Block-Wise writes to resources that have enough buffer for
the whole content. Calculate the offset before calling the
content specific write handlers when callback is not set.

Previously only resources with post-write callback were able to
assemble the content.

Signed-off-by: Seppo Takalo <seppo.takalo@nordicsemi.no>
2024-05-15 14:58:15 +02:00
Seppo Takalo a9e91af375 test: lwm2m: Add tests for Block-Wise transfers
Block-Wise GET, PUT and SEND

Signed-off-by: Seppo Takalo <seppo.takalo@nordicsemi.no>
2024-05-15 14:58:15 +02:00
Seppo Takalo 01b57b4999 net: lwm2m: Add offset to post-write callback
When Block-Wise transfer restarts, the post-write callback should
receive some indication that the block is actually a beginning of new,
instead of part of previous transfer.

Fixes #71351

Signed-off-by: Seppo Takalo <seppo.takalo@nordicsemi.no>
2024-05-15 14:58:15 +02:00
Emil Gydesen a6a14360a9 Bluetooth: BAP: Remove err from recv_state_removed callback
The callback is only ever called when we received a
notification from the BASS server that the receive state is
removed, which cannot contain an error code.
Thus it does not make sense for the callback to have an
error code.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2024-05-15 14:57:20 +02:00
Pisit Sawangvonganan 557ad8e45c shell: devmem: address cmd_dump multiple call problem
Call `getopt_init()` to reset `state->optind` instead of directly setting
`optind = 1`. The `getopt()` function uses `getopt_state` from
`getopt_state_get` for state handling, so `getopt_init()` should be called
to correctly run the command again.

Signed-off-by: Pisit Sawangvonganan <pisit@ndrsolution.com>
2024-05-15 10:13:23 +02:00
Pisit Sawangvonganan 93ee60fe87 shell: devmem: correct number of mand and opt of cmd_dump
According to the `SHELL_CMD_ARG` macro, the `mand` argument of `cmd_dump`
should be 5, including the command name itself, `dump`.
Meanwhile, the `opt` should be 2, as this value describes the optional
field, which is [-w <width>].

Signed-off-by: Pisit Sawangvonganan <pisit@ndrsolution.com>
2024-05-15 10:13:23 +02:00
Troels Nilsson 769409d41c Bluetooth: Controller: Add parameter to ISOALs sdu_write
For vendor datapaths that do not use a netbuffer to write SDUs
into, the callee of sdu_write currently has to keep track itself
of how much data has been written to the current SDU; This is wasteful
since ISOAL already keeps track of that. Add an sdu_written parameter
to the callback to inform the callee how much has been written to the
current SDU already so the callee can write using the correct offset

Signed-off-by: Troels Nilsson <trnn@demant.com>
2024-05-15 09:26:36 +02:00
Jukka Rissanen 6d129b2a2d net: http_server: Add support for specifying Content-Type
Allow user to specify the Content-Type header field for the
HTTP response.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2024-05-14 20:22:58 -04:00
Johann Fischer c0e8f0d96b usb: device_next: add initial HID device support
Add initial HID device support. Unlike the existing HID implementation,
the new implementation uses a devicetree to instantiate a HID device.
To the user, the HID device appears as a normal Zephyr RTOS device.

Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
2024-05-14 18:24:45 -04:00
Johann Fischer 92fc5316a4 usb: device_next: allow Get Descriptor with recipient interface
If the recipient is not the device then it is probably a
class specific  request where wIndex is the interface
number or endpoing and not the language ID. e.g. HID
Class Get Descriptor request.

Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
2024-05-14 18:24:45 -04:00
Johan Hedberg 484fe3f06c Bluetooth: Remove bt_read_static_addr() "hack"
This function was used to shortcut HCI for combined host + controller
builds. It doesn't provide much value and adds complexity to the HCI
driver interface, so just remove it. This means vendor-specific HCI
commands is now the only way for the host to access the same
information.

Signed-off-by: Johan Hedberg <johan.hedberg@gmail.com>
2024-05-14 18:21:11 -04:00
Johan Hedberg 35897ee66c Bluetooth: Kconfig: Get rid of BT_HCI_VS_EVT
Enabling vendor-specific extensions also implies support for vendor
events, so a separate Kconfig option for that is unnecessary.

One small additional thing this requires is the use of the
__maybe_unused annotation, since there's no-longer a single Kconfig
option that the controller hci.c can use to know that the vendor event
helper symbols are needed.

Signed-off-by: Johan Hedberg <johan.hedberg@gmail.com>
2024-05-14 18:21:11 -04:00
Johan Hedberg 18c23daee3 Bluetooth: Kconfig: Merge BT_HCI_VS_EXT into BT_HCI_VS
The naming of these two options was problematic, since it's both of them
are about vendor extensions, even though one has _EXT in the name and
the other doesn't. Just merge one option into the other. This has a
slight overhead on the controller side of enabling some more vendor
features if BT_HCI_VS is enabled, but that should hopefully be
acceptable.

Signed-off-by: Johan Hedberg <johan.hedberg@gmail.com>
2024-05-14 18:21:11 -04:00
Robert Lubos 50c523636b net: ipv6: Clear joined flag on all mcast address when operational down
When the network inteface goes operational DOWN (for example cable
unplugged), clear "joined" flag on all registered multicast addresses,
so that MLD report is sent for them when the interface goes back up.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2024-05-14 18:20:56 -04:00
Robert Lubos 3e046626c1 net: ipv6: Rejoin all solicited node mcast addresses
When bringing interface down, all IPv6 multicast addresses are removed
from the interface. However, when the interface was brought back up,
rejoin_ipv6_mcast_groups() would look only for solicited node mcast
addresses already present on the interface. In result, after going back
up, the interface was missing solicited-node mcast addresses for those
unicast addresses, that were already present on the interface when
bringing up.

As net_ipv6_mld_join() does similar checks to skip MLD when not needed,
we can just skip the lookup when rejoining, and use already defined
join_mcast_nodes().

Additionally, check for IPV6 and NO_ND flags on the interface before
attempting to add the address back, those multicast addresses are not
needed if ND is disabled on the interface.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2024-05-14 18:20:56 -04:00
Robert Lubos d48da4cfd1 net: ipv6: Fix missing DAD for link-local address
In case a network interface is brought down and back up, DAD was not
performed for link-local unicast address.

This happens because the logic in the network interface code assumed
that DAD for link-local address is triggered when the address is added,
and it's explicitly omited when looping over IPv6 address. This wasn't
the case however when interface was brought back up, as the address was
already present on the interface, hence DAD skipped.

In Linux, the link-local address is removed from the interface when the
interface is brought down. Such approach solves the issue described,
hence implement it in a similar way in Zephyr.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2024-05-14 18:20:56 -04:00
Jukka Rissanen 1d7970be04 net: context: Do not check our own ports
There is no need to check our own context when going through
the used ports in the system. This prevents error when binding
in some corner cases.

Fixes #72035

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2024-05-14 18:19:54 -04:00
Jukka Rissanen 3d1b8c6116 net: shell: Add command to show HTTP server information
The new command is "net http" which shows all services and
related resources defined in the system.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2024-05-14 15:51:20 +02:00
Emil Gydesen 0cb828d443 Bluetooth: CAP: Fix check for volume_mute_changed callback
The callback was guarded by a wrong check.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2024-05-14 10:56:26 +02:00
Emil Gydesen 36c1aeaf19 Bluetooth: BAP: Shell: Add support for USB audio in
Add support for receiving audio data from e.g. a PC
over USB and LC3 encode it before sending it
on BAP audio streams.

This refactores the entire TX path, as it has moved
from only support the sine wave generator, to also
supporting USB.

The encoding and sending of data is now in it's own
thread, instead of relying on the system workqueue thread
and k_work items.

Several other refactors have taken place to reduce lines
of codec (such as the introduction of the bap_foreach_stream
function.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2024-05-14 09:34:19 +02:00
Troels Nilsson 01b4f9d263 Bluetooth: Controller: Fix BIS IRC range check
Maximum possible value for IRC is 15, not 7

Signed-off-by: Troels Nilsson <trnn@demant.com>
2024-05-14 09:33:11 +02:00
Jordan Yates 23ca74b756 convert: use k_uptime_seconds
Replace usage of `k_uptime_get() / MSEC_PER_SEC` and
`k_uptime_get() / 1000` with dedicated function.

Signed-off-by: Jordan Yates <jordan@embeint.com>
2024-05-14 09:32:01 +02:00
Jukka Rissanen 70ab0e65a5 net: websocket: Add a way to unregister a websocket connection
Doing a normal close for a websocket does not close the underlying
real socket. If we do not have fd for the real socket, then it is
not possible to fully close a websocket connection. As we are allocating
a websocket using websocket_register() in HTTP server use case,
create a websocket_unregister() that will close both the real
socket and the websocket socket.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2024-05-14 09:31:37 +02:00
Jukka Rissanen 4d9d0ee64c net: websocket: Ignore error during close if we are disconnected
No need to return an error during a close if we are already
disconnected.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2024-05-14 09:31:37 +02:00
Corey Wharton bf114c6b1a logging: add API to trigger immediate processing of logs
There are use cases where it's beneficial to trigger the log
thread to process log messages as soon as able instead of waiting
for the processing timer or threshold triggers. An example would be
to flush the log buffer before entering the idle thread after
forcing a system power state.

Signed-off-by: Corey Wharton <xodus7@cwharton.com>
2024-05-13 16:06:11 -04:00
Jordan Yates af515ef87b logging: log_cache: ensure cache contains an entry
Return an error if the provided cache configuration is not large enough
to hold a single entry. An empty `active` and `idle` list causes NULL
dereferences in `log_cache_get`.

Signed-off-by: Jordan Yates <jordan@embeint.com>
2024-05-13 16:05:18 -04:00
Nicolas Pitre 57305971d1 kernel: mmu: abstract access to page frame flags and address
Introduce z_page_frame_set() and z_page_frame_clear() to manipulate
flags. Obtain the virtual address using the existing
z_page_frame_to_virt(). This will make changes to the page frame
structure easier.

Signed-off-by: Nicolas Pitre <npitre@baylibre.com>
2024-05-13 16:04:40 -04:00
Fin Maaß 9bd0170aad net: http: client: mark as unstable
As the http client API is currently used by two applications
(websocket and hawkbit), it should be marked as unstable, according
to the docs:
https://docs.zephyrproject.org/latest/develop/api/api_lifecycle.html

Signed-off-by: Fin Maaß <f.maass@vogl-electronic.com>
2024-05-13 16:02:55 -04:00
Marek Pieta b8fedfb6c1 bluetooth: host: conn: Fix assertion failure in wait_for_tx_work
Calling bt_disable in system workqueue context while BLE connected may
lead to calling wait_for_tx_work in this context. Fix check in code to
avoid assertion failure.

Signed-off-by: Marek Pieta <Marek.Pieta@nordicsemi.no>
2024-05-13 09:51:59 -05:00
Daniel Apperloo 9fc26804fb linker: decouple KERNEL_WHOLE_ARCHIVE from LLEXT
Dynamic code execution applications not using LLEXT for "extension"
loading are subject to the same linker optimization symbol resolution
issue described in commit 321e395 (in summary, libkernel.a syscalls
not used directly by the application result in weak symbol resolution
of their z_mrsh_ wrapper).

To support usecases where an application is using alternative methods
to load and execute code calling syscalls (likely from userspace) or
is using a mechanism where the linker may not be aware, the configuration
option has been decoupled from CONFIG_LLEXT (who is now a selector) to
KERNEL_WHOLE_ARCHIVE.

Signed-off-by: Daniel Apperloo <daniel.apperloo@intel.com>
2024-05-13 14:23:38 +02:00
Michael Stumpf 854685dfbc Fixes small typo in log_backend_fs.c
Signed-off-by: Michael Stumpf <michaelstumpf585@gmail.com>
2024-05-12 11:04:22 -04:00
Aurelien Jarno a6fbfc0612 lorawan: make possible to send empty frames
Empty frames are allowed by the LoRaWAN protocol and are actually useful
to open new RX slots or flush MAC commands in stack. Therefore allow the
data pointer to be NULL if len is 0.

Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
2024-05-12 11:01:18 -04:00
Tomi Fontanilles 6002abe519 mgmt: mcumgr: replace Tinycrypt by PSA
As part of ongoing work to move away from TinyCrypt and towards PSA
(#43712), make fs_mgmt use either PSA (when available) or MbedTLS
(as a fallback) for SHA-256.

The use of PSA is guarded by CONFIG_MBEDTLS_PSA_CRYPTO_CLIENT
which requires a locally-built PSA core for devices without TF-M.

Signed-off-by: Tomi Fontanilles <tomi.fontanilles@nordicsemi.no>
2024-05-10 18:24:38 -04:00
Tomi Fontanilles 2d61db9a60 mbedtls: introduce PSA-specific Kconfig file
It is meant specifically for configuration of the PSA crypto library.

The underlying PSA configuration items are guarded by the condition
that a PSA crypto provider must be present, which is the case when
either TF-M is in use or MbedTLS's PSA core is built as part of
the application image.

Signed-off-by: Tomi Fontanilles <tomi.fontanilles@nordicsemi.no>
2024-05-10 18:24:38 -04:00
Keith Short bfe8020c4c Revert "shell: backends: uart: avoid unnecessary TX IRQs"
This reverts commit d2e5eeb51d.

PR zephyrproject-rtos/zephyr#71172 is causing the bug reported on
issue zephyrproject-rtos/zephyr#72598.

Signed-off-by: Keith Short <keithshort@google.com>
2024-05-10 18:23:50 -04:00
Emil Gydesen 7d4c13f55f Bluetooth: CAP: Shell: Initiator fix chan_alloc
When using the CAP initiator shell AC commands, the channel
allocation were not done correctly, leading to cases where
we attempted to set e.g. 2 LEFT streams for the same device.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2024-05-10 18:09:14 -04:00
Adam Matus 684a28656e net: zperf: Add periodic reporting for upload
Add option for zperf tcp upload that will enable periodic result reporting.
This is useful for monitoring performance swings during a longer session.

Signed-off-by: Adam Matus <adam.matus@nxp.com>
2024-05-10 14:45:48 -05:00
Adam Matus a6ededcc9f net: zperf: Move TCP nodelay socket option
TCP nodelay option is part of zperf upload params, but was not being
set in common zperf_prepare_upload_sock function. Move it there
to align with how other options are set.

Signed-off-by: Adam Matus <adam.matus@nxp.com>
2024-05-10 14:45:48 -05:00
Robert Lubos 0ba6a20896 net: sockets: Move TLS sockets out of experimental
TLS socket have now been in Zephyr for a few years already and are
widely adopted across the codebase. Given above, they should no longer
be considered an experimental feature.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2024-05-10 14:42:03 -05:00
Théo Battrel 76559f27fd Bluetooth: Host: Map HCI cmd disallowed to errno
Make `bt_hci_cmd_send_sync` return `-EACCES` when receiving
`BT_HCI_ERR_CMD_DISALLOWED`.

Update some tests that were expecting `-EIO` when
getting `BT_HCI_ERR_CMD_DISALLOWED`.

Add a warning in `set_random_address` when getting that new error. This
is done in case someone try to set a new random address while legacy
advertising, scanning or initiating is enabled. This is illegal behavior
according to the Core Spec (see Vol 4, Part E 7.8.4).

Signed-off-by: Théo Battrel <theo.battrel@nordicsemi.no>
2024-05-10 17:38:06 +03:00
Vinayak Kariappa Chettimada 2c6306d099 Bluetooth: Controller: BT_CTLR_ISO_TX_BUFFER_SIZE from BT_ISO_TX_MTU
Derive BT_CTLR_ISO_TX_BUFFER_SIZE from BT_ISO_TX_MTU to have
optimal Controller memory allocations.
BT_CTLR_ISO_TX_BUFFER_SIZE can be set lower than
BT_ISO_TX_MTU in which case upper layer can send fragmented
SDU to the Controller.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2024-05-10 15:02:10 +02:00
Vinayak Kariappa Chettimada 3997479b49 Bluetooth: HCI: Rename to bt_hci_iso_sdu_hdr and bt_hci_iso_sdu_ts_hdr
Rename struct bt_hci_iso_data_hdr to bt_hci_iso_sdu_hdr, and
struct bt_hci_iso_ts_data_hdr to bt_hci_iso_sdu_ts_hdr.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2024-05-10 15:02:10 +02:00
Yong Cong Sin 2e072ad017 ztest: include: unittest: relocate cpu.h and include only if unit-test
The `cpu.h` is meant to be a hack around Zephyr's dependencies
for unit-test, relocate it to a folder that's included only by
unit-test.

Signed-off-by: Yong Cong Sin <ycsin@meta.com>
2024-05-10 11:50:36 +02:00
Yong Cong Sin af78efaa4d subsys/testsuite/ztest: create stub headers at CMake configure time
Create unittest stub headers at CMake configure time.

Signed-off-by: Yong Cong Sin <ycsin@meta.com>
2024-05-10 11:50:36 +02:00
Morten Priess 7f82b6a219 Bluetooth: controller: Prevent invalid compiler code reordering
In ull_disable, it is imperative that the callback is set up before a
second reference counter check, otherwise it may happen that an LLL done
event has already passed when the disable callback and semaphore is
assigned.

This causes the HCI thread to wait until timeout and assert after
ull_ticker_stop_with_mark.

For certain compilers, due to compiler optimizations, it can be seen
from the assembler code that the callback is assigned after the second
reference counter check.

By adding memory barriers, the code correctly reorders code to the
expected sequence.

Signed-off-by: Morten Priess <mtpr@oticon.com>
2024-05-10 11:49:50 +02:00
Konrad Derda 9074c07ae7 net: ipv6: mld: use proper MLDv2 modes
According to the RFC, MODE_IS_INCLUDE/MODE_IS_EXCLUDE codes should be
used while sendling Multicast Listener Reports in response to a query.
When performing a transition between states (e.g., when joining or
leaving a multicast group) CHANGE_TO_INCLUDE_MODE/CHANGE_TO_EXCLUDE_MODE
have to be used.

Signed-off-by: Konrad Derda <konrad.derda@nordicsemi.no>
2024-05-10 11:44:50 +02:00
Konrad Derda 7f5a481ec7 net: ipv6: mld: remove addition of unspecified source in MLDv2 report
From RFC:
* "source list" is an unordered list of zero or more unicast
addresses from which multicast reception is desired or not desired [...]

It means that there is no need to add any special address to specify
"block all" and "allow all" states explicitly. This commit removes the
unnecessary addition.

Signed-off-by: Konrad Derda <konrad.derda@nordicsemi.no>
2024-05-10 11:44:50 +02:00