当前位置:网站首页>[21-day learning challenge - kernel notes] (5) - devmem read and write register debugging
[21-day learning challenge - kernel notes] (5) - devmem read and write register debugging
2022-08-11 00:02:00 【light chases rain】
活动地址:CSDN21天学习挑战赛
学习的最大理由是想摆脱平庸,早一天就多一份人生的精彩;迟一天就多一天平庸的困扰.各位小伙伴,如果您:
想系统/深入学习某技术知识点…
一个人摸索学习很难坚持,想组团高效学习…
想写博客但无从下手,急需写作干货注入能量…
热爱写作,愿意让自己成为更好的人…
一、用途介绍
读写socthe value of the associated register,就是应用程序通过mmap函数对/dev/mem驱动中的mmap方法的使用,映射了设备的内存到用户空间,实现对这些物理地址的读写操作
二、配置
内核中对devmem的支持,进行如下配置
读取socthe value of the associated register,The value of some registers cannot be read,So an error occurs when reading
Symbol: DEVMEM [=y] │
│ Type : bool │
│ Prompt: /dev/mem virtual device support │
│ Location: │
│ -> Device Drivers │
│ (1) -> Character devices │
│ Defined at drivers/char/Kconfig:10
备注: The kernel configures this option:CONFIG_DEVMEM=y,Verify that the configuration is successful or not will be generated/dev/mem节点
busybox中对devmem的支持,进行如下配置:
Symbol: DEVMEM [=y] │
│ Prompt: devmem (2.5 kb) │
│ Defined at miscutils/Config.in:326 │
│ Location: │
│ -> Miscellaneous Utilities
备注: busyboxconfigure this optionCONFIG_DEVMEM=y,Verifying that the configuration was successful generates the applicationdevmem
三、读和写
读取:在地址0x97000000读取32bit值(WIDTH默认等于32, 可选值为[8, 16, 32, 64])
/dev # devmem 0x97000000
0x11111111
读取:在地址0x97000000读取16bit值
/dev # devmem 0x97000000 16
0x1111
写入:在地址0x97000000写入32bit值0x7777ABCD
/dev # devmem 0x97000000 32 0x7777ABCD
/dev # devmem 0x97000000
0x7777ABCD
注意:如果/dev下没有mem这个node,会出现错误:
/dev # devmem 0x97000000
devmem: can’t open ‘/dev/mem’: No such file or directory
这时可以在Host系统中手动创建一个(例如在NFS root filesystem模式):
[email protected]:~/embedded/tftpboot/nfsroot/dev$ sudo mknod mem -m666 c 1 1
注意这里的权限是666,允许任何人任意读写,可以很好的配合程序debug.
devmem的使用方式
语法: devmem ADDRESS [WIDTH [VALUE]]
●ADDRESS :The address to read and write directly
●WIDTH :Specifies the number of bits to read and write data(8/16/32...
●VALUE :data to write
读
●读32位: devmem 0x98000000
●读16位: devmem 0x98000000 16
●读8位: devmem 0x98000000 8
写
●写32位: devmem 0x98000000 32 0x12345678
●写16位: devmem 0x98000000 16 0x1234
●写8位: devmem 0x98000000 8 0x12
参考文章:
RK3399平台开发系列讲解(内核调试篇)2.6、devmem直接读写寄存器进行调试
Two small tools useful for driver debugging(devmem2、devkmem)
devmemRead and write physical memory and devkmemRead kernel virtual memory
边栏推荐
- [数据可视化] 图表设计原则
- Excel English automatic translation into Chinese tutorial
- 鲜花线上销售管理系统的设计与实现
- 【C语言】初识指针
- sqlmap combined with dnslog fast injection
- Why do programming languages have the concept of variable types?
- 【C语言】二分查找(折半查找)
- Three-column layout implementation
- 16. File upload
- Starting a new journey - Mr. Maple Leaf's first blog
猜你喜欢
Based on the SSM to reach the phone sales mall system
深度学习 Transformer架构解析
基于Web的疫情隔离区订餐系统
Excel English automatic translation into Chinese tutorial
[Excel knowledge and skills] Convert numeric format numbers to text format
【C语言】C语言程序设计:动态通讯录(顺序表实现)
13. Content Negotiation
Qt入门(六)——抽奖系统的实现
7. yaml
宝塔实测-搭建PHP在线模拟考试系统
随机推荐
Design and implementation of flower online sales management system
电脑桌面删除的文件回收站没有,电脑上桌面删除文件在回收站找不到怎么办
excel英文自动翻译成中文教程
15. 拦截器-HandlerInterceptor
基于SSM实现手机销售商城系统
有哪些可以投稿软件工程/系统软件/程序设计语言类外文期刊、会议?
sqlmap结合dnslog快速注入
UOJ#749-[UNR #6]稳健型选手【贪心,分治,主席树】
15. Interceptor - HandlerInterceptor
编程语言为什么有变量类型这个概念?
PMP每日一练 | 考试不迷路-8.10(包含敏捷+多选)
闭包详解,柯里化的含义及操作方法
SQL注入基础
Server Tips
翻译软件哪个准确度高【免费】
Promise in detail
[C language] First understanding of pointers
web 性能提升(将持续更新……)
推进牛仔服装的高质量发展
鲲鹏编译调试及原生开发工具基础知识