当前位置:网站首页>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
边栏推荐
猜你喜欢

In depth learning foundation summary

leetcode:22. bracket-generating

Open source technology exchange - Introduction to Chengying, a one-stop fully automated operation and maintenance manager

Visual Studio 2019软件安装包和安装教程

征文投稿丨使用轻量应用服务器搭建博客环境

Opengauss kernel: analysis of SQL parsing process

10 years of testing experience, worthless in the face of the physiological age of 35

平台即代码的未来是Kubernetes扩展

【MySQL】表连接为什么比子查询快
![[MySQL] official website document learning query statement SQL precautions](/img/aa/bf27b609e2fda1edaa46f134fc5626.png)
[MySQL] official website document learning query statement SQL precautions
随机推荐
leetcode:22. bracket-generating
Introduction to deep learning in machine learning
VC2010 编绎Qt5.6.3 提示 CVTRES : fatal error CVT1107:
How can the sports app keep the end-to-side background alive to make the sports record more complete?
What is the difference between treasury bonds and time deposits
Ffmpeg forbidden output banner log (30)
Cross cluster deployment of helm applications using karmada
昨日元宇宙| 沃尔玛成立探索元宇宙和Web3的创新部门,Dior发布元宇宙展览
Go zero micro Service Practice Series (VII. How to optimize such a high demand)
What is the maximum number of concurrent TCP connections for a server? 65535?
大神详解开源 BUFF 增益攻略丨直播讲座
NFT质押LP流动性挖矿系统开发详情
Deep learning convolutional neural network of machine learning to realize handwritten font recognition based on CNN network
In depth learning foundation summary
请问下大家有遇到过这种设置的主健和数据库一致的错误吗?
OpenHarmony—内核对象事件之源码详解
10年测试经验,在35岁的生理年龄面前,一文不值
wallys/DR7915-wifi6-MT7915-MT7975-2T2R-support-OpenWRT-802.11AX-supporting-MiniPCIe-Module
No win32/com in vs2013 help document
QT create 5.0.3 configuring qt4.8.7