Thread (44 messages) 44 messages, 12 authors, 2009-11-01

Re: Accessing flash directly from User Space

From: Josh Boyer <hidden>
Date: 2009-10-28 11:24:38

On Tue, Oct 27, 2009 at 04:24:53PM -0600, Jonathan Haws wrote:
quoted
quoted
quoted
quoted
How can I get that pointer?  Unfortunately I cannot simply use
the
quoted
quoted
quoted
address of the flash.  Is there some magical function call that
gives me access to that portion of the memory space?

$ man 2 mmap

You want MAP_SHARED and O_SYNC.

To use that I need to have a file descriptor to a device, do I
not?  However, I do not have a base flash driver to give me that
file descriptor.  Am I missing something with that call?
quoted
/dev/mem
Okay, I now have access to the flash memory, however when I write to it the writes do not take.  I have tried calling msync() on the mapping to no avail.  I have opened the fd with O_SYNC, but cannot get things to work right.

Here are the calls:

int fd = open("/dev/mem", O_SYNC | O_RDWR);
uint16_t * flash = (uint16_t *)mmap(NULL, NOR_FLASH_SIZE,
		(PROT_READ | PROT_WRITE), MAP_PRIVATE, fd,
		NOR_FLASH_BASE_ADRS);
What board and CPU are you using?  Is your flash really at 0xFC800000, or is
that the virtual address that VxWorks puts it at?

josh
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help