repeated write/reads from internal flash

Hi support

I am using the app core of the nrf5340 chip and currently testing using a nrf7002dk dev kit. I am compiling code using sdk v3.0.0.

I am trying to access the internal flash memory of the nrf5340 using the zephyr flash interface. However I am finding that when I write to the same address 2 times, the value that I read back is not correct.

Here are the steps that reproduce the problem

  • write 0x80808080 to internal flash at 0xf8000
  • read 0xf8000 and correctly get 0x80808080
  • write 0x0202020202 to internal flash at 0xf8000
  • read 0xf8000 and incorrectly get 0x00000000

Does the sdk allow a user to write to the same location more than once ? If so, does the flash API provide a mechanism to tell the user when the previous date write has completed so they can start another write operation ?

Parents
  • Hi,

    nor flash requires an erase before each write. This is because the flash can only change bits from 1 to 0 during a write. Resetting bits back to 1 requires an erase. Also, flash can only be erased 4096 bytes at a time (size of flash page on this device).  So even if only a few bytes need to be update, the entire 4 KB page must be erased first.

    Best regards,

    Vidar

Reply
  • Hi,

    nor flash requires an erase before each write. This is because the flash can only change bits from 1 to 0 during a write. Resetting bits back to 1 requires an erase. Also, flash can only be erased 4096 bytes at a time (size of flash page on this device).  So even if only a few bytes need to be update, the entire 4 KB page must be erased first.

    Best regards,

    Vidar

Children
Related