Jump to content

USB device driver in linux

- - - - -

  • Please log in to reply
5 replies to this topic

#1
B-80

B-80

    Newbie

  • Members
  • Pip
  • 4 posts
I am a college student,, and this summer I am working in a physics lab and have been given the task to write a device driver for a USB peripheral in linux for an experiment we are running. Basically I am just looking for the right resources to start this project (books, websites, ect..)

I have a decent knowledge of C, although it is mostly through systems programming, I have never dealt with hardware protocols and such. The idea is there is going to be a peripheral that I have to read data from whenever I get a signal from another piece of hardware, so I need to be able to bulk transfer from this USB device. The peripheral is not going to be a defined USB class, so I am also going to need to write the device driver for it. My main question is where do I start learning the syntax for this kind of stuff? I have been reading up on the USB specification already, which I assume is the first step. I have also read up on libusb, but IDK if I should use that or try to interface with the device in some other way, what do you guys suggest?

#2
conficker.e

conficker.e

    Newbie

  • Members
  • Pip
  • 3 posts
same problem @B-80. I have to find a guide to write a driver/firmware to enable my code to read/write files into a USB device. I looked through the LibUsb library (using it in my IDE) but I can to transmit only a stream, i.e. a character sequence. I suppose I've to dodge the file system w a my driver to operate on device.
Guys, is there a guide or some source-code to create a driver compliant w USB 2.0 specs? Cheers..

#3
WingedPanther

WingedPanther

    A spammer's worst nightmare

  • Moderators
  • 16,831 posts
  • Location:Upstate, South Carolina
  • Programming Language:C, C++, PL/SQL, Delphi/Object Pascal, Pascal, Transact-SQL, Others
  • Learning:Java, C#, PHP, JavaScript, Lisp, Fortran, Haskell, Others
Ultimately, all communications via USB will be a stream of characters. It's knowing WHAT characters to send that is the trick.
Programming is a branch of mathematics.
My CodeCall Blog | My Personal Blog

#4
conficker.e

conficker.e

    Newbie

  • Members
  • Pip
  • 3 posts
Bulk transfer supports only stream of characters. My main problem is how to build a char sequence that permits to recognise a file in the file system and to put it into the usb device.

Suggestions?

#5
WingedPanther

WingedPanther

    A spammer's worst nightmare

  • Moderators
  • 16,831 posts
  • Location:Upstate, South Carolina
  • Programming Language:C, C++, PL/SQL, Delphi/Object Pascal, Pascal, Transact-SQL, Others
  • Learning:Java, C#, PHP, JavaScript, Lisp, Fortran, Haskell, Others
It depends on the details of the device. You can both read and write to it, so you'll have to send it a message (write), and get a response (read).
Programming is a branch of mathematics.
My CodeCall Blog | My Personal Blog

#6
conficker.e

conficker.e

    Newbie

  • Members
  • Pip
  • 3 posts
I solved with this part of code:


snprintf( command, sizeof command, "sudo /bin/cp -p %s %s", source, destination );

l_iRet = system( command );


I wonder if I've really solved my problem with a system call? As a requirement of my task I have to work in Bulk-Transfer-Only mode that means using stream to communicate between host and USB mass storage.




1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users