Renesas Electronics America Inc. © 2012 Renesas Electronics America Inc. All rights reserved. LibUSB - Create a Solution Without the Class Struggle.

Slides:



Advertisements
Similar presentations
Primary Author: Girish Verma Secondary Author(s): Navya Prabhakar Presenter: Navya Prabhakar Company/Organization: CircuitSutra USB Modeling Quick Start.
Advertisements

So, you think you need USB On-The-Go?. Agenda Introduction Embedded Host terminology OTG – Electrical – Protocol When to use OTG 2.
Universal Serial Bus Grant Heileman. The History of USB In 1994 a collaborative effort to design a standard for peripheral devices was made between Compaq,
Software Frameworks for Acquisition and Control European PhD – 2009 Horácio Fernandes.
Introduction to USB. 2 Agenda Introduction to USB LPC23xx Block diagram MCB2300 demo.
Renesas Electronics America Inc. © 2012 Renesas Electronics America Inc. All rights reserved. Class ID: 3L02B Introduction to the RX-Arduino (Lab) Anthony.
USB: UNIVERSAL SERIAL BUS Joe Kaewbaidhoon Alex Motalleb Vishal Joshi Prepared for EECS 373 University of Michigan, Ann Arbor 1.
©2008. Renesas Technology America., All rights reserved. Renesas Direct Drive for Connecting to TFT-LCD Panels David Hedley – Staff Applications Engineer.
- Madhav Singh-.  This presentation describe the basics of USB device and Host side i.e. descriptors, endpoints, device controller, root hub etc.  It.
Renesas Electronics America Inc. © 2012 Renesas Electronics America Inc. All rights reserved. Using a Renesas Code Generation Tool for RL78 Devices.
Introduction Purpose Objectives Content Learning Time
May 8, The EASY Way to Create I/O Devices John Hyde Intel Corporation intel.com.
TUSB3210 Product Overview.
Renesas Electronics America Inc. © 2012 Renesas Electronics America Inc. All rights reserved. Using Embedded Tools for I2C, SPI, and USB Debugging for.
USB host for web camera connection
ID 413C: Can Touch This: Designing Capacitive-Based Touch Solutions Mark F Rodriguez Senior Engineering 13 October 2010 Version: 1.0 Xaplos Inc.
Introduction to USB Development. USB Development Introduction Technical Overview USB in Embedded Systems Recent Developments Extensions to USB USB as.
Introduction to USB © 2010 Renesas Electronics America Inc. All rights reserved.
USB host for web camera connection
Using the PSoC USB March 17, 2012 Lloyd Moore, President/Owner.
Renesas Electronics America Inc. © 2012 Renesas Electronics America Inc. All rights reserved. Increase the Dynamic Range and Precision of Digital Filters.
Renesas Electronics America Inc. © 2012 Renesas Electronics America Inc. All rights reserved. An Introduction to e 2 studio.
Renesas Electronics America Inc. © 2012 Renesas Electronics America Inc. All rights reserved. Know your Precise Position with RX600 MCU.
Renesas Electronics America Inc. © 2010 Renesas Electronics America Inc. All rights reserved. ID A15C: Application Code Reprogramming Using Different Serial.
Renesas Electronics America Inc. © 2010 Renesas Electronics America Inc. All rights reserved. ID 320L: Rapid RX600 System Development Using the RPDL and.
Renesas Electronics America Inc. © 2012 Renesas Electronics America Inc. All rights reserved. Class ID: 3L13B David Hedley, Applications Engineer Advanced.
Renesas Electronics America Inc. “© 2010 Renesas Electronics America Inc. All rights reserved ID 220L: Hands-on Embedded Ethernet Design with an Open Source.
Renesas Electronics America Inc. © 2010 Renesas Electronics America Inc. All rights reserved. 431L: Using a Graphics API to Create User Interface Components—Advanced.
Renesas Electronics America Inc. ID 322C:Using HEW's Many Capabilities to Boost Software Development Productivity Axel Wolf Marketing Manager, Development.
Renesas Electronics America Inc. © 2012 Renesas Electronics America Inc. All rights reserved. Migrating from CubeSuite+ to Eclipse.
Renesas Electronics America Inc. © 2012 Renesas Electronics America Inc. All rights reserved. Class ID: 2L03I RL78 Bluetooth Connectivity Anthony Harris,
Renesas Electronics America Inc. RX USB Peripheral The Renesas RX USB peripheral a.k.a. USBC_597IP_PP Ver
ID A16C: Outfitting Embedded Devices with Low Power Wireless Communications Design considerations for adding wireless communications to low power embedded.
Renesas Electronics America Inc. © 2012 Renesas Electronics America Inc. All rights reserved. e 2 Studio – Getting Started.
February 10 th 2010 Dehmani Feth-Allah M2 ISTRe Oral Presentation Universal Serial Bus.
Renesas Electronics America Inc. © 2012 Renesas Electronics America Inc. All rights reserved. Class ID: Know your Precise Position with RX600 MCU Huangsheng.
SW and HW platforms for development of SDR systems SW: Model-Based Design and SDR HW: Concept of Modular Design and Solutions Fabio Ancona Sundance Italia.
Renesas Electronics America Inc. © 2010 Renesas Electronics America Inc. All rights reserved. ID630L: Becoming Familiar with Sensorless Vector Control.
Class ID: Renesas Electronics America Inc. © 2012 Renesas Electronics America Inc. All rights reserved. Class ID: Using Virtual EEPROM and Flash API for.
Renesas Electronics America Inc. © 2012 Renesas Electronics America Inc. All rights reserved. QuantiPhi for RH850 and RL78 - The Fastest Path from Idea.
1 Control Software (CAT) Introduction USB Interface implementation Calorimeter Electronics Upgrade Meeting Frédéric Machefert Wednesday 5 th May, 2010.
Renesas Electronics America Inc. © 2012 Renesas Electronics America Inc. All rights reserved. Class ID: Increase the Dynamic Range and Precision of Digital.
Class ID: Renesas Electronics America Inc. © 2012 Renesas Electronics America Inc. All rights reserved. Implementing Bootloaders on Renesas MCUs.
2L01I Renesas Electronics America Inc. © 2012 Renesas Electronics America Inc. All rights reserved. Class ID: 2L02I CAN In A Day Carl Stenquist, Staff.
Renesas Electronics America Inc. © 2012 Renesas Electronics America Inc. All rights reserved. Class ID: Audio Solutions on the RX MCU Family Mitch Ferguson,
Renesas Electronics America Inc. © 2012 Renesas Electronics America Inc. All rights reserved. Advanced Debugging on the RX600.
Renesas Electronics America Inc. © 2012 Renesas Electronics America Inc. All rights reserved. Advanced E 2 Studio Topics.
Renesas Electronics America Inc. © 2012 Renesas Electronics America Inc. All rights reserved. Class ID: CC05B RX Project Configuration Tips John Breitenbach,
Updates and Common Questions Asked by Simulation Developers Peter Shier Architect Windows Devices and Storage Technologies
Renesas Electronics America Inc. © 2012 Renesas Electronics America Inc. All rights reserved. Class ID: Low Power Design Michael Thomas, Applications Engineer.
ID 222L: Get Connected with USB on RX62N
Renesas Electronics America Inc. © 2010 Renesas Electronics America Inc. All rights reserved. ID 230L: Simplify your Networked Application with CAN and.
Renesas Electronics America Inc. © 2012 Renesas Electronics America Inc. All rights reserved. Class ID: 3L08I Migrating from CubeSuite+ to Eclipse Neelima.
Renesas Electronics America Inc. © 2012 Renesas Electronics America Inc. All rights reserved. Class ID: 3L05I Advanced Debugging on the RX600 Fatih Peksenar.
Renesas Electronics America Inc. © 2012 Renesas Electronics America Inc. All rights reserved. Class ID: 5L08I Using the Renesas Graphics API to Create.
Renesas Electronics America Inc. © 2010 Renesas Electronics America Inc. All rights reserved. ID 322L:Advanced Debugging on the RX600 Brandon Hussey Applications.
Renesas Electronics America Inc. © 2010 Renesas Electronics America Inc. All rights reserved. ID 421L: R8C Segment-LCD API Lab Bob Proctor Staff Engineer.
Renesas Electronics America Inc. © 2010 Renesas Electronics America Inc. All rights reserved. ID A10L:A Flexible Flash Rewrite Application Brandon Hussey.
Renesas Electronics America Inc. © 2012 Renesas Electronics America Inc. All rights reserved. Class ID: QuantiPhi for RH850 and RL78 - The Fastest Path.
ID 021L: Model Based Control Design and Auto-Code Generation using the R8C Christopher Myers Director of Software Development 12 October 2010 Version:
SEPTEMBER 8, 2015 Computer Hardware 1-1. HARDWARE TERMS CPU — Central Processing Unit RAM — Random-Access Memory  “random-access” means the CPU can read.
Class ID: Renesas Electronics America Inc. © 2012 Renesas Electronics America Inc. All rights reserved. Class ID: Using Software Building Blocks for Faster.
USB The topics covered, in order, are USB background
David Hedley Staff AE, Applications Engineering 12 Oct 2010
USB- Universal Serial Bus
David Hedley Staff AE, Applications Engineering 13 October 2010
ID 325L: Getting Started with CubeSuite
Greg Bell Business Development Mgr Industrial & Security Markets
LibUSB - Create a Solution Without the Class Struggle
Presentation transcript:

