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

Parents
  • 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. 

  • Also, weirdly, I took a look at the example S140 SDFU images, and they appear to be using boot settings = 1.  This is from ble_app_buttonless_dfu_without_bonds_s140_with_setting_page.hex in the nrf52840 directory:

    :02000004000FEB
    :10E00000564ADC4D01000000010000000100000044
    :10E010000000000000000000ECC90000B14A0BAE97
    :10E0200001000000000000000000000000000000EF
    :10E0300000000000000000000000000000000000E0
    :10E0400000000000000000000000000000000000D0
    :0CE05000000000000000000000000000C4
    :10F00000564ADC4D01000000010000000100000034
    :10F010000000000000000000ECC90000B14A0BAE87
    :10F0200001000000000000000000000000000000DF
    :10F0300000000000000000000000000000000000D0
    :10F0400000000000000000000000000000000000C0
    :0CF05000000000000000000000000000B4
    :00000001FF

    Whereas the one I generated using settigns = 2 looks like this:

    :02000004000FEB
    :10E00000F4B7F598020000000000000000000000D6
    :10E01000000000000000000008280100374FC8156C
    :10E0200001000000000000000000000000000000EF
    :10E0300000000000000000000000000000000000E0
    :10E0400000000000000000000000000000000000D0
    :10E0500000000000000000000000000000000000C0
    :10E0600000000000000000000000000000000000B0
    :10E0700000000000000000000000000000000000A0
    :10E080000000000000000000000000000000000090
    :10E090000000000000000000000000000000000080
    :10E0A0000000000000000000000000000000000070
    :10E0B0000000000000000000000000000000000060
    :10E0C0000000000000000000000000000000000050
    :10E0D0000000000000000000000000000000000040
    :10E0E0000000000000000000000000000000000030
    :10E0F0000000000000000000000000000000000020
    :10E10000000000000000000000000000000000000F
    :10E1100000000000000000000000000000000000FF
    :10E1200000000000000000000000000000000000EF
    :10E1300000000000000000000000000000000000DF
    :10E1400000000000000000000000000000000000CF
    :10E1500000000000000000000000000000000000BF
    :10E1600000000000000000000000000000000000AF
    :10E17000000000000000000000000000000000009F
    :10E18000000000000000000000000000000000008F
    :10E19000000000000000000000000000000000007F
    :10E1A000000000000000000000000000000000006F
    :10E1B000000000000000000000000000000000005F
    :10E1C000000000000000000000000000000000004F
    :10E1D000000000000000000000000000000000003F
    :10E1E000000000000000000000000000000000002F
    :10E1F000000000000000000000000000000000001F
    :10E20000000000000000000000000000000000000E
    :10E2100000000000000000000000000000000000FE
    :10E2200000000000000000000000000000000000EE
    :10E2300000000000000000000000000000000000DE
    :10E2400000000000000000000000000000000000CE
    :10E2500000000000000000000000000099ECD5FE66
    :10E2600000000000000000000000000000000000AE
    :10E27000000000000000000000000000000000009E
    :10E28000000000000000000000000000000000008E
    :10E29000000000000000000000000000000000007E
    :10E2A0000001374FC815000000000000000000000A
    :10E2B000000000000000000000000000000000005E
    :10E2C000000000000000000000000000000000004E
    :10E2D000000000000000000000000000000000003E
    :10E2E000000000000000000000000000000000002E
    :10E2F000000000000000000000000000000000001E
    :10E30000000000000000000000000000000000000D
    :10E3100000000000000000000000000000000000FD
    :03E32000000000FA
    :10F00000F4B7F598020000000000000000000000C6
    :10F01000000000000000000008280100374FC8155C
    :10F0200001000000000000000000000000000000DF
    :10F0300000000000000000000000000000000000D0
    :10F0400000000000000000000000000000000000C0
    :10F0500000000000000000000000000000000000B0
    :10F0600000000000000000000000000000000000A0
    :10F070000000000000000000000000000000000090
    :10F080000000000000000000000000000000000080
    :10F090000000000000000000000000000000000070
    :10F0A0000000000000000000000000000000000060
    :10F0B0000000000000000000000000000000000050
    :10F0C0000000000000000000000000000000000040
    :10F0D0000000000000000000000000000000000030
    :10F0E0000000000000000000000000000000000020
    :10F0F0000000000000000000000000000000000010
    :10F1000000000000000000000000000000000000FF
    :10F1100000000000000000000000000000000000EF
    :10F1200000000000000000000000000000000000DF
    :10F1300000000000000000000000000000000000CF
    :10F1400000000000000000000000000000000000BF
    :10F1500000000000000000000000000000000000AF
    :10F16000000000000000000000000000000000009F
    :10F17000000000000000000000000000000000008F
    :10F18000000000000000000000000000000000007F
    :10F19000000000000000000000000000000000006F
    :10F1A000000000000000000000000000000000005F
    :10F1B000000000000000000000000000000000004F
    :10F1C000000000000000000000000000000000003F
    :10F1D000000000000000000000000000000000002F
    :10F1E000000000000000000000000000000000001F
    :10F1F000000000000000000000000000000000000F
    :10F2000000000000000000000000000000000000FE
    :10F2100000000000000000000000000000000000EE
    :10F2200000000000000000000000000000000000DE
    :10F2300000000000000000000000000000000000CE
    :10F2400000000000000000000000000000000000BE
    :10F2500000000000000000000000000099ECD5FE56
    :10F26000000000000000000000000000000000009E
    :10F27000000000000000000000000000000000008E
    :10F28000000000000000000000000000000000007E
    :10F29000000000000000000000000000000000006E
    :10F2A0000001374FC81500000000000000000000FA
    :10F2B000000000000000000000000000000000004E
    :10F2C000000000000000000000000000000000003E
    :10F2D000000000000000000000000000000000002E
    :10F2E000000000000000000000000000000000001E
    :10F2F000000000000000000000000000000000000E
    :10F3000000000000000000000000000000000000FD
    :10F3100000000000000000000000000000000000ED
    :03F32000000000EA
    :00000001FF
    

    Looking through nrf_dfu_types.h, which defines nrf_dfu_settings_t, clearly settings = 1 wouldn't work with a SDK 15.3 based SDFU bootloader.

  • Hi Mike, 

    It could be a bug with the ble_app_buttonless_dfu_without_bonds_s140_with_setting_page.hex file, maybe we didn't update the file. 

    I as asking if you can test doing DFU and mergehex with an SDK example so that we can reproduce here and can rule out any issue that may related to your application. 
    I was testing here with HRS example and can create the setting and merged everything together. The merged hex file worked fine for me here. Attached are the files.

     S140.zip

    If you still having problem, please try to test with HRS example and send us the files (sd, bl, setting, app, and the merged one)

Reply
  • Hi Mike, 

    It could be a bug with the ble_app_buttonless_dfu_without_bonds_s140_with_setting_page.hex file, maybe we didn't update the file. 

    I as asking if you can test doing DFU and mergehex with an SDK example so that we can reproduce here and can rule out any issue that may related to your application. 
    I was testing here with HRS example and can create the setting and merged everything together. The merged hex file worked fine for me here. Attached are the files.

     S140.zip

    If you still having problem, please try to test with HRS example and send us the files (sd, bl, setting, app, and the merged one)

Children
Related