linux设备树软中断,cpu_code

Linux_driver

@Author: cpu_code

@Date: 2020-07-08 21:13:40

@LastEditTime: 2020-07-08 21:15:27

@FilePath: \Linux_driver\README.md

介绍

Linux驱动开发

文件说明

kdev_t.h

of_fdt.h

types.h

uaccess.h

delay.h

jiffies.h

mutex.h

rwlock_types.h

rwlock.h

semaphore.h

seqlock.h

spinlock_types.h

spinlock.h

timer.h

interrupt.h:中断操作、tasklet

irqflags.h 中断操作

irqreturn.h:中断类型

workqueue.h: 工作

irqdomain.h:

poll.h:非堵塞

wait.h: 等待队列头

mod_devicetable.h: compatible比较

platform_device.h: platform 设备

miscdevice.h: MISC 设备

input.h: input设备

i2c.h: iic传输函数接口

bitops:

atomic.h

gpio.h

atomic-instrumented.h

atomic.h

param.h

current.h: 当前进程

linux:

input-event-codes.h: 可选的事件类型

major.h: input 子系统的所有设备主设备号都为 13

input.h: 表示所有的输入事件

time.h: 时间

i2c.h: 处理初始信息

arm:

boot\dts: 设备树

imx6ull.dtsi

inmx6ull-colibri.dtsi

Makefile

imx6ul.dtsi:中断设备

imx6ull-colibri-eval-v3.dtsi: 中断设备

include: 头文件

include/asm:

mach:

arch.h

gpio.h:中断

atomic.h

delay.h

mach-imx:

mach-imx6ul.c

mach-armadillo5x0.c:

kernel:

setup.c

devtrre.c

drivers\of:

fdt.c

softirq.c: 软中断

workqueue_internal.h: 工作线程

workqueue.c: 工作队列

irq:

manage.c: 释放掉相应的中断

sched:

wait.c: 等待队列项添加

/of:

irq.c: 设备号

Documentation\devicetree\bindings: 绑定文档,设备树是用来描述板子上的设备信息的,不同的设备其信息不同,反映到设备树中就是属性不同

\dtc: dtc工具

Makefile

使用说明

初次编译

xxx.dts 是设备树源码文件,编译 Linux 的时候会将其编译为xxx.dtb 文件

设备树:arch/arm/boot/dts/Makefile , 找 到 “ dtb-$(CONFIG_SOC_XXX) ”配置项( 什么芯片就放在那个配置项 ),在此配置项中加入“xxx.dtb”

设备树编写完成以后使用命令重新编译设备树

make dtbs

使用编译出来的 xxx.dtb 文件启动 Linux 系统

程序编译:

输入如下命令编译出驱动模块文件:

make

编译成功以后就会生成一个名为“xxx.ko”的驱动模块文件

输入如下命令编译测试 xxxAPP.c 这个测试程序

arm-linux-gnueabihf-gcc xxxAPP.c -o xxxApp

编译成功以后就会生成 xxxApp 这个应用程序

输入如下命令查看xxxAPP 这个程序的文件信息

file xxxApp

编译出来的 xxx.ko 和 xxxApp 这两个文件拷贝到 指定 目录中

sudo cpxxx.ko xxxApp /home/xxx -f

重启开发板,进入到指定的目录

cd /home/xxx

第一次加载驱动的时候需要运行此命令

depmod

驱动加载成功以后创建“/dev/xxx”设备节点

使用 modprobe 加载 xxx.ko

modprobe xxx.ko

输入“ lsmod ”命令即可查看当前系统中存在的模块

lsmod

创建设备节点文件

mknod /dev/xxx 字符设备 主设备号 次设备号

设备操作测试

./xxxApp /dev/xxx 参数

卸载驱动模块

rmmod xxx.ko

错误

注意 file_operations 是否在这些函数下面

make -C /home/cpucode/cpucodefile/linux-5.5.7/linux-5.5.7 M=/home/cpucode/cpucodefile/drivers/led modules

make[1]: Entering directory '/home/cpucode/cpucodefile/linux-5.5.7/linux-5.5.7'

CC [M] /home/cpucode/cpucodefile/drivers/led/led.o

/home/cpucode/cpucodefile/drivers/led/led.c:44:10: error: ‘led_open’ undeclared here (not ina function); did you mean ‘seq_open’?

.open = led_open,

^~~~~~~~

seq_open

/home/cpucode/cpucodefile/drivers/led/led.c:45:10: error: ‘led_read’ undeclared here (not ina function); did you mean ‘seq_read’?

.read = led_read,

^~~~~~~~

seq_read

/home/cpucode/cpucodefile/drivers/led/led.c:46:11: error: ‘led_write’ undeclared here (not ina function); did you mean ‘seq_write’?

.write = led_write,

^~~~~~~~~

seq_write

/home/cpucode/cpucodefile/drivers/led/led.c:47:14: error: ‘led_release’ undeclared here (not ina function); did you mean ‘seq_release’?

