简体   繁体   中英

Read from any ram address directly?

Im doing some debugging on hardware with a Linux OS.

Now there no way for me to know if any of it works unless I can check the allocated ram that I asked it to write to.

Is there some way that I can check what is in that block or RAM from an external program running in the same OS?

If I could write a little program in C to do that how will I go about it since I cant just go and assign pointers custom addresses ?

Thanks

I think the best way to do what you are asking for is to use a debugger. And you cannot read another programme's memory unless you execute your code in a privileged space (ie the kernel), and privileged from the point of view of the CPU. And this because each programme is running in its own virtual memory space (for security concerns) and even the kernel is running in a virtual memory space but it has the privilege to map any physical memory block inside the virtual memory space it is current running. Anyway, I will not explain more in depth how an modern OS manage memory with the underneath hardware, it would be long.

You should really look at using a debugger. Once you environment with your debugger is ready, you should put a break after that memory block allocation so the debugger will stop the programme there and so you can inspect that freshly allocated memory block as you wish. Depending on whether you use an IDE or not, it can be very easy to use a debugger ;)

/dev/mem could come to use. It is a device file that is an image of the physical memory (including non-RAM memory). It's generally used to read/write memory of peripheral devices. By mmap() ing to it, you could access physical memory.

See this linux documentation project page

memedit is a handy utility to display and change memory content for testing purposes. It's main purpose is to display SoC hardware registers but it could be used to display RAM. It is based on mmap() mechanism. It could be good starting point to write custom application.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM