<?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>Erase UICR and merge Bootloader problem</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/50948/erase-uicr-and-merge-bootloader-problem</link><description>Hello, 
 I am using NRF52832 with soft device 13.0.0 and Nordic&amp;#39;s bootloader from the examples. 
 What I do is develop an application which stores some values in uicr registers 0-7 (no soft device enabled yet). Before storing the values I erase the uicr</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Mon, 02 Sep 2019 14:15:06 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/50948/erase-uicr-and-merge-bootloader-problem" /><item><title>RE: Erase UICR and merge Bootloader problem</title><link>https://devzone.nordicsemi.com/thread/207442?ContentTypeID=1</link><pubDate>Mon, 02 Sep 2019 14:15:06 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:559c899b-23ee-48d8-9270-d56e9834a638</guid><dc:creator>Dimitris</dc:creator><description>&lt;p&gt;Hello Hung Bui,&amp;nbsp;&lt;/p&gt;
&lt;p&gt;you were right, the addresses you mentioned at uicr registers, were not restored properly after erase and write.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;After some changes and some checks on whether the registers were restored properly after the erase, the programming of the device was successful and the application, the bootloader and the soft device were verified correctly.&lt;/p&gt;
&lt;p&gt;Thank you for your help!&amp;nbsp;&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Erase UICR and merge Bootloader problem</title><link>https://devzone.nordicsemi.com/thread/204806?ContentTypeID=1</link><pubDate>Mon, 19 Aug 2019 13:48:23 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:a16813f8-e670-477d-82aa-27b474189e0e</guid><dc:creator>Hung Bui</dc:creator><description>&lt;p&gt;I don&amp;#39;t think you can write a whole page by just calling&amp;nbsp;*NRF_UICR = uicr_cpy; You need to write them word by word (32 bit)&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Could you please check after the erase and write to the UICR; you have the correct start address of the bootloader (NRF_UICR_BOOTLOADER_START_ADDRESS) at :&amp;nbsp;NRF_UICR_BASE + 0x14&lt;/p&gt;
&lt;p&gt;And the correct address of the MBR Param page address at&amp;nbsp;NRF_UICR_BASE + 0x18&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Erase UICR and merge Bootloader problem</title><link>https://devzone.nordicsemi.com/thread/204692?ContentTypeID=1</link><pubDate>Mon, 19 Aug 2019 09:54:16 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:2d029114-f820-4231-9ade-d5c04092fb09</guid><dc:creator>Dimitris</dc:creator><description>&lt;p&gt;Hello Hung Bui,&lt;/p&gt;
&lt;p&gt;I tried programming the device with nrfjprog and indeed verification did succeed. However the bootloader was not programmed again. I could see that from nRFGo Studio, but also tried it in the device. We have a button that enters bootloader mode. When pressed the device just restarts and does not enter DFU.&lt;/p&gt;
&lt;p&gt;Here are the screenshots from nrfjprog and nRFGo Studio (after programming with nrfjprog).&lt;/p&gt;
&lt;p&gt;&lt;img alt=" " src="https://devzone.nordicsemi.com/resized-image/__size/320x240/__key/communityserver-discussions-components-files/4/nrfjprog-cmd.jpg" /&gt;&lt;/p&gt;
&lt;p&gt;&lt;img alt=" " src="https://devzone.nordicsemi.com/resized-image/__size/320x240/__key/communityserver-discussions-components-files/4/goStudio.jpg" /&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;When I comment the&amp;nbsp;NRF_NVMC-&amp;gt;ERASEUICR = 1; command and repeat the same procedure, everything runs smoothly, and the when the button is pressed the device enters DFU normally.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;img alt=" " src="https://devzone.nordicsemi.com/resized-image/__size/320x240/__key/communityserver-discussions-components-files/4/nrfjprogworking.jpg" /&gt;&lt;/p&gt;
&lt;p&gt;&lt;img alt=" " src="https://devzone.nordicsemi.com/resized-image/__size/320x240/__key/communityserver-discussions-components-files/4/goStudioworking.jpg" /&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;I tried backing up the uicr registers and rewrite them after the erase but that did not solve the problem. Here is the code I used: ( I did not back up the customer registers)&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;	NRF_UICR_Type uicr_cpy = *NRF_UICR;
	
	for(int x=0; x&amp;lt;32;x++){
		uicr_cpy.CUSTOMER[x] = 0xFFFFFFFF;
	}
	
	//erase
	 NRF_NVMC-&amp;gt;CONFIG = NVMC_CONFIG_WEN_Een &amp;lt;&amp;lt; NVMC_CONFIG_WEN_Pos;
	 while (NRF_NVMC-&amp;gt;READY == NVMC_READY_READY_Busy){}
	 NRF_NVMC-&amp;gt;ERASEUICR = 1;
	 while (NRF_NVMC-&amp;gt;READY == NVMC_READY_READY_Busy){}

		//rewrite

		 
		 *NRF_UICR = uicr_cpy;
	&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;The problem is still there. I program the device with nrfjprog and although verification succeeds (only in nrfjprog), the bootloader is not programmed properly and would not start&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;The only thing that seems to work is the one I mentioned in my earlier reply, when I add this check before erasing uicr:&lt;/p&gt;
