<?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>Secure Bootloader with DFU will not start Valid Application</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/29121/secure-bootloader-with-dfu-will-not-start-valid-application</link><description>I have been at this for a few days now so I need to ask for help. 
 Configuration: 
 
 
 SDK13 
 
 
 SD 4.0.2 
 
 
 NRF52832, custom board 
 
 
 Linux (Mint) dev system 
 
 
 Actions taken: 
 
 
 Using the blog post at devzone.nordicsemi</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Thu, 23 Nov 2017 15:53:28 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/29121/secure-bootloader-with-dfu-will-not-start-valid-application" /><item><title>RE: Secure Bootloader with DFU will not start Valid Application</title><link>https://devzone.nordicsemi.com/thread/115661?ContentTypeID=1</link><pubDate>Thu, 23 Nov 2017 15:53:28 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:9abf53e8-94ff-4a17-8f2d-00f4adb6e639</guid><dc:creator>Hung Bui</dc:creator><description>&lt;p&gt;@Dev: The bootloader has been tested before release, and many users used it but didn&amp;#39;t have the same issue.&lt;/p&gt;
&lt;p&gt;It&amp;#39;s very strange that you tried with fresh SDK and still have the issue. Maybe you can send us your bootloader, your .zip (with blinky application) that we can test here.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Secure Bootloader with DFU will not start Valid Application</title><link>https://devzone.nordicsemi.com/thread/115659?ContentTypeID=1</link><pubDate>Thu, 23 Nov 2017 15:15:45 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:29713d0a-3dfd-4cdb-9828-6c09e3445e97</guid><dc:creator>Dev</dc:creator><description>&lt;p&gt;I have come to the following conclusions:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;The secure BL requires that an application be sent twice before it runs. There is a problem in the BL that mixes up the banks and believes that the app is no correct after DFU. Sending the app again places it in the other bank (0x1F000) and it runs just fine. This occurred with the HRM example, completely unchanged (using the test hex file).&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Building a &amp;#39;private&amp;#39; version of the BL and building HRM app with the private key works exactly like the example versions, it requires sending twice to work.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Debug text is not sent when the BL operates. The HRM app has debug output and it is not visible. This might explain why my app appeared not to work.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Having built an App with LED output and sent it (Twice), it runs.&lt;/p&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;This is all with the SDK downloaded clean.&lt;/p&gt;
&lt;p&gt;I will now proceed to see what I can do about not having any debug text available although that is not critical - I can develop with a BL and only use the BL when doing DFU etc.&lt;/p&gt;
&lt;p&gt;However, the issue with the BL, which seems to make errors with the banks etc. needs to be looked at, we require the newly-installed APP to run at startup. I assume I will have to invalidate the old App when installing the new one.&lt;/p&gt;
&lt;p&gt;I suspect that I will have to download the Application and flash it, with settings, and then reset the device and make it enter the bootloader using the buttonless mechanism.&lt;/p&gt;
&lt;p&gt;Thanks for your advice in any case.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Secure Bootloader with DFU will not start Valid Application</title><link>https://devzone.nordicsemi.com/thread/115658?ContentTypeID=1</link><pubDate>Thu, 23 Nov 2017 14:04:24 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:62239e02-7a9a-4937-94e2-fbcc5ba424a2</guid><dc:creator>Dev</dc:creator><description>&lt;p&gt;My application works correctly without the BL, no problem.&lt;/p&gt;
&lt;p&gt;I have tried flashing the BL, SD and the App and settings with no success.&lt;/p&gt;
&lt;p&gt;It is already a simple application, it just prints Hello.
I added a buzzer sound which works on our board only, but that also works no problem without the BL present.&lt;/p&gt;
&lt;p&gt;I have now done the following to gain more information:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;I have downloaded a new copy SDK13 to ensure any changes made locally are no longer present, because another dev worked on it before.&lt;/li&gt;
&lt;li&gt;I built the secure BL, with only the following changes:
a. Add the micro-ecc elements
b. Add the required gcc settings to make it build
c. Change the BL RAM settings and rebuild when the SD said they were not a match&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;I also have switched to the Nordic dev board to ensure there is no compatibility issue.&lt;/p&gt;
&lt;p&gt;I flashed the BL+SD as before and used the Toolbox to send the HRM test application package to the device.&lt;/p&gt;
&lt;p&gt;This flashed to 0x22000, it says but, after it completed, the debug said&lt;/p&gt;
&lt;p&gt;:INFO:Running SD version check ==============
:INFO:Successfully ran the postvalidation check!
:INFO:Invalidating old application in bank 0.
:DEBUG:Erasing old settings at: 0x0007f000
:DEBUG:Waiting for other flash operation to finish.
:DEBUG:Waiting for other flash operation to finish.
:DEBUG:Erasing: 0x0007f000, num: 1
:DEBUG:Writing 0x00000057 words
:DEBUG:Writing settings...
:DEBUG:Sending Response: [0x4, 0x1]
:INFO:Inside main
:DEBUG:In nrf_bootloader_init
:DEBUG:In real nrf_dfu_init
:DEBUG:running nrf_dfu_settings_init
:DEBUG:Enter nrf_dfu_continue
:DEBUG:Valid App
:DEBUG:Enter nrf_dfu_app_continue
:DEBUG:Erasing: 0x0001f000, num: 1
:ERROR:Invalid data during compare: target: 0x0001f000, src: 0x00022000
:DEBUG:Could not continue DFU operation: 0x0000000e&lt;/p&gt;
&lt;p&gt;As you can see, it did not run.&lt;/p&gt;
&lt;p&gt;I uploaded the app again without erasing anything and it flashed to 0x1f000 this time.&lt;/p&gt;
&lt;p&gt;:DEBUG:Enter nrf_dfu_find_cache
:DEBUG:Bank content
:DEBUG:Bank type: 0
:DEBUG:Bank 0 code: 0x00: Size: 10328
:DEBUG:Bank 1 code: 0x01: Size: 37380
:DEBUG:No previous, using bank 0&lt;/p&gt;
&lt;p&gt;Note: It did not see an app in bank 0 from before but it did see an app in bank 1&lt;/p&gt;
&lt;p&gt;After DFU finished, the debug said:&lt;/p&gt;
&lt;p&gt;:DEBUG:Sending Response: [0x4, 0x1]
:DEBUG:In nrf_bootloader_init
:DEBUG:In real nrf_dfu_init
:DEBUG:running nrf_dfu_settings_init
:DEBUG:Enter nrf_dfu_continue
:DEBUG:Valid App
:DEBUG:Enter nrf_dfu_app_is_valid
:DEBUG:Return true. App was valid
:DEBUG:Enter nrf_dfu_app_is_valid&lt;/p&gt;
&lt;p&gt;###RTT Client: Connection closed by J-Link DLL. Going to reconnect.
###RTT Client: Connecting to J-Link RTT Server via localhost:19021  Connected.
SEGGER J-Link V6.18 - Real time terminal output
J-Link OB-SAM3U128-V2-NordicSemi compiled Jul 24 2017 17:30:12 V1.0, SN=682396899
Process: JLinkExe&lt;/p&gt;
&lt;p&gt;And disconnected.&lt;/p&gt;
&lt;p&gt;If I reset, it repeats:&lt;/p&gt;
&lt;p&gt;:INFO:Inside main
:DEBUG:In nrf_bootloader_init
:DEBUG:In real nrf_dfu_init
:DEBUG:running nrf_dfu_settings_init
:DEBUG:Enter nrf_dfu_continue
:DEBUG:Valid App
:DEBUG:Enter nrf_dfu_app_is_valid
:DEBUG:Return true. App was valid
:DEBUG:Enter nrf_dfu_app_is_valid&lt;/p&gt;
&lt;p&gt;But , checking with the Toolbox App, I see that it is running.&lt;/p&gt;
&lt;p&gt;I will have to build my own version of the HRM App, with a private key and then move on to trying to see why my app cannot even send debug when the BL is present but works otherwise.&lt;/p&gt;
&lt;p&gt;FYI, we have a large App (130k) running quite happily on our board, with debug etc.&lt;/p&gt;
&lt;p&gt;There must be some clash with the App build and the BL build which prevents successful execution of the cut-down version. I cut it down to simplify the DFU development process.&lt;/p&gt;
&lt;p&gt;Thanks for the info and I will post results, one way or the other&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Secure Bootloader with DFU will not start Valid Application</title><link>https://devzone.nordicsemi.com/thread/115657?ContentTypeID=1</link><pubDate>Thu, 23 Nov 2017 13:20:50 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:4bd13f4f-227f-4593-9710-50f5ef40c8c5</guid><dc:creator>Hung Bui</dc:creator><description>&lt;p&gt;Hi Dev,&lt;/p&gt;
&lt;p&gt;Please clarify:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;If you flash SD+BL then flash application + bootloader setting, would the application works ? Have you check if the application actually entered ? You can run a debugger and put a break point in the application code to check. Or you can first test with very simple application for example blinking LED, just for testing.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Have you tried to do DFU with BLE example in the SDK ble_app_hrs for example ?&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;I suspect that your application was actually updated properly and branched to successfully but when running it crashes for some reasons (something used by the bootloader and then the application also use and something wrong with the register cause an issue).&lt;/p&gt;
&lt;p&gt;You can do &amp;quot;nrfjprog --readcode&amp;quot; to read the hex dump and then compare with when you flash SD+APP normally and see if there is anything different.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Secure Bootloader with DFU will not start Valid Application</title><link>https://devzone.nordicsemi.com/thread/115656?ContentTypeID=1</link><pubDate>Thu, 23 Nov 2017 11:54:16 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:38e805c6-c9fb-4e8d-a838-eddab9a3db29</guid><dc:creator>Dev</dc:creator><description>&lt;p&gt;After more investigation I have found further issues with the BL.&lt;/p&gt;
&lt;p&gt;The DFU shows text indicating that a given bank is being programmed...&lt;/p&gt;
&lt;p&gt;:INFO:Valid Data Create
:DEBUG:Erasing: 0x00022000, num: 1
:INFO:Creating object with size: 4096. Offset: 0x00000000, CRC: 0x00000000
:DEBUG:Sending Response: [0x1, 0x1]
:INFO:Storing 256 B at: 0x00022000
:INFO:Storing 256 B at: 0x00022100
:INFO:Storing 256 B at: 0x00022200
:INFO:Storing 256 B at: 0x00022300
:INFO:Storing 256 B at: 0x00022400&lt;/p&gt;
&lt;p&gt;and so on.&lt;/p&gt;
&lt;p&gt;However, when I read the flash before and after the operation, it reads thus.&lt;/p&gt;
&lt;p&gt;Before.
nrfjprog -f nrf52 --memrd 0x22000 --w 8 --n 8
0x00022000: FF FF FF FF FF FF FF FF&lt;/p&gt;
&lt;p&gt;nrfjprog -f nrf52 --memrd 0x1f000 --w 8 --n 8
0x0001F000: FF FF FF FF FF FF FF FF                           |........|&lt;/p&gt;
&lt;p&gt;After:
nrfjprog -f nrf52 --memrd 0x22000 --w 8 --n 8
0x00022000: FF FF FF FF FF FF FF FF                           |........|&lt;/p&gt;
&lt;p&gt;nrfjprog -f nrf52 --memrd 0x1f000 --w 8 --n 8
0x0001F000: 10 B5 05 4C 23 78 33 B9                           |...L#x3.|&lt;/p&gt;
&lt;p&gt;The DFU plainly programmed the 0X1F000 address despite saying that it was programming the 0x22000 address.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Secure Bootloader with DFU will not start Valid Application</title><link>https://devzone.nordicsemi.com/thread/115655?ContentTypeID=1</link><pubDate>Thu, 23 Nov 2017 10:38:55 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:b23308d2-7b23-4344-8d69-1d9c44478175</guid><dc:creator>Dev</dc:creator><description>&lt;p&gt;Also. I added debug after the call to sd_softdevice_vector_table_base_set in nrf_bootloader_app_start and noticed that that call does not return.&lt;/p&gt;
&lt;p&gt;So the problem would appear to be there rather than in the Application launch nrf_bootloader_app_start_impl itself.&lt;/p&gt;
&lt;p&gt;I assume the program Hex file creates a vector table at the start address of an Application?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Secure Bootloader with DFU will not start Valid Application</title><link>https://devzone.nordicsemi.com/thread/115654?ContentTypeID=1</link><pubDate>Thu, 23 Nov 2017 10:34:52 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:73f700ac-d069-41c6-80bf-4e23dba6bd8d</guid><dc:creator>Dev</dc:creator><description>&lt;p&gt;Of course, I am still looking at this and I have noted that the original question shows that the application is being flashed at 0x27000 and the Application is started at 0x1F000.&lt;/p&gt;
&lt;p&gt;I have looked at the code in nrf_dfu.c and noticed that the code which checks for a valid application and then runs one has no idea about the dual-banl nature of the DFU code.&lt;/p&gt;
&lt;p&gt;The nrf_dfu_init function always jumps to 0x1f000.&lt;/p&gt;
&lt;p&gt;I amended this to jump to 0x27000, which is the actual address that gets programmed, bank 1.&lt;/p&gt;
&lt;p&gt;Since I erased the flash using eraseall (and recover just in case), I am unsure why bank 1 is being chosen but the DFU finds an app at 0x1f000.&lt;/p&gt;
&lt;p&gt;Anyway, programming at 0x27000 and then running at 0x27000 still doesn&amp;#39;t work.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Secure Bootloader with DFU will not start Valid Application</title><link>https://devzone.nordicsemi.com/thread/115660?ContentTypeID=1</link><pubDate>Wed, 22 Nov 2017 14:56:23 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:f0a2473d-e54a-430c-ac02-21e989d216bd</guid><dc:creator>Dev</dc:creator><description>&lt;p&gt;More information, which may be useful:&lt;/p&gt;
&lt;p&gt;I merged a generated settings hex file with the application hex file.&lt;/p&gt;
&lt;p&gt;If I flash the DFU BL and SD and then use nrfjprog to flash the application, the BL rejects the application with a CRC error.&lt;/p&gt;
&lt;p&gt;:INFO:Inside main
:DEBUG:In nrf_bootloader_init
:DEBUG:In real nrf_dfu_init
:DEBUG:running nrf_dfu_settings_init
:DEBUG:Enter nrf_dfu_continue
:DEBUG:Valid App
:DEBUG:In weak nrf_dfu_enter_check
:DEBUG:Enter nrf_dfu_app_is_valid
:DEBUG:Return false in CRC
:DEBUG:In nrf_dfu_transports_init
:DEBUG:num transports: 1
:DEBUG:vector table: 0x00075000
:DEBUG:vector table: 0x00075000
:DEBUG:Error code - sd_softdevice_vector_table_base_set: 0x00000000
:DEBUG:Before SOFTDEVICE_HANDLER_APPSH_INIT
:DEBUG:After SOFTDEVICE_HANDLER_APPSH_INIT
:INFO:Error code - sd_ble_cfg_set: 0x00000000
:DEBUG:Enabling softdevice.
:DEBUG:RAM start at 0x20002060.
:DEBUG:Softdevice enabled
:DEBUG:After nrf_dfu_transports_init
:DEBUG:------- nrf_dfu_flash_init-------
:DEBUG:Waiting for events&lt;/p&gt;
&lt;p&gt;But, If I flash with the settings hex, the BL accepts the application:&lt;/p&gt;
&lt;p&gt;:INFO:Inside main
:DEBUG:In nrf_bootloader_init
:DEBUG:In real nrf_dfu_init
:DEBUG:running nrf_dfu_settings_init
:DEBUG:Enter nrf_dfu_continue
:DEBUG:Valid App
:DEBUG:In weak nrf_dfu_enter_check
:DEBUG:Enter nrf_dfu_app_is_valid
:DEBUG:Return true. App was valid
:DEBUG:Enter nrf_dfu_app_is_valid
:DEBUG:Return true. App was valid
:DEBUG:Jumping to: 0x0001f000
Running nrf_bootloader_app_start with address: 0x0001f000
Disabling interrupts
Setting SD vector table base: 0x0001f000&lt;/p&gt;
&lt;p&gt;Since the application was flashed at 0x1F000, I don&amp;#39;t see why it will not run but I see no output.&lt;/p&gt;
&lt;p&gt;Something I also noted was that using the BLE DFU, I see the application flashed to places other than 0x1F000, which would be fine since it is a twin bank BL (?)&lt;/p&gt;
&lt;p&gt;However, the application is still started at 0x1F000, which cannot be right.&lt;/p&gt;
&lt;p&gt;This occurs even if I have erased the flash previously.&lt;/p&gt;
&lt;p&gt;...
:INFO:Storing 256 B at: 0x0002eb00
:INFO:Storing 256 B at: 0x0002ec00
:INFO:Storing 256 B at: 0x0002ed00
:INFO:Storing 80 B at: 0x0002ee00
:DEBUG:Received calculate CRC
...
:DEBUG:Writing settings...
:DEBUG:In weak nrf_dfu_enter_check
:DEBUG:Enter nrf_dfu_app_is_valid
:DEBUG:Return true. App was valid
:DEBUG:Enter nrf_dfu_app_is_valid
:DEBUG:Return true. App was valid
:DEBUG:Jumping to: 0x0001f000&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>