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

Flashing nrf51422 through SWD interface

In my project, the nrf51422 chip will be hosted on a board with another CPU. I need to be able to flash the firmware through the SWD interface, controlled by the host CPU, I have already a code which is able to do it. However, I miss one some parameters that I am not able to find. Where can I find details about how to flash the memory from the SWD interface?

Once I set the CPU in debug mode, I want to program the flash memory with the updated firmware.

I have studied the ARM Debug Interface Architecture Specification I can issue the SWD commands for writing data to the flash (accessing it through the MEM-AP interface), but that won't work.

I guess I should issue some commands to prepare the CPU for the flash programming (such as unlocking the flash memory and so on) but all these things seem to be "implementation defined".

I tried to port this code which does exactly what i need, but for an EFM32 cpu (which has cortex-m0 core as well). I could make it work up to reading and writing AP & DP registers, but the flash programming part has many registers that are CPU-specific, and I cannot find the equivalent for the nRF51422.

To make it short, I need to know which sequence of SWD commands should I issue to write to and read from the flash memory.

Thanks, Vito

Related