I've managed to find some magic numbers/commands for working with nRF5x devices using the CTRL-AP interface, but having no such luck with the commands on an nRF9160. I've tried (using J-Link Commander):
J-Link>connect Please specify device / core. <Default>: CORTEX-M33 Type '?' for selection dialog Device> Please specify target interface: J) JTAG (Default) S) SWD T) cJTAG TIF> Device position in JTAG chain (IRPre,DRPre) <Default>: -1,-1 => Auto-detect JTAGConf> Specify target interface speed [kHz]. <Default>: 4000 kHz Speed> Device "CORTEX-M33" selected. Selected interface (JTAG) is not supported by the connected probe. J-Link>SWDSelect Select SWD by sending SWD switching sequence. Found SWD-DP with ID 0x6BA02477 J-Link>SWDWriteDP 1 0x50000000 Write DP register 1 = 0x50000000 J-Link>SWDWriteDP 2 0x01000000 Write DP register 2 = 0x01000000 J-Link>SWDWriteAP 1 0x00000001 Write AP register 1 = 0x00000001 J-Link>SWDReadAP 2 Read AP register 2 = 0x02000000 J-Link>SWDReadAP 2 Read AP register 2 = 0x00000000
Is there something different to be done on the nRF9160? I would have thought that, after having done the above, the device would have performed a mass erase of its flash.
The nRF9160 has sections on using things like the "mailbox" interface with CTRL-AP, but little to absolutely no examples/documentation on opening a terminal and actually using it (that I've found, anyway).