Você está na página 1de 16

PSG COLLEGE OF

(Autonomous
and an ISO 9001 certified
TECHNOLOGY
Institution)
COIMBATORE 641
004

DEPARTMENT OF ELECTRICAL AND ELECTRONICS


ENGINEERING
ME EMBEDDED & REAL-TIME SYSTEMS

USB DEVICE DRIVERS

Presented
By

JABEZ WINSTON C
15MU01
9/17/16

Guided By

DR.ILA. VENNILA
(Associate Professor)
1

Contents

What is a device driver?


USB
USB version history
USB version history
Various USB roles
Types of transfers
USB peripheral in microcontrollers
Linux
Linux kernel
Linux kernel USB sub system
Kernel space and user space
Commands related to module loading and unloading
Writing a simple driver

9/17/16

What is a device driver ?


A
driver
provides
asoftware
interfaceto
hardware
devices,
enabling operating systems and
other computer programs to access
hardware functions without needing
to know precise details of the
hardware being used.

9/17/16

USB
Initial design & development
Compaq,DEC,IBM,Intel, Microsoft,NEC
andNortel

Aimed to standardize connection of


computer peripheral
Almost replaced Serial Port , Parallel Port ,PS/2
port,etc.,

9/17/16

USB Version History


Maximum transfer
rate

Release name

Release date

USB 0.8

December 1994

USB 0.9

April 1995

USB 0.99

August 1995

USB 1.0 Release


Candidate

November 1995

USB 1.0

January 1996

USB 1.1

August 1998

USB 2.0

April 2000

High Speed (480 Mbit/s)

USB 3.0

November 2008

SuperSpeed (5 Gbit/s)

USB 3.1

July 2013

SuperSpeed+ (10Gbit/s)

9/17/16

Low Speed (1.5 Mbit/s),


Full Speed (12 Mbit/s)
Low Speed (1.5 Mbit/s),
Full Speed (12 Mbit/s)

USB roles
USB host
More responsibility in establishing
communication
Complex hardware and software
Eg:PC

USB device
Simple,Eg:USB Mouse,USB keyboard,USB
Mass Storage device,etc.,

USB OTG
Can act as device and host. Eg: Recent
Android mobile phones
9/17/16

Types of USB transfers


Control transfers
Interrupt transfers
USB Mouse ,USB keyboard,etc.,

Bulk transfers
USB Mass Storage devices , USB
printers,etc.,

Isochronous transfers
USB speakers ,USB webcams,etc.,
9/17/16

USB peripheral in
microcontrollers
Examples of microcontrollers which
have USB peripheral
TM4C123 (Tiva C)
PIC18F4550
Atmega32u4

9/17/16

Linux kernel
Linux kernel is the core of the Linux
OS
Monolithic architecture (drivers
reside in kernel space )
Written in C and Assembly
Drivers in Linux kernel are event
driven
Can be invoked by system calls /
exceptions
9/17/16
Can be invoked by hardware interrupts

USB subsystem Linux


kernel
Consists of the USB core which
provides core USB API
Drivers are built using the core USB
API like usb_register_dev()
,usb_set_intfdata(),
Drivers are found in
<KERNEL_SRC>/drivers/usb/
Using lsusb command one can view
descriptors related to USB
9/17/16

10

Kernel space & User space

9/17/16

11

Modules run in kernel space while


applications run in kernel space
OS enforces memory protection by using
MMU and separates kernel space from
user space
CPU can switch from user mode to kernel
mode by means of exception / interrupt
Eg:printf() uses a system call write() to
print in the console
9/17/16

12

Commands related to kernel module


loading
lsmod
List the modules loaded

rmmod
Remove a module

modinfo
Get info related to module

modprobe
Check for dependencies of modules and
resolves them loading and unloading
9/17/16

13

Writing a simple driver


#include<linux/init.h>
#include<linux/module.h>
MODULE_LICENSE(GPL);
static int hello_init(void)
{
printk(KERN_INFO Hello,World !!\n);
}
static void hello_exit(void)
{
printk(KERN_INFO Goodbye,World !!\n);
}
module_init(hello_init);
module_exit(hello_exit);
9/17/16

14

Project Execution
June Brief study of USB and Linux
kernel-USB subsystem
July Study of Linux kernel Core
USB API
August Study of USB peripheral in
microcontroller
September Writing driver for Linux
and firmware for microcontroller for
custom device
9/17/16

15

References
[1] The Linux Kernel Archives, http://www.kernel.org
[2] USB-IF, www.usb.org
[3] Greg Kroah-Hartman,Linux kernel in a
Nutshell:OReilly &Associates,Dec. 2006
[4] Jonathan Corbet,Alessandro Rubini and Greg KroahHartman,Linux Linux Device Drivers :OReilly
&Associates,Jan. 2005
[5] Linux USB, www.linux-usb.org
9/17/16

16

Você também pode gostar