Commit graph

18329 commits

Author SHA1 Message Date
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