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

Can't run hash verification after DFU (NRF_ERROR_CRYPTO_INPUT_LOCATION)

Hi,

I'm having problems with the bootloader in SDK 15.2. I'm using an NRF52840, I don't know if the CryptoCell is giving me issues.

The DFU fails when checking the FW hash for post validation. I'm getting error 0x8512 (NRF_ERROR_CRYPTO_INPUT_LOCATION), which means that the data should be in RAM. However, the bootloader uses this function to calculate the hash of the firmware that is in flash, in bank 1. Why am I getting this error? Any ideas?

This is the code that fails, in the function fw_hash_ok() in nrf_dfu_validation.c, line 553:

err_code = nrf_crypto_hash_calculate(&m_hash_context,
                                     &g_nrf_crypto_hash_sha256_info,
                                     (uint8_t*)fw_start_addr,
                                     fw_size,
                                     m_fw_hash,
                                     &hash_len);

if (err_code != NRF_SUCCESS)
{
    NRF_LOG_ERROR("Could not run hash verification (err_code 0x%x).", err_code);
    result = false;
}

I haven't modified the bootloader, the code is compiled directly out of the SDK directory.

Parents
  • Hi,

    The bootloader (ie crypto module) uses RAM buffer when calculating the hash of the image in flash so you shouldn't get this error. Could you double check that you have the following configuration in your sdk_config.h file?

    // <i> CC310_BL backend implementation for hardware-accelerated SHA-256.

    #ifndef NRF_CRYPTO_BACKEND_CC310_BL_HASH_SHA256_ENABLED
    #define NRF_CRYPTO_BACKEND_CC310_BL_HASH_SHA256_ENABLED 1
    #endif

    // <q> NRF_CRYPTO_BACKEND_CC310_BL_HASH_AUTOMATIC_RAM_BUFFER_ENABLED - nrf_cc310_bl buffers to RAM before running hash operation

    // <i> Enabling this makes hashing of addresses in FLASH range possible. Size of buffer allocated for hashing is set by NRF_CRYPTO_BACKEND_CC310_BL_HASH_AUTOMATIC_RAM_BUFFER_SIZE

    #ifndef NRF_CRYPTO_BACKEND_CC310_BL_HASH_AUTOMATIC_RAM_BUFFER_ENABLED
    #define NRF_CRYPTO_BACKEND_CC310_BL_HASH_AUTOMATIC_RAM_BUFFER_ENABLED 1
    #endif

    // <o> NRF_CRYPTO_BACKEND_CC310_BL_HASH_AUTOMATIC_RAM_BUFFER_SIZE - nrf_cc310_bl hash outputs digests in little endian
    // <i> Makes the nrf_cc310_bl hash functions output digests in little endian format. Only for use in nRF SDK DFU!

    #ifndef NRF_CRYPTO_BACKEND_CC310_BL_HASH_AUTOMATIC_RAM_BUFFER_SIZE
    #define NRF_CRYPTO_BACKEND_CC310_BL_HASH_AUTOMATIC_RAM_BUFFER_SIZE 4096
    #endif

  • Thank you! I had NRF_CRYPTO_BACKEND_CC310_BL_HASH_AUTOMATIC_RAM_BUFFER_ENABLED set to 0.

Reply Children
No Data
Related