从0学Linux驱动
嵌入式linux驱动本文主要参考b站up主:一口Linux HELLOWORLD驱动编写程序编写步骤: 确定主设备号 定义自己的 file operations结构体 实现对应的 open/read/write等函数,填入file_operations 结构体 把 file operations结构体告诉内核:注册驱动程序 谁来注册驱动程序啊?得有一个入口函数:安装驱动程序时,就会去调用这个入口函数 有入口函数就应该有出口函数:卸载驱动程序时,就会去调用这个出口函数 其他完善:提供设备信息,自动创建设备节点 设备号:主设备号+次设备号 函数:MKDEV(a,b)可返回设备号,a为主设备号,b为次设备号 rc = alloc_chrdev_region(&devid, 0, 1, "hello"); 用于分配设备号,主设备号由内核动态分配,此设备号由自己设计 ,该代码中次设备号从0开始,共1个设备号,名称为hello。 在ubantu虚拟机中跑驱动程序用echo指令确保架构设置和没有交叉编译,使用 unset ARCH 和 ...
Hello World
Welcome to Hexo! This is your very first post. Check documentation for more info. If you get any problems when using Hexo, you can find the answer in troubleshooting or you can ask me on GitHub. Quick StartCreate a new post1$ hexo new "My New Post" More info: Writing Run server1$ hexo server More info: Server Generate static files1$ hexo generate More info: Generating Deploy to remote sites1$ hexo deploy More info: Deployment
