Accessing flash directly from User Space
Jonathan Haws
Jonathan.Haws at sdl.usu.edu
Wed Oct 28 06:59:31 EST 2009
I know this is probably a really dumb question, but a wise man once said that the only stupid question is the one that is not asked.
So, I have written a flash driver in VxWorks that simply addresses the flash directly and handles all the hardware accesses just fine. I am porting that to Linux and need it to run in user space (mainly to simplify the interface with the user - I want to keep it the same as in VxWorks). Here is a snippet of what my question is:
static uint8_t bflashEraseSector(int sa, int verbose)
{
uint16_t * flash = (uint16_t *) NOR_FLASH_BASE_ADRS;
uint32_t offset;
...
/* We divide by 2 here to adjust for the 16-bit offset into the address */
offset = sa * NOR_FLASH_SECTOR_SIZE / 2;
flash[BFLASH_SECTOR_ERASE_ADDR1] = BFLASH_SECTOR_ERASE_BYTE1;
...
}
I am trying to get a pointer to NOR_FLASH_BASE_ADRS which is defined to be 0xFC000000. I then dereference that directly to write to the flash.
How can I get that pointer? Unfortunately I cannot simply use the address of the flash. Is there some magical function call that gives me access to that portion of the memory space?
Thanks for the help!
Jonathan
PS - I know that I could simply use the MTD driver provided by the kernel, but I need to be able to keep the interface the same so we can use previously written code.
More information about the Linuxppc-dev
mailing list