Reputation: 117
Suppose for an embedded program, the hardware is designed such a way that it performs certain operation if the memory address 0x8729 is filled with 0xff. Is there a way to access the memory address 0x8729 and write to it?
Upvotes: 0
Views: 587
Reputation: 256
I'd say that without more information about the specific Linux implementation we won't know if this is a problem with a "tiny" Linux implementation that doesn't support memory virtualization for userspace apps or if this is the normal behavior of a "standard" Linux implementation that does virtualize physical memory addresses from userspace.
I am inclined to believe this is userspace a virtualization issue, in which case you could use the techniques mentioned with this posting. It describes how to use devmem
to access physical memory from the command line, and how to use the device file handle /dev/mem
and memmap
from within a C program.
Upvotes: 1
Reputation: 57678
Try this:
uint8_t * p_memory = (uint8_t *) 0x8729;
const uint8_t value_from_memory = *p_memory;
*p_memory = 0xff; // Writing to memory.
You may not need the cast, but I put it there anyway.
Explanation:
uint8_t
pointer and assign to your memory address.Upvotes: 1