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

Bootloader only DFU failed.

Hi,

i have some issue regarding DFU-ing the bootloader.

Here is my command to generate zip file:
nrfutil pkg generate --hw-version 52 --bootloader-version 1 --bootloader output.hex --sd-req 0x9D --key-file private.key bootloader.zip

Now when i try to make the DFU on mobile phone i get NRF_DFU_EXT_ERROR_FW_VERSION_FAILURE.

I have extended bootloader logs and it says:

<error> dfu_req_handling: BL FW version too low, 01 <= 01
<error> dfu_req_handling: Prevalidate failed!

here is code part:

case DFU_FW_TYPE_BOOTLOADER: // fall through
case DFU_FW_TYPE_SOFTDEVICE_BOOTLOADER:
   // updating the bootloader is stricter. There must be an increase in version number
   if (p_init->fw_version <= fw_version)
  {
     NRF_LOG_ERROR("BL FW version too low, %02x <= %02x", p_init->fw_version, fw_version);
    return ext_error_set(NRF_DFU_EXT_ERROR_FW_VERSION_FAILURE);
  }
  break;

But the documentation says:

"The firmware version is too low. For an application, the version must be greater than the current application. For a bootloader, it must be greater than or equal to the current version. This requirement prevents downgrade attacks."

Is this a BUG? Can i keep the bootloader version?

  • Hi,

    Which SDK version are you using?

    Referring to the SDK 15.0.0 implementation, you can see that the implementation of fw_version_ok() should same version to be upgraded for the bootloader (anything not application or SoftDevice):

    static bool fw_version_ok(dfu_init_command_t const * p_init)
    {
        ASSERT(p_init != NULL);
        ASSERT(p_init->has_fw_version);
    
        if (  (p_init->type == DFU_FW_TYPE_APPLICATION)
           || (p_init->type == DFU_FW_TYPE_SOFTDEVICE))
        {
            return ((p_init->fw_version >= s_dfu_settings.app_version) || !NRF_DFU_APP_DOWNGRADE_PREVENTION);
        }
        else
        {
            return  (p_init->fw_version > s_dfu_settings.bootloader_version);
        }
    }

  • No, there is no tag in this question which indicate the SDK version. In any case it seems you have found a mismatch between the documentation and implementation in SDK 14.2. You can see that from line 339-347 in dfu_req_handling.c, where the bootloader and SoftDevice is required to have a higher version number:

                case DFU_FW_TYPE_BOOTLOADER:            // fall through
                case DFU_FW_TYPE_SOFTDEVICE_BOOTLOADER:
                    // updating the bootloader is stricter. There must be an increase in version number
                    if (p_init->fw_version <= fw_version)
                    {
                        NRF_LOG_ERROR("BL FW version too low");
                        return ext_error_set(NRF_DFU_EXT_ERROR_FW_VERSION_FAILURE);
                    }
                    break;

    You can allow upgrading bootloader to the same version by moving line 339 (case DFU_FW_TYPE_BOOTLOADER:) to above line 331.

Related