Surendran
Member – Technical (Software)
Basic Terms
USB On-The-Go introduces the concept that a device can perform both the master and
slave roles.
USB Host system has three main parts:
 USB Host
 USB Interconnect
 USB Device.
USB Host :Host interface contains host controller .Host controller is main software
driver for host.
The host includes an embedded hub called the root hub which provides one or
more attachment points, or ports.
USB Interconnect :USB interconnect is a tiered star topology. A maximum of seven
tiers are allowed, and the root hub occupies the first tier
USB devices are classified as either Hub or function
(Ex: Pen drive , Mouse , Keyboard...etc) .
USB Host Topology
Tier 1 : Root hub (Host)
Tier 2 : External or Internal hub or Function
Tier 3 : Function or External hub
Miscellaneous
Host Controller:
The host controller driver converts data between the format that is used by the host
computer and the format used by the USB host controller
Host Controller driver protocol:
• UHCI - Universal Host controller Interface.
• OHCI - Open Host controller Interface.
• EHCI - Enhanced Host controller interface.
• xHCI - Extensible Host controller interface.
Functions are Speed Type:
 High-speed functions operate at up to 480 Mb/s.
 Full-speed functions operate at up to 12 Mb/s.
 Low-speed functions operate at up to 1.5 Mb/s.
USB Device States
• Attached state
• Powered state
• Default state
• Address state
• Configured state
• Suspended state
Architecture Diagram
Client driver
USBD driver
HCD
Interface
Protocol driver
[Host controller
driver]
Host controller
Interface
Host controller
Hardware
 USB client device need and support the USB host
client driver.(Contains the API’s for HID and mass
storage)
 USBD is the driver for host system. Takes care of
attach, detach etc.
 HCD interface is the block for interconnecting the
Host controller driver and the USB driver.
 Host controller driver is the main host driver
 Host controller interface is communicate between
HC hardware and HC interface, Here protocol and
Designware block is done
Endpoints:
It occur at the end of the communications channel at the USB function.
Pipes :
While the device sends and receives data on a series of endpoints, the client software
transfers data through pipes. A pipe is a logical connection between the host and endpoint.
Endpoints and Pipes
Endpoint
Pipes
 There are 16 endpoint. Each endpoint has IN and OUT directions
Ex:EP0,EP1,EP2...
 EP0 is the Controlling the device.(Default)
 Length of the cable is limited to 5 meters.
Types of pipes:
• Message pipe
• Stream pipe
Message pipe:
 Control Exchange pipe ( Endpoint0 )
Stream Pipe:
 Interrupt pipe
 Bulk pipe
 Isochronous pipe
Endpoints and Pipes
Transfer and Packet Types
Transfer Type
• Control Transfer
• Interrupt Transfer
• Isochronous Transfer
• Bulk Transfer
Packet Types
• Token
• OUT
• IN
• SOF
• SETUP
• Data
• DATA0
• DATA1
• DATA2 [High speed data]
• MDATA [Split/high speed Data]
• Handshake
• ACK
• NAK
• STALL
• NYET
• Special
• PRE
• ERR
• SPLIT
• PING
• EXT
Data Transfer Types
Control :
 Non-periodic transfer
 Status operations
 Used for configuration
 Requesting information from the device
Interrupt :
 Periodical Transfer
Isochronous:
 Periodical and continuous
 It cannot used for low speed device
 Its is commonly used for time-dependent information
 Audio/video streaming.
Bulk:
 Non – periodical
 Large amount of the non-time sensitive data such as printer and scanner
 Bi-directional
 Have low priority
 If bus is busy with other transaction this will delay
