Skip to content

usb: make device-next default and move legacy sample code to legacy directory #87269

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 26 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
ea1dde5
boards/snippets: use new USB device stack for CDC ACM serial
jfischer-no Nov 20, 2024
19905af
board: remove CDC ACM serial backend legacy Kconfig defconfig
jfischer-no Jun 12, 2025
9606a13
sample: usb: move Audio 1.0 samples to legacy
jfischer-no Nov 4, 2024
1bd6c26
samples: usb: make USB DFU next sample default
jfischer-no Mar 17, 2025
aa3a4c6
samples: usb: make WebUSB next sample default
jfischer-no Mar 17, 2025
5127756
samples: usb: make console-next sample default
jfischer-no Mar 18, 2025
2c5f73f
samples: usb: move the legacy code out of the CDC ACM sample
jfischer-no Nov 5, 2024
54f61fb
samples: usb: move the legacy code out of the HID mouse sample
jfischer-no Nov 5, 2024
e83ee6a
samples: usb: move the legacy code out of the USB MSC sample
jfischer-no Nov 5, 2024
ff7a257
samples: usb: move the legacy code out of the HIC USB sample
jfischer-no Nov 5, 2024
be6c079
samples: usb: add a sample that covers legacy netusb
jfischer-no Nov 6, 2024
efcb052
sample: net: remove legacy USB code from the zperf sample
jfischer-no Nov 6, 2024
2ac2381
samples: modbus: use new USB device stack
jfischer-no Nov 21, 2024
3256fc8
samples: hci_uart: use new USB device stack
jfischer-no Nov 22, 2024
ef6287d
samples: sensortile_box: use new USB device stack
jfischer-no Nov 22, 2024
7a59c8a
samples: wpan_serial: use new USB device stack
jfischer-no Nov 25, 2024
de11398
samples: smp_svr: use new USB device stack
jfischer-no Nov 25, 2024
b5a07f5
samples: echo_server: use new USB device stack
jfischer-no Nov 25, 2024
58afdce
samples: http_server: use new USB device stack
jfischer-no Nov 25, 2024
1e515ac
samples: shell_module: use new USB device stack
jfischer-no Nov 25, 2024
ed50417
tests: bluetooth: use new USB device stack
jfischer-no Nov 25, 2024
df5d72b
tests: uart_basic_api: use new USB device stack
jfischer-no Nov 25, 2024
59be327
samples: usb: update USB samples root documentation
jfischer-no Mar 17, 2025
10d4cf2
usb: deprecate legacy USB device support
jfischer-no Jun 10, 2025
efaab4b
usb: mark new stack as unstable and set it as the default
jfischer-no Jun 10, 2025
72a1bf8
manifest: update MCUboot version
jfischer-no Jun 12, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 7 additions & 10 deletions boards/common/usb/Kconfig.cdc_acm_serial.defconfig
Original file line number Diff line number Diff line change
Expand Up @@ -23,23 +23,20 @@ config SHELL_BACKEND_SERIAL_CHECK_DTR
config UART_LINE_CTRL
default SHELL

config USB_DEVICE_STACK
default y

config USB_DEVICE_INITIALIZE_AT_BOOT
config USB_DEVICE_STACK_NEXT
default y if !MCUBOOT

config USB_DEVICE_REMOTE_WAKEUP
default n
config CDC_ACM_SERIAL_INITIALIZE_AT_BOOT
default y if !MCUBOOT

if LOG

choice USB_CDC_ACM_LOG_LEVEL_CHOICE
default USB_CDC_ACM_LOG_LEVEL_OFF
choice USBD_CDC_ACM_LOG_LEVEL_CHOICE
default USBD_CDC_ACM_LOG_LEVEL_OFF
endchoice

choice USB_DEVICE_LOG_LEVEL_CHOICE
default USB_DEVICE_LOG_LEVEL_OFF
choice USBD_LOG_LEVEL_CHOICE
default USBD_LOG_LEVEL_OFF
endchoice

