Usb device mode linux

USB Host Mode (Linux)

All our SoM provide one or more USB Host ports which allow connecting USB devices. Some ports can take both roles, depending on HW/SW configuration they can switch between host and device role. More info can be found here: USB Device Mode (Linux).

USB speed​

Configuration allows to limit the maximum speed the host will switch to when negotiating the speed with a newly connected USB Device. More info can be found here: USB 2.0 High Speed (480Mbps)

USB Hub Port Control​

  • A Verdin iMX8M Mini on a Dahlia Carrier Board.
  • Bus 01: SoM USB1 root hub goes to Dahlia X3 with a mass storage device connected.
  • Bus 02: SoM USB2 root hub goes to Dahlia onboard USB hub, then port 2 of the onboard hub goes to X4 with an external USB hub connected. Connected to the external USB hub is a keyboard on port 3 and a mouse on port 4.

Such a system reflects in the following lsusb output:

root@verdin-imx8mm:~# lsusb | sort Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub Bus 001 Device 002: ID 0951:162d Kingston Technology DataTraveler 102 Bus 002 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub Bus 002 Device 002: ID 0424:2744 Standard Microsystems Corp. Hub Bus 002 Device 003: ID 1a40:0101 Terminus Technology Inc. Hub Bus 002 Device 004: ID 0424:2740 Standard Microsystems Corp. Bus 002 Device 005: ID 0dc6:3100 Precision Squared Technology Corp. Bus 002 Device 006: ID 0458:0036 KYE Systems Corp. (Mouse Systems) Pocket Mouse LE root@verdin-imx8mm:~# lsusb -t /: Bus 02.Port 1: Dev 1, Driver=ci_hdrc/1p, 480M  |__ Port 1: Dev 2, If 0, Driver=hub/4p, 480M  |__ Port 2: Dev 3, If 0, Driver=hub/4p, 480M  |__ Port 3: Dev 5, If 0, Interface Device, Driver=usbhid, 1.5M  |__ Port 4: Dev 6, If 0, Interface Device, Driver=usbhid, 1.5M  |__ Port 4: Dev 4, If 0, Specific Class, Driver=, 480M /: Bus 01.Port 1: Dev 1, Driver=ci_hdrc/1p, 480M  |__ Port 1: Dev 2, If 0, Storage, Driver=usb-storage, 480M 

Print a list of hubs with the ability to switch ports:

root@verdin-imx8mm:~# uhubctl Current status for hub 2-1 [0424:2744 Microchip Tech USB2744, USB 2.10, 4 ports]  Port 1: 0100 power  Port 2: 0503 power highspeed enable connect [1a40:0101 USB 2.0 Hub]  Port 3: 0100 power  Port 4: 0503 power highspeed enable connect [0424:2740 Microchip Tech Hub Controller] Current status for hub 2 [1d6b:0002 Linux 4.14.170-4.0.0-devel+git.5c643afa32be ehci_hcd EHCI Host Controller ci_hdrc.1]  Port 1: 0503 power highspeed enable connect [0424:2744 Microchip Tech USB2744, USB 2.10, 4 ports] Current status for hub 1 [1d6b:0002 Linux 4.14.170-4.0.0-devel+git.5c643afa32be ehci_hcd EHCI Host Controller ci_hdrc.0]  Port 1: 0503 power highspeed enable connect [0951:162d Kingston DataTraveler 102 001372877298BB31C0000009] 

The root hubs for bus 1 and bus 2 and the hub 2-1 on the Dahlia are able to switch their port power. The external hub on X4 does not have that capability as it is not part of the list.

Switching power to the external hub on Bus 2 off:

root@verdin-imx8mm:~# uhubctl -l 2-1 -p 2 -a off Current status for hub 2-1 [0424:2744 Microchip Tech USB2744, USB 2.10, 4 ports]  Port 2: 0503 power highspeed enable connect [1a40:0101 USB 2.0 Hub] Sent power off request New status for hub 2-1 [0424:2744 Microchip Tech USB2744, USB 2.10, 4 ports]  Port 2: 0000 off root@verdin-imx8mm:~# [ 2944.305210] usb 2-1.2-port4: cannot reset (err = -71) [ 2944.314338] usb 2-1.2-port4: cannot reset (err = -71) [ 2944.323451] usb 2-1.2-port4: cannot reset (err = -71) [ 2944.332574] usb 2-1.2-port4: cannot reset (err = -71) [ 2944.341694] usb 2-1.2-port4: cannot reset (err = -71) [ 2944.346783] usb 2-1.2-port4: Cannot enable. Maybe the USB cable is bad? [ 2944.357892] usb 2-1.2-port4: cannot disable (err = -71) [ 2944.367204] usb 2-1.2-port3: cannot reset (err = -71) [ 2944.376319] usb 2-1.2-port3: cannot reset (err = -71) 

