This repository is a Character Device Driver project I developed to understand and implement the working logic of Embedded Linux systems at the kernel level.
Developed on Raspberry Pi, this project demonstrates the capabilities of dynamically adding/removing modules to the Linux kernel, creating virtual files, and exchanging data between user space and kernel space.
As an engineer, I aimed for and implemented the following in this project:
- Kernel Space vs User Space: Going beyond standard C code to run code in Kernel Space, the restricted and privileged area of the operating system.
- LKM (Loadable Kernel Modules): Mechanisms for loading (
insmod) and unloading (rmmod) drivers at runtime without recompiling the kernel. - Device Driver Architecture: Creating virtual devices under
/dev, in line with Linux's “Everything is a file” philosophy. - Secure Data Transfer: Using the
copy_from_userandcopy_to_userfunctions, which provide secure memory access instead of raw pointer access, when receiving data from the user to the kernel. - File Operations (
fops): Implementation of how standardopen,close,read,writesystem calls are handled on the driver side (callback functions).
- Hardware: Raspberry Pi 4 (ARM Architecture)
- Operating System: Raspberry Pi OS (Linux Kernel 6.x/5.x)
- Language: C (GNU C Standard)
- Compilation: Makefile & GCC (Cross-Compilation logic)
- Kernel Tools:
dmesg,insmod,rmmod,lsmod
To test this driver in your own Raspberry Pi environment, follow these steps:
Use Makefile to create the Kernel object (.ko):
make