Author Topic: User space on External Flash  (Read 2358 times)

Tepa76

  • Jr. Member
  • **
  • Posts: 7
    • View Profile
User space on External Flash
« on: May 31, 2013, 10:46:10 PM »
Hello,
Now i need to take in use the user space for storing the data.

I see at spiFlashWinbond.c contains the functions for accessing the flash!?
Before i start to messing with code can somebody little bit explain what things is have to take a care!
 
My target is to store the config string on the flash witch is given though the web page.  example (abc123)
After that... board sends that config string over the uart every time on the boot.

thanks,
Tepa76

netcruze

  • Jr. Member
  • **
  • Posts: 63
    • View Profile
Re: User space on External Flash
« Reply #1 on: August 01, 2013, 07:03:57 PM »
The system uses the beginning of the external FLASH. User applications should use the back. Also, the external FLASH has a sector (smallest area that can be erased) size of 4096. So, use blocks of 4096 at the back of the external FLASH.

Tepa76

  • Jr. Member
  • **
  • Posts: 7
    • View Profile
Re: User space on External Flash
« Reply #2 on: September 13, 2013, 05:37:31 AM »
Ok Thanks for the reply.
Now the flash part is working... But another question for handling writes!

What is the best way to buffer the old data before write some new data?

Example: if my configuration data takes the first 3000 bytes in the user space (many different config bytes and strings)
and i want to update the bytes 500-510 with the new data!?

 

netcruze

  • Jr. Member
  • **
  • Posts: 63
    • View Profile
Re: User space on External Flash
« Reply #3 on: September 16, 2013, 01:16:15 PM »
I guess you could buffer it in RAM, there are many KBs of free ram. In FLASH you can not erase and update only part of the memory. Memory can only be erased is 4kbyte (4096 bytes) blocks. You can program memory from 1 to 256 bytes. One way to do it would be to reserve two 4k blocks for your data. Only mark one as being active. When data changes, you copy the whole old block to the new one (that was erased). And, change the required bytes. After the copy, mark the new block as active. There are other ways you could do it too with smaller blocks.

Important is to remember the smallest area you can erase is a 4k block. You can not just update bytes 500-510 for example. After erasing a block all bits will be 1. You can write individual bytes, but once the value is 0, it can not be changed back to 1 with a write. An erase is required.