Renesas Electronics America Inc. © 2012 Renesas Electronics America Inc. All rights reserved. LibUSB - Create a Solution Without the Class Struggle

© 2012 Renesas Electronics America Inc. All rights reserved.2 Renesas Technology & Solution Portfolio

© 2012 Renesas Electronics America Inc. All rights reserved.3 Microcontroller and Microprocessor Line-up Wide Format LCDs  Industrial & Automotive, 130nm  350µA/MHz, 1µA standby 44 DMIPS, True Low Power Embedded Security, ASSP 165 DMIPS, FPU, DSC 1200 DMIPS, Performance 1200 DMIPS, Superscalar 500 DMIPS, Low Power 165 DMIPS, FPU, DSC 25 DMIPS, Low Power 10 DMIPS, Capacitive Touch  Industrial & Automotive, 150nm  190µA/MHz, 0.3µA standby  Industrial, 90nm  200µA/MHz, 1.6µA deep standby  Automotive & Industrial, 90nm  600µA/MHz, 1.5µA standby  Automotive & Industrial, 65nm  600µA/MHz, 1.5µA standby  Automotive, 40nm  500µA/MHz, 35µA deep standby  Industrial, 40nm  200µA/MHz, 0.3µA deep standby  Industrial, 90nm  1mA/MHz, 100µA standby  Industrial & Automotive, 130nm  144µA/MHz, 0.2µA standby bit 8/16-bit

