This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

What is the real nRF52840 max writes to a flash block?

The nRF52840 OPS 0.5.1, describes nWRITE,BLOCK as the amount of writes allowed in a block between erases, and lists nWRITE,BLOCK = 403 Maximum.

It looks like 8 blocks are in a 4 kB page, so each block is 512 Bytes.

Does this mean that only 403 of the 512 bytes in a page can be written? Or does the 403 number mean something else?

  • This is what I think:

    It means you can write to addresses in a block 403 times before the page that block is in has to be erased. Each write operation is a 32 bit word write operation. You can perform this write operation to addresses in a single block 403 times. So for an example, let’s talk about writing to a single block (Block1). You write to address1 in block1. This is one operation. You write to address2 in block1. Now you’ve written to the block 2 times. You write again to address1 in block1. Now you’ve written to block1 3 times. You can keep on doing this until you’ve written to a block 403 times without erasing it.

    Note, this is just a physical limitation. There is nothing actually (in software) stopping you from writing more than 403 times. It is just that after 403 times you can get undesirable results. The 403 number only becomes a problem if you are writing to an entire block 1 bit at a time or something of that nature. Maybe a Nordic employee can confirm what I wrote.

  • Ah, the NVMC only supports 32 bit write operations, so it takes 128 write operations to write the entire 512 byte block. That leaves 275 additional writes available to overwrite individual addresses within that block.

    So the entire block can be written without violating the nWRITE, BLOCK spec. And there are enough additional writes to allow the entire block to be overwritten a second time.

  • Keep in mind you cannot change a bit back from '0' to a '1'. So really an address can only be modified 32 times after that it becomes useless since you've modified all of the bits.

  • There's a spec for nWRITE that applies to a single address. For the nRF52840, nWRITE is 2. I think that means you can write a single address 2 times max. So I don't think there is any way to exceed nWRITE, BLOCK without first exceeding nWRITE.

    When I first posted the question I forgot that all flash writes had to be 32 bit. Now that I understand that, I can't find a way to exceed nWRITE, BLOCK without surpassing the max number of writes for a single address first.

    Yes, writing to the flash only clears bits. But this is still helpful for keeping non-volatile counters.

  • That is interesting. Looking at the spec for nRF52832, I don't see such a limitation (nWRITE). But for the nRF52840, there is the nWRITE limitation. You are right. I can't think of a situation either where you would exceed nWRITEBLOCK without exceeding nWRITE. I wonder if nRF52832 has such a limitation too, but they did not mention it.

Related