Writing data - SECUREAPPROTECT disabled

Use the standard Serial Wire Debug (SWD) Arm® CoreSight™ Debug Access Port (DAP) protocol to write data into flash.

  1. Check the corresponding SPU.FLASHREGION[n].PERM (0x5003600 + (n*4)), where n is the flash page.
    If the 4th bit is 0, the flash region is non-secure, otherwise it is secure. For non-secure regions, the CONFIG register in the following steps needs to be replaced with CONFIGNS (0x50039584).
  2. Write 0x00000001 to the CONFIG register (0x50039504) of the Non-volatile Memory Controller (NVMC).
    This enables writing to the non-volatile memory.
  3. Read the READY register (0x50039400) of the NVMC until the value is 0x00000001.
    When this value is read, the NVMC is ready and not currently performing any operations.
  4. Write the data to the desired, word-aligned address.
  5. Read the READY register (0x50039400) of the NVMC until the value is 0x00000001 before continuing to ensure the write operation has completed.
  6. Continue writing and then reading the READY register (0x50039400) as necessary.
  7. Write 0x00000000 to the CONFIG register (0x50039504) of the NVMC.
    This configures the non-volatile memory as read-only.

The ranges of writeable addresses are:

You can write to flash using different methods. For nRF9160, a good flash algorithm should take around 10 seconds to write the entire flash . If you cannot achieve this time, contact Nordic Semiconductor for assistance.