Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Read a specific memory address via /dev/mem from the command line

For context, programming a driver to interact with an FPGA IP core on an embedded Linux (Yocto: krogoth) on a Xilinx board.

For debugging purposes I would like to read out specific memory addresses from physical memory. /dev/mem looks promising. I wanted to ask how I can read out the value of a specific physical memory address from the command line. I was hoping for something along the lines of cat /dev/mem 0x2000000 to read the byte at 0x2000000.

like image 836
Moritz Avatar asked Dec 08 '17 13:12

Moritz


2 Answers

Usually you should already have devmem tool installed in your Linux image:

$ devmem 0x2000000

If you don't however, you can go to Busybox menu and tweak it to make sure it gets compiled and installed:

$ bitbake busybox -c menuconfig

(search for devmem)

like image 122
J. In Avatar answered Sep 20 '22 14:09

J. In


Hexdump is often installed in embedded systems. Then you can do

hexdump -C --skip 0x2000000 /dev/mem | head

in order to read more than a single word, and see it decoded in various ways. (The busybox hexdump is a little more limited, but still very useful.)

like image 22
Popup Avatar answered Sep 22 '22 14:09

Popup