<?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>What are the raw JLink.exe commands sent by nrfjprog.exe?</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/33911/what-are-the-raw-jlink-exe-commands-sent-by-nrfjprog-exe</link><description>My devices require calibration and self test to be carried out after programming. To implement this, my device checks the JLink reset pin (configured as a GPIO on my NRF52 device) if it has been pulled low on startup - if it has, it performs calibration</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Fri, 01 Jun 2018 10:48:15 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/33911/what-are-the-raw-jlink-exe-commands-sent-by-nrfjprog-exe" /><item><title>RE: What are the raw JLink.exe commands sent by nrfjprog.exe?</title><link>https://devzone.nordicsemi.com/thread/134334?ContentTypeID=1</link><pubDate>Fri, 01 Jun 2018 10:48:15 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:02da1863-4928-4dd8-a788-31aa2c185ac4</guid><dc:creator>H&amp;#229;kon Alseth</dc:creator><description>&lt;p&gt;nrfjprog interfaces the jlink.dll directly, so that works in a bit of a different way.&lt;/p&gt;
&lt;p&gt;JLink Commander is limited in terms of scripting, as you mention; you cannot continuously poll a register to wait for an operation to be finished, which makes it hard for you to optimize your delays.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Best 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: What are the raw JLink.exe commands sent by nrfjprog.exe?</title><link>https://devzone.nordicsemi.com/thread/134316?ContentTypeID=1</link><pubDate>Fri, 01 Jun 2018 09:33:34 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:3001cbf7-6de2-4abf-858b-48a0fe8ac21e</guid><dc:creator>cirlam</dc:creator><description>&lt;p&gt;Thank you for the advice H&amp;aring;kon! Will implement your recommendation.&lt;/p&gt;
&lt;p&gt;So the rest of the script, including using delays instead of polling the ready register, should be ok? Is this how the nrfjprog.exe script works?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: What are the raw JLink.exe commands sent by nrfjprog.exe?</title><link>https://devzone.nordicsemi.com/thread/134293?ContentTypeID=1</link><pubDate>Fri, 01 Jun 2018 08:25:14 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:b65d427b-7d13-4eb2-a358-7e7cfd30a67d</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;I see one improvement, as you are focusing on speed. The &amp;quot;FLASH DEVICE HERE&amp;quot; sequence does not need to write directly to the NVMC peripheral. You can just call &amp;quot;loadfile &amp;lt;myhex&amp;gt;&amp;quot;.&lt;/p&gt;
&lt;p&gt;This should also verify the content, as shown here when I load a test.hex file:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;J-Link&amp;gt;loadfile c:\test_s140.hex
Downloading file [c:\test_s140.hex]...
J-Link: Flash download: Bank 0 @ 0x00000000: 1 range affected (208896 bytes)
J-Link: Flash download: Total time needed: 3.058s (Prepare: 0.058s, Compare: 0.023s, Erase: 0.000s, Program: 2.960s, Verify: 0.005s, Restore: 0.010s)&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><item><title>RE: What are the raw JLink.exe commands sent by nrfjprog.exe?</title><link>https://devzone.nordicsemi.com/thread/134248?ContentTypeID=1</link><pubDate>Thu, 31 May 2018 17:37:28 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:42febabf-a8ec-4778-b9e2-5a1bc10c1746</guid><dc:creator>cirlam</dc:creator><description>&lt;p&gt;Bumping this, as a while back a Nordic engineer was assigned, but haven&amp;#39;t received a response yet.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: What are the raw JLink.exe commands sent by nrfjprog.exe?</title><link>https://devzone.nordicsemi.com/thread/130369?ContentTypeID=1</link><pubDate>Tue, 01 May 2018 09:05:46 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:4d985917-4948-47ad-884a-2c2ae5607127</guid><dc:creator>cirlam</dc:creator><description>&lt;p&gt;Thanks for that - that does help. I&amp;#39;ve also found this: &lt;a href="http://infocenter.nordicsemi.com/pdf/nwp_027.pdf"&gt;http://infocenter.nordicsemi.com/pdf/nwp_027.pdf&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;Based on these articles, I&amp;#39;ve changed my code to this. Both in the nrfjprog.sh github link you posted and from Nordic Devzone posts, I have seen people use short &amp;quot;sleep&amp;quot; commands instead of polling the ready register (as recommended in the Nordic Production Programming White Paper). Hopefully this is ok....any advice from Nordic would be appreciated on this though.&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;r0