© 2012 Renesas Electronics America Inc. All rights reserved.4 Smart Society Challenge You need to: Get your idea to market SOON Avoid the complexity of a class Quickly try out a complete PC-host / target solution Be “Vendor Specific” but don’t want to write a new Windows driver You don’t want to learn all about HID descriptors Etc.. Solution Use LibUSB! Today you will get a complete USB Host-PC to RX-function ‘template’ solution RX + = Connect to the Smart Society with USB!

© 2012 Renesas Electronics America Inc. All rights reserved.5 I: USB Basics Host Function Class II: LibUSB Why use LibUSB? What is LibUSB? – Win32-LibUSB Enumeration, INF-file Customer Install III: Lab RX Target (YRDK63N) – PC Host / Python app To do lab at home, download “LibUSB - A Complete RX Function and PC Host Solution”, R01AN0492_RX600_LibUSBv2 IV: Conclusion How to communicate with any USB device with LibUSB Agenda

© 2012 Renesas Electronics America Inc. All rights reserved.6 Do follow a class when Your solution naturally belongs there – Driver already exists in Windows Industry practise mandates Renesas has available source code for classes Mass Storage – HMSC – PMSC Communications Device – HCDC – PCDC Human Interface – HHID – PHID P.S. Think you “need” OTG??... Ready-made USB Class Solutions

