Hi Ran,
What I did for using the internal RAM fro userspace, is to use the 'mmap' function:
/*!
\brief Function to get a mapped to pointer to a specific address area
in memory. The address should be 4K (blocksize) aligned
\param address The 4K aligned physical address to map to
\param size The size in bytes to be mapped
\return The pointer to the mapped memory, NULL if mapping fails
*/
void * NonVolStorage::MapMemory(uint32_t address, size_t size)
{
int fd;
void *ret_addr;
fd = open("/dev/mem", O_RDWR | O_SYNC);
if (fd == -1) {
perror("open");
return NULL;
}
ret_addr = mmap(0, size, PROT_READ | PROT_WRITE, MAP_SHARED, fd, address);
if (ret_addr == MAP_FAILED) {
perror("mmap");
ret_addr = NULL;
}
if (close(fd) == -1) {
perror("close");
}
return ret_addr;
}
I call this function with the below defined address and size:
#define NV_RAM_ADDRESS 0x1B000
#define NV_RAM_SIZE 4096
I did not add an mmio-sram part to the device-tree.
Hope this helps. Regards,
Ruud