当前位置:网站首页>2. GPIO control summary (kernel driver) of nanopi M1 (Quanzhi H3)
2. GPIO control summary (kernel driver) of nanopi M1 (Quanzhi H3)
2022-04-23 22:03:00 【July meteor】
development environment :VM+Ubuntu
Compile environment :linux3.4
Cross compiler tool :arm-linux-gcc 4.4.3
GPIO Kernel driver link :https://download.csdn.net/download/ddffyhg/11022291
User application links :https://download.csdn.net/download/ddffyhg/11022286
Be careful : Development board linux Version and pc End Ubuntu Versions of can be inconsistent , But it has to do with compiler driven linux The kernel version is consistent
Development board :linux 3.4
pc Client downloaded linux kernel :/home/linux/Documents/lichee/linux3.4
1. The physical connections are as follows :
The hardware platform uses nanopi-m1,GPIO The physical pin corresponding to the output pin is pin7
LED The positive pole of the lamp ---------->PIN7(linux 213 Pin )
LED Lamp negative pole ---------->GND
2. stay PC End lichee/linux3.4/drivers/char/ Place under directory gpio The driver file for gpio.c
3. modify Makefile file , Add at the end of the file
obj-m += gpio.o
4. stay lichee Recompile the kernel under the directory
./build.sh -p sun8iw7p1 -b nanopi-h3 -m kernel
After successful compilation , stay lichee/linux3.4/drivers/char/ The directory will generate gpio.ko file
5. take gpio.ko Copy files to development board
gpio.ko The file is the compiled driver file ,app.c The file is the corresponding user application .
6. Mount the kernel module :
insmod gpio.ko
View the list of kernel modules :
lsmod
Check whether there is a device node :
ls /dev/gpio*
Compiling the application :
gcc -o app app.c
Execute the application :
./app
Running results :
Because I don't have LED The lamp , Use the power indicator of the sensor instead :
Uninstall the kernel module :
rmmod gpio
Realization GPIO Control function of kernel driver module .
版权声明
本文为[July meteor]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204200609125613.html
边栏推荐
猜你喜欢
通过OpenFeign传递对象类型参数
Common implementation schemes of delay message
Ali has another "against the sky" container framework! This kubernetes advanced manual is too complete
[leetcode refers to offer 52. The first common node of two linked lists (simple)]
开发consul 客户端即微服务
leetcode 2223 — 构造字符串的总得分和
Tear the Google SRE book by hand
阿里又一个“逆天”容器框架!这本Kubernetes进阶手册简直太全了
手撕《Google SRE Book》
[※ leetcode refers to offer 46. Translate numbers into strings (medium)]
随机推荐
Resolve the "chromedriver executable needs to be in path" error
Pipes and xargs
Devops and cloud computing
Ensuring the quality of living materials and food safety in Shanghai
How Axure installs a catalog
static关键字及应用
Common scenes of vector product in image
Detectron2 usage model
[leetcode refers to the maximum profit of offer 63. Stock (medium)]
[leetcode refers to offer 32 - III. print binary tree III from top to bottom (medium)]
Detectron2 using custom datasets
openfeign集成Hystrix的备选方案处理
[leetcode refers to offer 52. The first common node of two linked lists (simple)]
Common implementation schemes of delay message
微服务系统中服务降级
ERP function_ Financial management_ The difference between red and blue words in invoices
This paper solves the cross domain problem of browser
Pyuninstaller package exe cannot find the source code when running, function error oserror: could not get source code
Hystrix组件
Database Experiment 7 stored procedure experiment