The driver for the mouse and keyboard try to talk to their devices and complain loudly. So it is better to first remove the driver instances handling mouse, keyboard and the hub connected to X4. Only then remove power to port 2 of the hub on Dahlia:

root@verdin-imx8mm:~# echo 1 > /sys/bus/usb/devices/2-1.2.3/remove [ 73.942867] usb 2-1.2.3: USB disconnect, device number 5 root@verdin-imx8mm:~# echo 1 > /sys/bus/usb/devices/2-1.2.4/remove [ 78.813980] usb 2-1.2.4: USB disconnect, device number 6 root@verdin-imx8mm:~# echo 1 > /sys/bus/usb/devices/2-1.2/remove [ 92.273859] usb 2-1.2: USB disconnect, device number 3 root@verdin-imx8mm:~# uhubctl -l 2-1 -p 2 -a off Current status for hub 2-1 [0424:2744 Microchip Tech USB2744, USB 2.10, 4 ports]  Port 2: 0101 power connect [] Sent power off request New status for hub 2-1 [0424:2744 Microchip Tech USB2744, USB 2.10, 4 ports]  Port 2: 0000 off 

Now re-enable power on that port. Power is restored, the USB devices announce themselves and the respective drivers are instantiated and bring up the devices:

root@verdin-imx8mm:~# uhubctl -l 2-1 -p 2 -a on Current status for hub 2-1 [0424:2744 Microchip Tech USB2744, USB 2.10, 4 ports]  Port 2: 0000 off Sent power on request New status for hub 2-1 [0424:2744 Microchip Tech USB2744, USB 2.10, 4 ports]  Port 2: 0100 power root@verdin-imx8mm:~# [ 267.500712] usb 2-1.2: new high-speed USB device number 7 using ci_hdrc [ 267.615831] hub 2-1.2:1.0: USB hub found [ 267.619994] hub 2-1.2:1.0: 4 ports detected [ 267.912724] usb 2-1.2.3: new low-speed USB device number 8 using ci_hdrc [ 268.051938] input: SCISSORS Keyboard as /devices/platform/32e50000.usb/ci_hdrc.1/usb2/2-1/2-1.2/2-1.2.3/2-1.2.3:1.0/0003:0DC6:3100.0003/input/input4 [ 268.126362] hid-generic 0003:0DC6:3100.0003: input,hidraw0: USB HID v1.00 Keyboard [ SCISSORS Keyboard] on usb-ci_hdrc.1-1.2.3/input0 [ 268.216380] usb 2-1.2.4: new low-speed USB device number 9 using ci_hdrc [ 268.341552] input: Genius NetScroll + Mini Traveler as /devices/platform/32e50000.usb/ci_hdrc.1/usb2/2-1/2-1.2/2-1.2.4/2-1.2.4:1.0/0003:0458:0036.0004/input/input5 [ 268.356900] hid-generic 0003:0458:0036.0004: input,hidraw1: USB HID v1.10 Mouse [Genius NetScroll + Mini Traveler] on usb-ci_hdrc.1-1.2.4/input0 

Similarly for the mass storage device. First we eject it to get the file system in a consistent state, remove it and lastly we switch off port power of the root hub.

root@verdin-imx8mm:~# eject /dev/sda [ 630.140511] sda: detected capacity change from 2000683008 to 0 root@verdin-imx8mm:~# echo 1 > /sys/bus/usb/devices/1-1/remove root@verdin-imx8mm:~# [ 642.516578] usb 1-1: USB disconnect, device number 6 root@verdin-imx8mm:~# uhubctl -l 1 -p 1 -a off Current status for hub 1 [1d6b:0002 Linux 4.14.170-4.0.0-devel+git.5c643afa32be ehci_hcd EHCI Host Controller ci_hdrc.0]  Port 1: 0101 power connect [] Sent power off request New status for hub 1 [1d6b:0002 Linux 4.14.170-4.0.0-devel+git.5c643afa32be ehci_hcd EHCI Host Controller ci_hdrc.0]  Port 1: 0000 off 

Источник

Analog Devices Wiki

Diff

This version ( 27 Jan 2021 22:40 ) was approved by Robin Getz. The Previously approved version (27 Jul 2020 07:21) is available.

Table of Contents

USB Interface

Introduction

This document introduces usage of USB interface for SC5XX Linux. There are two different kinds of USB controller on SC5XX silicon, one supports OTG (On-The-Go) for USB2.0, which is able to work as Host or Device dynamically according to the standard USB HNP protocol. Another support Host or Device only, dedicated hardware and software configurations should be made in advance to identify it is for Host or Device mode.

Example Usage Description

In this page, we cover configuration and example on how to use USB interface in Host, Device, and OTG mode, and take ADSP -SC589 EZ-Kit ( with an OTG port and a HS port) as example to demonstrate the USB usage, which using the USB — OTG port to illustrate both Host (Host only mode) and OTG ( auto-detected Dual Role mode ) cases, and the USB1-HS port to illustrate DEVICE (Gadget only mode)example.

