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

OTA doesnt work on migrating DFU frimware from sdk15.0.0 to sdk17.0.2

Hello everyone, 

                         I am using NRF52840 development kit. OTA was working fine with SDK VERSION15.0.0. Now I am trying to migrate my developed code from SDK version 15.0.0 to SDK version 17.0.2.

While compiling the DFU firmware I got this error:-

error: #error The configuration NRF_CRYPTO_BACKEND_CC310_BL_ECC_LITTLE_ENDIAN_ENABLED was removed in SDK 15.1.0. Please see release notes for details on removing this error message.

I checked the files of 15.0.0 version, the code is a bit different from that in SDK17.0.2. I am getting the above error while compiling all the .c files from the folder "RF5_SDK_17.0.2_d674dde/components/libraries/crypto/backend/cc310_bl" 

So I removed the following defines from sdk_config.h. 

      NRF_CRYPTO_BACKEND_CC310_BL_HASH_LITTLE_ENDIAN_DIGEST_ENABLED
    - NRF_CRYPTO_BACKEND_CC310_BL_ECC_LITTLE_ENDIAN_ENABLED
    - NRF_CRYPTO_BACKEND_MICRO_ECC_LITTLE_ENDIAN_ENABLED
    - NRF_CRYPTO_BACKEND_NRF_SW_HASH_LITTLE_ENDIAN_DIGEST_ENABLED

after doing this, my code compiled properly. But while testing OTA is not working. I am getting wrong signature error.  

00> <info> nrf_dfu_validation: Calculating init packet hash (init packet len: 64)
00> <info> nrf_dfu_validation: Verify signature
00> <error> nrf_dfu_validation: Signature failed (err_code: 0x8542)

What might be the issue? Please help me on this. I somehow have a feeling that the above disabled defines have to do something with this error.

Parents
  • Hi,

    The configuration macro was removed and the nrf_crypto library no longer has configurable endianness. Therefor you must instead swap the endianness yourself if using little endian. You can refer to the SDK 17 code to see how this is done. Specifically endianness is swapped at three places in components\libraries\bootloader\dfu\nrf_dfu_validation.c (search for "swap_endian"), and that is requiered when using SDK versions that does not have NRF_CRYPTO_BACKEND_CC310_BL_ECC_LITTLE_ENDIAN_ENABLED.

  • Can I add the changes from sdk15 to sdk17 instead? 

  • I am not sure I understand the question. Do you want to modify SDK 17 so tha tit does endian swapping there instead? Iit is certainly possible. In that case, refer to how this is done in SDK 15 by searching for "NRF_CRYPTO_BACKEND_CC310_BL_ECC_LITTLE_ENDIAN_ENABLED" which is used in components\libraries\crypto\backend\cc310_bl\cc310_bl_backend_ecc.c components\libraries\crypto\backend\cc310_bl\cc310_bl_backend_ecdsa.c. I do not see why this is a good idea, though.

  • Thank you for your reply. Yes thats what I meant. I actually compared the changes from sdk 15 and added them in sdk17. The code is working properly but I dont know if its a good thing to do so. 

    Above you mentioned I have to swap endian myself. I am actually a bit confused on how to do it. I saw the file nrf_dfu_validation.c, as you said i see the 3 lines where swap_endian is mentioned. But what do I need to change here??? 

  • Hi,

    sne_333 said:
    Above you mentioned I have to swap endian myself. I am actually a bit confused on how to do it. I saw the file nrf_dfu_validation.c, as you said i see the 3 lines where swap_endian is mentioned. But what do I need to change here??? 

    First of all, nrf_crypto in general work on big endian. However, the DFU protocol works on little endian (for historical reasons and because that is used by BLE). Therefor, the endianness needs to be swapped. That is regardless of using SDK 15.0.0 or 17.0.2 or something else.

    Now, if you compare the SDK 15.0.0 implementation and SDK 17 implementation, you can see that the three function calls used to swap endianness is not used in SDK 15.0.0, because there the swapping is done inside the nrf_crypto module if NRF_CRYPTO_BACKEND_CC310_BL_ECC_LITTLE_ENDIAN_ENABLED is set to 1 in sdk_config.h. As this configuration was removed, swapping now has to be performed by the caller instead, which is why it is done in nrf_dfu_validation.c.

Reply
  • Hi,

    sne_333 said:
    Above you mentioned I have to swap endian myself. I am actually a bit confused on how to do it. I saw the file nrf_dfu_validation.c, as you said i see the 3 lines where swap_endian is mentioned. But what do I need to change here??? 

    First of all, nrf_crypto in general work on big endian. However, the DFU protocol works on little endian (for historical reasons and because that is used by BLE). Therefor, the endianness needs to be swapped. That is regardless of using SDK 15.0.0 or 17.0.2 or something else.

    Now, if you compare the SDK 15.0.0 implementation and SDK 17 implementation, you can see that the three function calls used to swap endianness is not used in SDK 15.0.0, because there the swapping is done inside the nrf_crypto module if NRF_CRYPTO_BACKEND_CC310_BL_ECC_LITTLE_ENDIAN_ENABLED is set to 1 in sdk_config.h. As this configuration was removed, swapping now has to be performed by the caller instead, which is why it is done in nrf_dfu_validation.c.

Children
Related