
Linux驱动笔记
go and see
wangdachui_ooi
这个作者很懒,什么都没留下…
展开
-
CH348驱动移植至Linux系统中
CH348实现linux 嵌入式端移植原创 2024-02-18 20:59:07 · 1371 阅读 · 1 评论 -
00-uboot下的调试
打断uboot启动后1、print/printenv: 打印当前uboot的环境变量print 环境变量名2、set/setenv: 新建/修改环境变量set 环境变量名 环境变量值3、save/saveenv:保存环境变量到emmcsave4、推出uboot继续加载boot5、常用的环境变量环境变量:bootdelay :启动后加载内核的延时时间bootcmd : 加载内核命令 bootcmd=ext4load mmc 2:1 0x48000000 uImage;b原创 2022-01-13 22:16:50 · 561 阅读 · 0 评论 -
07-platform_probe
1、platform_driver 函数中probe函数struct platform_driver { int (*probe)(struct platform_device *); int (*remove)(struct platform_device *); void (*shutdown)(struct platform_device *); int (*suspend)(struct platform_device *, pm_message_t state); int (*resu原创 2022-01-09 23:09:06 · 290 阅读 · 0 评论 -
06-platform_driver
接着05-platform_device的内容1、申请 platform_driver 结构体struct platform_driver { int (*probe)(struct platform_device *); // driver 和 device 匹配成功时执行 int (*remove)(struct platform_device *); //driver 和 device 任意一个 remove 时执行 void (*shutdown)(struct platform_dev原创 2022-01-09 21:33:31 · 340 阅读 · 0 评论 -
03-字符设备驱动开发流程总结
字符设备驱动开发流程总结原创 2022-01-09 18:44:13 · 223 阅读 · 0 评论 -
05-platform_device
1、platform平台总线模型就是把原来的驱动 C 文件给分成了两个, 一个是 device.c, 一个是 driver.c 。把稳定不变的放在 driver.c 里面, 需要变得就放在了 device.c 里面。平台总线模型将设备代码和驱动代码分离, 将和硬件设备相关的都放到 device.c 文件里面,驱动部分代码都放到 driver.c 文件里面。2、platform_device1)申请platform_device 结构体struct platform_device { const c原创 2022-01-09 18:41:01 · 673 阅读 · 0 评论 -
04-file_operations
file_operations填充1、open、read、write、release 参考ssize_t miscread (struct file *file, char __user *buf, size_t size, loff_t *loff){ printk("enter miscread success \n"); return 0;}ssize_t miscwrite (struct file *file, const char __user *buf, size_t size原创 2022-01-09 00:47:19 · 135 阅读 · 0 评论 -
03-杂项设备驱动框架
03-杂项设备驱动框架所有的 misc 设备驱动的主设备号都为 10, 不同的设备使用不同的从设备号。 主设设备号相同就可以节省内核的资源。需要的头文件如下:/*注册杂项设备头文件*/#include <linux/miscdevice.h>/*注册设备节点的文件结构体*/#include <linux/fs.h>主设备号查询:cat /proc/devices1、填充 miscdevice 结构体misc 设备用 miscdevice 结构体表示, misc原创 2022-01-08 23:04:07 · 515 阅读 · 0 评论 -
02-Linux驱动开发框架
Linux驱动开发框架1、驱动分为四个部分1)头文件#include <linux/init.h> //包含宏定义的头文件#include <linux/module.h> //包含初始化加载模块的头文件2)驱动模块的入口函数和出口函数module_init(入口函数名);module_exit(出口函数名);3)声明信息MODULE_LICENSE("GPL");4)函数的功能实现//入口函数static int hello_init(void){原创 2022-01-08 21:40:58 · 555 阅读 · 0 评论 -
01-Linux驱动开发环境配置
环境配置1、交叉编译器环境变量配置1)打开编辑.bashrc文档vi ~/.bashrc2)在末尾输入如下:export PATH=$PATH:/root/workspace/allwinner/A40i/bsp/lichee/out/sun8iw11p1/linux/common/buildroot/host/opt/ext-toolchain/bin/其中“/root/workspace/allwinner/A40i/bsp/lichee/out/sun8iw11p1/linux/com原创 2022-01-06 00:23:58 · 861 阅读 · 0 评论 -
C语言动态内存分配
动态分配内存存储区基本分类静态存储区:全局变量,静态局部变量(程序进程或线程结束后释放)动态存储区:栈:非静态局部变量(出局部变量作用域就被释放)堆:用户自行决定何时释放,用free进行操作,若不释放,则一直使用至程序结束;动态分配内存的库函数在动态分分配内存开始,需要引入如下库函数#include <stdlib.h>在 C 库函数 void *malloc(size_t size) 分配所需的内存空间,并返回一个指向它的指针。size – 内存块的大小,以字节为单位。原创 2021-10-06 16:13:31 · 102 阅读 · 0 评论