Linux Device Drivers – Exploring the Kernel And Reviewing A Book 10 Years Later

Apart from mobile, I like to explore other computer topics every now and then as there are often surprising ideas springing up from this that also impact my work in mobile. Android programming, Raspberry Pi's, Owncloud and my dive into PHP web programming and databases last year immediately filtered back to the work that earns the daily bread. Earlier this year I started having a closer look (again) at the Linux kernel.

The great thing about the Linux kernel is that it's open source and you can have a look yourself. The problem is, however, that it's a monumental piece of code and without any prior kernel knowledge, diving into the material seems daunting. I'm a hands-on person so just going through the code for the fun of it is not my piece of cake. So I was looking for some insight with practical things to be done along the way. That's not easy to come by as books on the topic with hands-on tutorials are rather dated. One of the best books on the topic is perhaps the "Linux Device Drivers" book as it explains many things about the kernel from a device driver perspective. The good thing about this approach is that it offers hand-on experience with a couple of sample drivers one can compile, modify and run. 

Unfortunately the current 3rd edition of the book is from 2005. Ancient history… I would have never bought it in print at first. Fortunately, it is available online free of charge and so I decided to start reading it in electronic form first and see if the sample code would still run. The source code would of course not compile anymore, too many changes were made to the kernel since. But a number of people have updated the source over time and there's a working version available that compiles with current kernels on Github by duxing2007.

Together with the working source the book suddenly made a lot more sense and even though some of the book's content is clearly dated (e.g. using the parallel port for some of the sample code or discussing the ISA bus) the majority of the content still gives a good introduction to the kernel with lots of things to try out via the driver examples that one can compile, run and modify. At some point I decided it was worth to buy the print version of the book as sometimes information in print still beats the electronic version. In other words, despite the book being 10 years old now, I still found it a worthwhile read!

While not necessary to compile and run the examples in the book, having the kernel source to explore is great. As it turns out it's quite simple to download and even compile it. If you are running Ubuntu, have a look here for how to do that. On my notebook in a virtual machine running an Ubuntu guest, it takes around 2.5 hours to compile the kernel. Installing the compiled kernel to boot from is a simple command. I wouldn't have dared that on my notebook but in a virtual machine there's nothing you can break in the process that couldn't be restored with the click of a button that restores a previous snapshot of the guest OS.

With all these things in place it's never been easier to explore the kernel! Have fun!