Find the skeleton driver source, built it, try it, and modify it. There's both an overall one, and some for particular types of things like USB-UARTs. Look at some existing drivers for common things. Find an actual hardware device you want to write a driver for, take time to understand how Linux handles the mechanisms it uses (for example by looking at drivers for other things that use those mechanisms...) and then write your own. Answer from UniWheel on reddit.com
🌐
GitHub
github.com › Johannes4Linux › Linux_Driver_Tutorial
GitHub - Johannes4Linux/Linux_Driver_Tutorial: My new Tutorial how to get started with Linux Kernel Modules and Linux Drivers. Started in 2024 · GitHub
My new Tutorial how to get started with Linux Kernel Modules and Linux Drivers. Started in 2024 - Johannes4Linux/Linux_Driver_Tutorial
Starred by 243 users
Forked by 43 users
Languages   C 89.5% | Makefile 10.5%
🌐
Apriorit
apriorit.com › home › blog › software development blog › linux device drivers: tutorial for linux driver development
Linux Device Drivers: Linux Driver Development Tutorial – Apriorit
February 16, 2026 - Building a Linux device driver demands in-depth knowledge of the operating system’s internals. Apart from understanding kernel architecture and memory management, your team also needs to have strong expertise in driver programming. In this tutorial, Apriorit experts provide you with step-by-step instructions on how to build a driver in Linux (starting from kernel version 6.14.0), including code samples.
🌐
Linux Kernel
kernel.org › doc › html › v4.13 › driver-api › index.html
The Linux driver implementer’s API guide — The Linux Kernel documentation
The kernel offers a wide variety of interfaces to support the development of device drivers. This document is an only somewhat organized collection of some of those interfaces — it will hopefully get better over time!
🌐
EmbeTronicX
embetronicx.com › tutorials › linux › device-drivers › linux-device-driver-part-1-introduction
Linux Device Drivers Tutorial | Linux Drivers and Kernel Modules
Understand basic concepts about Linux device drivers and practical examples for understanding device drivers in Linux.
Published   July 2, 2023
Views   0
🌐
Reddit
reddit.com › r/c_programming › resources for learning to write linux device drivers?
r/C_Programming on Reddit: Resources for learning to write Linux device drivers?
August 24, 2022 -

I'm coming from web development and learning C has been my first experience with a low level language. I have enjoyed learning the basics of the language but now I am having an issue: I have been unable to find any resources for learning how to actually write anything substantial in C. I can find loads of absolute beginner content for learning the basic syntax of the language, and I can find some advanced content, but I seem to be totally unable to find any intermediate content that bridges the large gap between those two extremes. The reason I decided to learn C to begin with was because I wanted to learn to write Linux device drivers, but after learning the basics of the language, I'm at a loss for where to go next. Can anyone point me to some resources? Maybe some books to read or concepts to learn?

🌐
SCIS
scis.uohyd.ac.in › ~chakcs › AOS2025 › code › device_drivers_linux.pdf pdf
Writing device drivers in Linux: A brief tutorial
Table 2. Device driver events and their associated functions between kernel space and the hardware ... I’ll now show you how to develop your rst Linux device driver, which will be introduced in the kernel as a
Find elsewhere
🌐
The Linux Kernel Module Programming Guide
sysprog21.github.io › lkmpg
The Linux Kernel Module Programming Guide
May 27, 2026 - A Linux kernel module is precisely defined as a code segment capable of dynamic loading and unloading within the kernel as needed. These modules enhance kernel capabilities without necessitating a system reboot. A notable example is seen in the device driver module, which facilitates kernel ...
🌐
YouTube
youtube.com › playlist
Learning Linux Device Drivers Development tutorial - YouTube
Linux is an operating system that consists of a monolithic kernel. This course will get you comfortable with setting up and building any device driver from s...
🌐
Medium
medium.com › @wedevelop21 › write-your-first-linux-device-driver-c3d9d0143cfb
Write your first Linux device driver | by We develop | Medium
November 25, 2024 - Unlock the secrets of writing your first Linux driver with simple steps using Multipass and VS Code. Dive into creating a character driver and explore the exciting world of Linux development!
🌐
nixCraft
cyberciti.biz › nixcraft › tutorials › howto › linux device driver tutorial using kernel driver frameworks
Linux device driver tutorial using kernel driver frameworks - nixCraft
July 5, 2007 - While no single article could possibly attempt to covered everything there is to know about writing drivers, Valerie Henson gives us a brief taste of what’s involved, by implementing a device to return “Hello World” using all the major driver frameworks. On a related note if you just want get a comprehensive overview of kernel configuration and building, a critical task for Linux users and administrators, try Linux Kernel in a Nutshell
🌐
Emertxe
emertxe.com › home › linux device drivers › linux device drivers | course materials
Linux Device Drivers Course Material | Free Resources | Emertxe
July 31, 2025 - Our Linux Device Driver course takes a hands-on approach to enable participants to create a driver on their own.
🌐
Opensource.com
opensource.com › article › 18 › 11 › how-install-device-driver-linux
How to install a device driver on Linux | Opensource.com
You can also download a driver from the internet, then just double-click it to run a wizard or import the driver through Device Manager. ... This process isn't as easy on a Linux operating system.
Top answer
1 of 4
75

