<?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>Erasing gazell pairing memory.</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/61741/erasing-gazell-pairing-memory</link><description>Environment - windows 10, ses release 4.12 nRFconnect programmer 3.3.3 using gnu C nRF52840 dongle programming with DFU. No softdevice, Gazell only. 
 I have two hex files, one containing my nrf52840 dongle program and the other containing the program</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Tue, 26 May 2020 15:01:06 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/61741/erasing-gazell-pairing-memory" /><item><title>RE: Erasing gazell pairing memory.</title><link>https://devzone.nordicsemi.com/thread/251755?ContentTypeID=1</link><pubDate>Tue, 26 May 2020 15:01:06 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:419e95f2-6ffc-4dcf-bc76-09d2a0aafb0c</guid><dc:creator>RayFoulkes</dc:creator><description>&lt;p&gt;Hi Hung Bui. Thanks very much for the explanation. I did not understand the consequences of the bootloader considering my data area as part of the program. I imagined that the start address of my program was simply hard-wired into the hardware for start-up once I had written the NVRAM with my program. I did not realise that, after programming with the DFU bootloader, the bootloader still intercepted the start-up sequence and carried out checks. I thought to make that happen I had to add bootloader functions to my program. Now all is clear - once the bootloader is loaded onto a processor it ALWAYS runs first, even if it doesn&amp;#39;t enable the USB port if it finds a valid program loaded.&lt;/p&gt;
