A simple example of how to create a Linux device driver and load it on the Raspberry Pi 3.
-
Kernel headers
sudo apt install raspberrypi-kernel-headers
-
Current kernel
build
directory must exists:$ ls /lib/modules/$(uname -r)/build Documentation Module.symvers certs fs ipc mm scripts tools Kconfig arch crypto include kernel net security usr Makefile block drivers init lib samples sound virt
To build
$ make
To clean build
$ make clean
sudo insmod driver-example.ko
$ dmesg
[ 132.515291] driver_example: loading out-of-tree module taints kernel.
[ 132.515774] Init function