Here you can find examples for simple Linux Kernel Modules and Linux Drivers.
I used a Raspberry Pi 3 to develop and test my modules and drivers. To compile them, you need to install the Kernel headers on your Pi. On Raspberry Pi OS you can do this with the following command:
sudo apt update && sudo apt upgrade -y
sudo apt install raspberrypi-kernel-headers
reboot
Raspberry Pi OS is only installs the latest kernel headers. So, make sure, you are running the latest kernel.
You also need the build utils (make, gcc, ...) but they come preinstalled on Raspberry Pi OS.
In this repo you can find examples for:
- Simple Hello World Kernel Module
- An improved Hello World Linux Kernel Module
- An example for using GPIOs in a driver without device tree
- Some info about Device Files, Device Numbers, Block and Character Devices
- Create a Character Device in a Driver
For more information about my Linux Driver examples check out my videos and my playlist
If you want to support me, you can buy me a coffee buymeacoffee.com/johannes4linux.