Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Linux USB programming

Tags:

c

linux

kernel

usb

I am new to Linux kernel programming. I wish to develop a program to read USB drive information like its manufacturer name, capacity, etc. I know about descriptors and their attributes. But I don't understand how to enumerate USB drives connected to the system. I am looking for the function which initiates connection between kernel and USB port. How is it possible?

like image 954
Jay Avatar asked Jun 23 '11 14:06

Jay


2 Answers

You don't need to program the kernel as such - in fact to read the device info you don't even need a device driver.

The USB system is different in the newer 2.6 kernels so a lot of the online tutorials may be out of date - but start here http://www.linux-usb.org/

If you do want to write a USB device driver see this Linux journal tutorial

like image 55
Martin Beckett Avatar answered Sep 22 '22 02:09

Martin Beckett


Do you really want to do a kernel programming? There is an lsusb utility, capable of reading "USB drive information like its manufacturer name", descriptors... It also can enumerate all usb devices.

Sources of lsusb are e.g. here http://www.google.com/codesearch#VKTEFMx6wp0/lsusb.c

If you are doing a writing an USB driver, which works in kernel mode, I suggest you read some existing usb driver and USB driver programming FAQ.

like image 45
osgx Avatar answered Sep 20 '22 02:09

osgx