K81 - TRNG_GetRandomData hanging

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

K81 - TRNG_GetRandomData hanging

576 Views
christian_niels
Contributor I

I am trying to get some random data from K81 hardware and I'm using TRNG_GetRandomData from fsl_trng.c.

I'm using it in connection with :

//***********************************************************************************************************

return_code = mbedtls_rsa_rsaes_pkcs1_v15_encrypt(key, trng_ctr_drbg_random, NULL, MBEDTLS_RSA_PUBLIC, sizeof(_pers_kbpk), (const uint8_t*)&_pers_kbpk.data, enc_pers_kbpk_ptr);

static int trng_ctr_drbg_random(void* notused, unsigned char* output, size_t output_len)
{
    return ( TRNG_GetRandomData(TRNG0, output, output_len) );
}

//***********************************************************************************************************

In TRNG_GetRandomData it hangs in the check while loop:

while ((TRNG_RD_MCTL_ENT_VAL(base) == 0) && (TRNG_RD_MCTL_ERR(base) == 0))
{
}

and never gets out.
If I run debug one step at a time it works perfect but if it runs normal it hangs.
Is there a workaround for this issue ?

It is configured with TRNG_Init and default config.

uint32_t trng_enable()
{
   trng_config_t trngConfig;

   TRNG_GetDefaultConfig(&trngConfig);
   trngConfig.sampleMode = kTRNG_SampleModeVonNeumann;

   return (TRNG_Init(TRNG0, &trngConfig));
}

0 Kudos
Reply
1 Reply

536 Views
jingpan
NXP TechSupport
NXP TechSupport

Hi Christian,

I can't reproduce you problem at my board. Did you try the trng example in the SDK?

 

Regards,

Jing

0 Kudos
Reply