<?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>nrfjprog --program: code starts executing though no --reset option has been given on command line. Causes unwanted activation of readback protection.</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/79263/nrfjprog---program-code-starts-executing-though-no---reset-option-has-been-given-on-command-line-causes-unwanted-activation-of-readback-protection</link><description>I&amp;#39;m using nrfjprog version: 10.13.0 / JLinkARM.dll version: 7.50a to flash a firmware onto a custom PCB with nRF52840. Programming hardware is a nRF52840 DK. Our firmware activates readback protection on the first boot. 
 Here is the programming script</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Mon, 20 Sep 2021 08:29:06 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/79263/nrfjprog---program-code-starts-executing-though-no---reset-option-has-been-given-on-command-line-causes-unwanted-activation-of-readback-protection" /><item><title>RE: nrfjprog --program: code starts executing though no --reset option has been given on command line. Causes unwanted activation of readback protection.</title><link>https://devzone.nordicsemi.com/thread/330186?ContentTypeID=1</link><pubDate>Mon, 20 Sep 2021 08:29:06 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:488831ce-3b1f-4406-a1cb-66f59c76a347</guid><dc:creator>Frank Viganske</dc:creator><description>&lt;p&gt;Just wanted to add that i also verified this after upgrading to the 10.13.0 again. That version had a much higher failure rate, but works fine now with the pinreset.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nrfjprog --program: code starts executing though no --reset option has been given on command line. Causes unwanted activation of readback protection.</title><link>https://devzone.nordicsemi.com/thread/330161?ContentTypeID=1</link><pubDate>Mon, 20 Sep 2021 07:17:57 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:b57f9a9d-dda6-4c2c-9702-97cbd59f5d8e</guid><dc:creator>Frank Viganske</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;The watchdog is&amp;nbsp;configured by a third party software component that we use, of which i do not have the source. But i inserted a debug print of the &lt;code&gt;WDT-&amp;gt;CONFIG&lt;/code&gt; register after the initialization of that component. The value read was 1, which is also the default value after a reset.&lt;/p&gt;
