Author Topic: Wearing out flash memory  (Read 2435 times)

kopsis

  • Sr. Member
  • ****
  • Posts: 329
    • View Profile
    • http://kopsisengineering.com
Wearing out flash memory
« on: October 05, 2004, 04:54:58 pm »
The following is a copy of a post I wrote addressing the question of flash memory "wear". I'm reposting it to it's own topic since it may be of interest to people not following the PDF reader topic (yes, I went a wee bit off-topic  ) where it originated. The original question was whether it's a good idea to routinely use a swapfile on a CF or SD card ...

Flash life is typically between 10K and 100K erase cycles per sector (depending on the flash memory technology used). When data (let's say a byte) is written to flash what really happens is that the chunk of flash (sector) where the byte is to be written first gets read into RAM. The byte in question is then changed in the RAM copy, the sector in the flash is erased back to all zeros (or ones depending on the technology), and then the RAM copy of the sector is programmed back into the flash. As a result, writing 512 contiguous bytes may be done with only a single erase cycle. Writing the same byte 512 times could be as much as 512 erase cycles.

Good flash cards combat wear by using wear leveling techniques. Wear leveling works by spreading the writes out amongst all the free flash sectors. Let's say you have one sector (perhaps in a swapfile) that's getting hit over and over. The logic in the card will actually map that logical sector to a different physical sector each time a write happens. That means that if the life of a sector is 10K cycles and the card has 128M sectors (typical for a 64M card) then the card can theoretically survive 1.28G writes. Now, wear leveling generally only works on "free" sectors so keeping your card 50% full would cut that number in half. Keeping your card 99% full is going to get you back down close to that 10K - 100K number since there are few free sectors to share the erase/write cycles.

When using flash as a file system, data is typically written in big chunks - and only when the user does something. User's aren't very fast (relatively speaking) so this keeps the number of erase cycles to a minimum. When you use a swapfile, the flash can get hammered at much higher rates. Note that Linux will often use the swapfile even with plenty of free RAM available so you don't have much control over the level of activity your swapfile will see. Needless to say, using a swapfile occasionally on a CF or SD card with plenty of free space isn't likely to have a noticeable impact on the life of your card. On the other hand, using a swapfile continuously on a relatively full card could significantly shorten its lifespan.

As for the question of internal memory, the SL-5xxx series use RAM for the internal file system so there are no worries.  The SL-Cxxx series use flash for the internal file system so there *is* a risk of intense activity wearing out the internal flash. And all Zaurii use flash for the operating system but it's typically only erased on a reflash and not too many folks are going to reflash 10K times.

lardman

  • Hero Member
  • *****
  • Posts: 4512
    • View Profile
    • http://people.bath.ac.uk/enpsgp/Zaurus/
Wearing out flash memory
« Reply #1 on: October 05, 2004, 05:26:46 pm »
Quote
As for the question of internal memory, the SL-5xxx series use RAM for the internal file system so there are no worries. The SL-Cxxx series use flash for the internal file system so there *is* a risk of intense activity wearing out the internal flash. And all Zaurii use flash for the operating system but it's typically only erased on a reflash and not too many folks are going to reflash 10K times.

Yes, but as long as you don't create a swap file on your flashROM you'll probably be okay.

A long time ago I found a spec sheet for the flashROM chip in the 5500 (it was linked from the devnet): the write cycle life was actually 100,000 iirc (and, FYI, it's not electro-magnetically hardened!).


Si
C750 OZ3.5.4 (GPE, 2.6.x kernel)
SL5500 OZ3.5.4 (Opie)
Nokia 770
Serial GPS, WCF-12, Socket Ethernet & BT, Ratoc USB
WinXP, Mandriva

Chaos

  • Full Member
  • ***
  • Posts: 197
    • View Profile
    • http://zaurus.duelmonsters.ca
Wearing out flash memory
« Reply #2 on: October 06, 2004, 02:38:40 am »
What applies to the C-series also applies to the 5600, as the 5600 is more or less the same internal hardware as the C700 (processor, RAM, flash, etc.).

Also applies to the 6000.

And as far as I know, creating a swapfile on a JFFS2 filesystem will not work, so creating a swapfile on a C-series/5600/6000 is not an issue.

But basically, keep the swapfile usage to a minimum... (Unless you mount a network partition and swap that way... But that'd be real slow, I can guess.)
Sorry. I just don't have the time...