Supported Board

Below table shows numbers of the USB controller for SC589/584/573 chips [supported: ✔ ; unsupported: ✘ ]

Board Hardware Port USB 2.0 Supported Mode
HOST-Host only mode DEVICE-Gadget only mode OTG-Dual Role mode
adsp-sc573-ezkit USB0 — OTG Port ( P23 )
adsp-sc584-ezkit USB0 — OTG Port ( P23 )
adsp-sc589-ezkit USB0 — OTG Port ( P10 )
USB1 — HS Port ( P11 )
adsp-sc589-mini USB0 — OTG Port ( P10 )
USB1 — HS Port ( J7 )

HOST — host only mode

With the USB Host mode, we can add a lot of USB dongle peripheral to the Ez-Kits and using the corresponding features.

Hardware Connection Software Configuration

Step 1: Linux kernel Configuration:

$ bitbake linux-adi -c cleansstate $ bitbake linux-adi -c menuconfig

Step 2: Configure the USB drivers to host mode:

Device Drivers ---> [*] USB support ---> Support for Host-side USB [*] Enable USB persist by default Inventra Highspeed Dual Role Controller MUSB Mode Selection (Host only mode) ---> *** Platform Glue Layer *** ADI *** MUSB DMA mode *** [N] Disable DMA (always use PIO) [*] Inventra

Step 3: Configure the USB host mode supported devices:

Device Drivers ---> SCSI device support ---> SCSI device support SCSI disk support [*] USB support ---> USB Mass Storage support

Step 4: Build target images:

USB Host Mode Example Usage:

DEVICE — gadget only mode

With the USB Device mode, we can connect the the Ez-Kits to a host PC other Hosts with the USB cable and make the Ez-Kits as an USB Devices: Hardware Connection Software Configuration

Step 1: Linux kernel Configuration:

$ bitbake linux-adi -c cleansstate $ bitbake linux-adi -c menuconfig

Step 2: Configure the USB drivers to device mode(gadget only):

Device Drivers ---> [*] USB support ---> Support for Host-side USB Inventra Highspeed Dual Role Controller MUSB Mode Selection (Gadget only mode) ---> *** Platform Glue Layer *** ADI *** MUSB DMA mode *** [N] Disable DMA (always use PIO) [*] Inventra USB Gadget Support ---> USB Physical Layer drivers ---> NOP USB Transceiver Driver

Step 3: Configure the USB device mode supported devices:

Device Drivers ---> [*] USB support ---> USB Gadget Support ---> USB Gadget precomposed configurations Gadget Zero (DEVELOPMENT) Audio Gadget [*] UAC 1.0 [*] UAC 1.0 (Legacy) Ethernet Gadget (with CDC Ethernet support) [*] RNDIS support Gadget Filesystem Mass Storage Gadget Serial Gadget (with CDC ACM and CDC OBEX support) HID Gadget

Step 4: Build target images:

USB Device Mode Example Usage:

OTG — dual role mode

The USB OTG port can work as either Host or Device, depends on the way we connect it, for Host or Device application, as illustrated previously.

resources/tools-software/linuxdsp/docs/linux-kernel-and-drivers/usb/start.txt · Last modified: 27 Jan 2021 22:35 by Robin Getz

Page Tools

Analog Devices Uses Cookies for Enhanced Online Performance

Some cookies are required for secure log-ins but others are optional for functional activities. Our data collection is used to improve our products and services. We recommend you accept our cookies to ensure you’re receiving the best performance and functionality our site can provide. For additional information you may view the cookie details. Read more about our privacy policy.

The cookies we use can be categorized as follows:

Strictly Necessary Cookies: These are cookies that are required for the operation of analog.com or specific functionality offered. They either serve the sole purpose of carrying out network transmissions or are strictly necessary to provide an online service explicitly requested by you. Analytics/Performance Cookies: These cookies allow us to carry out web analytics or other forms of audience measuring such as recognizing and counting the number of visitors and seeing how visitors move around our website. This helps us to improve the way the website works, for example, by ensuring that users are easily finding what they are looking for. Functionality Cookies: These cookies are used to recognize you when you return to our website. This enables us to personalize our content for you, greet you by name and remember your preferences (for example, your choice of language or region). Loss of the information in these cookies may make our services less functional, but would not prevent the website from working. Targeting/Profiling Cookies: These cookies record your visit to our website and/or your use of the services, the pages you have visited and the links you have followed. We will use this information to make the website and the advertising displayed on it more relevant to your interests. We may also share this information with third parties for this purpose. Decline cookies

©1995 — 2023 Analog Devices, Inc. All Rights Reserved

Источник

Читайте также:  Riseup vpn kali linux
Оцените статью
Adblock
detector