&lt;p&gt;So that means the watchdog should be paused while the CPU is halted by the debugger.&lt;/p&gt;
&lt;p&gt;I added a &lt;code&gt;--pinresetenable&lt;/code&gt; and a &lt;code&gt;--pinreset&lt;/code&gt; as you suggested. That gave me 0 errors on 100 iterations, so that seems to fix the problem. But i think for safety i will also check for the exit code 16 (for the readback protection error) and repeat the programming if that happens.&lt;/p&gt;
&lt;p&gt;Now that i think about it, the -&lt;code&gt;-verify --fast&lt;/code&gt; may be the option that caused all the trouble. If i understood that correctly, it will execute some code on the target to calculate a hash, so the CPU will no longer be halted by the debugger. That would also cause the watchdog to continue running.&lt;/p&gt;
&lt;p&gt;If that is correct, doing a slow verify might also be a possible solution.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nrfjprog --program: code starts executing though no --reset option has been given on command line. Causes unwanted activation of readback protection.</title><link>https://devzone.nordicsemi.com/thread/330078?ContentTypeID=1</link><pubDate>Fri, 17 Sep 2021 14:04:31 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:4627d9d1-0502-4c19-91d7-df58bc9b49e8</guid><dc:creator>run_ar</dc:creator><description>&lt;p&gt;Did you configure the Watchdog to halt while the debugger is connected: &lt;span&gt;&lt;a title="Temporarily pausing the watchdog" href="https://infocenter.nordicsemi.com/topic/ps_nrf52840/wdt.html?cp=4_0_0_5_35_1#concept_ml5_rzw_sr"&gt;Temporarily pausing the watchdog&lt;/a&gt;&lt;/span&gt;? That might cause the wdt to continue counting after you disconnect the debugger. Notice that not all resets will actually reset the wdt -&amp;gt; &lt;span&gt;&lt;a title="Reset behavior" href="https://infocenter.nordicsemi.com/topic/ps_nrf52840/power.html?cp=4_0_0_4_2_5_7#concept_res_behav"&gt;Reset behavior&lt;/a&gt;&lt;/span&gt;. I though the recover command should take care of everything. But I wonder if it could be that the WDT is running even after that. depending on what reset is performed. Could you try adding a pin reset command to the script between the --recover command and the program command. notice, you might need to issue an --pinresetenable command to begin with.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nrfjprog --program: code starts executing though no --reset option has been given on command line. Causes unwanted activation of readback protection.</title><link>https://devzone.nordicsemi.com/thread/329204?ContentTypeID=1</link><pubDate>Mon, 13 Sep 2021 11:34:37 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:0f9e410d-cf1c-4bf8-b168-287f686364f5</guid><dc:creator>Frank Viganske</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;it works better when i combine the options &lt;code&gt;--program&lt;/code&gt; and &lt;code&gt;--verify&lt;/code&gt;,&amp;nbsp;as you suggested, But still in 1% of the cases i get the readback protection error. With the original script it was 11%. I let both the orignal script and the modified script run in a loop for 100 iterations and counted the errors.&lt;/p&gt;
&lt;p&gt;I also noticed that when the error occurs the &lt;code&gt;RESETREAS&lt;/code&gt; register indicates a watchdog reset.&amp;nbsp;After a successful run &lt;code&gt;RESETREAS&lt;/code&gt; shows a Software reset.&lt;/p&gt;
&lt;p&gt;That surprised me a bit. When i pause the script after the &lt;code&gt;--program&lt;/code&gt; operation, there will be no watchdog reset, so it seems the &lt;code&gt;--recover&lt;/code&gt; and / or &lt;code&gt;--program&lt;/code&gt; operation&amp;nbsp;halts the watchdog. But the &lt;code&gt;--verify&lt;/code&gt; seems to start it again, which appears to be the reason why the code starts executing.&lt;/p&gt;
&lt;p&gt;The connection to the board is OK, I never had problems with the connection before, until i introduced the verification step in the script. To me it looks that the verify is the main suspect here. The failure rate going down from 11% to 1% after combining program and verify also points into that direction.&lt;/p&gt;
&lt;p&gt;We did power supply measurements during hardware validation, and they were stable. But i never&amp;nbsp;did some measurements during programming with the Nordic DK, i can try to do that during the next few days. What voltages are you interested in, just VDD and VDDH or also some of the DEC pins?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nrfjprog --program: code starts executing though no --reset option has been given on command line. Causes unwanted activation of readback protection.</title><link>https://devzone.nordicsemi.com/thread/329055?ContentTypeID=1</link><pubDate>Fri, 10 Sep 2021 13:32:07 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:769fe757-9c11-444a-9533-85f6426600d1</guid><dc:creator>run_ar</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;Could you try to combine the --program and --verify command like this: nrfjprog --program &lt;code&gt;final_image_1_1_8_no_sp&lt;/code&gt;.hex --verify --fast?&lt;/p&gt;
&lt;p&gt;Do you have a good connection to the board and a stable power supply?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nrfjprog --program: code starts executing though no --reset option has been given on command line. Causes unwanted activation of readback protection.</title><link>https://devzone.nordicsemi.com/thread/328222?ContentTypeID=1</link><pubDate>Mon, 06 Sep 2021 13:31:01 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:a8ac8b3e-e43c-42da-ba20-e4531b4a9c04</guid><dc:creator>Frank Viganske</dc:creator><description>&lt;p&gt;Update: i inserted a &amp;quot;pause&amp;quot; command after the --program and the --verify command and&amp;nbsp;added&amp;nbsp;some debug prints to the firmware when it starts. That showed me that the firmware does not start until the --verify operation begins.&lt;/p&gt;
&lt;p&gt;Also i tried downgrading to an older nrfjprog version (10.5.0) to see if that changes anything. The error occurs also with the older version, only a bit less often.&lt;/p&gt;
&lt;p&gt;Frank&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>