Failed to seed PRNG: mbedTLSError = <No-High-Level-Code> : CTR_DRBG - The Entropy source failed

I am using mbedTLS library and below API for initilaisation, i got stuck at adding entropy source to seed the PRNG. how can i proceed on this, any suggestions on this? Below is my code.

this is the error message i got :
Failed to seed PRNG: mbedTLSError = : CTR_DRBG - The Entropy source failed

      /* Initialize contexts for random number generation. */
     mbedtls_entropy_init( pEntropyContext );
     mbedtls_ctr_drbg_init( pCtrDrgbContext );

 /* Add a strong entropy source. At least one is required. */
    mbedtlsError = mbedtls_entropy_add_source( pEntropyContext,
                                                mbedtls_platform_entropy_poll,
                                                NULL,
                                                32,
                                                MBEDTLS_ENTROPY_SOURCE_STRONG );

     if( mbedtlsError != 0 )
     {
    	 LogError( ( "Failed to add entropy source: mbedTLSError= %s : %s.",
                     mbedtlsHighLevelCodeOrDefault( mbedtlsError ),
                     mbedtlsLowLevelCodeOrDefault( mbedtlsError ) ) );
         returnStatus = TLS_TRANSPORT_INTERNAL_ERROR;
     }

     if( returnStatus == TLS_TRANSPORT_SUCCESS )
     {
         /* Seed the random number generator. */
         mbedtlsError = mbedtls_ctr_drbg_seed( pCtrDrgbContext,
                                               mbedtls_entropy_func,
                                               pEntropyContext,
                                               NULL,
                                               0 );

Is this a FreeRTOS question?
If you step into the mbedtls_entropy_add_source() function in the debugger you should see what is failing, and why. Did you do that?

yes, i am not giving proper entropy source.
Can i use pkcs11 for RNG in my free RTOS application, where i have to use mbedTLS for mutual authentication.

You can use the PKCS #11 API to itnerface to the RNG, but PKCS #11 doesn’t provide RNG functionality itself.

Thankyou.
I am not very sure about the different ways to set RNG. I have started working with freertos recently, and i am trying to implement tls. It would be great if you could enlighten me with some tips and ways to achieve that. Thanks!

If you are looking for an example to use PKCS11 with mbedTLS, this can help - FreeRTOS/FreeRTOS-Plus/Demo/corePKCS11_MQTT_Mutual_Auth_Windows_Simulator at main · FreeRTOS/FreeRTOS · GitHub

Thankyou.
I am not very sure about the different ways to set RNG in mbedTLS. Can you suggest me other ways to do. Thanks!

You might be better off with the mbedTLS documentation: ⚡ Mbed TLS

hi, can i get any document where i get information on PKCS11 interface with mbedTLS. Also which version of mbedTLS will work with PKCS11.

There is a reference implementation here corePKCS11/source/portable/mbedtls at d6a519146598ec2ccd6f0230a01fca876767a8fe · FreeRTOS/corePKCS11 · GitHub if that helps.