nRF5 SDK is not maintained anymore
More Info: Consider nRF Connect SDK for new designs
This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Debug secure bootloader shows invalid app while secure bootloader shows valid app after programming board

Hi,

I'm working on modifying the secure bootloader (SDK 17, nRF52840, s140) to store the old app before the new app is programmed into Bank 0 (see this other thread). Since I need to debug the bootloader, I need to use the debug bootloader (pca10056_s140_ble_debug) instead of the one I normally use (pca10056_s140_ble). The weird part is that when I program the "normal" bootloader + SoftDevice + Application, the app boots up fine after programming. However, when I program the debug bootloader + SoftDevice + Application, the bootloader does not recognize the app as valid and stays in DFU mode.

What could be the reason for this? I get no warnings or errors at compile time so I would say that the public key in the bootloader that is being used is the correct one as there is no other one.

Thanks in advance.

Parents
  • Hi,

    Any chance the image checksum validation may have been disabled in the "release" version? When programming everything through the debug interface you normally have to include the bootloader settings page (Generating and displaying bootloader settings) to mark the application as valid. The bootloader will always fall back to DFU mode if it is unable to validate the application.

    nrfutil settings generate --family NRF52840 \
    --application $application_hex \
    --application-version-string $version \
    --bootloader-version 2 \
    --bl-settings-version 2 \
    --app-boot-validation VALIDATE_GENERATED_CRC \
    v$version/hex/bl_settings.hex

    Best regards,

    Vidar

  • Hi Vidar,

    In order to generate the bootloader settings I have been using the command 

    nrfutil settings generate --family NRF52840 --application $(OUTPUT_DIRECTORY)/nrf52840_xxaa.hex --application-version 1 --bootloader-version 1 --bl-settings-version 1 --no-backup settings.hex

    So I have not been including the flag --app-boot-validation VALIDATE_GENERATED_CRC before.

    I have tried to include this flag which required to change --bl-settings-version from 1 to 2 but I still get the same error. Removing the --no-backup flag didn't change the outcome either. 

    The logs show that the setting page is not valid.

    <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.
    <warning> nrf_dfu_settings: Resetting bootloader settings since neither the settings page nor the backup are valid (CRC error).

  • Hi,

    I'm surprised it says the settings page is invalid. The correct command for you SDK version should be (--app-boot-validation defaults to VALIDATE_GENERATED_CRC anyway):

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

    Here i omitted the --no-backup argument and set the settings version to '2' as required for this SDK version you are using.

    Could you please try with the command above again and program the settings.hex with the nrfjprog command below?

    $ nrfjprog --program settings.hex --sectorerase -r

Reply
  • Hi,

    I'm surprised it says the settings page is invalid. The correct command for you SDK version should be (--app-boot-validation defaults to VALIDATE_GENERATED_CRC anyway):

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

    Here i omitted the --no-backup argument and set the settings version to '2' as required for this SDK version you are using.

    Could you please try with the command above again and program the settings.hex with the nrfjprog command below?

    $ nrfjprog --program settings.hex --sectorerase -r

Children
  • Hi,

    I used the commands

    nrfutil settings generate --family NRF52840 --application _build/nrf52840_xxaa.hex --application-version 1 --bootloader-version 1 --bl-settings-version 2 settings.hex
    nrfjprog --program settings.hex --sectorerase -r
    to program the new bootloader settings and still got the same warning <warning> nrf_dfu_settings: Resetting bootloader settings since neither the settings page nor the backup are valid (CRC error).

  • Sorry, but I'm a bit out of ideas. Have you tried to see if what happens if you use the same settings.hex with the "release" build? Also, are you able to share the debug version of the bootloader so I can try to reproduce the same here?

  • Hi,

    It seems that now it's working properly. Unfortunately, I'm not 100% sure what fixed it, but I think your suggestions worked in the end.

    Thanks again.

Related