<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="https://devzone.nordicsemi.com/cfs-file/__key/system/syndication/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>nRF9160 CTRL-AP access using J-Link Commander/GDB</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/60813/nrf9160-ctrl-ap-access-using-j-link-commander-gdb</link><description>I&amp;#39;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&amp;#39;ve tried (using J-Link Commander): 
 
 
 Is there something different to be done on</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Tue, 05 May 2020 12:50:45 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/60813/nrf9160-ctrl-ap-access-using-j-link-commander-gdb" /><item><title>RE: nRF9160 CTRL-AP access using J-Link Commander/GDB</title><link>https://devzone.nordicsemi.com/thread/248183?ContentTypeID=1</link><pubDate>Tue, 05 May 2020 12:50:45 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:cbd8ca2d-21e1-429e-bf0e-22ffc13a8ed0</guid><dc:creator>erik.johnson</dc:creator><description>&lt;p&gt;Perfect! I was able to successfully use ERASEPROTECT.DISABLE to recover a completely locked-down device, and I am able to read and write from the mailbox interface successfully.&lt;/p&gt;
&lt;p&gt;Thanks a ton for the help with this!&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nRF9160 CTRL-AP access using J-Link Commander/GDB</title><link>https://devzone.nordicsemi.com/thread/248061?ContentTypeID=1</link><pubDate>Tue, 05 May 2020 07:11:33 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:49890d22-e8ca-420c-ab54-58a68fa533a3</guid><dc:creator>H&amp;#229;kon Alseth</dc:creator><description>&lt;p&gt;The documented form for selecting the bank seems to be incorrect in the comments in the script.&lt;/p&gt;
&lt;p&gt;It seems that the first byte is the address offset.&lt;/p&gt;
&lt;p&gt;Each bank has 8 entries, from 0 to 7. Reading register 8 will not work, as you&amp;#39;ll need to switch bank.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Here&amp;#39;s an example of reading IDR (0x0FC):&lt;/p&gt;
&lt;p&gt;SWDSelect&lt;/p&gt;
&lt;p&gt;&lt;span&gt;SWDWriteDP 1 0x50000000&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;SWDWriteDP 2 0x040000f0 // Select the correct bank&lt;/p&gt;
&lt;p&gt;SWDReadAP 3 // Read register offset 3 (0xc)&lt;/p&gt;
&lt;p&gt;SWDReadAP 3 // 0x12880000 should be read back&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;So, writing to 0x20 would be like this:&lt;/p&gt;
&lt;p&gt;SWDSelect&lt;/p&gt;
&lt;p&gt;&lt;span&gt;SWDWriteDP 1 0x50000000&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;SWDWriteDP 2 0x04000020 // Select the correct bank per the register offset&lt;/p&gt;
&lt;p&gt;SWDWriteAP 0 0x12341234&lt;/p&gt;
&lt;p&gt;SWDReadAP 0 // Read register offset 0 (0x0)&lt;/p&gt;
&lt;p&gt;SWDReadAP 0 // Should now read back what you wrote&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Opened up a gdb session, and read the register from the MCU:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;# addr from MCU: https://infocenter.nordicsemi.com/topic/ps_nrf9160/chapters/dif/ctrl-ap.html?cp=2_0_0_8_1_5#unique_1026387282
(gdb) print *0x50006400
$2 = 0x12341234
&lt;/pre&gt;&amp;nbsp;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Could you see if this works?&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Cheers,&lt;/p&gt;
&lt;p&gt;Håkon&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nRF9160 CTRL-AP access using J-Link Commander/GDB</title><link>https://devzone.nordicsemi.com/thread/247966?ContentTypeID=1</link><pubDate>Mon, 04 May 2020 15:23:53 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:10af2bf5-dbb7-4e79-a09a-54e462626705</guid><dc:creator>erik.johnson</dc:creator><description>&lt;p&gt;I also am not even able to write from the debugger to MAILBOX.TXDATA:&lt;/p&gt;
&lt;p&gt;J-Link&amp;gt;SWDSelect&lt;br /&gt;Select SWD by sending SWD switching sequence.&lt;br /&gt;Found SWD-DP with ID 0x6BA02477&lt;br /&gt;J-Link&amp;gt;SWDWriteDP 1 0x50000000&lt;br /&gt;Write DP register 1 = 0x50000000&lt;br /&gt;J-Link&amp;gt;SWDWriteDP 2 0x04000000&lt;br /&gt;Write DP register 2 = 0x04000000&lt;br /&gt;J-Link&amp;gt;SWDWriteAP 8 0x12345678&lt;br /&gt;Write AP register 8 = 0x12345678 ***ERROR&lt;/p&gt;
&lt;p&gt;The register address is 0x020 = 32, 32/4 = 8.&lt;/p&gt;
&lt;p&gt;Do I need to be selecting a different register bank than 0 or something?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nRF9160 CTRL-AP access using J-Link Commander/GDB</title><link>https://devzone.nordicsemi.com/thread/247951?ContentTypeID=1</link><pubDate>Mon, 04 May 2020 15:02:58 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:0168e691-9631-445f-9fbf-64fa38411568</guid><dc:creator>erik.johnson</dc:creator><description>&lt;p&gt;Looks like the erase process does occur on the first time through. I&amp;#39;m not sure exactly what was happening that made me think it needed to be on the second one... I think I might not have done the SWDReadAP 2 after the write attempt, which seems to be necessary in order to trigger the erase.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Does the index math for the various registers always use the offset value, or is it an index in the list of registers in section 9.2.5? That is, if I wanted to write to the ERASEPROTECT.DISABLE register, do I use 0x1C = 28, 28/4 = 7, or is it register 5 because it&amp;#39;s the fifth in the list? Just want to be sure, since I&amp;#39;m not having success initiating the mass erase with my nRF9160 (which is writing 0x12345678 to its ERASEPROTECT.DISABLE register).&lt;/p&gt;
&lt;p&gt;Is the byte order still the same endianess? That is, I should be doing:&lt;/p&gt;
&lt;p&gt;SWDWriteAP 7 0x12345678&lt;/p&gt;
&lt;p&gt;and not:&lt;/p&gt;
&lt;p&gt;SWDWriteAP 7 0x78563412&lt;/p&gt;
&lt;p&gt;correct?&lt;/p&gt;
&lt;p&gt;Is there a time or try limit to writing to that register? As in, if I write the wrong value, will I need to power cycle the device and try again? Or can I sort of brute force the value and still have it work? Should I be doing a read of register ERASEALLSTATUS after writing to the DISABLE register to trigger the mass erase?&lt;/p&gt;
&lt;p&gt;Thanks for the help so far!&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nRF9160 CTRL-AP access using J-Link Commander/GDB</title><link>https://devzone.nordicsemi.com/thread/247918?ContentTypeID=1</link><pubDate>Mon, 04 May 2020 14:09:42 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:2d1673f9-c7b8-47b9-8e3b-359f5df3820e</guid><dc:creator>H&amp;#229;kon Alseth</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;In combination with R&amp;amp;D, I have an updated&amp;nbsp;the original post, with comments on what is written/read etc.&lt;/p&gt;
&lt;p&gt;There was some errors in the original script, where the actual erase happened last.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&amp;nbsp;&lt;/p&gt;
[quote user="erik.johnson"]If I wanted to read a single word from the mailbox, would I need to do the same thing, but replace WriteAP 1 with ReadAP 8? Doing that returns 0xFFFFFFFE right now, which might be because my steps are wrong or my firmware isn&amp;#39;t properly writing to the mailbox; it&amp;#39;d just be nice to know if it&amp;#39;s likely to be one or the other.[/quote]
&lt;p&gt;Reading SWD registers must be done with two commands,&amp;nbsp;similar to how&amp;nbsp;reading&amp;nbsp;over I2C works. Each bank has 8 registers (0 to 7).&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Kind regards,&lt;/p&gt;
&lt;p&gt;Håkon&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nRF9160 CTRL-AP access using J-Link Commander/GDB</title><link>https://devzone.nordicsemi.com/thread/247634?ContentTypeID=1</link><pubDate>Thu, 30 Apr 2020 16:44:23 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:0ec8168f-a935-4491-92d6-3cf6b70656d7</guid><dc:creator>erik.johnson</dc:creator><description>&lt;p&gt;Okay, that does seem to work!&lt;/p&gt;
&lt;p&gt;From what I can gather with testing your steps, the first SWDWriteAP 1 0x0000001 doesn&amp;#39;t do anything, right? It seems I need to do the two WriteDP steps, reset with r0+r1, and then do the WriteDP steps again and *then* WriteAP 1... works. Skipping the first WriteAP 1 results in the same thing: the part being erased during the two ReadAP 3 steps.&lt;/p&gt;
&lt;p&gt;If I wanted to read a single word from the mailbox, would I need to do the same thing, but replace WriteAP 1 with ReadAP 8? Doing that returns 0xFFFFFFFE right now, which might be because my steps are wrong or my firmware isn&amp;#39;t properly writing to the mailbox; it&amp;#39;d just be nice to know if it&amp;#39;s likely to be one or the other.&lt;/p&gt;
&lt;p&gt;Thanks!&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nRF9160 CTRL-AP access using J-Link Commander/GDB</title><link>https://devzone.nordicsemi.com/thread/247493?ContentTypeID=1</link><pubDate>Thu, 30 Apr 2020 10:01:06 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:4e6c4e70-b711-4c1a-946c-d1955ca3b2b3</guid><dc:creator>H&amp;#229;kon Alseth</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;The algorithm is slightly changed, as the nRF9160 reset behavior is changed on the SWJ-DP compared to nRF52-devices:&lt;/p&gt;
&lt;p&gt;&lt;a href="https://infocenter.nordicsemi.com/topic/ps_nrf9160/pmureset.html?cp=2_0_0_4_0_4_7#reset_behaviour"&gt;https://infocenter.nordicsemi.com/topic/ps_nrf9160/pmureset.html?cp=2_0_0_4_0_4_7#reset_behaviour&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;a href="https://infocenter.nordicsemi.com/topic/ps_nrf52840/power.html?cp=4_0_0_4_2_5_7#concept_res_behav"&gt;https://infocenter.nordicsemi.com/topic/ps_nrf52840/power.html?cp=4_0_0_4_2_5_7#concept_res_behav&lt;/a&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;*Updated script* Could you try this script?&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;SWDSelect   // Activate SWD
SWDWriteDP 1 0x50000000  // Enable debug power
SWDWriteDP 2 0x04000000  // Selects the 0x04XXXXXX Access Port and 0xXXXX00XX Register bank in the access port
SWDWriteAP 1 0x00000001  // CTRL-AP Bank 0, register offset 1 (ERASEALL 0x004): Erase all command

SWDReadAP 2 // CTRL-AP Bank 0, register offset 2 (ERASEALLSTATUS 0x008): Erase all command status
SWDReadAP 2 // Must read twice to get the value.

// Wait a good amount of time, so eraseall process is done.
sleep 500

// Perform a pin reset
r0
sleep 10
r1
sleep 10

SWDSelect   // Activate SWD
SWDWriteDP 1 0x50000000  // Enable debug power
SWDWriteDP 2 0x04000000  // Selects the 0x04XXXXXX Access Port and 0xXXXX00XX Register bank in the access port

SWDReadAP 3 // CTRL-AP Bank 0, register offset 3 (APPROTECTSTATUS 0x00C): Access port protection status
SWDReadAP 3 // //Second read returns the value: 0: enabled 1: not enabled

exit&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Kind regards,&lt;/p&gt;
&lt;p&gt;Håkon&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>