• Home
  • History
  • Annotate
Name Date Size #Lines LOC

..--

boards/29-Dec-2025-3022

src/29-Dec-2025-135

CMakeLists.txtD29-Dec-2025272 107

README.rstD29-Dec-20252.5 KiB8773

device_and_host_prj.confD29-Dec-2025249 1310

nucleo_f413zh_dwc2.overlayD29-Dec-2025659 3228

prj.confD29-Dec-2025244 119

sample.yamlD29-Dec-2025716 3231

virtual.confD29-Dec-2025129 62

virtual.overlayD29-Dec-2025458 2621

README.rst

1.. zephyr:code-sample:: usb-shell
2   :name: USB shell
3   :relevant-api: usbd_api
4
5   Use shell commands to interact with USB device stack.
6
7Overview
8********
9
10The sample enables new experimental USB device support and the shell function.
11It is primarily intended to aid in the development and testing of USB controller
12drivers and new USB support.
13
14Building and flashing
15*********************
16
17Assuming the board has a supported USB device controller, the example can be
18built like:
19
20.. zephyr-app-commands::
21   :zephyr-app: samples/subsys/usb/shell
22   :board: reel_board
23   :goals: flash
24   :compact:
25
26For the USB host functionality a supported host controller is required,
27currently it is only MAX3421E. The example can be built as follows:
28
29.. zephyr-app-commands::
30   :zephyr-app: samples/subsys/usb/shell
31   :board: nrf52840dk/nrf52840
32   :shield: sparkfun_max3421e
33   :gen-args: -DCONFIG_UHC_DRIVER=y -DCONFIG_USB_HOST_STACK=y
34   :goals: flash
35   :compact:
36
37It is theoretically possible to build USB support using virtual USB controllers
38for all platforms, eventually the devicetree overlay has to be adjusted slightly if
39the platform has already defined or not ``zephyr_uhc0`` or ``zephyr_udc0`` nodelabels.
40
41.. zephyr-app-commands::
42   :zephyr-app: samples/subsys/usb/shell
43   :board: nrf52840dk/nrf52840
44   :gen-args: -DEXTRA_CONF_FILE=virtual.conf -DDTC_OVERLAY_FILE=virtual.overlay
45   :goals: flash
46   :compact:
47
48Sample shell interaction
49========================
50
51.. code-block:: console
52
53   *** Booting Zephyr OS build v4.2.0-1588-g83f1bd7341de ***
54   uart:~$ usbd defcfg
55   dev: added default string descriptors
56   dev: register FS loopback_0
57   dev: register HS loopback_0
58   dev: USB initialized
59   uart:~$ usbh init
60   host: USB host initialized
61   uart:~$ usbh enable
62   host: USB host enabled
63   uart:~$ usbh bus resume
64   host: USB bus resumed
65   uart:~$ usbd enable
66   dev: USB enabled
67   [160:04:13.870,000] <inf> usb_loopback: Enable loopback_0
68   uart:~$ usbh device list
69   1
70   uart:~$ usbh device descriptor device 1
71   host: USB device with address 1
72   bLength                 18
73   bDescriptorType         1
74   bcdUSB                  200
75   bDeviceClass            239
76   bDeviceSubClass         2
77   bDeviceProtocol         1
78   bMaxPacketSize0         64
79   idVendor                2fe3
80   idProduct               ffff
81   bcdDevice               402
82   iManufacturer           1
83   iProduct                2
84   iSerial                 3
85   bNumConfigurations      1
86   uart:~$
87