Single bank DFU update in SDK16 fails

Hello,

I am trying to do a single bank DFU update using nRF Connect app and have SDK 16 on my device. I have set NRF_DFU_SINGLE_BANK_APP_UPDATES to 1. Bot looking at postvalidate (attached below) in nrf_dfu_validation.c, it automatically swicthes to Bank 1. Is there some settings that I am missing?

Thank you.

nrf_dfu_result_t postvalidate(uint32_t data_addr, uint32_t data_len, bool is_trusted)
{
nrf_dfu_result_t ret_val = NRF_DFU_RES_CODE_SUCCESS;
dfu_init_command_t const * p_init = mp_init;

if (!fw_hash_ok(p_init, data_addr, data_len))
{
ret_val = EXT_ERR(NRF_DFU_EXT_ERROR_VERIFICATION_FAILED);
}
else
{
if (p_init->type == DFU_FW_TYPE_APPLICATION)
{
if (!postvalidate_app(p_init, data_addr, data_len, is_trusted))
{
ret_val = NRF_DFU_RES_CODE_INVALID_OBJECT;
}
}
#if NRF_DFU_SUPPORTS_EXTERNAL_APP
else if (p_init->type == DFU_FW_TYPE_EXTERNAL_APPLICATION)
{
if (!is_trusted)
{
// This function must be implemented externally
ret_val = nrf_dfu_validation_post_external_app_execute(p_init, is_trusted);
}
else
{
s_dfu_settings.bank_1.bank_code = NRF_DFU_BANK_VALID_EXT_APP;
}
}
#endif // NRF_DFU_SUPPORTS_EXTERNAL_APP
else
{
bool with_sd = p_init->type & DFU_FW_TYPE_SOFTDEVICE;
bool with_bl = p_init->type & DFU_FW_TYPE_BOOTLOADER;

if (!postvalidate_sd_bl(p_init, with_sd, with_bl, data_addr, data_len, is_trusted))
{
ret_val = NRF_DFU_RES_CODE_INVALID_OBJECT;
if (is_trusted && with_sd && !DFU_REQUIRES_SOFTDEVICE &&
(data_addr == nrf_dfu_softdevice_start_address()))
{
nrf_dfu_softdevice_invalidate();
}
}
}
}

if (!is_trusted)
{
if (ret_val == NRF_DFU_RES_CODE_SUCCESS)
{
s_dfu_settings.bank_current = NRF_DFU_CURRENT_BANK_1;
}
else
{
dfu_progress_reset();
}
}
else
{
if (ret_val == NRF_DFU_RES_CODE_SUCCESS)
{
// Mark the update as complete and valid.
s_dfu_settings.bank_1.image_crc = crc32_compute((uint8_t *)data_addr, data_len, NULL);
s_dfu_settings.bank_1.image_size = data_len;
}
else
{
nrf_dfu_bank_invalidate(&s_dfu_settings.bank_1);
}

dfu_progress_reset();
s_dfu_settings.progress.update_start_address = data_addr;
}

return ret_val;
}

  • Hey Terje,

    I set the --sd-req to 0xCD (I am using s112 v7.0.1) and I incremented the application version with the exact same outcome.

    Before:

    nrfjprog --memrd 0x7E000 --n 128 --family nrf52
    0x0007E000: D8D55457 00000002 00000001 00000002 |WT..............|
    0x0007E010: 00000000 00000000 0004625C C5DFD660 |........\b..`...|
    0x0007E020: 00000001 00000000 00000000 00000000 |................|
    0x0007E030: 00000000 00000000 00000000 00000000 |................|
    0x0007E040: 00000000 00000000 00000000 00000000 |................|
    0x0007E050: 00000000 00000000 00000000 FFFFFFFF |................|
    0x0007E060: FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF |................|
    0x0007E070: FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF |................|

    After:

    nrfjprog --memrd 0x7E000 --n 128 --family nrf52
    0x0007E000: C66D1D39 00000002 00000002 00000002 |9.m.............|
    0x0007E010: 00000000 00000000 00000000 00000000 |................|
    0x0007E020: 00000001 0004625C FFDD4169 00000000 |....\b..iA......|
    0x0007E030: 00000000 00000000 00000000 00000000 |................|
    0x0007E040: 00000000 00000000 00019000 00000000 |................|
    0x0007E050: 00000000 00000000 00000000 FFFFFFFF |................|
    0x0007E060: FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF |................|
    0x0007E070: FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF |................|

    I am also setting NRF_BL_DFU_ALLOW_UPDATE_FROM_APP to 1. Although setting it to 0 does not make a difference either.

  • Hey Terje,

    I am currently changing the code as follows to get single bank update to work. Please let me know if you see any issues with this. Thanks.

    nrf_dfu_result_t postvalidate(uint32_t data_addr, uint32_t data_len, bool is_trusted)

    .

    .

    .
    else
    {
    if (ret_val == NRF_DFU_RES_CODE_SUCCESS)
    {
    // Mark the update as complete and valid.
    s_dfu_settings.bank_1.image_crc = crc32_compute((uint8_t *)data_addr, data_len, NULL);
    s_dfu_settings.bank_1.image_size = data_len;
    #if NRF_DFU_SINGLE_BANK_APP_UPDATES
    s_dfu_settings.bank_0.image_crc = s_dfu_settings.bank_1.image_crc;
    s_dfu_settings.bank_0.image_size = data_len;
    #endif // NRF_DFU_SINGLE_BANK_APP_UPDATES
    }
    .

    .

    .

    return ret_val;
    }

Related