K81 - TRNG_GetRandomData hanging

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

K81 - TRNG_GetRandomData hanging

2,370件の閲覧回数
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 件の賞賛
返信
4 返答(返信)

2,293件の閲覧回数
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 件の賞賛
返信

2,293件の閲覧回数
christian_niels
Contributor I

Hi Jing

That's the funny part is I'm using" TRNG_GetRandomData(TRNG_Type *base, void *data, size_t dataSize) " from NXP.
I have seen that there is a new version on github but I got the same result with that.

0 件の賞賛
返信

2,293件の閲覧回数
jingpan
NXP TechSupport
NXP TechSupport

Hi,

If the SDK example works well, there must be some configure error in your code. For example, the clock is gated by accident or work in CPO mode. Can you share your project?

Regards,

Jing

0 件の賞賛
返信

2,293件の閲覧回数
christian_niels
Contributor I

HI,

Thank you but I'm sorry but I can't share the project but I have hard coded the routine to return a fixed decimal so I can get on with project but I need to solve the problem some hove.

0 件の賞賛
返信