<?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>merging examples with DFU cause NRF_ERROR_NO_MEM</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/85223/merging-examples-with-dfu-cause-nrf_error_no_mem</link><description>Windows 10, Segger Embedded Studio V5.60a 
 nRF52833-DK (also nRF52840-DK, along with custom boards for each for later purpose) 
 SDK 17.1.0 S140 
 
 Hello, I&amp;#39;m trying to merge my project (NUS example, BAS, bonding, etc) with DFU bootloader OTA. 
 It</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Mon, 14 Mar 2022 14:09:07 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/85223/merging-examples-with-dfu-cause-nrf_error_no_mem" /><item><title>RE: merging examples with DFU cause NRF_ERROR_NO_MEM</title><link>https://devzone.nordicsemi.com/thread/357975?ContentTypeID=1</link><pubDate>Mon, 14 Mar 2022 14:09:07 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:311a445d-5183-47c9-ab8e-2909a92d653e</guid><dc:creator>Edvin</dc:creator><description>&lt;p&gt;I&amp;#39;ll continue here, so it shows up approximately chronologically &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; If you lack a reply button, try reloading the page a couple of times.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
[quote user="June20"]I haven&amp;#39;t dig deep into the example, all I can tell is that peripheral will enter dfu-mode due to ble package from the central. I want my ble app to run until I decided to connect to dfu device (other case/explanation will be welcomed). How is bootloader_start() triggered?[/quote]
&lt;p&gt;I believe what you want to do is to add the buttonless service to your custom application. Strictly speaking, you don&amp;#39;t need this service, but it will be recognized as a DFU target by nRF Connect for Mobile/Desktop if you include it. An alternative is to have a custom service/characteristic that enters DFU mode, like the dfu_buttonless_service does, and then connect to the dfu target (advertisements from the bootloader) after it resets.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;So let us assume you are using the DFU buttonless service for now. The workflow here is that you connect to the device (when the application with the buttonless service is running). Then, whenever you want to enter DFU mode, it will write to the buttonless service&amp;#39;s characteristic, which will trigger it to reset into DFU mode. In order to reset into DFU mode, it needs to tell the bootloader when it wakes up to not start the application as normal, but to start advertising in DFU mode.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;If you open the buttonless dfu example, you can see how this is done in&amp;nbsp;ble_dfu_buttonless_bootloader_start_prepare() in ble_dfu_unbonded.c. in ble_dfu_buttonless_bootloader_start_finalize() (called from ble_dfu_buttonless_bootloader_start_prepare()), you can see that it writes to the GPREGRET register using sd_power_gpregret_set(). This will write to a register that the bootloader will check when it starts. If it has the value that is set here, it will enter DFU mode. This is the minimum that you must do from your application before resetting.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Does that answer the question that you had?&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Edvin&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: merging examples with DFU cause NRF_ERROR_NO_MEM</title><link>https://devzone.nordicsemi.com/thread/357822?ContentTypeID=1</link><pubDate>Mon, 14 Mar 2022 08:11:08 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:e1e49194-4ed8-4b4c-a701-54467402425a</guid><dc:creator>June20</dc:creator><description>&lt;p&gt;I haven&amp;#39;t dig deep into the example, all I can tell is that peripheral will enter dfu-mode due to ble package from the central. I want my ble app to run until I decided to connect to dfu device (other case/explanation will be welcomed). How is bootloader_start() triggered?&lt;/p&gt;
&lt;p&gt;Edit: Sorry for adding reply here, I don&amp;#39;t see reply button below for some reason.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: merging examples with DFU cause NRF_ERROR_NO_MEM</title><link>https://devzone.nordicsemi.com/thread/357693?ContentTypeID=1</link><pubDate>Fri, 11 Mar 2022 14:11:12 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:5a8ca184-021b-44c0-834d-4cf919faacff</guid><dc:creator>Edvin</dc:creator><description>&lt;p&gt;The guide that you already linked to (&lt;a href="https://devzone.nordicsemi.com/guides/short-range-guides/b/software-development-kit/posts/getting-started-with-nordics-secure-dfu-bootloader"&gt;https://devzone.nordicsemi.com/guides/short-range-guides/b/software-development-kit/posts/getting-started-with-nordics-secure-dfu-bootloader&lt;/a&gt;) is good. But it only covers the basics on how to compile, flash and generate update images. I am not aware of any other guides on related topics, but most use cases are already answered on DevZone, so browsing older cases is not a bad idea.&lt;/p&gt;
&lt;p&gt;What exactly is it that you want to do? And what do you mean by &amp;quot;make decent scenario related to buttonless DFU&amp;quot;?&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Edvin&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: merging examples with DFU cause NRF_ERROR_NO_MEM</title><link>https://devzone.nordicsemi.com/thread/357533?ContentTypeID=1</link><pubDate>Fri, 11 Mar 2022 06:30:16 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:b1d399d1-f765-4142-bbed-2e48e3c963f9</guid><dc:creator>June20</dc:creator><description>&lt;p&gt;After couple of more attempts, I realized that I&amp;#39;ve been putting in wrong parameters.&lt;/p&gt;
&lt;p&gt;After combining ble buttonless dfu example with my project, I was able to make it run.&lt;/p&gt;
&lt;p&gt;I am not very familiar with topic related to DFU, is there a good guide how to make decent&lt;/p&gt;
&lt;p&gt;scenario related to buttonless DFU?&lt;/p&gt;
&lt;p&gt;thanks&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: merging examples with DFU cause NRF_ERROR_NO_MEM</title><link>https://devzone.nordicsemi.com/thread/356150?ContentTypeID=1</link><pubDate>Thu, 03 Mar 2022 20:35:50 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:8af67a38-c450-4e3a-9b44-1e951f01b497</guid><dc:creator>Edvin</dc:creator><description>[quote user="June20"]unfortunately my &amp;#39;attach debugger&amp;#39; doesn&amp;#39;t respond (it&amp;#39;s just running and not much response from debugger [/quote]
&lt;p&gt;If you try to set a breakpoint at the very start of main() in your application before you attach the debugger, is it reached? Have you turned off optimization in your project?&lt;/p&gt;
&lt;p&gt;Can you show me all the commands that you use to generate your bl-settings, and then program it?&lt;/p&gt;
&lt;p&gt;Can you also send me the files that you are trying to run? Will I be able to reproduce what you are seeing on a DK?&lt;/p&gt;
[quote user="June20"]&lt;p&gt;Does nrfjprog order matters??&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;[/quote]
&lt;p&gt;As long as you don&amp;#39;t reset the device between programming the files, it shouldn&amp;#39;t matter. That is why I added the line &amp;quot;nrfjprog --reset&amp;quot; at the end, to indicate that you shouldn&amp;#39;t call it between every &amp;quot;nrfjprog --program ...&amp;quot;.&lt;/p&gt;
[quote user="June20"]&lt;p&gt;PS, Programmer gave me this response, &amp;quot;Part of the HEX regions are out of the device memory size, but you can still proceed write operation&amp;quot; &amp;lt;- is this safe?&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;[/quote]
&lt;p&gt;I have seen this as well. It is a bug in nRF connect for Desktop, because it thinks that the UICR (starting at address 0x10001000) is outside the flash. However, it is not, and using nRF Connect for Desktop to program the device also programs the UICR. You can confirm this by programming the bootloader and reading out the UICR using:&lt;/p&gt;
&lt;p&gt;nrfjprog --memrd 0x10001000 --n 128.&lt;/p&gt;
&lt;p&gt;It doesn&amp;#39;t write much, but you should see two registers holding the addresses of the bootloader and some settings page. (It is written to the &lt;a href="https://infocenter.nordicsemi.com/topic/ps_nrf52833/uicr.html?cp=4_1_0_3_4_0_0#register.NRFFW-0-12"&gt;UICR-&amp;gt;NRFFW registers&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Edvin&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: merging examples with DFU cause NRF_ERROR_NO_MEM</title><link>https://devzone.nordicsemi.com/thread/355950?ContentTypeID=1</link><pubDate>Thu, 03 Mar 2022 08:49:51 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:641e2a47-d102-4e8d-b783-e99e62e394a6</guid><dc:creator>June20</dc:creator><description>&lt;p&gt;Okay, I assume I finally built bootloader. However, I didn&amp;#39;t go so well.&lt;/p&gt;
&lt;p&gt;I got hex file after building SDK/examples/dfu/secure_bootloader/pca10100_s140_ble (secure_bootloader_ble_s140_pca10100.hex)&lt;/p&gt;
&lt;p&gt;I got hex file of Softdevice from SDK/components\softdevice\s140\hex\s140_nrf52_7.2.0_softdevice.hex&lt;/p&gt;
&lt;p&gt;Built my application and nrfjprog all 4 hex(app, bootloader, bootloader setting, softdevice)&lt;/p&gt;
&lt;p&gt;unfortunately my &amp;#39;attach debugger&amp;#39; doesn&amp;#39;t respond (it&amp;#39;s just running and not much response from debugger + nothing on my mobile nRF Connect)&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Are there things I might have forgot?&lt;/p&gt;
&lt;p&gt;Does nrfjprog order matters??&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;PS, Programmer gave me this response, &amp;quot;Part of the HEX regions are out of the device memory size, but you can still proceed write operation&amp;quot; &amp;lt;- is this safe?&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Thanks for replies.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: merging examples with DFU cause NRF_ERROR_NO_MEM</title><link>https://devzone.nordicsemi.com/thread/355717?ContentTypeID=1</link><pubDate>Wed, 02 Mar 2022 08:37:33 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:71961c68-c6e3-4fbc-81d7-ac86d5f96362</guid><dc:creator>Edvin</dc:creator><description>[quote user="June20"]tutorial I was relying on[/quote]
&lt;p&gt;That is a good guide. I use to point at this one when someone have questions about DFU in the nRF5 SDK.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;I suggest that you consider upgrading to python 3.8, as most of our tools use that.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;You don&amp;#39;t need to use mergehex, really. Do you have nrfjprog, and does that work? If so, you can just program all the components separately:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;nrfjprog --program bl.hex
nrfjprog --program softdevice.hex
nrfjprog --program app.hex
nrfjprog --program bl_settings.hex
nrfjprog --reset&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;I am not sure how nRF Connect for Desktop handles several writes. The issue is that if the chip is flashed between the bootloader being flashed and the bl settings being flashed, then the bootloader will generate its own settings, and the bl_settings.hex will not be able to be programmed correctly. That is why I prefer to use nrfjprog.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;BR,&lt;br /&gt;Edvin&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: merging examples with DFU cause NRF_ERROR_NO_MEM</title><link>https://devzone.nordicsemi.com/thread/355690?ContentTypeID=1</link><pubDate>Wed, 02 Mar 2022 04:50:52 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:fb00568c-bc60-433b-bfab-9855f73e5d90</guid><dc:creator>June20</dc:creator><description>&lt;p&gt;Thanks for the reply!&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;You were right, it was due to lack of bootloader - I didn&amp;#39;t program the bootloader.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;So I did &amp;#39;nrfutil setting&amp;#39; (is nrfutil setting ... same as programming bootloader?)&lt;/p&gt;
&lt;p&gt;nrfutil settings generate --family NRF52 --application &amp;quot;my_app.hex&amp;quot; --application-version 0 --bootloader-version 0 --bl-settings-version 2 bootloader_setting_user.hex&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;I couldn&amp;#39;t use &amp;#39;mergehex&amp;#39;, my cmd promt didn&amp;#39;t recognize the command. (Python27)&lt;/p&gt;
&lt;p&gt;Instead, I used nRF Connect - Programmer v2.3.3.&lt;/p&gt;
&lt;p&gt;I added my &lt;span&gt;bootloader_setting_user&lt;/span&gt;.hex + my_application.hex + softdevice_s140.hex(found on dfu example) and programmed over it.&lt;/p&gt;
&lt;p&gt;Sadly it didn&amp;#39;t went well (Sometime same error from &amp;#39;attach debugger&amp;#39;, sometime no response, sometime hardfault error)&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;About bootloader programming, am I heading the right direction?&lt;/p&gt;
&lt;p&gt;I&amp;#39;m on Windows 10 + Python27, how do I get mergehex to work?&lt;/p&gt;
&lt;p&gt;Is it alright to use Programmer instead of mergehex?&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;BTW thanks for the &amp;#39;Attach Debugger&amp;#39; tip, I was using Segger Studio.&lt;/p&gt;
&lt;p&gt;I also rely on &amp;#39;Tera Term&amp;#39; to debug via serial.&lt;/p&gt;
&lt;p&gt;tutorial I was relying on:&amp;nbsp;&lt;a href="https://devzone.nordicsemi.com/guides/short-range-guides/b/software-development-kit/posts/getting-started-with-nordics-secure-dfu-bootloader"&gt;https://devzone.nordicsemi.com/guides/short-range-guides/b/software-development-kit/posts/getting-started-with-nordics-secure-dfu-bootloader&lt;/a&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: merging examples with DFU cause NRF_ERROR_NO_MEM</title><link>https://devzone.nordicsemi.com/thread/355396?ContentTypeID=1</link><pubDate>Mon, 28 Feb 2022 23:17:42 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:e0336125-1556-4735-a5ec-4054a70a8294</guid><dc:creator>Edvin</dc:creator><description>&lt;p&gt;Hello,&lt;/p&gt;
&lt;p&gt;If&amp;nbsp;&lt;span&gt;ble_dfu_buttonless_async_svci_init() returns 4, it basically means that there are no bootloader programmed. The buttonless dfu service checks that there is actually a bootloader present by reading out some register addresses. If there isn&amp;#39;t, it will fail.&amp;nbsp;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;So try flashing the bootloader as well. Unfortunately adding a bootloader makes it a bit more tricky to debug. What IDE are you using? If you are using Segger Embedded Studio, you can use &amp;quot;attach debugger&amp;quot; for the reasons I will explain now:&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;img src="https://devzone.nordicsemi.com/resized-image/__size/320x240/__key/communityserver-discussions-components-files/4/pastedimage1646089673166v1.png" alt=" " /&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;When a bootloader is flashed it will check on startup that the application has the correct signature. If you just program the softdevice, application and bootloader, then the application doesn&amp;#39;t have the correct signature. So what we need to do is to generate something called bootloader settings. You can generate this using nrfutil (&amp;quot;nrfutil &lt;a href="https://infocenter.nordicsemi.com/topic/ug_nrfutil/UG/nrfutil/nrfutil_settings_generate_display.html?cp=10_7_6"&gt;settings generate&lt;/a&gt; --help&amp;quot;).&amp;nbsp;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;If you generate a DFU image using nrfutil, then this image is signed, and when the image is transferred to the DFU target, it will carry on that signature and CRC check and store it&amp;#39;s own generated bootloader settings, so this is what we are essensially bypassing by generating and programming the bootloader settings directly.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;The next obstacle when you want to debug is that when you start a debug session in an IDE, then the IDE will most likely program something other than the .hex file that you used for your bootloader settings. It will use some other file that is almost identical, but since changing a single bit will change the signature of the application, the bootloader will reject it, and enter DFU mode. This is why you need to use the &amp;quot;attach debugger&amp;quot; method. By doing so, you are telling your IDE that &amp;quot;I have already flashed the application. Just start debugging without uploading anything&amp;quot;. If you follow this, you should be able to debug when a bootloader is flashed. If you are not using Segger Embedded Studio, look for a similar option. If your IDE doesn&amp;#39;t provide one, you can use Segger&amp;#39;s debugging tool Ozone, which does have this option, and it works with almost all build files (Keil, IAR, armgcc, etc...).&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Since compiling, generating bootloader settings, flashing application and bootloader settings can be a bit tedious every single time you change a tiny piece of your code, I suggest that you write some sort of script (.bat scripts are easy to use on Windows). Just make it generate all the files from the .hex file that your compiler spits out, and then flash the application and bootloader settings (using nrfjprog:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;nrfutil settings generate -- ....
nrfjprog --program &amp;lt;path_to_app.hex&amp;gt; --verify --sectorerase
nrfjprog --program &amp;lt;path_to_bootloader_settings.hex&amp;gt; --verify --sectorerase
nrfjprog --reset&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;I hope this gave some clarity. Let me know if anything was unclear.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>