&lt;p&gt;I did know about the use of the DK to both load and examine memory but unfortunately I am stuck a very long way from my electronic workshop containing all my sockets, cables etc. The only thing I brought with me was some dongles and the DKs. I could start ordering parts but there is no point if the bootloader is guaranteed to fail the crc check after Gazell writes into the NVRAM.&lt;/p&gt;
[quote userid="2121" url="~/f/nordic-q-a/61741/erasing-gazell-pairing-memory/251732"]So I think the easiest solution is still to use 2 binaries, one to erase flash, and one to start normal application.[/quote]
&lt;p&gt;That was my chosen work-around.&lt;/p&gt;
[quote userid="2121" url="~/f/nordic-q-a/61741/erasing-gazell-pairing-memory/251732"]Or you can include a feature in the code to erase that 4kB of data when you press a button or when you send a command.[/quote]
&lt;p&gt;I already use the white button on the device end to permit re-pairing but that is used in the field, not during device preparation.&lt;/p&gt;
&lt;p&gt;The reason I was trying to do this in one step is not for me or some other techie but because there may well be a thousand or two of these being programmed (and potentially re-programmed and re-purposed) by people who are not that technologically inclined. Every step I add, including holding finger on button when powering up, just adds another operation to go wrong.&lt;/p&gt;
&lt;p&gt;I have already labelled one .hex as &amp;quot;erase.hex&amp;quot; so for re-purposing, they will just have to load that first. Unfortunately the volumes are not sufficient to warrant setting up an auto-programming system.&lt;/p&gt;
&lt;p&gt;Thank you once again for your efforts - I really appreciate the help of the community - this software and hardware environment is not the simplest to understand.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Erasing gazell pairing memory.</title><link>https://devzone.nordicsemi.com/thread/251732?ContentTypeID=1</link><pubDate>Tue, 26 May 2020 13:45:22 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:422984e5-ec25-4e93-b241-009e4057f57c</guid><dc:creator>Hung Bui</dc:creator><description>&lt;p&gt;Hi Ray,&lt;br /&gt;&lt;br /&gt;&lt;/p&gt;
&lt;p&gt;You can read the hex dump by connecting a programmer (nRF52 DK) to the dongle. This requires you to solder the header on port P1. and then use a 10 pin cable to connect the debug out port on the DK to this header. This way you can&amp;nbsp;access the dongle flash directly without using the bootloader (you can program the dongle ). Then you can read the code out either using nrf connect or use &amp;quot;nrfjprog.exe --readcode&amp;quot; command line tool.&amp;nbsp;&lt;br /&gt;&lt;br /&gt;But I think I found what could be wrong here. It&amp;#39;s the CRC check failed. Most likely because your code will write to the 4K &amp;quot;blank area&amp;quot; to store gazell data. And because of that CRC will fail. The bootloader expecting your application as a whole from 0x1000 to 0x15FFF. And any modification to flash in this range will result in CRC check fail on booting. And the bootloader will enter DFU mode.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;When you don&amp;#39;t include the &amp;quot;blank area&amp;quot; the bootloader wont check the address from 0x1000 to 0x15FFF but only to the last address of your code, meaning writing to 0x15000 won&amp;#39;t affect CRC.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;So I think the easiest solution is still to use 2 binaries, one to erase flash, and one to start normal application. Or you can include a feature in the code to erase that 4kB of data when you press a button or when you send a command. For example,&amp;nbsp;when application detect you hold SW1 when plug the dongle in USB port, it erases the 4kB flash.&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Erasing gazell pairing memory.</title><link>https://devzone.nordicsemi.com/thread/251679?ContentTypeID=1</link><pubDate>Tue, 26 May 2020 10:42:31 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:a2b6458e-3b51-4dbf-9e6c-b70b2f537bed</guid><dc:creator>RayFoulkes</dc:creator><description>&lt;p&gt;You wrote&lt;/p&gt;
[quote userid="2121" url="~/f/nordic-q-a/61741/erasing-gazell-pairing-memory/251553"]What we can do is to read out the hex dump from the dongle, and check the difference.&amp;nbsp;[/quote]
&lt;p&gt;I do not know&amp;nbsp; how to read the memory of a Dongle. When used in DFU mode, the menu items for reading and saving the contents of the memory of the dongle are always greyed out. The only buttons ever enabled are &amp;quot;reset&amp;quot; and &amp;quot;write&amp;quot;. I have confirmed with Nordic that that is always the case. You cannot do anything but write to the dongle using the programmer.&lt;/p&gt;
&lt;p&gt;I do have two hardware sdk so I do know that, if I added a socket to the dongle and had the appropriate lead, I maybe could use the Jlink buried in the sdk to read the memory but I don&amp;#39;t have the components at the moment to do that.&lt;/p&gt;
[quote userid="2121" url="~/f/nordic-q-a/61741/erasing-gazell-pairing-memory/251553"]I assume your application already made with start address at 0x1000 ? (to avoid the MBR)[/quote]
&lt;p&gt;Yes, you will see that from the screen captures that I posted. Also, please remember, without the zeroing the memory, the application works fine as does the DFU after I press the reset button to trigger it. (my application does not know about DFU). I have checked very carefully, there is no difference in the .hex files in the part which contain the program between the ones that FFFFFFFF the memory and the ones that do not.&lt;/p&gt;
[quote userid="2121" url="~/f/nordic-q-a/61741/erasing-gazell-pairing-memory/251553"]The question is why it worked for the firmware with no 4K of blank at 0x15000 and it didn&amp;#39;t work when there is that 4K.&amp;nbsp;[/quote]
&lt;p&gt;Exactly so. Why does blinky work, and not my application?&lt;/p&gt;
[quote userid="2121" url="~/f/nordic-q-a/61741/erasing-gazell-pairing-memory/251553"]My assumption is that in the binary generated, there will be all 0xFFFFFFFF all the way from the end of your application until address 0x15FFF.[/quote]
&lt;p&gt;That would be fine with me.&lt;/p&gt;
&lt;p&gt;I am wondering whether to give up on trying to reset the memory at program load time using the programmer. It will only be of importance in the case where the dongles are being re-purposed i.e. writing a new program and changing from Gazell device to host or vice versa. I might be able to write a program to detect the change of role and zero the memory myself during initialisation.&lt;/p&gt;
&lt;p&gt;Thank you for the references for the DFU - I had a quick look, but studying that will take more than a few minutes on a Tuesday morning!&lt;/p&gt;
&lt;p&gt;Thank you for your attention,&lt;/p&gt;
&lt;p&gt;Regards, Ray&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Erasing gazell pairing memory.</title><link>https://devzone.nordicsemi.com/thread/251675?ContentTypeID=1</link><pubDate>Tue, 26 May 2020 10:27:23 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:87d076c3-a832-46e4-a9f3-01f623e7f58c</guid><dc:creator>RayFoulkes</dc:creator><description>&lt;p&gt;Hello again Hung Bui, OK, now I am baffled - I am unable to replicate the problem using Blinky. I used V16 SDK, recompiled blinky for the dongle, then edited the .hex file to include the zeroing of the memory from 15000. When I load it into nRFconnect programmer it shows two segments - one the original blinky and the section that I want reset. I load this into a clean dongle and it works just fine. I load my program over it and that only goes back to DFU.&lt;/p&gt;
&lt;p&gt;I include some images (I hope). The first are blinky examples showing the result in the programmer:&lt;/p&gt;
&lt;p&gt;&lt;img alt="Programmer before writing." src="https://devzone.nordicsemi.com/resized-image/__size/640x480/__key/communityserver-discussions-components-files/4/blinky1.jpg" /&gt;&lt;/p&gt;
&lt;p&gt;The above shows the programmer after loading the file but before writing (for the second time) to the dongle. It shows the band of memory to be set to FFFFFFFF above the program.&lt;/p&gt;
&lt;p&gt;&lt;img alt="Showing the dimensions of the area to " src="https://devzone.nordicsemi.com/resized-image/__size/640x480/__key/communityserver-discussions-components-files/4/blinky2.jpg" /&gt;&lt;/p&gt;
&lt;p&gt;The above is the same showing the size of the FFFFFFFF band. Just a note - there seems to be no relation with respect to scaling between the two windows. i.e. Bytes to height varies from window to window.&lt;/p&gt;
&lt;p&gt;&lt;img alt="My app" src="https://devzone.nordicsemi.com/resized-image/__size/640x480/__key/communityserver-discussions-components-files/4/myapp1.jpg" /&gt;&lt;/p&gt;
&lt;p&gt;The above shows my application loaded into the programmer. When this is written and the dongle re-powered, it just goes into DFU mode immediately.&lt;/p&gt;
&lt;p&gt;I will write a bit more in a subsequent response - I am a bit disappointed that I cannot replicate the problem in Blinky. Maybe I will try with a Gazell example next. (post - note OOPS I cannot do that because the gazell examples do not include the pca10059 nor do they support SES and that would be a big job for me to covert them).&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Erasing gazell pairing memory.</title><link>https://devzone.nordicsemi.com/thread/251568?ContentTypeID=1</link><pubDate>Mon, 25 May 2020 20:23:48 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:848f2940-9acf-4ea7-a314-3d911f1f97d7</guid><dc:creator>RayFoulkes</dc:creator><description>&lt;p&gt;Hi Hung Bui,&amp;nbsp; I will respond to your answer in detail tomorrow. I hope that I can make a .hex file of the blinky example with the &amp;quot;zero memory&amp;quot; built in. If I can I will post that as well.&lt;/p&gt;
&lt;p&gt;I will also study the DFU protocol which looks interesting.&lt;/p&gt;
&lt;p&gt;Thanks for your attention.&lt;/p&gt;
&lt;p&gt;Regards, Ray&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Erasing gazell pairing memory.</title><link>https://devzone.nordicsemi.com/thread/251553?ContentTypeID=1</link><pubDate>Mon, 25 May 2020 15:40:56 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:d1b387dc-0969-4d8e-8d19-45ffbbb96df4</guid><dc:creator>Hung Bui</dc:creator><description>&lt;p&gt;Hi Raymond,&amp;nbsp;&lt;/p&gt;
&lt;p&gt;The protocol that nRF Connect uses to program the nRF528540 dongle is the DFU protocol.&amp;nbsp;The nRF Connect automatically switch the dongle to bootloader mode and flash the board via the bootloader. The USB bootloader can be found here:&amp;nbsp;&lt;a href="https://infocenter.nordicsemi.com/topic/sdk_nrf5_v16.0.0/ble_sdk_app_open_bootloader.html?cp=7_1_4_4_2"&gt;https://infocenter.nordicsemi.com/topic/sdk_nrf5_v16.0.0/ble_sdk_app_open_bootloader.html?cp=7_1_4_4_2&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;The protocol is here:&amp;nbsp;&lt;a href="https://infocenter.nordicsemi.com/topic/sdk_nrf5_v16.0.0/lib_dfu_transport.html?cp=7_1_3_5_2"&gt;https://infocenter.nordicsemi.com/topic/sdk_nrf5_v16.0.0/lib_dfu_transport.html?cp=7_1_3_5_2&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;The nRF Connect when given a hex file, will first convert it to a binary file. This is the place where your 4K of all 0xFFFFFFFF is realized. My assumption is that in the binary generated, there will be all 0xFFFFFFFF all the way from the end of your application until address 0x15FFF.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;NRF Connect will send all these 0xFFFFFFFF to the bootloader, and the bootloader will also write 0xFFFFFFFF into the chip, there will be no check.&lt;/p&gt;
&lt;p&gt;The question is why it worked for the firmware with no 4K of blank at 0x15000 and it didn&amp;#39;t work when there is that 4K.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;What we can do is to read out the hex dump from the dongle, and check the difference.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;From what you described that the device enter bootloader without going to the application, it may suggest that the CRC check was failed.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;If you can send us a sample hex files of a very simple application (blinking LED for example) one works and one doesn&amp;#39;t we can try to figure out the issue.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;I assume your application already made with start address at 0x1000 ? (to avoid the MBR)&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Erasing gazell pairing memory.</title><link>https://devzone.nordicsemi.com/thread/251519?ContentTypeID=1</link><pubDate>Mon, 25 May 2020 13:54:57 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:17b6c996-4227-42d5-99fb-badc5b467721</guid><dc:creator>RayFoulkes</dc:creator><description>&lt;p&gt;OOPs, I have just realised that there is a problem with the strategy of writing FFFFFFFF to every 32 bit word in the memory allocated to the Gazell database. If nRFconnect programmer is stupid enough to actually write FFFFFFFF (as opposed to recognising that, on an erased page, it will have no effect), then that will consume one &amp;quot;32 bit write&amp;quot; of the number permitted before the next erase. On the nRF52840 that number of permitted writes is only 2 - half the writes already gone as a result of my attempt at initialisation. Can anyone confirm whether nRFconnect programmer does actually write 32 bit words that are all FFFFFFFF or just leaves them erased?&lt;/p&gt;
&lt;p&gt;It would be REALLY nice if someone could document what the nRFconnect programmer actually does - or have I said that before?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>