© 2012 Renesas Electronics America Inc. All rights reserved.7 No class exists for what you want to do Examples – HID HID class only has control and interrupt endpoints – you need bulk / isochronous You don’t want to learn all about report descriptors Don’t want to ‘waste’ code and time parsing them… – CDC CDC limited to one bulk in and one bulk out EP – you need more The USBSER.SYS Windows driver causes you grief Need to minimize code space LibUSB is free from class protocol overhead Host Windows driver does not cooperate / has bug You don’t want to write a new Windows driver To avoid the complexity of a class You need to be “Vendor Specific” And again, you don’t want to write a new Windows driver To quickly try out a complete PC-host / target concept Consider LibUSB! Why LibUSB?

© 2012 Renesas Electronics America Inc. All rights reserved.8 USB Basic Concepts

© 2012 Renesas Electronics America Inc. All rights reserved.9 Controls enumeration Reads descriptors from a USB function to learn about VID/PID, endpoints… At lowest level Host initiates transactions - even for interrupt endpoints! – Continually polls a device just to see if it has data to transfer – Keeps USB protocol “simple” (but not very energy efficient) Poll rate specified by the function’s EP descriptor At application level Host or function can request to send data! Host - Basics

© 2012 Renesas Electronics America Inc. All rights reserved.10 USB “Function” “Device” or “Peripheral” ~ the same thing! Function = “A USB device that provides a capability to the host, such as an ISDN connection, a digital microphone, or speakers.” Device = “A logical or physical entity that performs a function” =>A device may contain several functions Peripheral = Not in spec. Could mean the USB hardware of host or function node. “Peripheral” or “device” could refer to host USB HW – confusing!? Function - Basics

© 2012 Renesas Electronics America Inc. All rights reserved.11 Endpoint Have meaning only at application level (host and function) EP number determines meaning of transmitted data (Speed, LED data, display color,..) Defined by function Host learns about the endpoints via the descriptors – As you will see in lab Example; “EP1 OUT” – “IN” or “OUT” = Dataflow as seen from host Function - Basics

© 2012 Renesas Electronics America Inc. All rights reserved.12 Defined by USB function At enumeration, host uses get_descriptor(X) to learn about function Device descriptor Contains VID & PID – PC selects driver listed in INF-file with matching VID-PID-string [DeviceList] %USB\VID_8765&PID_1234.DeviceDesc%=USBBulkInstall, USB\VID_8765&PID_1234 – VID from USB Implementers forum Descriptors - Basics

© 2012 Renesas Electronics America Inc. All rights reserved.13 Plug in the device – Host fetches Device descriptor containing VID and PID INF file What is its “main” purpose? – Used to match Windows driver to the VID and PID –DeviceID = VID + PID string –Located in C:\Windows\system\INF Windows search when new device plugged in – If matching INF-file not found? “Found New Hardware” pops up Enumeration - Basics

© 2012 Renesas Electronics America Inc. All rights reserved.14 Enumeration - Basics Windows found matching DeviceID in this file. => This is the correct INF-file! What drivers Windows should use

© 2012 Renesas Electronics America Inc. All rights reserved.15 Enumeration - Basics Displayed in Device Mgr.

© 2012 Renesas Electronics America Inc. All rights reserved.16 Device descriptor to select host driver String descriptors Describes function with text to host There can be multiple – Many different uses Configuration descriptor Contains – Interface descriptor(s) – Endpoint descriptors Descriptors - Basics

