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

SDK 15.3.0 Flash_fstorage example not working as expected

Hello,

nRF52840-DK

SDK 15.3.0

SoftDevice: s140

IDE: SES

Example: Flash_fstorage_s140_pca10056

I do not read back the expected value in the example. The terminal image also show a read of the entire section of memory. I would expect the results to look something like this:

read hex 0x3E000 4
0xBA 0xDC 0x0F 0xFE

read hex 0x3E100 4
0xDE 0xAD 0xBE 0xEF

read str 0x3F000 12
hello world

  • Hi Paul, 

    Could you erase the flash with the following command and load the image again?

    nrfjprog -e

    I tested the project under \nRF5_SDK_15.3.0_59ac345\examples\peripheral\flash_fstorage\pca10056\s140. It could work as the following figure, and you also could view the values in the Segger memory window. 

    -Amanda H.

  • I was able to get the example to work by erasing the board first.

    In SES:

    1. Target >> Connect J-Link
    2. Target >> Erase All
    3. Target >> Download

    Do you have an explanation of why this does not work if you do not erase? The idea is that you are writing to flash, so regardless of what is there I would expect the value to be written?

  • The reason for this behavior is the following: When flash is erased, all bits in flash is set to '1'. Writing to flash consists of setting the necessary bits to '0'. Setting bits back to '1' can only be done by erasing the flash page.

    If you did not erase the flash, some of them will already be '0', and some new ones will have to be switched. In addition, some bits that should be '1' will also be '0', because it is already written before. Therefore, it will not work as you expect. 

    Please also see this post

    -Amanda H.

Related