1
0
Fork
You've already forked Linux_Driver_Tutorial
0
My new Tutorial how to get started with Linux Kernel Modules and Linux Drivers. Started in 2024
  • C 89.5%
  • Makefile 10.5%
2026年02月04日 20:36:11 +01:00
01_hello Added more information to hello world kernel module 2025年03月25日 21:27:18 +01:00
02_better_hello Update README.md 2024年11月04日 20:11:49 +01:00
03_gpioctrl Removed IO numbers in printk with defines 2024年12月07日 16:45:22 +01:00
04_devicefiles Device Files lesson added 2024年12月07日 14:44:44 +01:00
05_hello_cdev Merge branch 'main' of github.com:Johannes4Linux/Linux_Driver_Tutorial 2025年03月12日 20:19:39 +01:00
06_log_level fixed typo 2025年01月13日 19:40:20 +01:00
07_open_release_cdev Added example for open and close function for cdev 2025年01月28日 21:12:27 +01:00
08_read_write_cdev Added example for read and write cdev 2025年02月10日 20:39:06 +01:00
09_manual_cdev Added example for automatical device file creation 2025年03月27日 10:46:43 +01:00
10_auto_devfile kmalloc & private_data example 2025年05月14日 22:05:00 +02:00
11_kmalloc Replaced sizeof(text) with MEMSIZE 2025年05月14日 22:16:15 +02:00
12_simple_ioctl Added intro to ioctl 2025年08月11日 16:59:46 +02:00
13_ioctl Added ioctl example 2025年08月11日 17:58:43 +02:00
14_device_tree Upload Markdown for Device Tree Explaination 2025年11月13日 11:06:11 +01:00
15_dt_overlay Example for a device tree overlay 2025年11月13日 11:32:24 +01:00
16_dt_dev_driver Added DT Overlay compilation to Makefile 2025年12月29日 14:49:10 +01:00
17_dt_read_property Example for parsing device tree device parameters 2025年12月29日 15:46:40 +01:00
18_dev_logging Added example for device logging 2025年12月30日 13:13:35 +01:00
19_dt_dev_gpios Added example for using GPIOs in a DT Dev Driver 2025年12月30日 14:18:23 +01:00
20_dt_dev_data Added example for device data 2026年01月21日 18:20:06 +01:00
21_miscdev Added miscdev example 2026年01月27日 20:32:40 +01:00
22_platform_misc Example for adding a misc device to the platform device driver 2026年02月04日 20:36:11 +01:00
.gitignore Example for a device tree overlay 2025年11月13日 11:32:24 +01:00
LICENSE Initial commit 2024年10月29日 18:46:56 +01:00
README.md Example for adding a misc device to the platform device driver 2026年02月04日 20:36:11 +01:00

Linux Driver Tutorial

Here you can find examples for simple Linux Kernel Modules and Linux Drivers.

Preparation

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.

Content

In this repo you can find examples for:

  1. Simple Hello World Kernel Module
  2. An improved Hello World Linux Kernel Module
  3. An example for using GPIOs in a driver without device tree
  4. Some info about Device Files, Device Numbers, Block and Character Devices
  5. Create a Character Device in a Driver
  6. Linux Kernel log levels
  7. Implement open and release functions for character devices
  8. Implement read and write functions for character devices
  9. Create a Character Device in a Driver manually
  10. Automatically create a Device File within the driver
  11. Dynamical memory allocation and private data in the struct file
  12. First introduction to ioctl
  13. Implementing ioctl properly
  14. The device tree
  15. Adding a device over the device tree
  16. A Device Tree Device Driver
  17. Parsing parameters of a Device Tree Device Driver
  18. Writing to the kernel's log with device information
  19. Using GPIOs in a Device Tree Device Driver
  20. Allocating and using device data
  21. Miscellaneous devices for easy device files
  22. Adding a misc device to the platform device driver

More Information

For more information about my Linux Driver examples check out my videos and my playlist

Support me

If you want to support me, you can buy me a coffee buymeacoffee.com/johannes4linux.