RE: Accessing flash directly from User Space [SOLVED]
From: Jonathan Haws <hidden>
Date: 2009-10-28 21:59:26
quoted
On Tue, Oct 27, 2009 at 04:24:53PM -0600, Jonathan Haws wrote:quoted
quoted
quoted
quoted
quoted
How can I get that pointer? Unfortunately I cannot simplyusequoted
quoted
thequoted
quoted
quoted
address of the flash. Is there some magical function callthatquoted
quoted
quoted
quoted
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, doIquoted
quoted
quoted
not? However, I do not have a base flash driver to give methatquoted
quoted
quoted
file descriptor. Am I missing something with that call?quoted
/dev/memOkay, I now have access to the flash memory, however when I writeto 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.quoted
Here are the calls: int fd =3D open("/dev/mem", O_SYNC | O_RDWR); uint16_t * flash =3D (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?=20 I am using a custom board based on the AMCC Kilauea development board. It uses a 405EX CPU. Yes, the flash is really at 0xFC000000.
I have found the problem. It occurred to me in the shower (okay not really= , but most good ideas happen there). What was happening is that I was in fact able to write to the correct regis= ters. However, I would try and write to them in a batch. But the way mmap= works (at least according to the man page) with MAP_SHARED is that the fil= e may not be updated until msync() is called. Now, I thought that O_SYNC w= ould take care of that when I open /dev/mem, but that was not the case. Anyway, to make a long story short, I inserted an msync() after each assign= ment to the flash. This resolved my problem and I can now program my flash= . Thanks everyone for your help! Jonathan