当前位置:网站首页>[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
边栏推荐
- “蔚来杯“2022牛客暑期多校训练营2 DGHJKL题解
- 9. Rest style request processing
- [Data Visualization] Chart Design Principles
- u盘数据不小心删除怎么恢复,u盘数据删除如何恢复
- How to recover deleted files from the recycle bin, two methods of recovering files from the recycle bin
- Why do programming languages have the concept of variable types?
- 【C语言】猜数字游戏的实现
- 从0开始设计JVM ,忘记名词跟上思路一次搞懂
- 地下管廊可视化管理系统搭建
- 如何判断一个数为多少进制?
猜你喜欢
随机推荐
oai 采样频率计算
Qt入门(六)——抽奖系统的实现
9. Rest style request processing
8. WEB 开发-静态资源访问
镜头之滤光片---关于日夜两用双通滤光片
2. Dependency management and automatic configuration
13. Content Negotiation
多语种翻译-多语种翻译软件免费
基于Web的疫情隔离区订餐系统
Design and implementation of flower online sales management system
What is the ASIO4ALL
[21天学习挑战赛——内核笔记](五)——devmem读写寄存器调试
CF1427F-Boring Card Game【贪心】
三栏布局实现
图片懒加载(纯手写)
App的回归测试,有什么高效的测试方法?
【C语言】初识指针
C语言%(%d,%c...)
[Excel知识技能] 将数值格式数字转换为文本格式
iNFTnews | In the Web3 era, users will have data autonomy