Three USB process:
1.Dynamic detection
2.Enumeration
3.Configuration
There are two types of USB Hub
Self-powered hub Bus powered hub
USB HUB
Suspend Mode
Suspend mode is to reduce the power consumption .
Devices will go into suspend if they see an idle bus for an extended period of time. (3 ms)
Start of Frames (SOF) are also used to keep devices from going into suspend. the host is
issuing traffic on the bus and keeping devices from entering their suspended state.
Keep Alive: Signal used in low-speed devices. Low-speed devices lack a Start-of-Frame
packet that is required to prevent suspend. They use an EOP every 1 ms to keep the device from
entering suspend.
Some devices, typically keyboards and mice, support the ability to issue a remote wakeup
signal to the host.
Resume is used to wake up a device from suspend.
How it works
Enumeration
Once device has been attached. Device will notifies the host via its status change pipe .Host
in Attached state
At this point power host will powerup all the port. powered state at this point.
The port to which it has been attached is disabled.
Host request for Descriptor.
Wait at least 100 millisecond to allow a device to complete its insertion process.
Once hub is connected and device is not connected to hub , Host will be in Suspend state .
Hub will reset port which has been attached, the port is enabled and the device enters the
default state.
Host assigns the device a unique address, thereby transitioning the device into the address
state.
How it works
Host requests the device descriptor from the device via the default control pipe.
Host controller will started configuration process(Configuration state) .
Then detach ,re-attached ,data transfer process are done.
OTG controller
OTG Controller
USB OTG mini port can produce maximum current upto 100mA .
Host Controller
USB micro OTG Port
Challenges Undertaken
Learning process :
Understood the USB host functionality of Altera cyclone V.
Understood the software flow of the USB host and architecture.
As per altera cyclone V , host not supports any of the common protocols like
EHCI,UHCI,OHCI or XHCI .It is of Synopsys designware controller.
Initially USB host not supports Hub. Later , USB hub Features are enabled.
With this stage bus-powered hub able to detect one device and self-powered hub able to
detect maximum of 2 device.
Linux USB Designware OTG controller software flow is analyzed and documented.
WEC7 Designware host controller compared with Linux DW code and modified .From
this implementation data read/write and detection time is reduced.
USB host driver source code flow is captured and documented for Reference.
Challenges Undertaken
Data transfer is tested, small file able to transfer the data’s properly, large files (90 MB) not
able to transfer. And this is fixed by giving delay before issuing the data.
Analyzed Reference code from iMX6 platform and thread wait time is changed to
infinite .As a result of the modification pendrive not able to mount.
UsbInterruptThread function is the main IST and it is re-structured according to Linux
working model. Due to this implementation Performance is improved in USB detection.
Tested Self-Powered Hub, Hub goes suspend mode .Suspend block is removed from the
code. So that it won’t suspend the device. Suspend issue is corrected.
Analyzed HNP (Host Negotiation Protocol) and concluded that it is not required for the
Hub implementation.
SetorClearFeature function fails randomly sometimes. Solved by adding the delay before
the feature setting and clearing process .
Challenges Undertaken
WaitForPortStatusChange function is restructured. Now able to get descriptor for all the
hub port and connect/disconnect is stable. But device not able to mount.
Now ,
Through Hub
(self- powered)
Connect/Disconnect
Mounting Data Transfer Time Test Result
Mouse --- --- --- Not working
Keyboard --- --- --- Not working
Pendrive 1
Inconsistent( Need to
connect one by one )
yes yes ( 90MB Takes 20mins ) Working
Pendrive 2 yes yes Working
Pendrive 3 yes yes Working
Pendrive 4 yes yes Working
Split protocol
Low or Full speed device Through hub needs split protocol.
Ex: Mouse and Keyboard
The host controller and the hub support a special type of transaction called a split transaction.
A split transaction involves only the host controller and a high-speed hub
It is transparent to any devices.
This scheme of using split-transaction to support low-speed and full-speed devices on a high-
speed hub.
For working of multiple mouse/keyboard split protocol implementation is required. Split
protocol code enabled and tested with the bus powered Hub. In this code, device was not able to
detect.
Split protocol
THANK YOU

