<?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>Please clarify/explain use of --sectorerase with nrfjprog</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/83316/please-clarify-explain-use-of---sectorerase-with-nrfjprog</link><description>We have some dev code where the workflow is as follows: 
 1. an engineering version of firmware is loadded to target. The target is erased then programmed in the normal way. 
 2. various config operations are carried out, and config data is written to</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Thu, 06 Jan 2022 09:11:09 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/83316/please-clarify-explain-use-of---sectorerase-with-nrfjprog" /><item><title>RE: Please clarify/explain use of --sectorerase with nrfjprog</title><link>https://devzone.nordicsemi.com/thread/346380?ContentTypeID=1</link><pubDate>Thu, 06 Jan 2022 09:11:09 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:88bf5626-5b17-450b-a9fc-bfe9c3e2f8e3</guid><dc:creator>Amanda Hsieh</dc:creator><description>&lt;p&gt;Hi,&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&amp;quot;--sectorerase&amp;quot; only erase the &lt;strong&gt;targeted&lt;/strong&gt;&amp;nbsp;non-volatile memory pages excluding UICR instead of &lt;strong&gt;all&lt;/strong&gt;&amp;nbsp;the available user non-volatile memory. That means only the required area of the flash will be erased. If there are SD, BL, APP, and Setting in the flash, it now only programs new SD and BL with&amp;nbsp;&amp;nbsp;&amp;quot;--sectorerase&amp;quot;. Only the SD and BL are updated, but the previous APP and Setting are still there and not be erased. As the statement of &amp;quot;--no-backup&amp;quot; describes, it doesn&amp;#39;t contain the part to overwrite the backup page. That might cause the&amp;nbsp;&amp;quot;--sectorerase&amp;quot; only erase the area required for the settings image with&amp;nbsp;&amp;quot;--no-backup&amp;quot; (not clear all of the previous settings image part). Therefore, it led to CRC error. I think that might be the reason why removing&amp;nbsp;&amp;quot;--no-backup&amp;quot; in the command can fix the issue.&amp;nbsp;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;DFU settings backup page is the&amp;nbsp;bootloader settings page which contains sensitive information that should be changed only as a result of authorized firmware upgrades. Because of this, it always keeps a protected backup. The original settings can be left open to allow the application to exchange data with the bootloader (for example, for background DFU). However, the sensitive parts of the settings page are always read from the backup to protect against both malicious and unintended tampering.&amp;nbsp;&lt;/span&gt;See&amp;nbsp;&lt;a title="Bootloader settings backup" href="https://infocenter.nordicsemi.com/topic/sdk_nrf5_v17.0.2/lib_secure_boot.html?cp=8_5_0_3_5_0_8_4#secure_boot_settings_backup"&gt;Bootloader settings backup&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;Hope this can help. &lt;span class="emoticon" data-url="https://devzone.nordicsemi.com/cfs-file/__key/system/emoji/1f642.svg" title="Slight smile"&gt;&amp;#x1f642;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;-Amanda&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Please clarify/explain use of --sectorerase with nrfjprog</title><link>https://devzone.nordicsemi.com/thread/346156?ContentTypeID=1</link><pubDate>Wed, 05 Jan 2022 12:01:44 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:fd9366ae-6d8d-4942-a5fc-d78e1ca033c2</guid><dc:creator>danmcb</dc:creator><description>&lt;p&gt;Thank you Amanda. Indeed, removing the nobackup flag seems to fix the issue.&lt;/p&gt;
