Usb Device Driver for Bulk Data Transfer

Embed Size (px)

Citation preview

  • 7/30/2019 Usb Device Driver for Bulk Data Transfer

    1/8

    DESIGN OF USB DEVICE DRIVER FOR BULK DATA

    TRANSFERABSTRACT

    USB has become a popular interface for exchanging data between PCs and peripherals. Anincreasing number of portable peripherals are using the USB interface to communicate with the

    PC. The design and implementation of a synthesizable model of the USB 1.1 protocol engine is

    presented in this report The PHY is compatible with the USB 1.1 transceiver macrocell interface

    (UTMI) specification and the simulation test confirmed the successful operation of circuits for

    both full speed (12 Mbps) and low speed (1.5 Mbps) data transmission. The model is written

    completely in behavioral HDL with a top down approach and the model was verified and

    validated.This thesis describes the protocol used in USB 1.1 systems low-level interface. It also

    describes the type of transactions and errors in USB transactions. The goal is to Designing of

    Protocol Engine for the USB device. The design of SIE (Serial Interface Engine) is implemented

    in a Verilog Hardware Description Language.

    INTRODUCTION

    Universal Serial Bus (USB) has emerged as a result of the difficulties associated with

    thecost, configuration, and attachment of the peripheral devices in the personal computer

    environment. In short, USB creates a method of attaching, and accessing peripheraldevices that

    reduce overall cost, simplifies the attachment and configuration from theenduser perspective, and

    attempt to solve several technical issues associated with the old style peripherals.

    The motivation for the Universal Serial Bus (USB) comes from two interrelated considerations:

    Ease of use: The lack of flexibility in reconfiguring the PC has been acknowledged as the

    Achillesheel to its further deployment. The combination of user-friendly graphical interfaces

    and the hardware and software mechanisms associated with new generation bus architectures

    have made computers less confrontational and easier to reconfigure. However, from the end

    users point of view, the I/O interfaces of PCs, such as serial/parallel ports,

    keyboard/mouse/joystick interfaces, etc., do not have the attributes of plug-and-play. Other once

    is Port Expansion: The addition of external peripherals continues to be constrained by port

    availability. The lack of a bi-directional, low-cost, low-to-mid speed peripheral bus has held back

    the creative proliferation of peripherals such as telephone/fax/modem adapters, answering

  • 7/30/2019 Usb Device Driver for Bulk Data Transfer

    2/8

    machines, scanners, PDAs, keyboards, mice, etc. Existing interconnects are optimized to

    connect products for one or two ports. As each new function or capability is added to the PC, a

    new interface has been defined to address this need. The USB is the answer to connectivity for

    the PC architecture. It is a fast, bidirectional, isochronous, low-cost, dynamically attachable

    serial interface that is consistent with the requirements of the PC platform of today and

    tomorrow.

    BLOCK DIAGRAM:

    Serial_out

    Serial_in

    Ack

    Nack

    ADVANTAGES:

    Used to transfer large bursty data.

    Error detection via CRC, with guarantee of delivery.

    No guarantee of bandwidth or minimum latency.

    Stream Pipe - Unidirectional

    Full & high speed modes only.

    TOOLS:

    Language: Verilog HDL

    Simulation: Modelsim

    A Ack

    Parallel_in

    Nack

    Serial_in

    Tx Rx

    State Machine

    Host

    Client

  • 7/30/2019 Usb Device Driver for Bulk Data Transfer

    3/8

    USB 2.0 cables and peripherals were designed to be backward compatible with USB 1.1 devices.

    Brief USB Overview and USB History

    All Articles: USB Internals

    USB Overview

    In the past, connecting multiple peripheral devices to computer has been a real problem. There were too

    many different port types (serial port, parallel port, PS/2 etc.) and their use imposes limitations such as no

    hot-pluggability and automatic configuration. There are very limited number of ways to attach the peripheral

    devices in the original IBM PC implementation due to the requirements in terms of non-shareable IRQ lines

    and I/O address space. The main reason that Universal Serial Bus was implemented to provide a

    replacement for those legacy ports on a computer to make the addition of the peripheral devices quick and

    easy for end user.

    USB is designed to allow many peripherals to be connected using a single standardized interface. It provides

    an expandable, fast, bi-directional, low-cost, hot-pluggable Plug and Play serial hardware interface that

    makes the life of the computer users easier allowing them to plug different peripheral devices into a USB

    port and have them automatically configured and ready to use. Using a single connector type, USB allows

    the user to connect a wide range of peripheral devices, such as keyboards, mice, printers, scanners, mass

    storage devices, telephones, modems, digital still-image cameras, video cameras, audio devices to a

    computer. USB devices do not directly consume system resources. They are not mapped into I/O address

    space, nor do they use IRQ lines or DMA channels. The only system resources required by a USB system are

    the memory buffers used by the USB system software. Due to its success and widespread acceptance, USB

    became the 'de-facto' industry standard for connecting peripheral devices to PCs and laptops.

    The USB has the following key features:

    Single connector type: USB replaces all the different legacy connectors with one well-defined,

    standardized USB connector for all USB peripheral devices, eliminating the need for different cables

    and connectors and thus simplifying the design of the USB devices. So all USB devices can be

    connected directly to a standard USB port on a computer.

    Hot-swappable: USB devices can be safely plugged and unplugged as needed while the computer is

    running. So there is no need to reboot.

    Plug and Play: Operating system software automatically identifies, configures, and loads the

    appropriate device driver when a user connects a USB device.

    High performance: USB offers low speed (1.5 Mbit/s), full speed (12 Mbit/s) and high speed (up to

    480 Mbit/s) transfer rates that can support a variety of USB peripherals. USB 3.0 (SuperSpeed USB)

    achieves the throughput up to 5.0 Gbit/s.

    http://www.usblyzer.com/usb-internals.htmhttp://www.usblyzer.com/usb-internals.htm
  • 7/30/2019 Usb Device Driver for Bulk Data Transfer

    4/8

    Expandability: Up to 127 different peripheral devices may theoretically be connected to a single bus

    at one time.

    Power supplied from the bus: USB distributes the power to all connected devices eliminating the

    need for external power source for low-power devices. High-power devices can still require their

    own local power supply. USB also supports power saving suspend/resume modes.

    Easy to use for end user: A single standard connector type for all USB devices simplifies the end

    user's task at figuring out which plugs go into which sockets. The operating system automatically

    recognizes the USB device attachment and loads appropriate device drivers.

    Low-cost implementation: Most of the complexity of the USB protocol is handled by the host, which

    along with low-cost connection for peripherals makes the design simple and low cost.

    A Brief USB History

    The USB was developed and standardized by a group of leading companies from the computer and

    electronics industries in 1995.

    The Universal Serial Bus specification, which defines all aspects of the USB system from the physical layer

    (mechanical and electrical) all the way up to the software layer, was developed by Compaq, Digital

    Equipment Corporation (DEC),IBM, Intel, Microsoft andNEC, joined later by Hewlett-Packard,Lucent and

    Philips. Compaq, which merged with Hewlett Packard, bought DEC and Lucent merged with Alcatel to form

    Alcatel-Lucent.

    These companies also formed the USB Implementers Forum, Inc. (USB-IF) as a non-profit corporation to

    publish the specifications and provide a support organization and forum for the advancement and adoption

    of USB technology.

    USB Specification

    The design of USB is standardized in Universal Serial Bus Specification that provides the technical details to

    understand USB requirements. The specification describes the bus attributes, the protocol definition, types

    of transactions, bus management, and the programming interface required to design USB compatible

    http://www.compaq.com/http://www.digital.com/http://www.digital.com/http://www.ibm.com/http://www.ibm.com/http://www.intel.com/http://www.microsoft.com/http://www.nec.com/http://www.nec.com/http://www.hp.com/http://www.lucent.com/http://www.lucent.com/http://www.philips.com/http://www.philips.com/http://www.alcatel.com/http://www.alcatel-lucent.com/http://www.usb.org/http://www.usb.org/http://www.compaq.com/http://www.digital.com/http://www.digital.com/http://www.ibm.com/http://www.intel.com/http://www.microsoft.com/http://www.nec.com/http://www.hp.com/http://www.lucent.com/http://www.philips.com/http://www.alcatel.com/http://www.alcatel-lucent.com/http://www.usb.org/
  • 7/30/2019 Usb Device Driver for Bulk Data Transfer

    5/8

    peripherals and software. USB Specifications and all related documents are freely downloadable from USB

    Implementers Forum web site.

    Versions of USB specification:

    Revision 1.0 released on January 15, 1996, introduced a low-speed transfer rate of 1.5 Mbit/s and a

    full-speed transfer rate of 12 Mbit/s.

    Revision 1.1 released on September 23, 1998, introduced the improved specification and was the

    first widely used version of USB.

    Revision 2.0 released on April 27, 2000. The major feature of revision 2.0 was the addition of a

    high-speed transfer rate of 480 Mbit/s.

    Revision 3.0 released on November 17, 2008, brings significant performance enhancements to the

    USB standard while offering backward compatibility with the peripheral devices currently in use.

    Legacy USB 1.1/2.0 devices continue to work while plugged into new USB 3.0 host and new USB

    3.0 devices work at USB 2.0 speed while plugged into USB 2.0 host. Delivering data transfer rates

    up to ten times faster (the raw throughput is up to 5.0 Gbit/s) than Hi-Speed USB (USB 2.0),

    SuperSpeed USB is the next step in the continued evolution of USB technology.Data Transfer Rate Comparison

    USB Revision USB1.0 USB2.0 USB3.0

    Media (Data Size) Transfer Time

    Song / Pic (4 MB) 5.3 sec 0.1 sec 0.01 sec

    256 Flash (256 MB) 5.7 min 8.5 sec 0.8 sec

    USB Flash (1 GB) 22 min 33 sec 3.3 sec

    SD-Movie (6 GB) 2.2 hr 3.3 min 20 sec

    USB Flash (16 GB) 5.9 hr 8.9 min 53.3 sec

    HD-Movie (25GB) 9.3 hr 13.9 min 70 sec

    Note, however, that all above mentioned are theoretical maximum data transfer rates that do not take into

    consideration some USB protocol overhead and bus utilization, which makes a difference in actual maximum

    throughput. The actual maximum throughput may vary depending on the transfer type, maximum packet

    size, time reserved for control transfers, the overhead due to signaling imposed bit stuffing etc.

    Each iteration of the specification is backward compatible with previous revisions. Since all USB devices use

    the same cables, connectors and software interfaces, there is no change in the usage model for the end

    user. USB 1.0, USB 1.1 and USB 2.0 compliant peripheral devices can operate on a computer at the same

    time. It is possible for a high-speed USB 2.0 device to plug into a USB1.1 port and operate at the

    appropriate transfer rate.

    Using USBlyzer - Viewing the USB Specification Version

    You can view USB Specification revision number for USB devices and external hubs.

    To view USB Specification revision number a USB device compliant with

    1. Open USBlyzer.

    http://www.usb.org/developers/docs/http://www.usb.org/developers/docs/http://www.usb.org/developers/docs/http://www.usb.org/developers/docs/
  • 7/30/2019 Usb Device Driver for Bulk Data Transfer

    6/8

    2. In the USB Device Tree panel select the device for which you want to see USB Specification revision

    number.

    3. In the USB Properties panel see the bcdUSB field value of the Device Descriptor.

    Device Descriptor VOIP USB Phone

    Offset Field Size Value Description0 bLength 1 12h1 bDescriptorType 1 01h Device2 bcdUSB 2 0101h Fails WHQL testing. Should be 0110h4 bDeviceClass 1 00h Class information in the Interface Descriptors5 bDeviceSubClass 1 00h6 bDeviceProtocol 1 00h7 bMaxPacketSize0 1 40h 64 bytes8 idVendor 2 6 99 3h Freshtel

    10 idProduct 2 B 00 1h12 bcdDevice 2 0 00 0h 0.0014 iManufacturer 1 01h "Yealink Network Technology Ltd."15 iProduct 1 02h "VOIP USB Phone"16 iSerialNumber 1 00h

    17 bNumConfigurations 1 01h

    Note, that in the above example the U.S. Robotics USB Phone 9600 incorrectly reports its compliance with

    the USB Specification 1.1 as 0101h.

    bcdUSB field in the standard USB Device Descriptor may have the following values:

    0100h - USB Specification 1.0

    0110h - USB Specification 1.1

    0200h - USB Specification 2.0

    Since some devices incorrectly expose bcdUSB field as 0101h instead of 0110h, the operating system

    accepts both as valid revision number. But failure to correctly report this value can prevent the driver from

    passing the Windows Hardware Quality Labs (WHQL) testing and may also cause a device to fail tests in theUSB test tools.

    USB Logo

    To complement the USB specification in real products, the USB-IF maintains a Compliance Program that

    provides reasonable measures of acceptability. Products that pass compliance testing have the right to

    license the USB-IF certified USB Logo. Products that operate at either low-speed or full-speed can use only

    the Basic-Speed version of the logo. Only products that support high-speed can use the Hi-Speed version of

    the logo.

    Certified Logo for USB Devices

    USB Extensions

    http://www.usb.org/developers/compliance/http://www.usb.org/developers/compliance/http://www.usb.org/developers/compliance/
  • 7/30/2019 Usb Device Driver for Bulk Data Transfer

    7/8

    There are also the extensions to the original USB design. These are USB On-The-Go (OTG) and Certified

    Wireless USB. USB On-The-Go allows connecting portable peripheral devices to each other directly without

    having to connect to a PC. Certified Wireless USB is a wireless radio communication protocol that combines

    the ease-of-use of USB with the convenience of wireless technology. Like standard USB, the USB-IF also

    maintains the Compliance Program for OTG and Wireless USB devices.

    Certified Logo for USB OTG and Wireless USB Devices

    USB On-The-Go and Certified Wireless USB technologies are beyond the scope of this article series, the

    details and specifications can be found on the USB-IF website.

    Next Article:Basic Components of a USB System Architecture

    The device (digital camera, card reader, scanner, hard drive, cable modem, etc.)

    will work with the USB 2.0 ports even if the device only has a USB 1.0 or 1.1connection. The physical connectors are exactly the same for USB 1.1 and USB 2.0.However, the device will only work at USB 1.1 speeds (12 Mbps) and not USB 2.0speeds (480 Mbps).

    Conversely, if your computer only has USB 1.0 or 1.1 ports and you would like touse a USB 2.0 device with it, the device will probablywork. Again, you will only beable to transfer data at the slower USB 1.1 transfer rate. Most USB 2.0 devices arebackwards compatible with USB 1.1, but for data-intensive devices (like a hard driveor iPod), the data transfer is so slow with USB 1.1, it may not even be worth using it.

    Connecting

    f lash memory cards, p en-like memory devices, d igital camera,

    p rinter,

    m ouse-device, P ocketPC,

    v ideo games,

    S canner

    A crc field in a data packet permits error detection

    USB Specification 1.1 was designed for low to medium speed applications

    running at less then 12 Mbits/sec. As such it is not suited for high-end data

    transfer such as high-speed back-ups to hard disks or CDs , high resolution

    color printing and interactive gaming

    http://www.usb.org/developers/onthego/http://www.usb.org/developers/wusb/http://www.usb.org/developers/wusb/http://www.usb.org/http://www.usblyzer.com/usb-system-architecture-components.htmhttp://www.usblyzer.com/usb-system-architecture-components.htmhttp://www.usb.org/developers/onthego/http://www.usb.org/developers/wusb/http://www.usb.org/developers/wusb/http://www.usb.org/http://www.usblyzer.com/usb-system-architecture-components.htm
  • 7/30/2019 Usb Device Driver for Bulk Data Transfer

    8/8

    BUS COMPARISON

    Type of BusBus

    ClockSignal

    Bus

    Width

    Theoretical Maximum

    Transfer RateAdvantages Disadvantages

    ISA 8 MHz 16-bit8 Mbytes/sec (64

    Mbits/sec)low cost, compatibility,

    widely usedlow speed, Jumpers & DIP

    switches. becoming obsolete

    Microchannel 10 MHz 32-bit40 Mbytes/sec (240

    Mbits/sec)higher speed than ISA obsolete

    PCI133MHz

    64-bit 1 Gbytes/sec (8 Gbits/sec)very high speed, Plug

    & Play, dominantboard-level bus

    incompatible with older systems,can cost more

    CompactPCI 33 MHz 64-bit132 Mbytes/sec (1

    Gbit/sec)

    designed for industrialuse, hot

    swapping/Plug & Play,ideal for embedded

    systems

    lower speed than PCI, needadapter for PC use, incompatible

    with older systems

    PCMCIA 10 MHz 16-bit20 Mbytes/sec (160

    Mbits/sec)

    Ideal for portablesystems, hot

    swappable, Plug &Play

    lower speed , needs special drive

    for use in desktop PCs

    USB 1.1 n/a n/a1.5 Mbytes/sec (12

    Mbits/sec)

    low cost, ideal forportable systems, hotswapping/plug & play,

    up to 127 devices via 1port

    slower than PCI and other plug-inbusses (such as Firewire), not

    compatible with older peripherals

    USB 2.0 n/a n/a60 Mbytes/sec (480

    Mbits/sec)

    All the advantages ofUSB plus significantlyhigher speeds makingit compatible with high-

    speed peripheralssuch as data drivesand video cameras.

    Not compatible with older

    peripherals, still slower than PCI

    Ethernet 10Base T

    n/a n/a1.25 Mbyte/sec (10

    Mbits/sec)

    Enables multiple PCsto remotely shareinformation and

    peripheral devices,provides error

    checking lacking instandard serialcommunication

    Most peripheral devices cannotbe connected directly to ethernet,

    adapter is required. Slow datacommunication by current

    standards Possible securityissues.

    Ethernet 100

    Base T (FastEthernet) n/a n/a

    12.5 MBytes/sec (100

    Mbits/sec)

    All advantages of10BaseT, with

    significant speed

    improvement.Backward compatiblewith 10Base Tinstallations.

    Most peripheral devices cannotbe connected directly to ethernet,

    adapter is required. Possiblesecurity issues.

    http://www.quatech.com/support/comm-over-mca.phphttp://www.quatech.com/support/comm-over-pci.phphttp://www.quatech.com/support/comm-over-cpci.phphttp://www.quatech.com/support/comm-over-pcmcia.phphttp://www.quatech.com/support/comm-over-usb.phphttp://www.quatech.com/support/comm-over-mca.phphttp://www.quatech.com/support/comm-over-pci.phphttp://www.quatech.com/support/comm-over-cpci.phphttp://www.quatech.com/support/comm-over-pcmcia.phphttp://www.quatech.com/support/comm-over-usb.php