This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Combining app + bootloader + sd + settings page on v15.3

Using: Linux (Ubuntu 18.04), gcc/Eclipse, nrf52840, v15.3.0 SDK, SD 6.1.1

It has been a real bear of time using the SDFU in the newest version of the SDK.  There were a lot of "breaking changes" and limitations.  

1.  The linker directive for SDFU changed from previous revs, as discussed here.  Because of the MBR changes, and how nrfjprog erases 0x0, you MUST program the SD and the bootloader together.  I got this working, and the bootloader runs reliably.

2.  To be able to program an application, you need to generate a bootloader settings page, and then use mergehex to put in with the BL + SD created above.  The bootloader settings page is created against the application you want to build, as described here and may other posts.  To use on the 840, on 15.3, you must use --family NRF52840 (not just NRF52), and you must set --bl-settings-version 2 (not 1).  Generating the settings is fine, I get:

Generated Bootloader DFU settings .hex file and stored it in: ../_build/bootloader_settings.hex

Bootloader DFU Settings:
* File:                     ../_build/bootloader_settings.hex
* Family:                   NRF52840
* Start Address:            0x000FF000
* CRC:                      0x98F5B7F4
* Settings Version:         0x00000002 (2)
* App Version:              0x00000000 (0)
* Bootloader Version:       0x00000000 (0)
* Bank Layout:              0x00000000
* Current Bank:             0x00000000
* Application Size:         0x00012808 (75784 bytes)
* Application CRC:          0x15C84F37
* Bank0 Bank Code:          0x00000001
* Softdevice Size:          0x00000000 (0 bytes)
* Boot Validation CRC:      0xACDA1BA2
* SD Boot Validation Type:  0x00000000 (0)
* App Boot Validation Type: 0x00000000 (0)

3.  After merging the settings page in, I merge in my application.  I flash the whole pile onto my board, and the bootloader runs, but doesn't see a valid app.

<info> app: Inside main
<debug> app: In nrf_bootloader_init
<debug> nrf_dfu_settings: Calling nrf_dfu_settings_init()...
<debug> nrf_dfu_flash: Initializing nrf_fstorage_nvmc backend.
<debug> nrf_dfu_settings: Using settings page.
<debug> nrf_dfu_settings: Copying forbidden parts from backup page.
<debug> nrf_dfu_settings: Destination settings are identical to source, write not needed. Skipping.
<info> nrf_dfu_settings: Backing up settings page to address 0xFE000.
<debug> nrf_dfu_settings: Destination settings are identical to source, write not needed. Skipping.
<debug> app: Enter nrf_bootloader_fw_activate
<info> app: No firmware to activate.
<info> app: Boot validation failed. No valid app to boot.
<debug> app: DFU mode because app is not valid.
<info> nrf_bootloader_wdt: WDT is not enabled
<debug> app: timer_stop (0x200057C4)
<debug> app: timer_activate (0x200057C4)
<info> app: Entering DFU mode.
<debug> app: Initializing transports (found: 1)
<debug> nrf_dfu_ble: Initializing BLE DFU transport
<debug> nrf_dfu_ble: Setting up vector table: 0x000F1000
<debug> nrf_dfu_ble: Enabling SoftDevice.
<debug> nrf_dfu_ble: Configuring BLE stack.
<debug> nrf_dfu_ble: Enabling the BLE stack.
<debug> nrf_dfu_ble: No advertising name found
<debug> nrf_dfu_ble: Using default advertising name
<debug> nrf_dfu_ble: Advertising...
<debug> nrf_dfu_ble: BLE DFU transport initialized.
<debug> nrf_dfu_flash: Initializing nrf_fstorage_sd backend.
<debug> app: Enter main loop

4.  I run nrfutil to look at the settings of the combined (BL + SD + settings + app), it looks weird... no Start Address, and some weird message saying "Bad access at 0x7F000".

nrfutil settings display --------.hex 
Bad access at 0x7F000: not enough data to read 4 contiguous bytes

Bootloader DFU Settings:
* File:                     ----------.hex
* Family:                   NRF52840
* Start Address:            0x00000000
* CRC:                      0x98F5B7F4
* Settings Version:         0x00000002 (2)
* App Version:              0x00000000 (0)
* Bootloader Version:       0x00000000 (0)
* Bank Layout:              0x00000000
* Current Bank:             0x00000000
* Application Size:         0x00012808 (75784 bytes)
* Application CRC:          0x15C84F37
* Bank0 Bank Code:          0x00000001
* Softdevice Size:          0x00000000 (0 bytes)
* Boot Validation CRC:      0xACDA1BA2
* SD Boot Validation Type:  0x00000000 (0)
* App Boot Validation Type: 0x00000000 (0)

I'm out of steam, this has been a real pain.  Any thoughts on why my integrated app won't work?

Thanks,

M

  • Alternatively, you can use the IDAP-Link CMSIS-DAP JTAG to flash the whole thing without any merging or generating setting page.  The IDAPnRFProg command line program provided is specifically made to flash SD + App + DFU directly and automatically sets all require settings.  Nothing to merge, just give it the 3 hex files that's it.  The software is avail for Linux, Windows, OSX & RPI.

  • Nguyen - you should probably say something like "full disclosure, I'm the creator of IDAP...." 

    This isn't really a good solution for me, I can't just tell my board vendors "use this special chip to program the board".   I need to have my project correctly set up, and using the Nordic tools correctly.

  • No problem, I created it because I needed it and it could be useful for other as well.   Just recently that you are allow to use the DK to flash external board.  It wasn't the case before.  The IDAP was created initially for that purpose and also allows parallel flashing for production and it is not limited to nRF.  I am not forcing you to use it, just give you an alternative.  The choice is yours to make.

  • Hi Medved, 

    Please test using one of our example image, just to be sure the issue can be reproduced with any image. 

    Could you provide the script you used to generate bootloader setting ? Do you use application-version = 0 ? 

    Have you tried to compare the hex you have after you merged everything with the hex of the bootloader setting to check if the bootloader setting was merged without any modification ?

    The log "<info> app: Boot validation failed. No valid app to boot." saying that the bootloader setting has not marked the application as valid on bank 1. 

  • Yeah, flashing the example images works fine.

    What I noticed now is that if I merge the bootloader_settings file in at all it doesn't work (ie nothing comes out the RTT).  If I merge the BL, SD, and app and run it, it runs fine (of course with the invalid app problem).  If I merge in the bootlaoder settings, or manually flash it, nothing comes out RTT.

    I do use application-setting = 0.  Here is the line I'm using to generate the bootloader settings:

    nrfutil settings generate --family NRF52840 --application $(OUTPUT_DIRECTORY)/nrf52840_xxaa.hex --application-version 0  --bootloader-version 0 --bl-settings-version 2 $(OUTPUT_DIRECTORY)/bootloader_settings.hex

    I'm concerned that this is GCC related, as discussed in this post.  Do I need to manually hack the settings file?  Look in the accepted answer.

    M

Related