views:

175

answers:

4

I would like to learn how to write device drivers because I think it would be fun. I use a Mac OS X Macbook, but I also have an Ubuntu machine (running on a Mac Min). I am pretty familiar with C and currently am reading this book. I have found some links online such as Mac Dev Center. I am doing this because it would be fun. I think there would be real gratification to see hardware operate because of software I wrote.

I guess what I would like is some tips or advice and guidance, and does anyone know of a list of devices that don't have drivers or can I write a driver for something that's already supported (would prefer the former so I'm actually providing value). What's a good device to get started with? Am I biting off more than I can chew? I'm not afraid of low level programming or assembly or whatever amount of effort is required. I'd like a challenge really!

+1  A: 

For Mac you might want to take a look at Mac OS X Internals book. It's think and heavy but fun to read. It is mostly about PowerPC-based Macs but has an appendix about Intel-based ones. For Linux take a look at Linux Device Drivers, 3rd Edition - it's lighter (free PDFs online :) and is really device driver-oriented, might be a better start.

Nikolai N Fetissov
Thank you! How much work is it to write a device driver? Is it more or less work than writing a big complex application?
apphacker
Hmm, in both cases you need to know what you are doing, so you need to understand the surrounding environment, and that comes from experience, which you don't get until you try :) Work through several examples from LDDv3, the source code is online but a bit outdated for current kernels, you'll get a feel of what's involved and what you'd like to learn next.
Nikolai N Fetissov
+2  A: 

If you want to go for Linux device driver development, the freely available O'Reilly book Linux Device Drivers, Third Edition is a must read.

In order to find unsupported hardware pieces for which you could write a driver, ask on the Linux mailing lists. Maybe some USB 3.0 device? ;)

AndiDog
Thank you! How much work is it to write a device driver? Is it more or less work than writing a big complex application?
apphacker
+3  A: 

For Linux, you might look into picking up the O'Reilly Linux Device Drivers book or reading PDFs online. In my opinion, it is one of the better texts around on the subject.

The Linux Kernel Module Programming Guide is another good resource.

You may also want to pick up a book specifically on the Linux Kernel. I picked up a copy of Robert Love's Linux Kernel Development (2nd Edition) for this purpose (3rd Edition on the way).

jschmier
Thank you! How much work is it to write a device driver? Is it more or less work than writing a big complex application? I asked everyone who answered this question, because I really want an answer. Thanks again!
apphacker
The difficulty and amount of work involved depends on the complexity of the device. A *tty* device driver may be much less complex than a *usb* or *pci* device driver.
jschmier
+2  A: 

Writing a device driver can be pretty simple, or it can be almost arbitrarily complicated. For instance, I've been involved in a project where it took six of us almost three years to solve ONE bug in a device driver. Of course, we cleared out dozens of other bugs while looking for it... the code improved immensely. The fix turned out to be an eight line patch, that cost, conservatively, about a million dollars.

But, as a side project to that, I wrote an ethernet driver from the chip data sheet in a week, and took another week to debug it. Haven't needed to touch it since.

There's no way to say in general how much work a driver will be; a GPU driver could cost hundreds of millions, a driver for a single LED costs a couple of hours work at the most.

Andrew McGregor