//RECOVER NRF52 from APPROTECT
SWDSelect //Selects the SWD Interface
SWDWriteDP 1 0x50000000 //Enables power
SWDWriteDP 2 0x01000000 //Selects the 0x01XXXXXX 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
sleep 1000 
SWDReadAP 2 //CTRL-AP Bank 0, register offset 2 (ERASEALL 0x008): Erase all command status
SWDReadAP 2 //Second read returns the value
SWDWriteAP 0 0x00000001 //RESET register write - soft reset
SWDWriteAP 0 0x00000000 //RESET register write
SWDWriteAP 1 0x00000000 //ERASEALL register write
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

sleep 500 //probably not necessary

//JLink connection parameters
device nrf52
speed 50000

//ERASE ALL HERE
h
w4 4001e504 2 //CONFIG register of NVMC
sleep 100 //TODO read ready register of NVMC (4001e400). Wait until value is 0x00000001
w4 4001e50c 1
sleep 100 //TODO read ready register of NVMC (4001e400). Wait until value is 0x00000001
w4 4001e504 0 //NVM back to read only
sleep 100
r //reset and halt
h //halt

//FLASH DEVICE HERE
w4 4001e504 1 //Configure NVM for writing
sleep 100 //TODO read ready register (4001E504) of NVMC until value is 1
loadfile myCombinedHexFile.hex //softdevice and application combined using mergehex.exe
sleep 100 //TODO read ready register (4001E504) of NVMC until value is 1
w4 4001e504 0 //CONFIG register back to read only
sleep 100
verifybin myCombinedHexFile.bin 0x00000000 //converted using JFlash
r //reset and halt

//ENTER CALIBRATION ROUTINE ON NRF52
r0 //take reset pin low
g //Enable CPU of NRF52
//CALIBRATION ROUTINE STARTS ON NRF52 HERE
exit

&lt;/pre&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: What are the raw JLink.exe commands sent by nrfjprog.exe?</title><link>https://devzone.nordicsemi.com/thread/130352?ContentTypeID=1</link><pubDate>Mon, 30 Apr 2018 21:28:41 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:bf0f7c25-8685-401d-97f6-b70143213a36</guid><dc:creator>mstrouse</dc:creator><description>&lt;p&gt;Not to be pedantic ... your -&amp;gt; you&amp;#39;re&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: What are the raw JLink.exe commands sent by nrfjprog.exe?</title><link>https://devzone.nordicsemi.com/thread/130351?ContentTypeID=1</link><pubDate>Mon, 30 Apr 2018 21:25:10 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:82aee3fb-993e-478c-a95a-288d8ce19eef</guid><dc:creator>mstrouse</dc:creator><description>&lt;p&gt;Not &amp;quot;exactly&amp;quot; what your looking for, but please have&amp;nbsp;a look. Perhaps some good inspiration.&amp;nbsp;&lt;a href="https://github.com/WayneKeenan/nrfjprog.sh"&gt;github.com/.../nrfjprog.sh&lt;/a&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: What are the raw JLink.exe commands sent by nrfjprog.exe?</title><link>https://devzone.nordicsemi.com/thread/130350?ContentTypeID=1</link><pubDate>Mon, 30 Apr 2018 21:09:37 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:2e4083a8-c428-47d7-a9d1-676317b58bf7</guid><dc:creator>cirlam</dc:creator><description>&lt;p&gt;I have cobbled together some code found on the devzone and have something which seems to work (it also removes the need to power cycle my board, so makes my programming and calibration sequence take less than half as long as my original script):&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;r0
//Clear App Protect and Erase All
SWDSelect //Selects the SWD Interface
SWDWriteDP 1 0x50000000 //Enables power
SWDWriteDP 2 0x01000000 //Selects the 0x01XXXXXX 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
sleep 1000 
SWDReadAP 2 //CTRL-AP Bank 0, register offset 2 (ERASEALL 0x008): Erase all command status
SWDReadAP 2 //Second read returns the value
SWDWriteAP 0 0x00000001 
SWDWriteAP 0 0x00000000 
SWDWriteAP 1 0x00000000 
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

sleep 500

//Program Device
device nrf52
speed 50000
w4 4001e504 1
w4 4001e504 2
w4 4001e50c 1
sleep 100
r
loadfile myCombinedHexFile.hex //softdevice and application combined using mergehex.exe
sleep 100
verifybin myCombinedHexFile.bin 0x00000000 //converted using JFlash
r
r0
g
exit&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;Is someone from Nordic able just to double check this is sensible please (particularly the programming sequence part)?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>