Useful USB Gadgets on Linux



Similar documents
Embedded Linux Platform Developer

Ways to Use USB in Embedded Systems

TivaWare USB Library USER S GUIDE SW-TM4C-USBL-UG Copyright Texas Instruments Incorporated

Do More With Less. On Driver-less Interfacing with Embedded Devices. Peter Korsgaard

Lean and Easy Ways to Adopt MOST Technology

UM1734 User manual. STM32Cube USB device library. Introduction

Freescale MQX USB Device User Guide

Learning USB by Doing.

Leveraging the Android Accessory Protocol

Atmel AVR4950: ASF - USB Host Stack. 8-bit Atmel Microcontrollers. Application Note. Features. 1 Introduction

i.mx USB loader A white paper by Tristan Lelong

smxusbd USB Device Stack

AT89C5131A Starter Kit... Software User Guide

An introduction to nxpusblib. March 2012

To perform Ethernet setup and communication verification, first perform RS232 setup and communication verification:

USB Debugging and Profiling Techniques. Kishon Vijay Abraham I and Basak Partha

Example of Standard API

An Analysis of Wireless Device Implementations on Universal Serial Bus

Network Licensing. White Paper 0-15Apr014ks(WP02_Network) Network Licensing with the CRYPTO-BOX. White Paper

SBC8600B Single Board Computer

Universal Serial Bus Communications Class Subclass Specification for Ethernet Emulation Model Devices. Revision 1.0

Embedded Linux development training 4 days session

Real-time Operating Systems Lecture 27.1

Going Linux on Massive Multicore

Troubleshooting Guide

Yun Shield User Manual VERSION: 1.0. Yun Shield User Manual 1 / 22.

Freescale MQX RTOS USB Host User s Guide

Application Note. 8-bit Microcontrollers. AVR270: USB Mouse Demonstration

Using AnywhereUSB to Connect USB Devices

Creating a More Secure Device with Windows Embedded Compact 7. Douglas Boling Boling Consulting Inc.

SuperSpeed USB Developers Conference

User Manual (DA-70155)

Atmel AVR4903: ASF - USB Device HID Mouse Application. Atmel Microcontrollers. Application Note. Features. 1 Introduction

Application Development Kit for Android Installation Guide

Technical Note TN_146. Creating Android Images for Application Development

CITRIX 1Y0-A14 EXAM QUESTIONS & ANSWERS

Zynq SATA Storage Extension (Zynq SSE) - NAS. Technical Brief from Missing Link Electronics:

The easy way! Mark Maszak. Jane Lawrence Program Manager Microsoft. Microsoft

USB TO SERIAL CONVERTER

LPT1 Printer Connector. External Power Supply Connector Power Indicator

A guide to CLARiSUITE TM network solutions

VIA CONNECT PRO Deployment Guide

The care and feeding of Pythons at the Redmond Zoo. (Using Micro Python and pyboard with Windows)

Chapter 02: Computer Organization. Lesson 04: Functional units and components in a computer organization Part 3 Bus Structures

Freescale USB Device Stack Users Guide

Chord Limited. Mojo Dac Headphone Amplifier OPERATING INSTRUCTIONS

Embedded Display Module EDM6070

A Design of Video Acquisition and Transmission Based on ARM. Ziqiang Hao a, Hongzuo Li b

Embedded Linux BSP BootCAMP

ARM Processors for Computer-On-Modules. Christian Eder Marketing Manager congatec AG

Plug and Play for Windows 2000

IEEE /ZigBee USB Dongle

Operating Systems Design 16. Networking: Sockets

Deployment Guide: Transparent Mode

04/08/2011. Andy Davis Research Director Telephone: +44 (0)

Linux Driver Devices. Why, When, Which, How?

Android Virtualization from Sierraware. Simply Secure

Wireless ATA: A New Data Transport Protocol for Wireless Storage

Kernel Testing: Tool and Techniques. Matt Porter Texas Instruments 21 February 2013

Ethernet Interface Manual Thermal / Label Printer. Rev Metapace T-1. Metapace T-2 Metapace L-1 Metapace L-2

R&S AFQ100A, R&S AFQ100B I/Q Modulation Generator Supplement

Track One Building a connected home automation device with the Digi ConnectCore Wi-i.MX51 using LinuxLink

PU-USBX. USB over Ethernet Extender OPERATION MANUAL

HDMI on OMAP4 PANDA. Design, Challenges and Lessons Learned Mythri P K

Chapter 2 System Structures

Data Transfer between Two USB Flash SCSI Disks using a Touch Screen

Analysis to develop an ISCSI Layer inside Microsoft Windows NT/2K/XP

Network Scanning: A New Feature for Digital Copiers

Remote Supervisor Adapter II. User s Guide

Access control designed simply for you

HotelTV. Client Software Update REV A0.10 D October. Web : Mail : support@vestek.com.tr Tel :

Mobile Broadband Module Simulation Framework

MBC-SAM9G35 Core Board Overview

R&S AFQ100A, R&S AFQ100B I/Q Modulation Generator Supplement

Customer Experience. Silicon. Support & Professional Eng. Services. Freescale Provided SW & Solutions

Software for Android Platform VCNL4020 and VCNL3020

Tutorial for MPLAB Starter Kit for PIC18F

Version 1.0. File System. Network Settings

Universal Serial Bus Implementers Forum EHCI and xhci High-speed Electrical Test Tool Setup Instruction

STM32F102xx and STM32F103xx series Microcontrollers

Sam440ep-flex User Guide

Board also Supports MicroBridge

Open Network Install Environment (ONIE) LinuxCon North America 2015

PrioVR Production Plan:

Contents. Connection Guide. What is Dante? Connections Network Set Up System Examples Copyright 2015 ROLAND CORPORATION

Easy H.264 video streaming with Freescale's i.mx27 and Linux

Linux Embedded devices with PicoDebian Martin Noha

Exploring the Remote Access Configuration Utility

The proliferation of the raw processing

What the student will need:

Application Note: AN00121 Using XMOS TCP/IP Library for UDP-based Networking

PARALLELS SERVER BARE METAL 5.0 README

Atmel AVR4920: ASF - USB Device Stack - Compliance and Performance Figures. Atmel Microcontrollers. Application Note. Features.

SBC8100 Single Board Computer

Experience with the integration of distribution middleware into partitioned systems

Ultra Thin Client TC-401 TC-402. Users s Guide

VLAN for DekTec Network Adapters

ML310 VxWorks QuickStart Tutorial. Note: Screen shots in this acrobat file appear best when Acrobat Magnification is set to 133.3%

Wave Relay System and General Project Details

Transcription:

Useful USB Gadgets on Linux February, 2012 Gary Bisson Adeneo Embedded Embedded Linux Conference 2012 1

Agenda Introduction to USB USB Gadget API Existing Gadgets Design your own Gadget Demo Conclusion 2

Who am I? Software engineer at Adeneo Embedded (Bellevue, WA) Linux, Android Main activities: BSP adaptation Driver development System integration 3

Context and objectives General knowledge of the API Focused on USB not general driver development Nothing on the host side Case study Using a generic embedded device, see how we can create a USB Gadget Show potential How to fulfill every need 4

Universal Serial Bus Industry standard developed in the mid-1990s Defines the cables, connectors and protocols used for connection, communication and power supply between computers and electronic devices 2 billion USB devices were sold each year (as of 2008) 5

Universal Serial Bus Benefits: Replace lots of old buses Automatic configuration Multiple speeds Reliable Limits: Distance Peer-To-Peer Broadcasting 6

Universal Serial Bus Architecture: Master-Slave protocol Up to 127 devices addressable Can be hot-plugged Identification to the host Supports high speeds Multifunction device possibility 7

Universal Serial Bus Description: 8

Universal Serial Bus Endpoints Source and Sink of data Uniquely identifiable Unique direction (except setup) 9

Universal Serial Bus 4 transfer types: Control Configuration and control information Interrupt Bulk Small quantities time-sensitive data Large quantities time-insensitive data Isochronous Real-time data at predictable bit rates 10

Typical Device Driver Device Firmware Driver Hardware specific routines USB interrupts/events Chapter 9 Enumeration process Transfer data to upper layer USB Class Driver Defines the behavior Provides configuration 11

Gadget API Provides essential infrastructure Similar to Chapter 9 in typical USB device software Handles USB protocol specific requirements Flexible enough to expose more complex USB device capabilities 12

Gadget API vs. Linux-USB API Similarities Share common definitions for the standard USB messages, structures and constants Use queues of request objects to package I/O buffers Both APIs bind and unbind drivers to devices Differences Control transfers Configuration management => Thanks to similarities, Gadget API supports OTG 13

Gadget API Lower boundary: handling setup requests (ep0 protocol responses) possibly including class-specific functionality returning configuration and string descriptors (re)setting configurations and interface altsettings, including enabling and configuring endpoints handling life cycle events, such as managing bindings to hardware, USB suspend/resume, remote wakeup, and disconnection from the USB host managing IN and OUT transfers on all currently enabled endpoints 14

