Can zero-filling reset wear leveling of USB sticks / Flash drives

lifespanusb-flash-drive

As I understand it wear-leveling on USB-sticks / Flash-drives will:

  • help to make the last longer. (reduce the "wear-out", that a physical flash cell can only be writen to XX times)
  • can only really work if there is unused flash-memory cells to switch to. (The more filled the USB-stick is, the less alternative cells to level the wear out are there)

In worst case at one point of time I have used up all and every memory of the USB-Stick. Then it is less likely that some wear leveling can happen still. Can/(How would) I revert this state?

I mean in terms of USB-sticks what is empty

0000 0000 0000 0000 (zero fill) seems to me just to be as valid a data as
1111 1111 1111 1111 or 1010 1110 0011 1111 or any other bit-pattern.

The firmware of the Usb-stick needs somehow to know what is considered an "unused" Flash-cell, so that it can use it for wear leveling again. But after I have one-time eventually filled the whole USB Stick I have trouble to see how the firmware will be able to determine what data can be "overwriten" since it is not containing data?

So my question is: Can zero-filling be a way to reset the wear-leveling a USB-Stick

Allthough I fear that maybe this will often depend on the implementation ("firmware" and "manufacturer") I still think there could be a logic to this approach to assume that "zero-filling" can be reseting the usb-stick on certain -better designed- Usb-Sticks.

The logic I imagine would be, that the firmware's wear leveling would recogize that an entire block (i.e. 512bytes or 2kbytes) would be set to only zeros.

Block before: 1101 1011 1000 0010 ... 0001 0011
Block after: 0000 0000 0000 0000 ... 0000 0000

When I read from this Block I would like to receive of course this information:
Block after: 0000 0000 0000 0000 ... 0000 0000
But this information could be generated on the fly by storing that
Block XYZ= empty in a certain flash cell only available to the firmware.

If this would be the case the pool when "reset" (by zero-filling) would be enabled to serve for other purposes, since the information is stored in the BLOCK XYZ=empty firmware memory part of the stick.

I have read that there should be some USB-sticks that have such a firmware and hence can be reset? Can this be true? I would like to know by the question a "tendency" maybe backed up with information from prominent manufacturer. Maybe there exists even a list that lists USB-sticks which can be reset in this way. So that the answer could contain a link to such a list.

Also I assume that there is not "a new firmware" designed by each USB-Stick produced and maybe there is a prominent(often used) USB-firmware that does such a wear leveling. So then the quesiton could be answered with respect to that firmware.

At best there some smart person could come up with a way to answer the question in that form that it contains some instructions that enabled us users (of super-user) to "find out" if this wear leveling is enable or not.

some background to my question

USB-sticks / Flash-drives are a nice things sure.
But the problem is that the way they store the data wears out, which means after only XX Writes to a data cell !BINGO! your Stick is dead!

A way to aliviate the problem (that Flash memory cells can only be writen to quite small number of times) is "wear leveling". Which will care that -if possible- the data is not always writen to the same flash memory cells.

The way that works is that instead of writing the data always to the same physical cells the data (when changed) is writen to some other new physical cells. This reduces the "stress" because in best case this will go on like this.

To help understand some basic of wear leveling I included this concept below, which
shows how the information of "hello","salut","hola" and "hi" is subsequently stored in
a logical data cell named data, which is actually writen to a different physical flash memory each time (hence a small "concept" of wear leveling).


state 1:
[CELL1: e-m-p-t-y] [CELL2:e-m-p-t-y] [CELL3: e-m-p-t-y]


=> write data "hello"


state 2:
[CELL1: hello]     [CELL2:e-m-p-t-y] [CELL3: e-m-p-t-y]
 data=CELL1

=> update data to "salut"


state 3:
[CELL1: hello]     [CELL2: salut]    [CELL3: e-m-p-t-y]
 data=CELL2

=> update data to "hola"

state 4:
[CELL1: hello]     [CELL2: salut]    [CELL3: hola]
 data=CELL3

=> update data to "hi"

state5
[CELL1: hi]     [CELL2: salut]    [CELL3: hola]
 data=CELL1 


Observe how after writing 4 times data each cell in average was only writen 1.33 times.
Also observe that the information which cell contains the "logical data" is to be also stored and updated (which requires the firmware to do this accounting -using some reserved memory for this also)

Best Answer

Some flash drives can check if written data is all zeroes and just unmap that region instead of programming flash memory. Though I don't know how common it is.

Currently I am working at MMC controller (can't tell you whose, this is a secret :-) ) and its firmware checks data content, not on write, but later during erase and GC. It unmaps all found zero regions.

As to how to

"find out" if this wear leveling is enable or not.

You can try to compare reading speed of previosly written zero-filled data block and random-filled data block (better to poweroff you drive after write to avoid cache using). If your flash drive checks content of incoming data and just unmaps written region, then reading this region should be much faster because controller can skip actual reading from flash (which is a long operation).