Compile the driver code and mount steps

Put the written code in the drivers/char/ directory

cp pin4driver2.c /drivers/char/ .

Modify the Makefile

obj-m    pin4driver2.o

Compile the .ko file

ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- KERNEL=kernel7 make modules

Copy the generated ko file to the Raspberry Pi

scp drivers/char/pin4driver2.ko pi@192.168.1.72:/home/pi

Cross compile

arm-linux-gnueabihf-gcc pin4text.c -o pin4text

Copy cross-compiled files to Raspberry Pi

scp pin4text pi@192.168.1.72:/home/pi

Load kernel driver instructions

sudo insmod pin4driver2.ko

Check if pin4 file is generated

ls /dev/pin4

Modify file permissions so that everyone can access the file

sudo chmod 666 /dev/pin4

Show message

Dmesg

View the latest mount

md5sum pin4driver2.ko 

View mount

lsmod 

Guess you like

Origin blog.csdn.net/hhltaishuai/article/details/107463310