# Wait 4000ms at startup for logging
Expand Down
1 change: 1 addition & 0 deletions boards/nxp/usb_kw24d512/usb_kw24d512.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,6 @@ toolchain:
supported:
- flash
- usb_device
- usbd
- watchdog
vendor: nxp
2 changes: 0 additions & 2 deletions boards/peregrine/sam4l_wm400_cape/Kconfig.defconfig
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,4 @@ endif # NETWORKING
config USE_DT_CODE_PARTITION
default y

source "boards/common/usb/Kconfig.cdc_acm_serial.defconfig"

endif # BOARD_SAM4L_WM400_CAPE
4 changes: 2 additions & 2 deletions boards/peregrine/sam4l_wm400_cape/sam4l_wm400_cape.dts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@
};

chosen {
zephyr,console = &usart1;
zephyr,shell-uart = &usart1;
zephyr,sram = &sram0;
zephyr,flash = &flash0;
zephyr,code-partition= &code_partition;
Expand Down Expand Up @@ -185,5 +187,3 @@ zephyr_udc0: &usbc {
pinctrl-0 = <&usbc_default>;
pinctrl-names = "default";
};

#include <../boards/common/usb/cdc_acm_serial.dtsi>
4 changes: 2 additions & 2 deletions doc/connectivity/usb/device/api/index.rst
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
.. _usb_api:

USB device support APIs
#######################
USB device support APIs (deprecated)
####################################

.. toctree::
:maxdepth: 1
Expand Down
4 changes: 2 additions & 2 deletions doc/connectivity/usb/device/api/usb_dc.rst
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
.. _usb_dc_api:

USB device controller driver API
################################
USB device controller driver API (deprecated)
#############################################

The USB device controller driver API is described in
:zephyr_file:`include/zephyr/drivers/usb/usb_dc.h` and sometimes referred to
Expand Down
4 changes: 2 additions & 2 deletions doc/connectivity/usb/device/api/usb_device.rst
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
.. _usb_device_stack_api:

USB device stack API
####################
USB device stack API (deprecated)
#################################

API reference
*************
Expand Down
4 changes: 2 additions & 2 deletions doc/connectivity/usb/device/api/usb_device_bos.rst
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
.. _usb_bos_api:

Binary Device Object Store (BOS) support API
############################################
Binary Device Object Store (BOS) support API (deprecated)
#########################################################

API reference
*************
Expand Down
4 changes: 2 additions & 2 deletions doc/connectivity/usb/device/api/usb_device_hid.rst
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
.. _usb_hid_device:

USB HID Class API
#################
USB HID Class API (deprecated)
##############################

USB device specific part for HID support defined in
:zephyr_file:`include/zephyr/usb/class/usb_hid.h`.
Expand Down
19 changes: 8 additions & 11 deletions doc/connectivity/usb/device/usb_device.rst
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
.. _usb_device_stack:

USB device support
##################
USB device support (deprecated)
###############################

.. contents::
:local:
Expand All @@ -26,10 +26,9 @@ over time. It provides the following functionalities:
:zephyr_file:`include/zephyr/usb/usb_device.h`

.. note::
It is planned to deprecate all APIs listed in :ref:`usb_api` and the
functions that depend on them between Zephyr v4.1.0 and v4.2.0, and remove
them in v4.4.0. The new USB device support, represented by the APIs in
:ref:`usb_device_next_api`, will become the default in Zephyr v4.2.0.
All APIs listed in :ref:`usb_api` and the functions that depend on them are
deprecated and will be remove in v4.4.0. Please use the new USB device
support represented by the APIs in :ref:`usb_device_next_api`.

Supported USB classes
*********************
Expand Down Expand Up @@ -212,7 +211,7 @@ DFU
USB DFU class implementation is tightly coupled to :ref:`dfu` and :ref:`mcuboot_api`.
This means that the target platform must support the :ref:`flash_img_api` API.

See :zephyr:code-sample:`usb-dfu` sample for reference.
See :zephyr:code-sample:`legacy-usb-dfu` sample for reference.

USB Human Interface Devices (HID) support
=========================================
Expand Down Expand Up @@ -373,9 +372,7 @@ Ethernet connection between the remote (USB host) and Zephyr network support.
* CDC EEM class, enabled with :kconfig:option:`CONFIG_USB_DEVICE_NETWORK_EEM`
* RNDIS support, enabled with :kconfig:option:`CONFIG_USB_DEVICE_NETWORK_RNDIS`

See :zephyr:code-sample:`zperf` or :zephyr:code-sample:`socket-dumb-http-server` for reference.
Typically, users will need to add a configuration file overlay to the build,
such as :zephyr_file:`samples/net/zperf/overlay-netusb.conf`.
See :zephyr:code-sample:`legacy-netusb` sample for reference.

Applications using RNDIS support should enable :kconfig:option:`CONFIG_USB_DEVICE_OS_DESC`
for a better user experience on a host running Microsoft Windows OS.
Expand All @@ -389,7 +386,7 @@ The application should register descriptors such as Capability Descriptor
using :c:func:`usb_bos_register_cap`. Registered descriptors are added to the root
BOS descriptor and handled by the stack.

See :zephyr:code-sample:`webusb` sample for reference.
See :zephyr:code-sample:`legacy-webusb` sample for reference.

Interface number and endpoint address assignment
************************************************
Expand Down
4 changes: 2 additions & 2 deletions doc/connectivity/usb/device_next/api/index.rst
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
.. _usb_device_next_api:

New USB device support APIs
###########################
USB device support APIs
#######################

.. toctree::
:maxdepth: 1
Expand Down
2 changes: 1 addition & 1 deletion doc/connectivity/usb/device_next/api/udc.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ The USB device controller driver API is described in
:zephyr_file:`include/zephyr/drivers/usb/udc.h` and referred to
as the ``UDC driver`` API.

UDC driver API is experimental and is subject to change without notice.
UDC driver API is unstable and is subject to change without notice.
It is a replacement for :ref:`usb_dc_api`. If you wish to port an existing
driver to UDC driver API, or add a new driver, please use
:zephyr_file:`drivers/usb/udc/udc_skeleton.c` as a starting point.
Expand Down
6 changes: 3 additions & 3 deletions doc/connectivity/usb/device_next/api/usbd.rst
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
.. _usbd_api:

USB device stack (next) API
###########################
USB device stack API
####################

New USB device stack API is experimental and is subject to change without notice.
USB device stack API is unstable and is subject to change without notice.

API reference
*************
Expand Down
20 changes: 5 additions & 15 deletions doc/connectivity/usb/device_next/usb_device.rst
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
.. _usb_device_stack_next:

New USB device support
######################
USB device support
##################

Overview
********
Expand All @@ -10,19 +10,16 @@ USB device support consists of the USB device controller (UDC) drivers
, :ref:`udc_api`, and USB device stack, :ref:`usbd_api`.
The :ref:`udc_api` provides a generic and vendor independent interface to USB
device controllers, and although, there a is clear separation between these
layers, the purpose of :ref:`udc_api` is to serve new Zephyr's USB device stack
layers, the purpose of :ref:`udc_api` is to serve Zephyr's USB device stack
exclusively.

The new device stack supports multiple device controllers, meaning that if a
The device stack supports multiple device controllers, meaning that if a
SoC has multiple controllers, they can be used simultaneously. Full and
high-speed device controllers are supported. It also provides support for
registering multiple function or class instances to a configuration at runtime,
or changing the configuration later. It has built-in support for several USB
classes and provides an API to implement custom USB functions.

The new USB device support is considered experimental and will replace
:ref:`usb_device_stack`.

Samples
=======

Expand All @@ -34,13 +31,6 @@ Samples

* :zephyr:code-sample:`uvc`

Samples ported to new USB device support
----------------------------------------

To build a sample that supports both the old and new USB device stack, set the
configuration ``-DCONF_FILE=usbd_next_prj.conf`` either directly or via
``west``.

* :zephyr:code-sample:`bluetooth_hci_usb`

* :zephyr:code-sample:`usb-cdc-acm`
Expand All @@ -51,7 +41,7 @@ configuration ``-DCONF_FILE=usbd_next_prj.conf`` either directly or via

* :zephyr:code-sample:`usb-hid-mouse`

* :zephyr:code-sample:`zperf` To build the sample for the new device support,
* :zephyr:code-sample:`zperf` To build the sample for the device support,
set the configuration overlay file
``-DDEXTRA_CONF_FILE=overlay-usbd_next_ecm.conf`` and devicetree overlay file
``-DDTC_OVERLAY_FILE="usbd_next_ecm.overlay`` either directly or via ``west``.
Expand Down
4 changes: 2 additions & 2 deletions doc/connectivity/usb/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@
USB
###

**USB device support**
**Legacy USB device support**

.. toctree::
:maxdepth: 1

device/usb_device.rst
device/api/index.rst

**New experimental USB support**
**USB support**

.. toctree::
:maxdepth: 1
Expand Down
6 changes: 3 additions & 3 deletions doc/releases/release-notes-4.1.rst
Original file line number Diff line number Diff line change
Expand Up @@ -942,7 +942,7 @@ New Samples
* :zephyr:code-sample:`bluetooth_ccp_call_control_client`
* :zephyr:code-sample:`bluetooth_ccp_call_control_server`
* :zephyr:code-sample:`coresight_stm_sample`
* :zephyr:code-sample:`dfu-next`
* :zephyr:code-sample:`usb-dfu`
* :zephyr:code-sample:`i2c-rtio-loopback`
* :zephyr:code-sample:`lvgl-screen-transparency`
* :zephyr:code-sample:`mctp_endpoint_sample`
Expand All @@ -957,8 +957,8 @@ New Samples
* :zephyr:code-sample:`tmc50xx`
* :zephyr:code-sample:`uart`
* :zephyr:code-sample:`usb-midi2-device`
* :zephyr:code-sample:`usbd-cdc-acm-console`
* :zephyr:code-sample:`webusb-next`
* :zephyr:code-sample:`usb-cdc-acm-console`
* :zephyr:code-sample:`webusb`

Other notable changes
*********************
Expand Down
1 change: 1 addition & 0 deletions drivers/usb/device/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

menuconfig USB_DEVICE_DRIVER
bool "USB device controller drivers"
select DEPRECATED
help
Enable USB device controller drivers.

Expand Down
3 changes: 1 addition & 2 deletions drivers/usb/udc/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@


menuconfig UDC_DRIVER
bool "USB device controller drivers [EXPERIMENTAL]"
select EXPERIMENTAL
bool "USB device controller drivers"
select NET_BUF
help
USB device controller driver.
Expand Down
4 changes: 3 additions & 1 deletion include/zephyr/drivers/uart/cdc_acm.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ typedef void (*cdc_dte_rate_callback_t)(const struct device *dev,
/**
* @brief Set the callback for dwDTERate SetLineCoding requests.
*
* @deprecated Use @ref usbd_api and @ref USBD_MSG_CDC_ACM_LINE_CODING instead.
*
* The callback is invoked when the USB host changes the baud rate.
*
* @note This function is available only when
Expand All @@ -44,7 +46,7 @@ typedef void (*cdc_dte_rate_callback_t)(const struct device *dev,
*
* @return 0 on success.
*/
int cdc_acm_dte_rate_callback_set(const struct device *dev,
__deprecated int cdc_acm_dte_rate_callback_set(const struct device *dev,
cdc_dte_rate_callback_t callback);

#ifdef __cplusplus
Expand Down
Loading
Loading