samples: usb: shell: extend new USB support sample by host support

Extend new USB support sample to include experimental host support.

Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
This commit is contained in:
Johann Fischer 2022-10-05 10:40:39 +02:00 committed by Carles Cufí
commit eb6207707a
7 changed files with 132 additions and 0 deletions

View file

@ -22,6 +22,28 @@ built like:
:goals: flash
:compact:
For the USB host functionality a supported host controller is required,
currently it is only MAX3421E. The example can be built as follows:
.. zephyr-app-commands::
:zephyr-app: samples/subsys/usb/shell
:board: nrf52840dk_nrf52840
:shield: sparkfun_max3421e
:gen-args: -DCONFIG_UHC_DRIVER=y -DCONFIG_USB_HOST_STACK=y
:goals: flash
:compact:
It is theoretically possible to build USB support using virtual USB controllers
for all platforms, eventually the devicetree overlay has to be adjusted slightly if
the platform has already defined or not `zephyr_uhc0` or `zephyr_udc0` nodelabels.
.. zephyr-app-commands::
:zephyr-app: samples/subsys/usb/shell
:board: nrf52840dk_nrf52840
:gen-args: -DOVERLAY_CONFIG=virtual.conf -DDTC_OVERLAY_FILE=virtual.overlay
:goals: flash
:compact:
Sample shell interaction
========================
@ -34,5 +56,30 @@ Sample shell interaction
dev: added USB class foobaz to configuration 1
uart:~$ usbd init
dev: USB initialized
uart:~$ usbh init
host: USB host initialized
uart:~$ usbh enable
host: USB host enabled
[611:00:28.620,000] <wrn> usbd_core: VBUS detected event
uart:~$ usbh bus resume
host: USB bus resumed
uart:~$ usbd enable
host: USB device connected
dev: USB enabled
uart:~$ usbh device descriptor device 0
host: transfer finished 0x20006250, err 0
00000000: 80 06 00 01 00 00 12 00 |........ |
bLength 18
bDescriptorType 1
bcdUSB 200
bDeviceClass 239
bDeviceSubClass 2
bDeviceProtocol 1
bMaxPacketSize0 64
idVendor 2fe3
idProduct ffff
bcdDevice 301
iManufacturer 1
iProduct 2
iSerial 3
bNumConfigurations 1

View file

@ -0,0 +1,5 @@
# Copyright (c) 2022 Nordic Semiconductor ASA
# SPDX-License-Identifier: Apache-2.0
CONFIG_UHC_DRIVER=y
CONFIG_USB_HOST_STACK=y

View file

@ -0,0 +1,23 @@
/*
* Copyright (c) 2022 Nordic Semiconductor ASA
*
* SPDX-License-Identifier: Apache-2.0
*/
/ {
zephyr_uhc0: uhc_vrt0 {
compatible = "zephyr,uhc-virtual";
zephyr_udc0: udc_vrt0 {
compatible = "zephyr,udc-virtual";
num-bidir-endpoints = <8>;
maximum-speed = "high-speed";
};
udc1: udc_vrt1 {
compatible = "zephyr,udc-virtual";
num-bidir-endpoints = <8>;
maximum-speed = "full-speed";
};
};
};

View file

@ -0,0 +1,12 @@
CONFIG_SHELL=y
CONFIG_USB_DEVICE_STACK_NEXT=y
CONFIG_USBD_SHELL=y
CONFIG_USB_HOST_STACK=y
CONFIG_USBH_SHELL=y
CONFIG_LOG=y
CONFIG_USBD_LOG_LEVEL_WRN=y
CONFIG_USBH_LOG_LEVEL_WRN=y
CONFIG_UDC_DRIVER_LOG_LEVEL_WRN=y
CONFIG_UHC_DRIVER_LOG_LEVEL_WRN=y

View file

@ -6,3 +6,18 @@ tests:
depends_on: usb_device
harness: keyboard
tags: usb
sample.usbh.shell:
depends_on: usb_device
tags: usb shield
extra_args: CONF_FILE="device_and_host_prj.conf"
SHIELD="sparkfun_max3421e"
platform_allow: nrf52840dk_nrf52840 frdm_k64f
build_only: true
sample.usbh.shell.virtual:
depends_on: usb_device
tags: usb
extra_args: CONF_FILE="device_and_host_prj.conf"
OVERLAY_CONFIG="virtual.conf"
DTC_OVERLAY_FILE="virtual.overlay"
platform_allow: qemu_cortex_m3
build_only: true

View file

@ -0,0 +1,5 @@
# Copyright (c) 2022 Nordic Semiconductor ASA
# SPDX-License-Identifier: Apache-2.0
CONFIG_UHC_DRIVER=y
CONFIG_USB_HOST_STACK=y

View file

@ -0,0 +1,25 @@
/*
* Copyright (c) 2022 Nordic Semiconductor ASA
*
* SPDX-License-Identifier: Apache-2.0
*/
/delete-node/ &zephyr_udc0;
/ {
zephyr_uhc0: uhc_vrt0 {
compatible = "zephyr,uhc-virtual";
zephyr_udc0: udc_vrt0 {
compatible = "zephyr,udc-virtual";
num-bidir-endpoints = <8>;
maximum-speed = "high-speed";
};
udc1: udc_vrt1 {
compatible = "zephyr,udc-virtual";
num-bidir-endpoints = <8>;
maximum-speed = "full-speed";
};
};
};