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

bootloader only enters DFU when using a breakpoint due to watchdog timeout.

We use nRF SDK5 17.0.2 with Softdevice S140 on an nRF52840-DK.

We have a firmware that we always want to start in DFU mode, then use the abort command to be used to start the application.
We use the bootloader with USB from the examples, that we have modified slightly.

I've added:
    sd_power_gpregret_clr(0, 0xffffffff);
    sd_power_gpregret_set(0, 0xb1);
to my application when it starts.

After around five seconds I reset it with NVIC_SystemReset and expect to get back to DFU mode. That doesn't happen, the application starts again.

Setting a breakpoint on nrf_bootloader_wdt_init and hitting continue, it always works as expected.
Setting a breakpoint on loop_forever, I can see the code reaches there, but if I then disable the breakpoint, the bootloader soon resets and starts the application.


I can see wdt_feed_timer_handler is called regularly, but the WDT_IRQHandler gets called.

The reduced_timeout_ticks value is 62336 when nrf_bootloader_wdt_feed_timer_start is called. Changing MAX_FLASH_OP_TIME_TICKS to 20000 doesn't help, I still get watchdog timeouts.

We use these changes in sdk_config.h:

#define NRF_BL_DFU_ENTER_METHOD_BUTTON 0
#define NRF_BL_DFU_INACTIVITY_TIMEOUT_MS 0
#define NRF_DFU_REQUIRE_SIGNED_APP_UPDATE 0
#define NRF_LOG_DEFERRED 0


otherwise the bootloader is like the example.

Is there something else we need to change to get this working?

We also use the watchdog in our application, but I hope that's been cleared after NVIC_SystemReset().

Parents
  • Yes, NRF_BL_DFU_ENTER_METHOD_GPREGRET was turned on in our project otherwise the bootloader wouldn't get to the mentioned breakpoints. Our project is a copy of the secure_bootloader example, with the mentioned changes in sdk_config.h.

    I now turned on NRF_BL_DFU_ENTER_METHOD_GPREGRET in the open_bootloader/pca10056_usb_debug example and tried it.

    I get the same behaviour with that bootloader. The log says:

    <info> app: Open USB bootloader started
    <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.
    <debug> app: App is valid
    <warning> nrf_dfu_settings: No additional data erased
    <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: Running nrf_bootloader_app_start with address: 0x00001000
    <debug> app: Disabling interrupts. NVIC->ICER[0]: 0x0
    <info> app: Open USB bootloader started
    <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.
    <debug> app: App is valid
    <debug> app: DFU mode requested via GPREGRET.
    <info> nrf_bootloader_wdt: WDT enabled CRV:65536 ticks
    <info> nrf_bootloader_wdt: Starting a timer (62336 ticks) for feeding watchdog.
    <debug> app: timer_activate (0x20000038)
    <debug> app: in weak nrf_dfu_init_user
    <debug> app: timer_stop (0x20000028)
    <info> app: Entering DFU mode.
    <info> app_timer: RTC: initialized.
    <debug> app: Initializing transports (found: 1)
    <debug> nrf_dfu_serial_usb: Initializing drivers.
    <debug> nrf_dfu_serial_usb: Starting USB
    <debug> nrf_dfu_serial_usb: USB Transport initialized
    <debug> nrf_dfu_flash: Initializing nrf_fstorage_nvmc backend.
    <debug> app: Enter main loop
    <info> nrf_dfu_serial_usb: USB power detected
    <info> nrf_dfu_serial_usb: USB ready

    <info> app: Open USB bootloader started
    <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.
    <debug> app: App is valid
    <warning> nrf_dfu_settings: No additional data erased
    <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: Running nrf_bootloader_app_start with address: 0x00001000
    <debug> app: Disabling interrupts. NVIC->ICER[0]: 0x0

    I can also get it to work in the same way by adding a breakpoint in the right place and pressing continue. Then it stays in DFU mode until I ask it to start the application via the ABORT command over the USB connection.

Reply
  • Yes, NRF_BL_DFU_ENTER_METHOD_GPREGRET was turned on in our project otherwise the bootloader wouldn't get to the mentioned breakpoints. Our project is a copy of the secure_bootloader example, with the mentioned changes in sdk_config.h.

    I now turned on NRF_BL_DFU_ENTER_METHOD_GPREGRET in the open_bootloader/pca10056_usb_debug example and tried it.

    I get the same behaviour with that bootloader. The log says:

    <info> app: Open USB bootloader started
    <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.
    <debug> app: App is valid
    <warning> nrf_dfu_settings: No additional data erased
    <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: Running nrf_bootloader_app_start with address: 0x00001000
    <debug> app: Disabling interrupts. NVIC->ICER[0]: 0x0
    <info> app: Open USB bootloader started
    <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.
    <debug> app: App is valid
    <debug> app: DFU mode requested via GPREGRET.
    <info> nrf_bootloader_wdt: WDT enabled CRV:65536 ticks
    <info> nrf_bootloader_wdt: Starting a timer (62336 ticks) for feeding watchdog.
    <debug> app: timer_activate (0x20000038)
    <debug> app: in weak nrf_dfu_init_user
    <debug> app: timer_stop (0x20000028)
    <info> app: Entering DFU mode.
    <info> app_timer: RTC: initialized.
    <debug> app: Initializing transports (found: 1)
    <debug> nrf_dfu_serial_usb: Initializing drivers.
    <debug> nrf_dfu_serial_usb: Starting USB
    <debug> nrf_dfu_serial_usb: USB Transport initialized
    <debug> nrf_dfu_flash: Initializing nrf_fstorage_nvmc backend.
    <debug> app: Enter main loop
    <info> nrf_dfu_serial_usb: USB power detected
    <info> nrf_dfu_serial_usb: USB ready

    <info> app: Open USB bootloader started
    <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.
    <debug> app: App is valid
    <warning> nrf_dfu_settings: No additional data erased
    <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: Running nrf_bootloader_app_start with address: 0x00001000
    <debug> app: Disabling interrupts. NVIC->ICER[0]: 0x0

    I can also get it to work in the same way by adding a breakpoint in the right place and pressing continue. Then it stays in DFU mode until I ask it to start the application via the ABORT command over the USB connection.

Children
Related