How to learn linux device driver

时间:2023-03-08 17:56:26
How to learn linux device driver

To learn device driver development, like any other new knowledge, the bestapproach for me is to learn first the theory and then to do some practice.

If you don't know about operating systems, I recommend "Willam Stalling's OS book" [1]. This book has a more hardware oriented approach unlike other OS books that focused more on the algorithms and data structures used in operating systems.

After having a high level overview of operating systems, you have to learn aboutLinux kernel development. Robert Love's book [2] is for me the best one on thesubject. You can learn not only about Linux kernel development, but also themotivations behind the technical decisions that lead to the design.

Then you have to learn about device drivers development on Linux, two books that are very good are "Linux Device Drivers" [3] and "Essential Linux Device Drivers" [4].This two books are complementary. The former teaches how to write virtual devicedrivers for memory based devices, so you can try the examples without the need ofspecial hardware. While the latter shows you how device drives for real devices are actually written. I maintain an up-to-date repository with all LDD3 examples so you can compile and test on recent kernels [5].

Once you have the theory you can begin with the practice by writing real device drivers. You need a hardware that still is not supported on Linux. The good news is that you probably already have one of these devices. With the popularity of the Android platform, is very likely that you own an Android device.

Even when Android is a Linux-based operating system, Google by a design decision forked the Linux kernel and added some APIs [6] that don't exist on the Linux kernel. These APIs are used by device drivers and for that reason, a developer has to choose whether to write a device driver for Android or Linux.

So, porting Android device drivers to Linux is an excellent opportunity to learn device driver development skills, the Linux kernel development process and how to work with the Linux community while doing something useful.

[1]: http://williamstallings.com/OS/
[2]: http://blog.rlove.org/2010/07/li...
[3]: http://lwn.net/Kernel/LDD3/
[4]: http://elinuxdd.com/
[5]: https://github.com/martinezjavier/ldd3
[6]: http://lwn.net/Articles/416690/