Use the standard Serial Wire Debug (SWD)
Arm®
CoreSight™
Debug Access Port (DAP) protocol to write data into flash.
-
Check the corresponding SPU.FLASHREGION[n].PERM (0x4003600 + (n*4)), where n is
the flash page.
-
Write the value 0x00000001 to the CONFIGNS register (0x400395084) of the
Non-volatile Memory Controller (NVMC).
This configures the non-volatile memory for writing.
-
Read the READY register (0x40039400) of the NVMC until the value is 0x00000001.
When this value is read, the NVMC is ready and not currently performing any
operations.
-
Write the data to the desired, word-aligned address.
-
Read the READY register (0x40039400) of the NVMC until the value is 0x00000001
before continuing to ensure the write operation has completed.
-
Continue writing and then reading the READY register (0x40039400) as necessary.
-
Write the value 0x00000000 to the CONFIGNS register (0x40039584) of the NVMC.
This configures the non-volatile memory back to read-only.
The range of writeable addresses are all program flash that is configured to be non-secure. The size and addresses of the non-secure flash are dependent on earlier programmed firmware.
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.