Mike Chirico on 5 Apr 2004 00:54:02 -0000


[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]

[PLUG] Writing your own (2.6 kernel) USB driver


Writing your own (2.6 kernel) device driver 101.

If you're looking for a weekend device driver project, check out the
products on http://www.delcom-eng.com.  You may have seen the article
in Linux Journal.  http://www.linuxjournal.com/article.php?sid=7353

I sent away for the USB Numeric display ($68)
(http://www.delcom-eng.com/products_USBNDisplay.asp) which actually
does a lot. It's more than just a numeric display. In raw mode
there are between 0 and 255 settings for each character. So it's
possible to create block letters in addition to numbers.  Plus,
there are different flash rates.  along with a 85db piezo buzzer.

They don't have a Linux driver; but, they do make a Window's
source program version available, so you can see how the calls
are made. And, with the Linux Journal article, and a little time,
it's instructive to build your own.

WHAT TO DO WHILE YOU'RE WAITING FOR DELIVERY

I think it's best to  build the 2.6.x kernel from source.
http://osdn.dl.sourceforge.net/sourceforge/souptonuts/README_26.txt

Then, if you've never built a kernel module, take a look at
http://prdownloads.sourceforge.net/souptonuts/procreadwrite.0.0.1a.tar.gz?download
This is a simple module that creates /proc/files for user-space
"input" and also includes  tty output.. so you can print out what's
happening in each stage of the module. This example is useful for
understanding the series of in lwn.net article, because you can
see the output on your tty (screen), and NOT always reference the
console or log files. Once you download this, make sure you change
the Makefile to point to your source...obviously you're not going
to have a /home/chirico/


NOTE:

Greg's has the user write to sysfs.  You'll see this creates a
lot of disk io.  The sysfs or /sys/bus/usb is on disk, whereas
/proc/... is all ram.  For the  USB numeric display it's probably
best to create /proc/files for user-space input.


Here's a summary of the references:

 Linux Journal.
  http://www.linuxjournal.com/article.php?sid=7353

 Excellent (series of articles):
  http://lwn.net/Articles/driver-porting/

 Again here's my sample program (proc only no USB device):

http://prdownloads.sourceforge.net/cpearls/procreadwrite.0.0.1a.tar.gz?download

 Good but dated for 2.4 kernel:
  http://www.oreilly.com/catalog/linuxdrive2/

  http://linuxdevices.com/articles/AT4389927951.html
  http://linuxdevices.com/articles/AT5793467888.html


Regards,

Mike Chirico

___________________________________________________________________________
Philadelphia Linux Users Group         --        http://www.phillylinux.org
Announcements - http://lists.phillylinux.org/mailman/listinfo/plug-announce
General Discussion  --   http://lists.phillylinux.org/mailman/listinfo/plug