Gadget API Upper layer: user mode code, using generic (gadgetfs) or application specific files in /dev networking subsystem (for network gadgets, like the CDC Ethernet Model gadget driver) data capture drivers, perhaps video4linux or a scanner driver; or test and measurement hardware input subsystem (for HID gadgets) sound subsystem (for audio gadgets) file system (for PTP gadgets) block i/o subsystem (for usb-storage gadgets) 15

Gadget API Main structures struct usb_gadget represents a gadget device usb_gadget_ops contains callbacks for hardware operations struct usb_ep device hardware management usb_ep_ops contains callbacks for endpoints operations struct usb_gadget_driver device functions management (bind, unbind, suspend etc...) struct usb_request USB transfers management 16

Gadget API Main functions General operations (usb_gadget_x()): probe_driver / unregister_driver set_selfpowered / clear_selfpowered vbus_connect / vbus_disconnect connect / disconnect frame_number Endpoint operations (usb_ep_x()): autoconf / autoconf_reset enable / disable alloc / free queue / dequeue set_halt / clear_halt fifo_status / fifo_flush Decriptor operations: usb_descriptor_fillbuf usb_gadget_config_buf 17

Gadget API Driver life cycle: Register driver for a particular device controller Register gadget driver (bind) Hardware powered, enumeration starts Gadget driver returns descriptors (setup) Gadget driver returns interfaces configuration Do real work (data transfer) until disconnect Gadget driver unloaded (unbind) 18

Existing Gadgets Ethernet Enumerate to the host as an Ethernet device Can easily be bridging, routing, or firewalling access to other networks Interoperability with hosts running Linux, MS- Windows among others Possibility to set parameters such as MAC address, IP configuration or DHCP use thanks to the bootargs if using a boot firmware like U-Boot 19

Existing Gadgets GadgetFS Provides User-Mode API Each endpoint presented as single I/O file descriptor Normal read() and write() calls Async I/O supported Configuration and descriptors written into files Note that user mode gadget drivers do not necesarily need to be licensed according to the GPL. 20

Existing Gadgets File-backed Storage Implements the USB Mass Storage Class Up to 8 disk drives can be set Store file or block device is called the backing storage Backing storage requires preparation If a file is used, it must created with its desired size before launching the driver If a block device, it must match host reaquirements (DOS partition for MS-Windows host) The backing storage must not change while FBS is running, only the host should access it 21

Existing Gadgets Webcam Acts as a composite USB Audio and Video Class device Provides a userspace API to process UVC control requests and stream video data Serial Gadget Useful for TTY style operation Supports a CDC-ACM module option 22

Existing Gadgets MIDI Exposes an ALSA MIDI interface Both recording and playback support GadgetZero Useful to test device controller driver Helps verify that the driver stack pass USB-IF (for USB branding) On the host side, useful to test USB stack 23

Design your own Gadget 3 main operations to consider Hardware Functional Endpoints 24

Design your own Gadget First implement the register/unregister functions usb_gadget_probe_driver Resgistration of the usb_gadget_driver Responsible for binding the gadget driver and powering up the device usb_gadget_unregister_driver Responsible for unbinding the gadget from the functional driver and powering down the device Then define callbacks hardware related Fill usb_ep_ops and usb_gadget_ops Not necessary to support all functions 25

Design your own Gadget Implement the control request handles (ep0) Gadget driver handles only a part of it The rest is routed to the class driver 26

Design your own Gadget Power Management requests Comes from the PDC to the Gadget The Gadget must pass the events to the class driver Once enumeration is done, class driver requests usb_request structure for IN/OUT transfers Gadget receives data in interrupt routine (OUT) Only when the expected amount is received the Gadget calls the complete function Gadget sends data to the PDC (IN) Wait send completion to inform the class driver 27

Design your own Gadget 28

Demo: Hardware BeagleBoard xm ARM Cortex -A8 1000 MHz USB connectivity: 4 host ports 1 OTG port (used as device) 29

Demo: Software Bootloader U-boot 2011.12 r4 Kernel 3.0.17 r115c Root filesystem Console image Custom recipe (lighttpd) Additional modules 30

Conclusion Easy to implement Hardware independent Scalability Large panel of existing gadgets Awareness of limitations 31

Questions? 32

Appendix: Files The files used for this experiment should be attached with the presentation Rootfs: Custom recipe provided if rebuild is necessary Additional modules: Instructions to recompile them Demo script Lighttpd configuration file 33

Appendix: References Linux-USB Gadget API Framework: General presentation. USB Gadget API for Linux: Full description of the API. Essential Linux Device Drivers (Sreekrishnan Venkateswaran) : General device driver book containing a useful USB section. Bootstrap Yourself with Linux-USB Stack (Rajaram Regupathy): Very detailed and easy-to-read book about Linux-USB. 34