© 2012 Renesas Electronics America Inc. All rights reserved.17 Determines how 1 ms (FS) frames are filled with user data Set for each endpoint in “Pipe Information Table” (PIT) Control Used for EP0, control commands at e.g. enumeration: “Standard Device Requests” = get_descriptor, set_interface,.. – (Can be used by Vendor Specific application for user data) Interrupt Max latency guaranteed; ms Example: keyboard, mouse Isochronous Bandwidth guaranteed (latency is not) Fixed nr of bytes per frame Example: Audio Bulk For time insensitive data 1 ms frame is filled with bulk data after other types have taken what they need Example: mass storage Transfer Types - Basics

© 2012 Renesas Electronics America Inc. All rights reserved.18 Node’s “channel” of communication for certain endpoint Pipe  endpoint pairing in PIT Function PIT defined statically at compile time Host PIT setup at enumeration Pipe - Basics

© 2012 Renesas Electronics America Inc. All rights reserved.19 PIT element members Pipe  Endpoint number Direction of data (IN, OUT) Transfer type etc… Pipe - Basics

© 2012 Renesas Electronics America Inc. All rights reserved.20 Group of similar functionality services Predefined descriptor set Same host driver (No ‘Found New HW’) USB classes defined by USB-IF What is a USB Class? - Basics

© 2012 Renesas Electronics America Inc. All rights reserved.21

© 2012 Renesas Electronics America Inc. All rights reserved.22 Class does allow some descriptor data to be unique vendor string capabilities data format …without being “Vendor Specific” If any descriptor item is set to 0xFF; Not a class!  “Vendor Specific” – New INF-file needed! – New host driver needed Vendor Specific - Basics

© 2012 Renesas Electronics America Inc. All rights reserved.23 LibUSB

© 2012 Renesas Electronics America Inc. All rights reserved.24 An API for host (PC) applications Includes PC driver to enable PC-application USB function communication What is LibUSB? Open source Windows XP, Vista, Win7: Libusb-win Contains driver LibUSB.dll A pre-written, pre-tested, generic driver Linux: Even easier for user than for Windows: USB kernel driver usbfs automatically associates device to LibUSB driver

© 2012 Renesas Electronics America Inc. All rights reserved.25 Application Level Tools that use LibUSB

© 2012 Renesas Electronics America Inc. All rights reserved.26 Python Create PC applications Object-oriented language Object.property = 5#Set a variable Object.procedure()#Run a procedure Easy to get started (compared to VC++)? No cost/license – GUI modules for Python: Tkinter, wxPython PyUSB Python module from sourceforge.net/apps/trac/pyusb sourceforge.net/apps/trac/pyusb PyUSB accesses the Windows LibUSB driver (LibUSB.dll) Lab uses Python & PyUSB

© 2012 Renesas Electronics America Inc. All rights reserved.27 Installs drivers libusb0.sys, libusb0_x86.dll to C:\windows\system\drivers INF-file Wizard Test tool “Install-filter-win.exe” Access ANY device via LibUSB The ability to communicate with USB devices referred to as the “Windows LibUSB Backend” Libusb-win32

© 2012 Renesas Electronics America Inc. All rights reserved.28 Find USB device(s) find_devices() Standard Device requests get_descriptor(x) - Retrieve device descriptor x set_configuration(x) - Set configuration x of device R/W to endpoints write_endpoint(), read_endpoint() YOU WILL USE ALL THESE IN LAB LibUSB Calls Lab output Import PyUSB

© 2012 Renesas Electronics America Inc. All rights reserved.29 Need to create INF file for your Device ID How to create INF-file? – INF-Wizard Easy to create INF-file! INF-Wizard starts up by listing all connected devices via LibUSB Any info it cannot get from incoming descriptors it will ask you for Comes with Libusb-Win32 INF-file

