Kernel-space programming – Writing code that interacts directly with the Linux kernel.
Device registration and module management – Ensuring the system recognizes and loads the driver.
User-space interaction – Enabling controlled communication between applications and hardware.
This blog documents my learning journey, where I explore character, block, and procfs drivers, leading toward writing basic kernel modules that interface with Raspberry Pi 4B hardware and user-space applications.
How character devices interact with the Linux kernel.
How to create and register a character device.
Where to find major and minor device numbers in /dev/.
How to compile, load, and remove kernel modules (make, insmod, rmmod).
Using dmesg to debug driver behavior.
Implementing file operations (read, write, ioctl) to interact with a driver.
"Linux Device Drivers Development Course for Beginners" (FreeCodeBootCamp.org) – A structured introduction to kernel programming.
YouTube @LowLevelTV Raspberry Pi Kernel Driver tutorial playlist – Covers procfs device implementation for GPIO control.
Johannes 4GNU_Linux tutorials – Covers drivers, USB, networking/ethernet, and embedded systems in-depth.
Read from the device buffer – Retrieve stored data.
Write to the device buffer – Modify contents while logging changes in the kernel.
Use ioctl to modify driver behavior – Send custom commands to control driver operations.
Used getline() to send data to the driver.
Read the stored data from the driver buffer.
Used ioctl to send predefined arguments (0, 1, 2) and receive different responses.
How to manage buffers effectively in kernel space.
The importance of proper state management for stability.
How ioctl provides additional control beyond basic read/write operations.
How the Linux kernel initializes hardware and loads drivers – The kernel loads built-in drivers during boot, while loadable modules (like custom drivers) can be inserted later using insmod or automatically by udev.
Kernel Space vs. User Space – Drivers run in kernel space with full system access, while applications run in user space and communicate with drivers through system calls like read(), write(), and ioctl(). (More info)
Different types of Linux device drivers – Linux device drivers include character (byte stream, e.g., serial ports, GPIO), block (fixed-size blocks, e.g., HDDs, SSDs), network (packet-based, e.g., Ethernet, Wi-Fi), and pseudo-filesystem drivers (kernel data via /proc, /sys). Other types include USB, PCI, platform, and virtual drivers for various hardware interfaces. While it's important to understand these categories, I'll focus on character and procfs drivers, which are most relevant for embedded systems using GPIO, I2C, and SPI.