&lt;p&gt;if ( NRF_UICR-&amp;gt;CUSTOMER[0] != 0xFFFFFFFF ) { erase uicr }&lt;/p&gt;
&lt;p&gt;and changing slightly the way I call the function which erases uicr (instead of calling 2 wrapper functions I call only one - I move the code for erasing one level up, nothing else changes)&lt;/p&gt;
&lt;p&gt;Although this solution works, I am really curious why this happens...&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Erase UICR and merge Bootloader problem</title><link>https://devzone.nordicsemi.com/thread/204529?ContentTypeID=1</link><pubDate>Fri, 16 Aug 2019 13:32:12 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:7cb4cc00-0bb1-4f46-b4ee-7d30c1034638</guid><dc:creator>Hung Bui</dc:creator><description>&lt;p&gt;Hi Dimitris,&amp;nbsp;&lt;/p&gt;
&lt;p&gt;I would not suggest to use nRFGo Studio for programming. Please use nrfjprog.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;With nRFGo Studio the chip may not be halted between programming and verification. And if you do any flash modification in between it may result in verification failed.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Please try again with nrfjprog and provide us the log/screenshot.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Please note that even though there is part of the UICR is &amp;quot;reserved for customer&amp;quot; but when you erase the UICR the whole page is erased.You would need to make sure you back up the rest of UICR page and write it back after you erase.&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Erase UICR and merge Bootloader problem</title><link>https://devzone.nordicsemi.com/thread/204427?ContentTypeID=1</link><pubDate>Fri, 16 Aug 2019 08:57:55 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:08af8e99-4fc8-4963-b743-211d5cfcccbc</guid><dc:creator>Dimitris</dc:creator><description>&lt;p&gt;Thank you for the response,&lt;/p&gt;
&lt;p&gt;The data&amp;nbsp;that are stored in the uicr registers are connected to the hardware version of the device and some calibration values. They are stored once and remain there during the lifetime of the device. The only occasion where these registers are deleted and written again is when the device is re-calibrated.&lt;/p&gt;
&lt;p&gt;As for the uicr registers only the uicr customer registers are used, so I suppose it is safe to use them. I have done it in the past in another application (with a bootloader added also) and everything seemed to work fine.&lt;/p&gt;
&lt;p&gt;The weird thing is that when I add some code to check if the uicr customer register has data before deleting it, then the problem disappears&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;if ( NRF_UICR-&amp;gt;CUSTOMER[0] != 0xFFFFFFFF )	{
			
	 NRF_NVMC-&amp;gt;CONFIG = NVMC_CONFIG_WEN_Een &amp;lt;&amp;lt; NVMC_CONFIG_WEN_Pos;
	 while (NRF_NVMC-&amp;gt;READY == NVMC_READY_READY_Busy){}
	 NRF_NVMC-&amp;gt;ERASEUICR = 1;
	 while (NRF_NVMC-&amp;gt;READY == NVMC_READY_READY_Busy){}
}&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;I would understand it if the deletion of the uicr caused a crash after programming the device, during run time.&lt;/p&gt;
&lt;p&gt;I would expect for the device to program properly and then the application or bootloader to fail, not to see a problem during the programming of the device with the hex file.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;How is it possible for a line of code inside the application to have such an effect in the programming of the device? I checked the map file of the application and the soft device, application and bootloader areas do not overlap.&lt;/p&gt;
&lt;p&gt;How this line of code can create problems in the merging of the hex files, and can affect the programming of the device so that verification fails? And why programming the bootloader separately solves the problem?&lt;/p&gt;
&lt;p&gt;I understand these are a lot of questions but this seems like a rather strange problem to me.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Erase UICR and merge Bootloader problem</title><link>https://devzone.nordicsemi.com/thread/204144?ContentTypeID=1</link><pubDate>Wed, 14 Aug 2019 15:40:59 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:a9a3d1ac-449c-41c5-b960-5bfcf97e4f39</guid><dc:creator>Hung Bui</dc:creator><description>&lt;p&gt;Hi Dimitris,&amp;nbsp;&lt;/p&gt;
&lt;p&gt;When you use the bootloader you must be very careful with the UICR. This is because we store the bootloader address in the UICR. You can read about that &lt;a href="https://infocenter.nordicsemi.com/topic/com.nordic.infocenter.sdk5.v13.1.0/lib_bootloader.html?cp=5_5_5_3_4_0_1#lib_bootloader_memory"&gt;here&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;If you have some data that need to be changed more often, I would suggest to use a dedicated flash page to store, instead of using UICR. UICR is more of something like serial number, or hard coded configuration. And please be aware and avoid the address that is used by the bootloader.&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>