Linux Device Drivers In Only A Few Years

[Johannes 4GNU_Linux] has been filming a video series on how to write Linux device drivers for a couple of years now, but luckily, you won’t need that long to watch them or to create your own driver. He’s added some recent videos to the series, like the one below, but might want to rewind a few years and start at the beginning.

If you build your own hardware for Linux, you’ll probably eventually want to write a driver which runs as a privileged program. While there are many things you can do in user space, for the ultimate control and performance, you can’t beat a driver.

One problem, though, is that drivers can really crash your system in a big way. In the old days, it was common to have a dedicated system for driver development. Today, for many drivers, you can get away with running a virtual machine that you can crash and reload without much trouble.

The videos cover diverse topics like interrupts, completions, polling, and threads. He even uses a Raspberry Pi, which will be very useful for many embedded projects. Of course, the trend these days is to have one driver — like the USB driver — and have it provide user-space access so that everyone doesn’t have to write their own drivers. But, as usual, that only goes so far.

We aren’t sure how many more videos there will be, but if you make it through the first 31, maybe more will be waiting for you. It has been a while since we looked at SPI drivers in Linux. As an example of why you might want to roll your own, consider a custom FPGA driver.

10 thoughts on “Linux Device Drivers In Only A Few Years

    1. linux kernel sources.
      Not joking, really the most useful advice: go and see what other have done, then learn from this and not outdated books (ie linux device drivers cover 2.6 kernel, totally outdated).

  1. A great video series on a difficult subject and in digestible chunks. It can be terribly hard to scrape together all the info you need to write a driver, get your tools and libraries all working, and troubleshoot. I like Device Tree and all that clear back to SUN and Open Firmware/Open Boot. But there must be an easier way!

  2. A word of warning: the Linux kernel is a moving target, and a lot changed during the last years; there are many excellent books about writing device drivers for Linux out there, but some may be outdated; always aim at the latest editions and check before buying anything older than a few years.

    1. I think most are quite outdated. I have a couple massive books that are basically useless unless you are writing for old hardware running legacy kernels.

      I would think a concise intro that details what you need before you start: Tools, resources like data sheets, how many files you will create and where they will go, how you will turn items like pin numbers into something the device tree compiler will like, and the formats and naming schemes that will keep you out of trouble with other developers (if you plan to contribute).

  3. BTW, if anyone here had embedded Linux courses from Doug Abbott or used his excellent book “Linux for Embedded and Real-Time Applications” he passed away suddenly in late May. His writing is so clear and concise and complete that I had asked him earlier that month if he could write a book on modern device drivers and device tree, or add a couple chapters to a new edition. It is quite a saddening loss.

  4. My Linux Driver series mentioned in a Hackaday article. That is very cool. Thank you :-)

    There will be more videos on this series in the future. In two separate playlists I have also some tutorials about PCI(e) or USB drivers.

    As mentioned in the article I already had to rewind some videos, like the one about I2C and SPI. As the Linux Kernel APIs keep changing, I will have to update some other videos in the future for sure.

Leave a Reply

Please be kind and respectful to help make the comments section excellent. (Comment Policy)

This site uses Akismet to reduce spam. Learn how your comment data is processed.