/********************************************************************** * busybox devmem 直接獲取、修改內存信息 * 說明: * 有時候再進行一些硬件測試的時候為了加快處理速度,可能會希望通過 * shell直接修改內存地址中的信息,devmem內部還是mmap進行地址映射,另外 * 覺得可以直接用outb/inb等函數直接操作。 * * 2018-6-25 深圳 寶安西鄉 曾劍鋒 *********************************************************************/ 一、參考文檔: 1. How to access the i.MX6 unique ID/serial number in Linux https://community.nxp.com/thread/434775 2. Linux驅動開發常用內存調試工具 memtool and devmem https://blog.csdn.net/mike8825/article/details/51505218 二、devmem help [buildroot@root ~/lmbench-3.0-a9/scripts]# devmem --help BusyBox v1.26.2 (2018-06-21 15:47:27 CST) multi-call binary. Usage: devmem ADDRESS [WIDTH [VALUE]] Read/write from physical address ADDRESS Address to act upon WIDTH Width (8/16/...) VALUE Data to be written 三、用i.MX6 SN驗證devmem獲取地址數據正確性: [buildroot@root ~]# cat /sys/fsl_otp/HW_OCOTP_CFG0 0xe6b416f0 [buildroot@root ~]# cat /sys/fsl_otp/HW_OCOTP_CFG1 0x1f2231d4 [buildroot@root ~]# devmem 0x21BC410 32 0xE6B416F0 [buildroot@root ~]# devmem 0x21BC420 32 0x1F2231D4