First, start by writing a generic kernel module. There are multiple places to look up for information but I found this link to be very useful. After you have gone through all examples specified there you can start writing your own Linux Driver Module.

Please note, that you will not get away with just copy-pasting the example code and hope it will work, no. Kernel API can sometimes change and examples will not work. Examples provided there should be looked at as a guide on how to do something. Depending on the kernel version you are using you have to modify the example in order to work.

Consider using TI platform-provided functions as much as you can, because that can really do a lot of work for you, like requesting and enabling needed clocks, buses, and power supplies. If I recall correctly you can use the functions to acquire memory-mapped address ranges for direct access to registers. I have to mention that I have a bad experience with TI-provided functions because they do not properly release/clean up all acquired resources, so for some resources, I had to call other kernel services to release them during module unload.

Edit 1:

I'm not entirely familiar with Linux SPI implementation but I would start by looking at omap2_mcspi_probe() function in drivers/spi/spi-omap2-mcspi.c file. As you can see there, it registers it's methods to Linux master SPI driver using this API: Linux/include/linux/spi/spi.h. In contrast to char driver, the main functions here are *_transfer() functions. Look up the struct descriptions in spi.h file for further details. Also, have a look at this alternative device driver API, too.

2 of 4
21

I assume your OMAP4 linux uses one of arch/arm/boot/dts/{omap4.dtsi,am33xx.dtsi} device-tree, thus it compiles drivers/spi/spi-omap2-mcspi.c (if you don't know about device-tree, read this). Then:

  • the SPI master driver is done,
  • it (most probably) registers with Linux SPI core framework drivers/spi/spi.c,
  • it (probably) works fine on your OMAP4.

You actually don't need to care about the master driver to write your slave device driver. How do I know spi-omap2-mcspi.c is a master driver? It calls spi_register_master().

SPI master, SPI slave ?

Please refer to Documentation/spi/spi_summary. The doc refers to Controller driver (master) and Protocol drivers (slave). From your description, I understand you want to write a Protocol/Device driver.

SPI protocol ?

To understand that, you need your slave device datasheet, it shall tell you:

  • the SPI mode understood by your device,
  • the protocol it expects on the bus.

Contrary to i2c, SPI does not define a protocol or handshake, SPI chips manufacturers have to define their own. So check the datasheet.

SPI mode

From include/linux/spi/spi.h:

 * @mode: The spi mode defines how data is clocked out and in.
 *  This may be changed by the device's driver.
 *  The "active low" default for chipselect mode can be overridden
 *  (by specifying SPI_CS_HIGH) as can the "MSB first" default for
 *  each word in a transfer (by specifying SPI_LSB_FIRST).

Again, check your SPI device datasheet.

An example SPI device driver?

To give you a relevant example, I need to know your SPI device type. You would understand that a SPI flash device driver is different from a SPI FPGA device driver. Unfortunately there are not so many SPI device drivers out there. To find them:

$ cd linux 
$ git grep "spi_new_device\|spi_add_device"
🌐
Udemy
udemy.com › development
Linux Device Drivers Development training
July 16, 2020 - This course contains prerecorded Linux Device Driver video classes or Linux Device Driver video tutorials on linux device drivers concepts , which covers from basic to advance concepts . Below is the course outlines Training Lessons Introduction to Linux kernel Kernel configuration and build ...
Rating: 3.8 ​ - ​ 40 votes
🌐
Medium
medium.com › @mwafa2sh › write-your-own-linux-device-driver-6996ccb815db
Write your own Linux Device Driver | by Mo Aljabi | Medium
April 6, 2025 - In this article, we’ll explore how to start developing Linux kernel device drivers. Specifically, we’ll write a simple driver to control an LED on a Raspberry Pi and use a Bash script to toggle it.