S32K312 cannot get random numbers

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

S32K312 cannot get random numbers

1,697件の閲覧回数
MengWang1
Contributor I

S32K312 cannot get random numbers

 

/* Identifier for the only MU instance used in this example (MU0) */
#define MU0_INSTANCE_U8                     ((uint8)0U)

/* Identifier of the MU channel used by HSE to listen for administrative requests (eg. read/write attributes) */
#define MU_ADMIN_CHANNEL_U8                 ((uint8)0U)
 
#define TIMEOUT_TICKS_U32                   ((uint32)10000000U)
 
hseSrvResponse_t getRandomNumReq(hseRngClass_t rngClass, uint32_t rngNumSize, uint8_t *rngNum)
{
    hseSrvResponse_t hseStatus = HSE_SRV_RSP_GENERAL_ERROR;

    hseGetRandomNumSrv_t *pGetRndSrv;
    hseSrvDescriptor_t *pHseSrvDesc  = &Hse_aSrvDescriptor[MU_ADMIN_CHANNEL_U8];
    memset(pHseSrvDesc, 0, sizeof(hseSrvDescriptor_t));
    pHseSrvDesc->srvId = HSE_SRV_ID_GET_RANDOM_NUM;
    pGetRndSrv = &(pHseSrvDesc->hseSrv.getRandomNumReq);
    pGetRndSrv->rngClass = rngClass;
    pGetRndSrv->pRandomNum = (HOST_ADDR)rngNum;
    pGetRndSrv->randomNumLength = rngNumSize;

    /* Build the request to be sent to Hse Ip layer */
    HseIp_aRequest[MU_ADMIN_CHANNEL_U8].eReqType   = HSE_IP_REQTYPE_SYNC;
    HseIp_aRequest[MU_ADMIN_CHANNEL_U8].u32Timeout = TIMEOUT_TICKS_U32;

    // hseStatus = HSE_Send(muIf, muChannelIdx, gSyncTxOption, pHseSrvDesc);
    /* Send the request to Hse Ip layer */
    hseStatus = Hse_Ip_ServiceRequest(MU0_INSTANCE_U8, MU_ADMIN_CHANNEL_U8, &HseIp_aRequest[MU_ADMIN_CHANNEL_U8], pGetRndSrv);

    return hseStatus;
}

hseSrvResponse_t cmd_rnd(uint8_t *rngNum)
{
    return getRandomNumReq(HSE_RNG_CLASS_DRG3, 16U, rngNum);
}
 



0 件の賞賛
返信
2 返答(返信)

1,499件の閲覧回数
AlehTS
Contributor II

In my case the following helped:

1. Disable data cache by deleting D_CACHE_ENABLE in Preprocessor

2. Use channel 1 (in your case MU_ADMIN_CHANNEL_U8 = 0)

1,516件の閲覧回数
AlehTS
Contributor II

Hello. I have the same problem. Did you solve it?

My code looks the same as yours.

Hse_Ip_ServiceRequest function returns HSE_SRV_RSP_NOT_ALLOWED.

With demo_app everything is fine. So the HSE is able to regerate randoms.

Before requesting the random numbers I do the same steps, which are performed in Hse_Ip_AesEncAsyncIrq_S32K344 example:

Install and enable the needed interrupt handlers,

Check that HSE is initialized (along with RNG module) by reading the status bits in FSR,

Initialize Hse Ip layer for MU0 instance,

Read HSE FW Capabilities, by sending a request over MU0.

If it is important, the capabilities are: 0x1fdffbdb7

 

Thank you.

 

 

 

 

0 件の賞賛
返信