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

Is it possible to update firmware via BLE DFU from v14 to v15 of the nRF5 SDK?

I am trying to update firmware that uses v14 of the nRF5 SDK to firmware that uses v15.3, but I am getting the error "Init command larger than expected.".

I'm wondering if this is supposed to be possible, or if v15.3 is not backwards compatible (I didn't see anything in the documentation saying it's not compatible).

It looks like the size of the init command buffer was increased in this version.

#define INIT_COMMAND_MAX_SIZE      512 /**< Maximum size of the init command stored in dfu_settings. */
#define INIT_COMMAND_MAX_SIZE_v1   256 /**< Maximum size of the init command in settings version 1. */

Thank You,
Josh

Parents
  • Hi Josh, 

    I'm wondering if this is supposed to be possible, or if v15.3 is not backwards compatible (I didn't see anything in the documentation saying it's not compatible).

     Yes, you should be able to update from v14 to v15.3 using DFU.

    I am getting the error "Init command larger than expected.

     What command are you using when generating the DFU package?

    Kind regards,
    Øyvind

  • Here is what we are using:

    nrfutil settings generate 
        --family NRF52 
        --application $APP_HEX_FILE 
        --application-version $APP_FW_VERSION 
        --bootloader-version 3 
        --bl-settings-version 2
        $BOOT_SETTINGS_HEX_FILE
    
    nrfutil pkg generate 
        --hw-version 52 
        --sd-req 0x98,0x99,0x9E,0x9D,0xB7 
        --sd-id 0xB7 
        --application $APP_HEX_FILE 
        --application-version $APP_FW_VERSION 
        --bootloader $BOOT_HEX_FILE
        --bootloader-version 3 
        --softdevice nrf5sdk/components/softdevice/s132/hex/s132_nrf52_6.1.1_softdevice.hex 
        --sd-boot-validation VALIDATE_ECDSA_P256_SHA256 
        --app-boot-validation VALIDATE_ECDSA_P256_SHA256 
        --key-file $PRIVATE_KEY_FILE
        $PKG_OUTPUT_FILE

    I noticed that we never merge the $BOOT_SETTINGS_HEX_FILE and the $BOOT_HEX_FILE, and I'm thinking that this merged file is what actually should be passed to the "nrfutil settings generate --bootloader" option? Otherwise the default settings are used and the DFU firmware doesn't know it needs to upgrade the settings page.

    I'll try this while waiting for an answer.

    Thank You,
    Josh

  • Hi Josh, 

    I have not been able to reproduce your issue yet but it is work in progress. Discussing the issue with my team as well and we think there might be an issue with the:

    --sd-boot-validation VALIDATE_ECDSA_P256_SHA256
    --app-boot-validation VALIDATE_ECDSA_P256_SHA256

    But will verify. In the mean time, please have look at the DFU tutorial (if you have not looked at this) it mentions: "For bootloader and softdevice update, please see the Appendix."

    Kind regards,
    Øyvind

  • Hello again, 

    I've managed to reproduce the issue, and the issue seems to be

    --sd-boot-validation VALIDATE_ECDSA_P256_SHA256

    which was not supported in SDK14.2, but is new in SDK15.3. 

    The following call worked for me:

    nrfutil pkg generate --application ble_app_hrs_pca10040_s132.hex --application-version 1 --softdevice s132_nrf52_6.1.1_softdevice.hex --bootloader secure_bootloader_ble_s132_pca10040.hex --bootloader-version 3  --hw-version 52 --sd-req 0x98,0x99,0x9E,0x9D,0xB7 --sd-id 0xB7 --app-boot-validation VALIDATE_ECDSA_P256_SHA256 --sd-boot-validation VALIDATE_ECDSA_P256_SHA256  --key-file private.pem hrs_dfu.zip

    This updated the bootloader and softdevice to newest and installed the correct app. 

    Please try to remove sd-boot-validation and let me know how that works for you.

    Kind regards, 
    Øyvind

  • So I changed two things that got me further along (at least with nRF Connect 4.22.3 on Android):

    1) Removed the `--sd-boot-validation` as you said.
    2) Changed

    --sd-req 0x98,0x99,0x9E,0x9D,0xB7

    to 

    --sd-req 0x9D

    Without #2 the "SD req not met" pre-validate was failing. For some reason it was only seeing the last SD ID in the list, so removing all but the one matching the current firmware fixed it.

    I'm still getting the same original error using the iOS DFU library, but not Android, so that's likely a separate issue I need to open with them.

    Now I'm stuck here:

    [00175162] <debug> dfu_req_handling: Reset.
    [00000000] <info> app: Inside main
    [00000000] <debug> app: In nrf_bootloader_init
    [00000000] <debug> app: in weak nrf_dfu_init_user
    [00000000] <debug> app: In real nrf_dfu_init
    [00000000] <debug> nrf_dfu_settings: Running nrf_dfu_settings_init(sd_irq_initialized=false).
    [00000000] <debug> nrf_dfu_flash: Calling nrf_dfu_flash_init(sd_irq_initialized=false)...
    [00000000] <debug> nrf_dfu_flash: Initializing nrf_fstorage_nvmc backend.
    [00000000] <debug> app: Initializing the clock.
    [00000000] <debug> app: Enter nrf_dfu_continue
    [00000002] <debug> app: Valid SD + BL
    [00000003] <debug> app: Enter nrf_dfu_sd_bl_continue
    [00000006] <debug> app: Enter nrf_bootloader_dfu_sd_continue
    [00000009] <debug> app: Updating SD. Old SD ver: 50, New ver: 60
    [00000012] <debug> app: Copying [0x00023000-0x0002D000] to [0x00001000-0x0000B000]: Len: 0x0000A000
    [00000757] <debug> app: Finished copying [0x00023000-0x0002D000] to [0x00001000-0x0000B000]: Len: 0x0000A000
    [00000766] <debug> app: Validated 0x00023000-0x0002D000 to 0x00001000-0x0000B000: Size: 0x0000A000
    [00000770] <debug> app: Finished with the SD update.
    [00000773] <debug> nrf_dfu_settings: Writing settings...
    [00000775] <debug> nrf_dfu_settings: Erasing old settings at: 0x0007F000
    [00000779] <debug> nrf_dfu_flash: nrf_fstorage_erase(addr=0x0x0007F000, len=1 pages), queue usage: 1
    [00000785] <debug> nrf_dfu_flash: Flash erase success: addr=0x0007F000, pending 0
    [00000789] <debug> nrf_dfu_flash: nrf_fstorage_write(addr=0x0007F000, len=0x1B8 bytes), queue usage: 1
    [00000802] <debug> nrf_dfu_flash: Flash write success: addr=0x0007F000, pending 0
    [00000805] <debug> app: Copying [0x0002D000-0x00037000] to [0x0000B000-0x00015000]: Len: 0x0000A000
    [00001551] <debug> app: Finished copying [0x0002D000-0x00037000] to [0x0000B000-0x00015000]: Len: 0x0000A000
    [00001560] <debug> app: Validated 0x0002D000-0x00037000 to 0x0000B000-0x00015000: Size: 0x0000A000
    [00001564] <debug> app: Finished with the SD update.
    [00001567] <debug> nrf_dfu_settings: Writing settings...
    [00001569] <debug> nrf_dfu_settings: Erasing old settings at: 0x0007F000
    [00001573] <debug> nrf_dfu_flash: nrf_fstorage_erase(addr=0x0x0007F000, len=1 pages), queue usage: 1
    [00001579] <debug> nrf_dfu_flash: Flash erase success: addr=0x0007F000, pending 0
    [00001583] <debug> nrf_dfu_flash: nrf_fstorage_write(addr=0x0007F000, len=0x1B8 bytes), queue usage: 1
    [00001596] <debug> nrf_dfu_flash: Flash write success: addr=0x0007F000, pending 0
    [00001599] <debug> app: Copying [0x00037000-0x00041000] to [0x00015000-0x0001F000]: Len: 0x0000A000
    [00002345] <debug> app: Finished copying [0x00037000-0x00041000] to [0x00015000-0x0001F000]: Len: 0x0000A000
    [00002353] <debug> app: Validated 0x00037000-0x00041000 to 0x00015000-0x0001F000: Size: 0x0000A000
    [00002358] <debug> app: Finished with the SD update.
    [00002360] <debug> nrf_dfu_settings: Writing settings...
    [00002363] <debug> nrf_dfu_settings: Erasing old settings at: 0x0007F000
    [00002366] <debug> nrf_dfu_flash: nrf_fstorage_erase(addr=0x0x0007F000, len=1 pages), queue usage: 1
    [00002373] <debug> nrf_dfu_flash: Flash erase success: addr=0x0007F000, pending 0
    [00002377] <debug> nrf_dfu_flash: nrf_fstorage_write(addr=0x0007F000, len=0x1B8 bytes), queue usage: 1
    [00002389] <debug> nrf_dfu_flash: Flash write success: addr=0x0007F000, pending 0
    [00002393] <debug> app: Copying [0x00041000-0x00048000] to [0x0001F000-0x00026000]: Len: 0x00007000
    [00002916] <debug> app: Finished copying [0x00041000-0x00048000] to [0x0001F000-0x00026000]: Len: 0x00007000
    [00002924] <debug> app: Validated 0x00041000-0x00048000 to 0x0001F000-0x00026000: Size: 0x00007000
    [00002928] <debug> app: Finished with the SD update.
    [00002931] <debug> nrf_dfu_settings: Writing settings...
    [00002933] <debug> nrf_dfu_settings: Erasing old settings at: 0x0007F000
    [00002937] <debug> nrf_dfu_flash: nrf_fstorage_erase(addr=0x0x0007F000, len=1 pages), queue usage: 1
    [00002943] <debug> nrf_dfu_flash: Flash erase success: addr=0x0007F000, pending 0
    [00002947] <debug> nrf_dfu_flash: nrf_fstorage_write(addr=0x0007F000, len=0x1B8 bytes), queue usage: 1
    [00002960] <debug> nrf_dfu_flash: Flash write success: addr=0x0007F000, pending 0
    [00002963] <debug> app: Verifying BL: Addr: 0x00073000, Src: 0x00047150, Len: 0x00005A10
    [00002967] <debug> app: Bootloader not verified, copying: Src: 0x00047150, Len: 0x00005A10
    
    <hangs here, reset doesn't help either>

    Thank You,
    Josh

  • Hello, 

    Can you provide a memory dump of your device? One after each try, one with iOS and one with Android. Can you run the following command?

      

    nrfjprog --memrd 0x73000 --n 0xd000 > dump.txt
     

    Are you updating from SDK 14.0 or 14.2?

    jlubawy said:
    Now I'm stuck here:

    Is this with iOS or Android? 

    Thanks!

    Kind regards,
    Øyvind

Reply Children
Related