LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software > Linux - Kernel
User Name
Password
Linux - Kernel This forum is for all discussion relating to the Linux kernel.

Notices


Reply
  Search this Thread
Old 12-02-2009, 07:34 AM   #1
Penguin01
LQ Newbie
 
Registered: Dec 2009
Posts: 23

Rep: Reputation: 15
Linux device drivers


Does anybody know where I can get the source code for a USB mass storage device driver for Linux?
I have been trying to search for it, but have had no luck.
I would have thought it would be easy as Linux is opensource.
 
Old 12-02-2009, 07:45 AM   #2
raju.mopidevi
Senior Member
 
Registered: Jan 2009
Location: vijayawada, India
Distribution: openSUSE 11.2, Ubuntu 9.0.4
Posts: 1,155
Blog Entries: 12

Rep: Reputation: 92
This link may be helpful for you . Click here
 
Old 12-02-2009, 07:58 AM   #3
raju.mopidevi
Senior Member
 
Registered: Jan 2009
Location: vijayawada, India
Distribution: openSUSE 11.2, Ubuntu 9.0.4
Posts: 1,155
Blog Entries: 12

Rep: Reputation: 92
to know how to write USB driver code , follow this
 
Old 12-02-2009, 08:27 AM   #4
Penguin01
LQ Newbie
 
Registered: Dec 2009
Posts: 23

Original Poster
Rep: Reputation: 15
Thanks for your reply.
Does this mean that there is no current source code for a USB mass storage device that can be downloaded and modified?
I want to try and understand how USB device drivers read and write.
 
Old 12-02-2009, 08:29 AM   #5
sundialsvcs
LQ Guru
 
Registered: Feb 2004
Location: SE Tennessee, USA
Distribution: Gentoo, LFS
Posts: 10,665
Blog Entries: 4

Rep: Reputation: 3945Reputation: 3945Reputation: 3945Reputation: 3945Reputation: 3945Reputation: 3945Reputation: 3945Reputation: 3945Reputation: 3945Reputation: 3945Reputation: 3945
Of course there are.

/usr/src/linux/drivers/usb/usb_skeleton.c is a great start.

It is pretty much de rigeur that the proper way to approach this sort of thing is to look at "prior art." Find something that is very-close to what you are doing and adapt it ... or, quite likely, discover that you actually don't have to. If your purpose is simply to discover how something works: "Use the Source, Luke!"

Last edited by sundialsvcs; 12-02-2009 at 08:44 AM.
 
1 members found this post helpful.
Old 12-03-2009, 09:26 AM   #6
Penguin01
LQ Newbie
 
Registered: Dec 2009
Posts: 23

Original Poster
Rep: Reputation: 15
Thanks.
I am running the 2.6.28 kernel and when I try and compile a basic "Hello World" device driver. When I try to compile it I get "cannot find module.h".
I have read that I may need to enter the following command

$ sudo apt-get install module-assistant

But this just says "E: Couldn't find package module assistant."

Does anyone know what the problem is and how I can fix it?
 
Old 12-03-2009, 10:04 AM   #7
raju.mopidevi
Senior Member
 
Registered: Jan 2009
Location: vijayawada, India
Distribution: openSUSE 11.2, Ubuntu 9.0.4
Posts: 1,155
Blog Entries: 12

Rep: Reputation: 92
which distribution you are using ? is it debian based ?
 
Old 12-04-2009, 04:36 AM   #8
Penguin01
LQ Newbie
 
Registered: Dec 2009
Posts: 23

Original Poster
Rep: Reputation: 15
Yes it is debian based (as far as I am aware). Is there anyway of checking what the distribution? I am running Ubuntu.
 
Old 12-04-2009, 07:22 AM   #9
raju.mopidevi
Senior Member
 
Registered: Jan 2009
Location: vijayawada, India
Distribution: openSUSE 11.2, Ubuntu 9.0.4
Posts: 1,155
Blog Entries: 12

Rep: Reputation: 92
Edit /etc/apt/sources.list (you need to be root to do this).
In there somewhere there should be lines that look
more or less like this:
Code:

Code:
deb http://archive.ubuntu.com/ubuntu/ breezy  universe
deb-src http://archive.ubuntu.com/ubuntu/ breezy universe
They may say dapper if you are using a Dapper release, and the archive
URL may be slightly different, might have us or ca or eu or something in it.

Then in a terminal do
Code:

Code:
sudo apt-get update
or in Synaptic, select the Reload button.
 
Old 12-04-2009, 03:26 PM   #10
Penguin01
LQ Newbie
 
Registered: Dec 2009
Posts: 23

Original Poster
Rep: Reputation: 15
I am using:
Linux version 2.6.28-11-generic (buildd@palmer) (gcc version 4.3.3 (Ubuntu 4.3.3-5ubuntu4) ) #42-Ubuntu SMP

When I open the sources.list file I have:
deb http://gb.archive.ubuntu.com/ubuntu/ jaunty universe
deb-src http://gb.archive.ubuntu.com/ubuntu/ jaunty universe

I tried:
sudo apt-get update
This seems to run fine, but again when running gcc -c hello.c as on http://www.freeos.com/articles/2677/
I get:
hello.c:2:26: error: linux/module.h: No such file or directory


Please help, Thanks.
 
Old 12-04-2009, 04:27 PM   #11
Penguin01
LQ Newbie
 
Registered: Dec 2009
Posts: 23

Original Poster
Rep: Reputation: 15
So after restarting my machine and following http://linuxdevcenter.com/pub/a/linu...ux.html?page=2 instead, the Hello World device driver works!!!

Does 'sudo apt-get update' command compile the kernel? As it is very different to '$ sudo apt-get install module-assistant'

Thanks for your help raju, now I'll try the usb-skeleton.c.
 
Old 12-04-2009, 07:05 PM   #12
raju.mopidevi
Senior Member
 
Registered: Jan 2009
Location: vijayawada, India
Distribution: openSUSE 11.2, Ubuntu 9.0.4
Posts: 1,155
Blog Entries: 12

Rep: Reputation: 92
Quote:
Originally Posted by Penguin01 View Post

Does 'sudo apt-get update' command compile the kernel?
"$sudo apt-get update" is designed for package management, and software updating.
Passing the update argument to the Apt-Get command results in a system update process. This process will contact the configured repositories and compare them to existing files on the local system. If an update is possible, the “sudo apt-get upgrade” command will process the respective program upgrade.
 
Old 12-07-2009, 02:42 PM   #13
Penguin01
LQ Newbie
 
Registered: Dec 2009
Posts: 23

Original Poster
Rep: Reputation: 15
I have been looking at the usb-skeleton.c code.
I got this code from http://lxr.free-electrons.com/source...ton.c?v=2.6.28, as it is supposed to be in linux/drivers/usb but I cannot seem to find it on my ubuntu machine.

From what I know, the code from the site above seems to be OK, but the only confusing thing is that the device gets registered at the end, rather than the beginning.
Is this correct? As I thought the first thing that happens is the device is registered???
Can someone please verify if the usb-skeleton.c is correct for USB mass storage devices...

Thanks.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
regarding linux - device drivers bafflaq Linux - Kernel 3 12-02-2009 06:37 AM
Linux Device Drivers isalmbio Linux - Hardware 4 12-16-2006 11:33 AM
Automatic Device Drivers for linux tstolber Linux - General 2 04-09-2006 04:06 PM
linux kernel device drivers alaios Linux - General 1 08-16-2004 08:08 AM
linux device drivers alaios Programming 1 05-24-2003 08:23 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software > Linux - Kernel

All times are GMT -5. The time now is 08:18 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration