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

Error finding #if NRF_MODULE_ENABLED(NRF_CRYPTO_RNG)

Hello - 

I have created a project with both a SoftDevice S132 and nRF Crypto libraries. All has gone well so far. I am now trying to implementing RNG, following the example project \nRF5_SDK_17.0.2_d674dde\examples\crypto\nrf_crypto\rng\pca10040\blank\ses\nrf_crypto_rng_pca10040.emProject

The example project runs fine. Unfortunately, when I try to mimic its functions in my main project, it is failing compilation because it does not recognize the definition "#if NRF_MODULE_ENABLED(NRF_CRYPTO_RNG)" in line 52 of the file nrf_crypto_rng.c. I have tried to mimic includes, all project options, sdk_config.h settings but I still cannot figure out how to enable NRF_CRYPTO_RNG so that it compiles the portion of code below line 52 of file nrf_crypto_rng.c

My question is.... in the nrf_crypto_rng_pca10040 example project, where exactly is NRF_CRYPTO_RNG (line 52 of file nrf_crypto_rng.c) defined? I thought that stating "#define NRF_CRYPTO_RNG_AUTO_INIT_ENABLED 1" in my sdk_config.h file might achieve this but it does not.

Thank you for your support.

Regards,

Kevin

  • FYI, I believe I solved this. The fix was to arrange the user include directories (project options) in the same sequence as the example project. The same directories were always there, but somehow the sequence mattered. Lame.

  • Hello,

    That's not good, the order of which the files are included should obviously not matter. I have gone through the process of adding nrf crypto to new projects a few times, but don't think I have encountered this exact problem before. I might have been lucky. Anyway. I have tried to do a quick review of the code and I couldn't spot any coding errors that could explain why you got the build error. And to answer your question, NRF_CRYPTO_RNG_ENABLED should become defined in either nrf_hw_backend_rng.h, or nrf_hw_backend_rng_mbedtls.h, depending on whether you have both NRF_CRYPTO_BACKEND_NRF_HW_RNG_ENABLED and NRF_CRYPTO_BACKEND_NRF_HW_RNG_MBEDTLS_CTR_DRBG_ENABLED enabled or not.

    Best regards,

Related