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?