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

App will not launch after updating Bootloader with BLE DFU

I am trying to update the bootloader using BLE DFU and it does not seem like the app is launching after the bootloader update. 

I currently have an app that works with the original bootloader built off one of the secure bootloader examples. (examples/dfu/secure_bootloader_ble_s140/pca10056_ble). But we have an app update that enables in-app DFU for remote updates. This all works but the problem is we require a bootloader update with some configuration changes. In particular Bootloader v2 enables NRF_BL_DFU_ALLOW_UPDATE_FROM_APP which is currently the only change, if that matters. Everything works great when I load the bootloader.hex alongside the application as an "Additional load file" with a settings page. The app runs, the BLE DFU works, and our in-app DFU works as long as bootloader V2 is loaded as an "additional load file".

The problem is that we have some devices that we would like to update without having to open them up and connect a programmer. I have generated a bootloader2 zip with "nrfutil pkg generate --bootloader secure_bootloader.hex --bootloader-version 2 --hw-version 52 --sd-req 0xB6 --sd-id 0xB6 --key-file private.pem BL2.zip" and using my phone to do the DFU the process appears to finish correctly. But then when the device reboots it does not load the app that was previously programmed. 

This is the log from the RTT viewer after the update, the example bootloader files haven't been modified except for "sdk_config.h" so all these log messages are default. 

00> <info> app: Inside main
00> <debug> app: In nrf_bootloader_init
00> <debug> nrf_dfu_settings: Calling nrf_dfu_settings_init()...
00> <debug> nrf_dfu_flash: Initializing nrf_fstorage_nvmc backend.
00> <debug> nrf_dfu_settings: Using settings page.
00> <debug> nrf_dfu_settings: Destination settings are identical to source, write not needed. Skipping.
00> <debug> app: Enter nrf_bootloader_fw_activate
00> <debug> app: Valid BL
00> <debug> app: Verifying BL: Addr: 0x000F1000, Src: 0x00059000, Len: 0x0000C598
00> <debug> app: No bootloader copy needed, bootloader update complete.
00> <warning> nrf_dfu_settings: Settings write aborted since it tries writing to forbidden settings.
00> Received a fault! id: 0x00004002, pc: 0x00000000, info: 0x2003ffa0

This message repeats constantly as I am assuming the device is restarting. 

Using SEGGER, SDK 15.3, and nrF Connect android app to do BLE transfers. Any help would be appreciated I will answer any questions if I have left anything out. I also have the ability to add additional log messages to the bootloader. 

Parents Reply Children
  • The 'in-app/background' DFU process does not work with 'bootloader v1' which is the reason for the upgrade. 

    The DFU process to attempt the upgrade from 'bootloader v1' to 'bootloader v2' was performed by connecting to the device via Bluetooth nRF Connect Android application while the device was running the application code, which includes a DFU service. The process appears to finish correctly and there is a verification message from the android app, but when the device reboots the application does not run. This same process works for application updates but not for bootloader updates. 

  • What version of nrfutil did you use? 

    I see that e.g. we have this statement, here, that might be relevant:
    "1Use nRF Util v5.0.0 or later when creating update packages of bootloaders compiled from nRF5 SDK 15.3.0 or later to ensure the correct size of generated packages."

  • The code that prints this:

    00> <warning> nrf_dfu_settings: Settings write aborted since it tries writing to forbidden settings.

    Looks like this:

        if (NRF_DFU_IN_APP && !settings_forbidden_parts_equal_to_backup((uint8_t *)&s_dfu_settings))
        {
            NRF_LOG_WARNING("Settings write aborted since it tries writing to forbidden settings.");
            return NRF_ERROR_FORBIDDEN;
        }

    NRF_DFU_IN_APP is documented as this:

    // <q> NRF_DFU_IN_APP  - Specifies that this code is in the app, not the bootloader, so some settings are off-limits.
     
    
    // <i> Enable this to disable writing to areas of the settings that are protected
    // <i> by the bootlader. If this is not enabled in the app, certain settings write
    // <i> operations will cause HardFaults or will be ignored. Enabling this option
    // <i> also causes postvalidation to be disabled since this is meant to be done
    // <i> in the bootloader. NRF_BL_DFU_ALLOW_UPDATE_FROM_APP must be enabled in the bootloader.
    
    #ifndef NRF_DFU_IN_APP
    #define NRF_DFU_IN_APP 0
    #endif

    What did you set NRF_DFU_IN_APP to in your bootloader project?

  • Bootloader project:

    #define NRF_DFU_IN_APP 0

    (also #define NRF_BL_DFU_ALLOW_UPDATE_FROM_APP 1)

    Application project: 

    #define NRF_DFU_IN_APP 1

    Do you think this means that the app is running and just crashing here? What is the app trying to write to the settings page? Anyway to change what is being written?

Related