I have recently started playing with raspberry pi and want to write device driver for it. Already installed cross tool chain in development PC (having Ubuntu), compiled and downloaded application code (simple hello world) in raspberry pi board (having raspbian wheezy OS).

Can anybody suggest me the steps need to write device driver? Does it require to compile raspbian wheezy OS? Does it require to download source code of kernel?

  • 1
    What have you tried? Have you done any research on the matter? What exactly do you want from us? Your question is very vague and discusses a very complicated task.
    – Jacobm001
    Dec 30 '13 at 16:42
  • I agree, start with compiling an existing driver and modifying it to see if you understand what makes it tick. Dec 30 '13 at 17:45
  • Thanks for the comments!! I understand that i haven't explain much my problem.
    – saurabh
    Dec 31 '13 at 5:16
  • Thanks for the comments!! I understand that i haven't explain my problem properly? I have written simple driver code using "printk" function (on Ubuntu OS) and tried to build it using existing kernel source folder (usr/src/linux-headers-3.8.0-29-generic) but got lots of error. After that i have started googling and found that need to compile kernel first and then start building driver with kernel source. Does it right to download fresh copy of kernel and getting compile first before to build linux device driver?
    – saurabh
    Dec 31 '13 at 5:30
  • What is the device that you want to write a driver for? And do you actually need a kernel driver or is it something that could run in user space?
    – Atonewell
    Mar 20 '14 at 20:35

The best resource to start learning how to write Linux device driver is the free eBook Linux Device Drivers 3rd Edition. You can download the entire book at https://lwn.net/Kernel/LDD3/

The example code that came with the book when it was published are outdated, so you should use the more up-to-date example code instead, like the one at https://github.com/duxing2007/ldd3-examples-3.x


If you want to learn basics of device driver first go through this series it's explained in a very simple and elegant manner here http://www.linuxforu.com/2010/12/writing-your-first-linux-driver/

and then read ldd 3rd edition to make your concepts concrete http://www.makelinux.net/ldd3/

I also advice to first practice the examples on your PC using a virtual machine to avoid crashes all the best :)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.