Part 1
요약·해설
MAX3421E host, virtual UHC/UDC와 sample descriptor session을 설명합니다.
Experimental USBD
MAX3421E UHC
USB shell commands
Part 2
접을 수 있는 영어 원문 전체
영어 원문 전체 펼치기
7993768693E71F6D03A3E4D224D96BDF3EB72E04B90663F91DA860BA75C7E8C2
.. zephyr:code-sample:: usb-shell
:name: USB shell
:relevant-api: usbd_api
Use shell commands to interact with USB device stack.
Overview
********
The sample enables new experimental USB device support and the shell function.
It is primarily intended to aid in the development and testing of USB controller
drivers and new USB support.
Building and flashing
*********************
Assuming the board has a supported USB device controller, the example can be
built like:
.. zephyr-app-commands::
:zephyr-app: samples/subsys/usb/shell
:board: reel_board
: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: -DEXTRA_CONF_FILE=virtual.conf -DDTC_OVERLAY_FILE=virtual.overlay
:goals: flash
:compact:
Sample shell interaction
========================
.. code-block:: console
uart:~$ usbd defaults
dev: USB descriptors initialized
uart:~$ usbd config add 1
uart:~$ usbd class add foobaz 1
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
Part 3
한국어 전문 번역
개요
이 sample은 새 experimental USB device support와 shell 기능을 활성화합니다. USB controller driver와 새 USB support를 개발하고 시험하는 작업을 돕는 것이 주목적입니다.
빌드 및 flash
Board에 지원되는 USB device controller가 있다고 가정하면 다음과 같이 reel_board용 example을 build하고 flash할 수 있습니다.
west build -b reel_board samples/subsys/usb/shell
west flash
USB host 기능에는 지원되는 host controller가 필요하며 현재 지원 대상은 MAX3421E뿐입니다. 다음 example은 nRF52840 DK에 SparkFun MAX3421E shield를 연결하고 UHC driver와 USB host stack을 활성화합니다.
west build -b nrf52840dk/nrf52840 --shield sparkfun_max3421e samples/subsys/usb/shell -- -DCONFIG_UHC_DRIVER=y -DCONFIG_USB_HOST_STACK=y
west flash
이론상 모든 platform에서 virtual USB controller로 USB support를 build할 수도 있습니다. Platform이 zephyr_uhc0 또는 zephyr_udc0 nodelabel을 이미 정의했는지에 따라 Devicetree overlay를 약간 조정해야 할 수 있습니다.
west build -b nrf52840dk/nrf52840 samples/subsys/usb/shell -- -DEXTRA_CONF_FILE=virtual.conf -DDTC_OVERLAY_FILE=virtual.overlay
west flash
Shell 상호 작용 예제
다음 session은 default USB descriptor를 만들고 configuration 1에 foobaz class를 추가한 뒤 device와 host stack을 초기화합니다. Host를 enable하고 bus를 resume한 다음 device를 enable해 연결을 성립시키고, device 0의 descriptor를 읽어 byte dump와 각 field를 확인합니다.
uart:~$ usbd defaults
dev: USB descriptors initialized
uart:~$ usbd config add 1
uart:~$ usbd class add foobaz 1
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
Source
출처
영어 원문에는 문단, 문서 지시문, 표, 코드, 코드 심벌, 경로를 그대로 보존했습니다.