.release = led_release,

^~~~~~~~~~~

seq_release

/home/cpucode/cpucodefile/drivers/led/led.c:181:12: warning: ‘led_release’ defined but not used [-Wunused-function]

static int led_release(struct inode *inode, struct file *filp)

^~~~~~~~~~~

/home/cpucode/cpucodefile/drivers/led/led.c:145:16: warning: ‘led_write’ defined but not used [-Wunused-function]

static ssize_t led_write(struct file *filp, const char __user *buf, size_t cnt, loff_t *offt)

^~~~~~~~~

/home/cpucode/cpucodefile/drivers/led/led.c:127:16: warning: ‘led_read’ defined but not used [-Wunused-function]

static ssize_t led_read(struct file *filp, char __user *buf, size_t cnt, loff_t *offt)

^~~~~~~~

/home/cpucode/cpucodefile/drivers/led/led.c:109:12: warning: ‘led_open’ defined but not used [-Wunused-function]

static int led_open(struct inode *inode, struct file *filp)

^~~~~~~~

scripts/Makefile.build:265: recipe fortarget '/home/cpucode/cpucodefile/drivers/led/led.o' failed

make[2]: *** [/home/cpucode/cpucodefile/drivers/led/led.o] Error 1

Makefile:1694: recipe fortarget '/home/cpucode/cpucodefile/drivers/led' failed

make[1]: *** [/home/cpucode/cpucodefile/drivers/led] Error 2

make[1]: Leaving directory '/home/cpucode/cpucodefile/linux-5.5.7/linux-5.5.7'

Makefile:19: recipe fortarget 'kernel_modules' failed

make: *** [kernel_modules] Error 2

make -C /home/cpucode/cpucodefile/linux-4.1.15/linux-imx-rel_imx_4.1.15_2.1.0_ga M=/home/cpucode/cpucodefile/drivers/led modules

make[1]: Entering directory '/home/cpucode/cpucodefile/linux-4.1.15/linux-imx-rel_imx_4.1.15_2.1.0_ga'

CC [M] /home/cpucode/cpucodefile/drivers/led/led.o

cc1: error: code model kernel does not support PIC mode

scripts/Makefile.build:264: recipe fortarget '/home/cpucode/cpucodefile/drivers/led/led.o' failed

make[2]: *** [/home/cpucode/cpucodefile/drivers/led/led.o] Error 1

Makefile:1384: recipe fortarget '_module_/home/cpucode/cpucodefile/drivers/led' failed

make[1]: *** [_module_/home/cpucode/cpucodefile/drivers/led] Error 2

make[1]: Leaving directory '/home/cpucode/cpucodefile/linux-4.1.15/linux-imx-rel_imx_4.1.15_2.1.0_ga'

Makefile:19: recipe fortarget 'kernel_modules' failed

make: *** [kernel_modules] Error 2

make -C /home/cpucode/cpucodefile/linux-5.5.7/linux-5.5.7 M=/home/cpucode/cpucodefile/drivers/led modules

make[1]: Entering directory '/home/cpucode/cpucodefile/linux-5.5.7/linux-5.5.7'

CC [M] /home/cpucode/cpucodefile/drivers/led/led.o

In file included from ./include/linux/types.h:6:0,

from /home/cpucode/cpucodefile/drivers/led/led.c:9:

./include/uapi/linux/types.h:5:10: fatal error: asm/types.h: No such file or directory

#include

^~~~~~~~~~~~~

compilation terminated.

scripts/Makefile.build:265: recipe fortarget '/home/cpucode/cpucodefile/drivers/led/led.o' failed

make[2]: *** [/home/cpucode/cpucodefile/drivers/led/led.o] Error 1

Makefile:1693: recipe fortarget '/home/cpucode/cpucodefile/drivers/led' failed

make[1]: *** [/home/cpucode/cpucodefile/drivers/led] Error 2

make[1]: Leaving directory '/home/cpucode/cpucodefile/linux-5.5.7/linux-5.5.7'

Makefile:19: recipe fortarget 'kernel_modules' failed

make: *** [kernel_modules] Error 2

make -C /home/cpucode/cpucodefile/linux-5.5.7 M=/home/cpucode/cpucodefile/drivers/led modules

make[1]: Entering directory '/home/cpucode/cpucodefile/linux-5.5.7'

make[1]: *** No rule to make target 'modules'. Stop.

make[1]: Leaving directory '/home/cpucode/cpucodefile/linux-5.5.7'

Makefile:19: recipe fortarget 'kernel_modules' failed

make: *** [kernel_modules] Error 2

make -C /home/cpucode/linux-5.5.7 M=/home/cpucode/cpucodefile/drivers/led modules

make[1]: *** /home/cpucode/linux-5.5.7: No such file or directory. Stop.

Makefile:19: recipe fortarget 'kernel_modules' failed

make: *** [kernel_modules] Error 2

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值