© 2012 Renesas Electronics America Inc. All rights reserved.30 INF-Wizard Result The information in the INF-file comes from different places. The INF-Wizard figured it all out for you! Wizard got DeviceID (VID, PID) and Class (LibUSB) by using LibUSB’s get_descriptor(DEVICE) You entered Vendor name into INF-Wizard…

© 2012 Renesas Electronics America Inc. All rights reserved.31 Your product install will need to provide the following (Or have the user download): INF-file with your DeviceID (VID&PID string) LibUSB drivers (libusb0.sys & libusb_x86.dll) A PC user application –Python, PyUSB? –In the Renesas LibUSB download, Python/PyUSB not needed. PyInstaller was used to convert the application to an EXE-file Customer Install Lab

© 2012 Renesas Electronics America Inc. All rights reserved.32 Host: “Renesas_libusb_host.py” Function: LibUSB project R01AN0492 for RSK62N, or YRDK63N The demo Set an LED (host->RX) Write to LCD (host->RX) Take an ADC measurement (host->RX) + send it over USB to host (RX->host) Lab

© 2012 Renesas Electronics America Inc. All rights reserved.33 Control (enumeration) EP0 OUT Bulk (general data transfer) Lab commands to RSK; EP1 OUT – Set an LED – Write to the LCD – Take an ADC measurement Read ADC data from RSK; EP2 IN Interrupt (e.g. user input) Read demo data when SW1 is pushed; EP3 IN Lab Endpoints

© 2012 Renesas Electronics America Inc. All rights reserved.34 You can talk to ANY USB device with LibUSB! Learn about connected devices, test, … Run “LibUSB Install-filter” - comes with Libusb-win32 – You enable a device from a list – Now you can read descriptors, read/write endpoints without an associated INF-file – But, do not change interface or configuration if device already enumerated by Windows (Linux) PC’s USB subsystem may crash!!! LibUSB updates libusbx Has newer LibUSB library and Windows driver Fully backwards compatible – Main site: – Reasons for: Access ANY USB Device! Updates

© 2012 Renesas Electronics America Inc. All rights reserved.35 Libusb-Win32 FAQ

© 2012 Renesas Electronics America Inc. All rights reserved.36 Questions? Questions?

© 2012 Renesas Electronics America Inc. All rights reserved.37 Smart Society Challenge You need to get your idea to market SOON avoid the complexity of a class quickly try out a complete PC-host / target solution be “Vendor Specific” but don’t want to write a new Windows driver You don’t want to learn all about HID descriptors etc.. Solution Use LibUSB! Do you agree? RX + = Connect to the Smart Society with USB!

© 2012 Renesas Electronics America Inc. All rights reserved.38 Use LibUSB when No class exists for what you want to do – Examples HID o HID class only has control and interrupt endpoints – you need bulk / isochronous o You don’t want to learn all about report descriptors Don’t want to ‘waste’ code and time parsing them… CDC o CDC limited to one bulk in and one bulk out EP – you need more o The USBSER.SYS Windows driver causes you grief You need to minimize code space – LibUSB is free from class protocol overhead The host Windows driver does not cooperate / has bug You don’t want to write a new Windows driver You want to avoid the complexity of a class You need to be “Vendor Specific” – And again, you don’t want to write a new Windows driver You need to quickly try out a complete PC-host / target concept Summary

© 2012 Renesas Electronics America Inc. All rights reserved.39 RX63x MCUs added Easy to switch between RX MCU types New, improved, more user friendly application notes One user config file for setting up USB system ANSI-C IO type USB class APIs C-startup code etc as of latest compiler manuals used DebugConsole tracing standard, enabled with one define (HEW) Source code tree more logical organization Basic firmware is now in common repository for all classes (one fix fixes all) Source code commenting is revised "Internal" APIs consolidated, more modular Improvements “USBv2” (Released summer ’12)

Renesas Electronics America Inc. © 2012 Renesas Electronics America Inc. All rights reserved.