当前位置:网站首页>LDD 知识整理
LDD 知识整理
2022-06-28 15:51:00 【全栈程序员站长】
大家好,又见面了,我是你们的朋友全栈君。
学习总结:
1、 学习内核自带的文档
昨天阅读了一下内核中的文档:
README
Documentation/HOWTO学到了不少东西。知道了一个网站 http://kernelnewbies.org,一些FAQ , 摘录如下
(1) Code Browsing
a) cscope,tags
原来内核中有生成 cscope和tags的脚本
make cscope
make tags给make加上V=1,可以看到哪些命令被执行。
$ make cscope V=1
/bin/bash linux-2.6.32.63/scripts/tags.sh cscope
.....
+ cscope -b -f cscope.out可以看到调用的是 scripts/tags.sh 这个脚本。
b) find + grep
查找结构体定义
find . -name ‘*.[chS]’ | xargs grep -EnH “\W*struct\W+task_struct\W*{“
查找函数定义
find . -name ‘*.[chS]’ | xargs grep -EnH “cdev_init\W*\(struct cdev”
注: find 命令用来确定查找文件的类型,这里查找 .c .h .S(汇编) 文件。
xargs 比较关键,没有他,无法 正确运行,它将前面命令的输出作为后面命令的参数。(管道是将前面的输出作为后面的输入stdin。)
grep -E 表示使用正则表达式。 \W 代表空白字符, * 表示前面的字符出现0次或多次
c) lxr (很好的网站)
2、 准备好’游戏机’
写好的驱动需要insmod来测试。可以准备一个专门用于学习驱动开发的虚拟机。就当它是你的游戏机吧!
下载fedora 12。用virtual box安装成虚拟机。然后下载你要研究的内核。我下载的是 2.6.32
然后编译安装你的内核。成功后,以此内核为源码树,然后就写驱动,尽情的insmod吧
(原来是在开发板子上验证驱动,不过LDD3的例子不涉及具体硬件的时候,可以用这个虚拟机。不过真正的驱动怎么能不和硬件打交道呢,所以最后一定要为开发板写个驱动,将理论用于实践最重要!)
编译安装内核参考:
http://blog.chinaunix.net/uid-26497520-id-3593098.html
http://lesca.me/archives/config-and-install-kernel.html
http://www.cnblogs.com/parrynee/archive/2010/05/13/1734791.html
下载,解压内核之后。
cd linux-2.6.32
cp /boot/config-`uname -r` ./.config
make menuconfig
make
make modules
sudo make install
sudo make modules_install将虚拟机运行级别变成文本模式: 修改 /etc/inittab文件
id:3:initdefault:使用ssh方式登陆虚拟机。 ssh ip地址。
使用screen来管理回话,很方便。
3、 编写驱动
写过的驱动代码放到github,然后写一个总结页面,把链接放在这里
4、内核源码分析
分许与驱动相关或其他内核源码
copy_to_user and copy_from_user
学习资料:
1、LDD3 book
英文:
中文:
http://oss.org.cn/kernel-book/ldd3/index.html
感谢 作者和开源中国 oss.org.cn
2、代码下载
kernel 2.6.X http://examples.oreilly.com/9780596005900/
kernel 3.x https://github.com/kerneltravel/ldd3-examples-3.x
other: https://github.com/4get/ldd3_examples
发布者:全栈程序员栈长,转载请注明出处:https://javaforall.cn/132879.html原文链接:https://javaforall.cn
边栏推荐
- Sample explanation of batch inserting data using MySQL bulkloader
- Tiktok actual battle ~ list of bloggers I follow, follow and check
- QT create 5.0.3 configuring qt4.8.7
- Big God explains open source buff gain strategy live lecture
- 扎克伯格致投资者:不要对元宇宙有任何期待
- 请问下大家有遇到过这种设置的主健和数据库一致的错误吗?
- 物联网云融合安全指南
- Go zero micro Service Practice Series (VII. How to optimize such a high demand)
- 软件测试员的悲哀竟是...自己的技术能力不能满足大厂要求?
- Fleet | "backstage exploration" issue 3: status management
猜你喜欢

薅羊毛的机会了,点个“赚”即有机会赚取高额佣金

Analysis of PostgreSQL storage structure

In depth learning foundation summary

Why MySQL table connection is faster than subquery
![[Spock] process non ASCII characters in an identifier](/img/ab/d2cd6802d1e2af009da077ae82bdf8.png)
[Spock] process non ASCII characters in an identifier

Technical secrets of ByteDance data platform: implementation and optimization of complex query based on Clickhouse

Lecturer solicitation order | Apache dolphin scheduler meetup sharing guests, looking forward to your topic and voice!

3. caller service call - dapr

What are the most powerful small and medium-sized companies in Beijing?

Cross cluster deployment of helm applications using karmada
随机推荐
大神详解开源 BUFF 增益攻略丨直播讲座
Knowing these commands allows you to master shell's own tools
昨日元宇宙|Meta “元宇宙”部门一季度亏损29.6亿美元,六福珠宝发行数字藏品
RedmiBook Pro 14增强版 打不开台达软件DRAStudio_v1.00.07.52
A bug liver a week I can't help mentioning issue
零钱兑换(动态规划)
Xinchuang operating system -- kylin kylin desktop operating system (project 10 security center)
How can the sports app keep the end-to-side background alive to make the sports record more complete?
【推荐系统】多任务学习之ESMM模型(更新ing)
[leetcode] 13. Roman numeral to integer
【高并发基础】MySQL索引优化
Classic model transformer
VS2013 帮助文档中没有 win32/com
10 years of testing experience, worthless in the face of the physiological age of 35
among us私服搭建
Geoffrey Hinton:我的五十年深度学习生涯与研究心法
Azure Kinect微软摄像头Unity开发小结
In depth learning foundation summary
榜单首发——线控制动「新周期」,本土供应商市场竞争力TOP10
Visual Studio 2010 编绎Qt5.6.3