Beware that this post is related to an SDK in maintenance mode
More Info: Consider nRF Connect SDK for new designs
This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Unable to merge bootloader softdevice and application.

Hi,

I'm unable to get a working example with the bootloader, softdevice and application.
I'm following this:
https://devzone.nordicsemi.com/nordic/nordic-blog/b/blog/posts/getting-started-with-nordics-secure-dfu-bootloader

I'm using nRF5 SDK v16.0 with a nRF52840 and s140 7.0.1 softdevice.
examples/dfu/open_bootloader/pca10056_usb_debug (changed to use uart debug instead of RTT, and to boot from button press instead of reset)
examples/peripheral/blinky/pca10056/blank (FLASH_START=0x27000 so it works with the 7.0.1 softdevice)
flash offset found here: https://infocenter.nordicsemi.com/topic/sdk_nrf5_v16.0.0/lib_bootloader.html?cp=7_1_3_5_0_7#lib_bootloader_memory
I'm using the following command to generate the bootloader settings

nrfutil settings generate --family NRF52840 --application blinky.hex --application-version 0 --bootloader-version 0 --bl-settings-version 2 bootloader_setting.hex


When only flashing the softdevice and blinky example, it works as intended.
When flashing without the bootloader settings, the bootloader complains there is no application, which is expected.

When combining the bootloader softdevice application and bootloader settings, either combining with nRF Connect v3.3.0 or with the mergehex.
I can't get it to work.

I get the following output from the UART
When not holding the bootloader button during reset it tries to boot into the application but no LED's are blinking.
<info> app: Open USB bootloader started
<debug> app: In nrf_bootloader_init


When holding the bootloader button it goes into the main loop and outputs that the app is valid.
<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 button.
<info> nrf_bootloader_wdt: WDT is not enabled
<debug> app: in weak nrf_dfu_init_user
<debug> app: timer_stop (0x2000004C)
<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


Any help would be appreciated.

  • Hi, 

     Have you tried to flash Softdevice + Bootloader and then do a DFU update the blinky firmware ? (1)


    It's normal what you described when holding the bootloader button. The bootloader should enter DFU mode when requested (button is pressed)

    The case when the button is not pressed, you may want to step into the bootloader and debug. (Make sure you change the optimization level to 0).

    Please check if dfu_enter_check() return false. dfu_enter variable should equal false and nrf_bootloader_app_start() should be called. 

    Please double check that the softdevice is flashed, not just the MBR. 

    One thing you can do is to compare the hex dump you have at (1) after you DFU update the blinky firmware (use nrfjprog --readcode or use nRF Connect app) and hex dump after you flash the merged hexes. 

  • The issue was inside the bootloader code.
    examples/dfu/open_bootloader/pca10056_usb_debug
    Probably because I changed the logging to UART instead of RTT.
    The NRF_LOG_FLUSH() in the nrf_bootloader_app_start did not return, so the application did not start and the bootloader got stuck.
    Commenting out the NRF_LOG_FLUSH() fixed this, now everything works.

    Thanks for the help though!

Related