&lt;p&gt;I don&amp;#39;t quite understand how though. Why does the app work after eraseall but not after sectorerase? nrfutil is just generating params for the DFU, how does it influence what happens later at the programming stage in this way?&lt;/p&gt;
&lt;p&gt;what actually *is* the DFU settings backup page?&lt;/p&gt;
&lt;p&gt;Can it be that with this change, the app still finds a CRC issue but then is able to use the &amp;quot;backup&amp;quot; to recover (which would not work if the app had changed between cycles?&lt;/p&gt;
&lt;p&gt;To me, it still seems that nrfjprog not programming the actual data in the .hex file to the target when given the sectorerase flag must be considered a bug - or do I miss something important here?&lt;/p&gt;
&lt;p&gt;Thanks again for helping.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Please clarify/explain use of --sectorerase with nrfjprog</title><link>https://devzone.nordicsemi.com/thread/346051?ContentTypeID=1</link><pubDate>Wed, 05 Jan 2022 08:35:59 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:e15176b2-03a1-4299-9563-5a67d3b6b94e</guid><dc:creator>Amanda Hsieh</dc:creator><description>&lt;p&gt;Hi,&amp;nbsp;&lt;/p&gt;
&lt;p&gt;I guess &amp;quot;&lt;span&gt;--no-backup&lt;/span&gt;&amp;quot; might cause the issue. Try to remove it.&amp;nbsp;&lt;/p&gt;
&lt;pre&gt;--no-backup Do not overwrite DFU settings backup page.&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; If not specified, than the resulting .hex&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; file will contain a copy of DFU settings,&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; that will overwrite contents of DFU settings&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; backup page.&lt;/pre&gt;
&lt;p&gt;-Amanda&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Please clarify/explain use of --sectorerase with nrfjprog</title><link>https://devzone.nordicsemi.com/thread/345923?ContentTypeID=1</link><pubDate>Tue, 04 Jan 2022 13:38:02 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:e259d445-a9c3-4ad5-aeec-2047fccaed84</guid><dc:creator>danmcb</dc:creator><description>&lt;p&gt;sure. Thanks for responding. We do it in several steps:&lt;/p&gt;
&lt;p&gt;&lt;br /&gt;&lt;code&gt;nrfutil.exe settings generate --no-backup --family NRF52 --key-file private.key --application my_app.hex --application-version 0 --bootloader-version 0 --bl-settings-version 2 bl_setting.hex&lt;/code&gt;&lt;br /&gt;&lt;code&gt;mergehex.exe --merge ../path/to/dfu_bootloader.hex bl_setting.hex --output bl.hex&lt;/code&gt;&lt;br /&gt;&lt;code&gt;mergehex.exe --merge my_app.hex bl.hex --output bl_app.hex&lt;/code&gt;&lt;br /&gt;&lt;code&gt;mergehex$.exe --merge $(SDK_ROOT)/components/softdevice/s112/hex/s112_nrf52_7.2.0_softdevice.hex bl_app.hex --output the_image.hex&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;Then:&lt;/p&gt;
&lt;p&gt;&lt;code&gt;nrfjprog.exe -f nrf52 --snr $(SNR) --program the_image.hex&amp;nbsp; --sectorerase&lt;/code&gt;&lt;br /&gt;&lt;code&gt;nrfjprog.exe -f nrf52 --snr $(SNR) --reset&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;Look to me to be the same as your example?&lt;code&gt;&lt;/code&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Please clarify/explain use of --sectorerase with nrfjprog</title><link>https://devzone.nordicsemi.com/thread/345909?ContentTypeID=1</link><pubDate>Tue, 04 Jan 2022 12:58:00 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:a11a598a-f41b-4d28-a4b8-5ae73caa9602</guid><dc:creator>Amanda Hsieh</dc:creator><description>[quote user=""]we see that the bootloader settings at top of FLASH do not match the .hex file they were built from - even though step 4 completed without error (log file shows no indication anything did not work).[/quote]
&lt;p&gt;How do you merge the images in the step. 3? Can you provide the commands you used? The mergehex supports to combine up to three .HEX files into one single file, so I usually merge and program the images with the following commands:&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;nrfjprog --eraseall
mergehex -m bootloader.hex softdevice.hex -o SD_BL.hex
nrfjprog --program SD_BL.hex --chiperase -r
nrfutil settings generate --family NRF52 --application ble_app.hex --application-version 1 --bootloader-version 1 --bl-settings-version 1 settings.hex
mergehex -m ble_app.hex settings.hex -o merged.hex
nrfjprog --program merged.hex --sectorerase -r&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;Please let me know this flow help the issue or not.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;-Amanda&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Please clarify/explain use of --sectorerase with nrfjprog</title><link>https://devzone.nordicsemi.com/thread/345887?ContentTypeID=1</link><pubDate>Tue, 04 Jan 2022 12:13:16 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:727a1ac2-fe47-4983-b35d-8196c35cc565</guid><dc:creator>danmcb</dc:creator><description>&lt;p&gt;&amp;quot;If --sectorerase is given, only the targeted&amp;nbsp;non-volatile memory pages excluding UICR will&amp;nbsp;be erased.&amp;quot;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;our case seems to contradict this. The hex file defintely has information in the bootloader settings part (&lt;/p&gt;
&lt;p&gt;0x0007 F000 on an nRF52832) that was NOT correctly written to FLASH using this flag.&lt;/p&gt;
&lt;p&gt;I don&amp;#39;t know if that page was programmed but not erased (which would not work because the FLASH driver can only write 1&amp;#39;s to 0&amp;#39;s) or not programmed at all and what I saw was from the last program cycle. But at any rate, the behaviour we observe does not match your description.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Please clarify/explain use of --sectorerase with nrfjprog</title><link>https://devzone.nordicsemi.com/thread/345883?ContentTypeID=1</link><pubDate>Tue, 04 Jan 2022 11:57:35 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:57033c33-2ca3-4356-89e6-21daf9ac544e</guid><dc:creator>Amanda Hsieh</dc:creator><description>&lt;p&gt;Hi,&amp;nbsp;&lt;/p&gt;
&lt;p&gt;You can type &amp;quot;&lt;code&gt;nrfjprog -h&lt;/code&gt;&amp;quot; command to get the explanation.&amp;nbsp;If --sectorerase is given, only the targeted&amp;nbsp;non-volatile memory pages excluding UICR will&amp;nbsp;be erased. I would suggest to use &amp;quot;--chiperase&amp;quot;, then all the&amp;nbsp;available user non-volatile memory, including UICR, will be erased before programming.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;The&amp;nbsp;&lt;a title="Memory layout" href="https://infocenter.nordicsemi.com/topic/sdk_nrf5_v17.1.0/lib_bootloader.html?cp=8_1_3_5_0_7#lib_bootloader_memory"&gt;Memory layout&lt;/a&gt;&amp;nbsp;doc&amp;nbsp;describes the layout of bootload, SD, app, and settings in the memory.&amp;nbsp;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Regards,&lt;br /&gt;Amanda&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>