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

Using the S132 soft device on an nRF52 DK and calling the sd_flash_write function always produces the NRF_ERROR_FORBIDDEN code.

Using the S132 soft device on an nRF52 DK and calling the sd_flash_write function always produces the NRF_ERROR_FORBIDDEN code. The following is the line believe is causing the problem...

err_code = (sd_flash_write((uint32_t*)cur_addr, value, 1));

The cur_addr pointer is calculated using the following line of code...

cur_addr = (uint32_t*)(512 * cur_block);

The variable 'value' is a uint32_t type and I can read what I believe is the value stored at that address. I have written several loops to cycle and check through the flash storage to see if a block is available (or is all ones, like it's been erased). It would appear that my addresses are correct as I am no longer getting the NRF_INVALID_ADDR. I am able to find 256 blocks and read the data. This makes sense to me with the flash storage size on the DK. Is there another setting or function I need to use in order to write to these addresses? Is it possible that the whole flash is getting write protected?

  • Hello Bjorn,

    I appreciate your efforts in trying to help me. I have been working with my lead on the project and asked about sending the code to you. I'll let you know what we decide. Also, you are correct when you asked if the entire flash had something other than 0xFFFFFFFF written there. It may be something in my code, so I want to see if my lead has any suggestions before we open it up to you. Some of the addresses at the end seem to have a 'dead code' value stored as well.

    Thanks again,

    Matt

  • Happy to help. Having the actual code would make debugging this issue a lot easier. 

    As for the "deadcode" value,  it's a magic word used by the FDS library to tag the flash pages it uses. 

    Best regards

    Bjørn

1 2