Very Slow Flash Writing

When using the flash API in NET+OS for writing data to the flash, it takes extremely long time to complete a write operation (several seconds). This is the case even if you just write one byte. How should one do to reduce this time? As it is now it is completely unusable in a real application. It is of course crucial that this problem is solved very soon. Best Regards, Fredric

If the flash is configured in 16 bit mode, we program 2 bytes of data to the flash per command and will require 64K / 2 or 32K write commands to progran the entire sector. If the flash is configured in 32 bit mode, we can program 4 bytes of data to the flash per command and will require (assuming the same 64K bytes sector) (64K / 2) / 2 or 16K write commands to progam the entire sector.

There are several write options for NAFlashWrite() as described below: ERASE_AS_NEEDED — For a full sector write, erases the sector (if necessary) and writes the new data. For a partial sector write, updates the new data but does not destroy the rest of the sector data. ALWAYS_ERASE — For a full sector write, erases the sector before writing new data. For a partial sector write, updates the new data and erases the rest of the sector. DO_NOT_ERASE — Writes new data without first erasing the sector. If the write operation changes a bit from 0 to 1, the function returns NAFLASH_WRITE_FAILED. You need to select the appropriate write option for your application.

Using our Flash driver, we use a 50us delay after each word (16-bit or 32-bit) write. So if we have a 16-bit flash configuration where one sector is 64K bytes (or 32K words), we can estimate that writing one 16-bit 64K flash sector would take: (50 x 10e-6) x 32768 = 1.6384 seconds. The above number does not take into account the additional overhead of verifying each word write and the overhead of calling the NAFlashWrite() function. Also, writing a whole sector with one NAFlashWrite() is faster than writing a whole sector using multiple NAFlashWrite() calls due to overhead.

Hello and thank you for your answers. I have been using the ERASE_AS_NEEDED option to make it as convenient as possible to write to the flash without having to worry about what bit patterns are stored in the flash prior to the write. Looking at the code in NAFlashWrite() there is reading, erasing, writing and verifying of at least a whole sector for every call to NAFlashWrite(), even if it is just a one byte write. Obviously this takes a lot of time. I was hoping that it would be possible to reduce this time significantly and still have the convenient ERASE_AS_NEEDED functionality. Is it technically possible to do this or not considering the flash technology limitations?

You have to erase the entire sector if you want to write one byte unless the address at which you are trying to write the data is already erased (all ones).