Skip to content

madhawapolkotuwa/linux_driver_development_with_raspberrypi

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

67 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

✅ Linux Driver Development with Raspberry Pi - Full Tutorial Series Roadmap

SECTION 0 - Introduction & Preparation

1. Introduction to the Series

  • What the series covers
  • Tools, requirements
  • Recommended references (inc. Linux Device Drivers 3rd Edition)

2. Understanding the Linux Kernel

  • Kernel architecture
  • User space vs kernel space

3. Linux Device Drivers Overview

SECTION 1 - Raspberry Pi Setup & Development Environment

  • Installing Raspberry Pi OS (64-bit)
  • Enabling SSH
  • Installing kernel headers
  • Recommended directory layout

SECTION 2 - Character Device Driver Foundations

  • Allocating major/minor numbers
  • cdev_init, cdev_add
  • Manual mknod vs udev auto-creation
  • File operations overview
  • open, release, read, write
  • copy_to_user, copy_from_user
  • Using file->private_data
  • Defining IOCTL commands
  • Handling IOCTL in driver
  • User application examples
  • kmalloc, kzalloc, vmalloc
  • GFP flags
  • Slab allocator overview
  • list_head, iterating, adding, deleting
  • Using linked lists in drivers

SECTION 3 - GPIO, Interrupts, Timers

  • Request/release GPIO
  • Set/get GPIO state
  • request_irq
  • IRQ numbers
  • Debouncing
  • Top-half vs bottom-half
  • One-shot, periodic timers

SECTION 4 - I2C & SPI Drivers

  • Linux I2C architecture
  • Client vs adapter vs driver
  • Registering an I2C driver
  • Creating a device via /sys/bus/i2c/devices
  • Read/write registers
  • Calibration
  • Temperature & pressure reading
  • Exposing sensor values to user space
  • SPI architecture
  • Full duplex transfers
  • SPI message & transfer structs

SECTION 5 - Concurrency & Synchronization

  • Creating, running, stopping threads
  • Thread loop best practices
  • Deferred execution
  • System vs dedicated workqueues
  • Comparison with tasklets

SECTION 6 - Linux Device Model & Sysfs

  • Devices, drivers, buses, classes
  • Probe/remove lifecycle
  • Hotplug & Uevents (plug/unplug)
  • Device attributes
  • Creating and removing sysfs files
  • Sysfs class interfaces (/sys/class/mydriver)
  • Creating debugfs entries
  • Live introspection of driver variables
  • Differences from sysfs

SECTION 7 - Device Tree & Raspberry Pi Overlays

  • Why Device Tree exists
  • Structure of .dts and .dtsi
  • Status, compatible, reg, gpios

25. Writing Raspberry Pi Device Tree Overlays

  • Overlay structure
  • Adding nodes dynamically
  • Applying overlays live

26. Device Tree - GPIO Example

  • Creating a GPIO LED/button node
  • Binding to your driver
  • Reading GPIO from DT

27. Device Tree - I2C Device

  • Adding BMP180 in DT
  • Custom compatible string
  • Passing configuration via DT

28. Platform Driver

  • Introduction to platform bus
  • Platform_device vs platform_driver
  • Useful for non-I2C/SPI devices

29. Pin Control & Pinmux

  • Pin configuration in DT
  • Alternate functions on Raspberry Pi pins

30. OF (Open Firmware) Parsing

  • Using DT helper APIs
  • Parsing strings, ints, gpios from DT

SECTION 8 - Advanced Topics

31. Misc Device Driver

  • Easiest way to expose /dev/mydevice
  • When to prefer over char device

32. Regmap API

  • Excellent for I2C/SPI register-mapped chips
  • Reduces boilerplate
  • Cache & sync

33. DMA Engine Basics & DMA memcpy

  • DMA vs CPU copy
  • DMA mapping APIs
  • Simple DMA example

34. Accessing Files from Kernel (Safely)

  • filp_open, kernel_read, kernel_write
  • Kernel warnings & limitations
  • Practical example: writing logs to SD card

35. Memory Mapping (mmap)

  • Expose kernel buffers to user space
  • Example: custom framebuffer
  • Page faults inside driver

36. Industrial I/O (IIO) Framework

  • When to use IIO
  • Creating an IIO device
  • Reading ADC-like data

37. Sending Signals to User Space

  • Real-time signals
  • Notify app when an event occurs
  • Example: IRQ → signal to application

SECTION 9 - Serial Drivers

38. UART (Serial) Driver

  • UART on Raspberry Pi
  • Writing a minimal UART driver
  • Using termios from user space

SECTION 10 - Final Project

39. Complete Raspberry Pi Kernel Driver Project

  • A sophisticated final driver combining everything:
  • Device Tree overlay
  • Char device with IOCTL
  • Sysfs interface
  • GPIO + interrupt + poll
  • High-resolution timer
  • Optional I2C or SPI communication
  • debugfs runtime variables
  • User-space test application

40. Packaging & Publishing

  • Versioning
  • DKMS support
  • GitHub best practices
  • Share as a Linux kernel module package

About

This series is designed to build a strong, practical foundation in Linux kernel driver development, step by step, from basics to real implementation.

Topics

Resources

Stars

Watchers

Forks

Contributors

Languages