| Notes from OLS2005 | |||
|---|---|---|---|
| <<< Previous | Next >>> | Blog | |
| Tutorial: Write a Real, Working Linux Driver |
| Greg Kroah-Hartman |
| personal: http://kroah.com/linux/ |
| slides: http://www.kroah.com/linux/talks/ols_2005_driver_tutorial/ |
| code: http://www.kroah.com/linux/talks/ols_2005_driver_tutorial_example_code.tar.gz |
The OLS2005 organizers decided to try something a little new this year and offer a hands-on tutorial session, led by Greg, regarding how to write a 2.6.x USB kernel driver. In order to ease the typing strain there were USB keys being passed around that had various revisions of the driver code on it. The talk was fast paced and it was a good thing the code was already available, that way we could concentrate on what was going on instead of how to do it.
When we entered the tutorial Greg had USB temperature probes that he gave out to everyone who was registered. It was necessary to pre-register for this tutorial and we were told to bring $40CAN to pay for the device. This was going to be a real Linux driver that actually interfaced with a real device (instead of just a lot of hand waving and statements like "if you had a real USB device you would need to do this"). As I reached for my wallet Greg said: "no money, no money", the company who makes the devices had donated 80 of them for this tutorial! What a great gesture! The device itself is the Go!Temp temperature device from Vernier Software & Technology.
Greg started off by talking briefly about the USB spec, referring only to the parts that were required to understand how this device worked (i.e. he didn't talk about all the transfer methods, just the one this device used). He talked about interfaces and configuration and how that relates to the controller.
Getting to the code he started off with a basic "Hello, world!\n" type driver. We compiled that code and loaded it into the kernel. We then played around in the /sys tree investigating this and that as well as playing around with modinfo, insmod, and rmmod. Incrementally Greg started adding to this code to demonstrate things like getting a sysfs entry, initialization, exit code, read, write, and other functions. At the end he added the USB command that actually received the information from the device.
| <<< Previous | Home | Next >>> |
| 13h30 - Building Murphy Compatible Embedded Linux Systems | Up | 21h00 - BOFS: Xen Hypervisor |