Usb old

  • 1.
  • 2.
    Basic Terms USB On-The-Gointroduces the concept that a device can perform both the master and slave roles. USB Host system has three main parts:  USB Host  USB Interconnect  USB Device. USB Host :Host interface contains host controller .Host controller is main software driver for host. The host includes an embedded hub called the root hub which provides one or more attachment points, or ports. USB Interconnect :USB interconnect is a tiered star topology. A maximum of seven tiers are allowed, and the root hub occupies the first tier USB devices are classified as either Hub or function (Ex: Pen drive , Mouse , Keyboard...etc) .
  • 3.
    USB Host Topology Tier1 : Root hub (Host) Tier 2 : External or Internal hub or Function Tier 3 : Function or External hub
  • 4.
    Miscellaneous Host Controller: The hostcontroller driver converts data between the format that is used by the host computer and the format used by the USB host controller Host Controller driver protocol: • UHCI - Universal Host controller Interface. • OHCI - Open Host controller Interface. • EHCI - Enhanced Host controller interface. • xHCI - Extensible Host controller interface. Functions are Speed Type:  High-speed functions operate at up to 480 Mb/s.  Full-speed functions operate at up to 12 Mb/s.  Low-speed functions operate at up to 1.5 Mb/s. USB Device States • Attached state • Powered state • Default state • Address state • Configured state • Suspended state
  • 5.
    Architecture Diagram Client driver USBDdriver HCD Interface Protocol driver [Host controller driver] Host controller Interface Host controller Hardware  USB client device need and support the USB host client driver.(Contains the API’s for HID and mass storage)  USBD is the driver for host system. Takes care of attach, detach etc.  HCD interface is the block for interconnecting the Host controller driver and the USB driver.  Host controller driver is the main host driver  Host controller interface is communicate between HC hardware and HC interface, Here protocol and Designware block is done
  • 6.
    Endpoints: It occur atthe end of the communications channel at the USB function. Pipes : While the device sends and receives data on a series of endpoints, the client software transfers data through pipes. A pipe is a logical connection between the host and endpoint. Endpoints and Pipes Endpoint Pipes  There are 16 endpoint. Each endpoint has IN and OUT directions Ex:EP0,EP1,EP2...  EP0 is the Controlling the device.(Default)  Length of the cable is limited to 5 meters.
  • 7.
    Types of pipes: •Message pipe • Stream pipe Message pipe:  Control Exchange pipe ( Endpoint0 ) Stream Pipe:  Interrupt pipe  Bulk pipe  Isochronous pipe Endpoints and Pipes
  • 8.
    Transfer and PacketTypes Transfer Type • Control Transfer • Interrupt Transfer • Isochronous Transfer • Bulk Transfer Packet Types • Token • OUT • IN • SOF • SETUP • Data • DATA0 • DATA1 • DATA2 [High speed data] • MDATA [Split/high speed Data] • Handshake • ACK • NAK • STALL • NYET • Special • PRE • ERR • SPLIT • PING • EXT
  • 9.
    Data Transfer Types Control:  Non-periodic transfer  Status operations  Used for configuration  Requesting information from the device Interrupt :  Periodical Transfer Isochronous:  Periodical and continuous  It cannot used for low speed device  Its is commonly used for time-dependent information  Audio/video streaming. Bulk:  Non – periodical  Large amount of the non-time sensitive data such as printer and scanner  Bi-directional  Have low priority  If bus is busy with other transaction this will delay
  • 10.
    Three USB process: 1.Dynamicdetection 2.Enumeration 3.Configuration There are two types of USB Hub Self-powered hub Bus powered hub USB HUB
  • 11.
    Suspend Mode Suspend modeis to reduce the power consumption . Devices will go into suspend if they see an idle bus for an extended period of time. (3 ms) Start of Frames (SOF) are also used to keep devices from going into suspend. the host is issuing traffic on the bus and keeping devices from entering their suspended state. Keep Alive: Signal used in low-speed devices. Low-speed devices lack a Start-of-Frame packet that is required to prevent suspend. They use an EOP every 1 ms to keep the device from entering suspend. Some devices, typically keyboards and mice, support the ability to issue a remote wakeup signal to the host. Resume is used to wake up a device from suspend.
  • 12.
    How it works Enumeration Oncedevice has been attached. Device will notifies the host via its status change pipe .Host in Attached state At this point power host will powerup all the port. powered state at this point. The port to which it has been attached is disabled. Host request for Descriptor. Wait at least 100 millisecond to allow a device to complete its insertion process. Once hub is connected and device is not connected to hub , Host will be in Suspend state . Hub will reset port which has been attached, the port is enabled and the device enters the default state. Host assigns the device a unique address, thereby transitioning the device into the address state.
  • 13.
    How it works Hostrequests the device descriptor from the device via the default control pipe. Host controller will started configuration process(Configuration state) . Then detach ,re-attached ,data transfer process are done.
  • 14.
    OTG controller OTG Controller USBOTG mini port can produce maximum current upto 100mA . Host Controller USB micro OTG Port
  • 15.
    Challenges Undertaken Learning process: Understood the USB host functionality of Altera cyclone V. Understood the software flow of the USB host and architecture. As per altera cyclone V , host not supports any of the common protocols like EHCI,UHCI,OHCI or XHCI .It is of Synopsys designware controller. Initially USB host not supports Hub. Later , USB hub Features are enabled. With this stage bus-powered hub able to detect one device and self-powered hub able to detect maximum of 2 device. Linux USB Designware OTG controller software flow is analyzed and documented. WEC7 Designware host controller compared with Linux DW code and modified .From this implementation data read/write and detection time is reduced. USB host driver source code flow is captured and documented for Reference.
  • 16.
    Challenges Undertaken Data transferis tested, small file able to transfer the data’s properly, large files (90 MB) not able to transfer. And this is fixed by giving delay before issuing the data. Analyzed Reference code from iMX6 platform and thread wait time is changed to infinite .As a result of the modification pendrive not able to mount. UsbInterruptThread function is the main IST and it is re-structured according to Linux working model. Due to this implementation Performance is improved in USB detection. Tested Self-Powered Hub, Hub goes suspend mode .Suspend block is removed from the code. So that it won’t suspend the device. Suspend issue is corrected. Analyzed HNP (Host Negotiation Protocol) and concluded that it is not required for the Hub implementation. SetorClearFeature function fails randomly sometimes. Solved by adding the delay before the feature setting and clearing process .
  • 17.
    Challenges Undertaken WaitForPortStatusChange functionis restructured. Now able to get descriptor for all the hub port and connect/disconnect is stable. But device not able to mount. Now , Through Hub (self- powered) Connect/Disconnect Mounting Data Transfer Time Test Result Mouse --- --- --- Not working Keyboard --- --- --- Not working Pendrive 1 Inconsistent( Need to connect one by one ) yes yes ( 90MB Takes 20mins ) Working Pendrive 2 yes yes Working Pendrive 3 yes yes Working Pendrive 4 yes yes Working
  • 18.
    Split protocol Low orFull speed device Through hub needs split protocol. Ex: Mouse and Keyboard The host controller and the hub support a special type of transaction called a split transaction. A split transaction involves only the host controller and a high-speed hub It is transparent to any devices. This scheme of using split-transaction to support low-speed and full-speed devices on a high- speed hub. For working of multiple mouse/keyboard split protocol implementation is required. Split protocol code enabled and tested with the bus powered Hub. In this code, device was not able to detect.
  • 19.
  • 20.