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

USB DFU combined with Buttonless BLE DFU

Hi

I am working with nRF52840 DK  v2.0.1, in SDK 17.0.2., trying to implement combined BLE+USB DFU in my application.

First I tried combining bootloaders from SDK (secure_bootloader/pca10056_s140_ble and secure_bootloader/pca10056_usb), and I used pca10056_s140_ble  as starting point.

I imported all files that are in the pca10056_usb bootloader, along with all skd_config.h definitions and include paths. Also, I changed flash start and flash size, to fit new bootloader into the flash memory.

In my main application, I tried using USB DFU trigger library, to trigger USB DFU (BLE DFU was already implemented before but now it doesn't work)

I connected P0.05 to P.018, as required by the library, and I've enabled PINRESET entry mode in the bootloader sdk_config.h.

Can anyone tell me what am I missing here? The application works fine, I'm using BLE, UART and USB CLI, It's just won't go into DFU mode.

I would appreciate if someone could tell me steps required to combine two bootloaders, and including these bootloaders into the main application?

Thanks!

Parents
  • Another update:

    I've added this part of the code to the bootloader's main.c (line 2 and line 3):

     NRF_LOG_INFO("Inside main");
        nrf_drv_clock_init();
        nrf_drv_power_init(NULL);
        ret_val = nrf_bootloader_init(dfu_observer);
        APP_ERROR_CHECK(ret_val);

    BLE transport gets initialized, but the USB transport won't initialize now, with the following log in terminal:

    <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: in weak nrf_dfu_init_user
    <debug> app: timer_stop (0x2000599C)
    <debug> app: timer_activate (0x2000599C)
    <info> app: Entering DFU mode.
    <debug> app: Initializing transports (found: 2)
    <debug> nrf_dfu_ble: Initializing BLE DFU transport
    <debug> nrf_dfu_ble: Setting up vector table: 0x000E0000
    <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_serial_usb: Initializing drivers.
    <debug> app: Failed to initialize transport 1, error 133
    <error> app: Could not initalize DFU transport: 0x00000085
    <error> app: C:\SDKs\nRF5_SDK_17.0.2_d674dde\examples\dfu\secure_bootloader\main.c:150
     

  • I'm beginning to think this is due to order of transport initialization. Program initializes BLE transport first. Is there any elegant way to force initialize USB transport first?

  • Could you tell me the following:

    • Which SDK version are you using?
    • What DevKit are you working on?
    • Which Softdevice are you using?
  • Since it says "SD_VERSION_FAILURE" in the picture you sent me, I'm assuming it has something to do with the .zip package you made, and the SD version you selected there.

    This is what I use to make DFU package for s140 SD, on my nRF52840

    nrfutil pkg generate --application ble_app_cli_pca10056_s140.hex --application-version-string "2.0.0" --hw-version 52 --sd-req 0xCA --key-file C:\Users\Em\Downloads\Milestone-1\DFU-test\private.key app_v2.zip
    

    --sd-req 0xCA, this is where you difine SD version I hink, for the s132 you need to select --sd-req 0xCB, but you can check that inside the s132 documentation.

    Could you please share the "nrfutil pkg generate" command that you were using?

  • nrfutil pkg generate --application nrf52840_xxaa.hex --application-version-string "1.2.3" --hw-version 52 --sd-req 0xCA --key-file private_key.pem app_v1.zip

  • Also, did you use correct SD when performing the mergehex? 

    mergehex --merge bl_setting.hex secure_bootloader_usb_mbr_pca10056.hex s140_softdevice.hex --output bl_set_s140.hex

Reply Children
  • This is where you merge bootloader settings hex, softdevice hex, bootloader hex and the application hex file.. This needs to be done, to be able to flash the bootloader, softdevice and the application at the same time(in one hex file) . That's why I'm telling you to follow the tutorial that I have sent you. 

  • i am following tutorial upto page 18. in that merging is not required

  • can you take acess of my pc and help it is much needed as i am struck

  • I'm sorry, I can't do that right now. Here are the key steps that you need to take:

    • Build your main application
    • Build the bootloader
    • Copy the bootloader hex and the main application hex and put them in the same folder
    • Use the nrfutil to create settings file (as shown in the example below)

    nrfutil settings generate --family NRF52840 --application ble_app_cli_pca10056_s140.hex --application-version 0 --bootloader-version 0 --bl-settings-version 2 bl_setting.hex
    

    • Use the mergehex to combine settings, bootloader, application and the softdevice (it must be done in 2 steps as shown in the example following)

    mergehex --merge bl_setting.hex secure_bootloader_usb_mbr_pca10056.hex s140_softdevice.hex --output bl_set_s140.hex
    mergehex --merge bl_set_s140.hex ble_app_cli_pca10056_s140.hex --output bl_set_s140_app.hex
    

    • Use the nRF Connect programmer to flash the device with bl_set_s140_app.hex file (your app should be working now on the device, and the next step is to perform DFU)
    • Make needed changes in your main app and perform build. Use the new resulting application hex file to create .zip package with the following command:

    nrfutil pkg generate --application ble_app_cli_pca10056_s140.hex --application-version-string "2.0.0" --hw-version 52 --sd-req 0xCA --key-file C:\Users\Em\Downloads\Milestone-1\DFU-test\private.key app_v2.zip

    • Use the .zip package to perform the DFU

    (Example commands that I have provided is used for applications that are based on s140 SD)

    This all I can help you with. If this doesn't work for you, you have failed to install required software and libraries, go through the installation process again.

Related