AM2634: HSM Client TRNG only works once after power up

Part Number: AM2634

Tool/software:

Hi TI Team,

I am facing the same issue. Please check the below logs -

[HSM_CLIENT] New Client Registered with Client Id = 1

>
> 591021127,2844193811,1501736650,2937302301
TRNG: 591021127

>
>
[HSM_CLIENT] Get Random Number request NACKed by HSM server
TRNG: 0

Code Implementation -

void init_trng(void) {

	HsmClient_register(&hsm_client, APP_CLIENT_ID);

    getRNG.DRBGMode = 0x5A;
    getRNG.seedSizeInDWords = SEED_SIZE_IN_DWORDS;
    getRNG.seedValue = (uint32_t *)&RngDrbgSeed;
    getRNG.resultLengthPtr = &rng_length;
    getRNG.resultPtr = (uint8_t *)rng_val;
}

uint32_t generate_trng(void) {
	int32_t status = SystemP_SUCCESS;

	status = HsmClient_gettRandomNum(&hsm_client, &getRNG);

	if (SystemP_SUCCESS == status) {
		UPRINTF("%u,%u,%u,%u\n\r", rng_val[0], rng_val[1], rng_val[2], rng_val[3]);
		return rng_val[0];
	} else {
		return 0;
	}
}

Thanks,
Rahul

  • Hi Rahul,

    Sorry for the delay in response. Is this seen on HS-FS or HS-SE device?

    Thanks and Regards,

    Nikhil Dasan

  • Hi Nikhil,

    It is for HS-SE device. I am using the tifs_am263x_hs_se.release.bin file.

    Thanks,

    Rahul

  • Hi Rahul,

    I apologize as the expert is currently out of office. Please expect a response sometime next week when they return

    Thank you,

    AJ Favela

  • Logs of HSM Service example -

    Starting QSPI Bootloader ...
    KPI_DATA: [BOOTLOADER_PROFILE] Boot Media : NOR SPI FLASH
    KPI_DATA: [BOOTLOADER_PROFILE] Boot Media Clock : 80.000 MHz
    KPI_DATA: [BOOTLOADER_PROFILE] Boot Image Size : 40 KB
    KPI_DATA: [BOOTLOADER_PROFILE] Cores present :
    r5f0-0
    KPI_DATA: [BOOTLOADER PROFILE] System_init : 303us
    KPI_DATA: [BOOTLOADER PROFILE] Drivers_open : 83us
    KPI_DATA: [BOOTLOADER PROFILE] LoadHsmRtFw : 9039us
    KPI_DATA: [BOOTLOADER PROFILE] Board_driversOpen : 49us
    KPI_DATA: [BOOTLOADER PROFILE] CPU load : 2938us
    KPI_DATA: [BOOTLOADER PROFILE] SBL End : 2384us
    KPI_DATA: [BOOTLOADER_PROFILE] SBL Total Time Taken : 14799us

    Image loading done, switching to application ...

    [HSM CLIENT] Sending UID Request to HSM Server..
    [HSM CLIENT] Device UID Successfully retrived from the HSM Server.

    [HSM CLIENT_PROFILE] Time taken by GetUID Request : 47us

    [HSM CLIENT] Device UID is : 1686C4B362F67028D5A3BBD60F298B3BDD19C18A0E6BF46D384A7F017DCB06BB5CCA50C6B9A55DD30D13FE20063C38C8A67239FB950B26DA7C3BD78854D55D78[HSM CLIENT] TIFS-MCU 64bit version string = 0

    [HSM CLIENT] TIFS-MCU Information
    [Soc Type] = AM263x
    [Device Type] = HS-FS
    [HSM Type] = HSM_V1
    [Bin Type] = STANDARD
    [TIFS-MCU Version] = 10.0.0

    RNG output word -- 0xB96F8BFE
    RNG output word -- 0x3C4EA0E6
    RNG output word -- 0x445E988D
    RNG output word -- 0x83E8656A


    [HSM CLIENT_PROFILE] Time taken by get RNG request : 451us

    [HSM_CLIENT] Get Random Number request NACKed by HSM server
    ASSERT: 0.80674s: ../trng_service_app.c:HsmRngApp_start:75: status == SystemP_SUCCESS failed !!!

  • Hi,

    Sorry for the delay here. 

    Can you share me the source code for the above for me to check the way the service is called in the SBL code?

    Thanks and Regards,

    Nikhil Dasan

  • Hi Nikhil,

    I am using the TI example code located at:
    C:\ti\mcu_plus_sdk_am263x_10_01_00_31\examples\drivers\hsmclient\hsm_services

    In the hsm_client_app.c file, the function HsmRngApp_start(&gHSMClient); is called twice. On the second call, the following error occurs:
    [HSM_CLIENT] Get Random Number request NACKed by HSM server

    /* Demo Application code on R5 */
    void HsmClientApp_start(void)
    {
        /*Function call to the desired services*/
        getUIDApp(&gHSMClient);
        getVersionApp(&gHSMClient);
        HsmRngApp_start(&gHSMClient);
    	HsmRngApp_start(&gHSMClient);
        HsmFirewallApp(&gHSMClient);
    }

    Thanks,
    Rahul

  • Hi Rahul,

    I checked this at my end on the latest SDK 11.0 and there was no issue on this SDK

    [SBL] Starting QSPI Bootloader ...
    KPI_DATA: [BOOTLOADER_PROFILE] CPU Clock        : 400.000 MHz
    KPI_DATA: [BOOTLOADER_PROFILE] Boot Media       : NOR SPI FLASH
    KPI_DATA: [BOOTLOADER_PROFILE] Boot Media Clock : 80.000 MHz
    KPI_DATA: [BOOTLOADER_PROFILE] Boot Image Size  : 39 KB
    KPI_DATA: [BOOTLOADER_PROFILE] Cores present    :
    r5f0-0
    KPI_DATA: [BOOTLOADER PROFILE] System_init                      :        540us
    KPI_DATA: [BOOTLOADER PROFILE] Drivers_open                     :         95us
    KPI_DATA: [BOOTLOADER PROFILE] Board_driversOpen                :        114us
    KPI_DATA: [BOOTLOADER PROFILE] LoadHsmRtFw                      :       9393us
    KPI_DATA: [BOOTLOADER PROFILE] CPU load                         :       6718us
    KPI_DATA: [BOOTLOADER PROFILE] SBL End                          :          3us
    KPI_DATA: [BOOTLOADER_PROFILE] SBL Total Time Taken             :      16865us
    
    [SBL] Image loading done, switching to application ...
    
     [HSM CLIENT] Sending UID Request to HSM Server..
     [HSM CLIENT] Device UID Successfully retrived from the HSM Server.
    
     [HSM CLIENT_PROFILE] Time taken by GetUID Request : 47us
    
     [HSM CLIENT] Device UID is : 5240D89758660F169881920163AC410103527C947EAE763D40897B8757EC2603E90662D275A42EEE433F8447E72E8EC912337423EC3E180C421FF4AE4BC17C52[HSM CLIENT] TIFS-MCU 64bit version string = 0x0015501000b0000
    
     [HSM CLIENT] TIFS-MCU Information
    [Soc Type]          = AM263x
    [Device Type]       = HS-FS
    [HSM Type]          = HSM_V1
    [Bin Type]          = STANDARD
    [TIFS-MCU Version]  = 11.0.0
    
    RNG output word -- 0x6349DD14
    RNG output word -- 0xDA962868
    RNG output word -- 0xC944888B
    RNG output word -- 0x817520C
    
    
     [HSM CLIENT_PROFILE] Time taken by get RNG request : 449us
    RNG output word -- 0x41D8C172
    RNG output word -- 0x71061C8C
    RNG output word -- 0xBDF8250D
    RNG output word -- 0xBFBBABD4
    
    
     [HSM CLIENT_PROFILE] Time taken by get RNG request : 448us
    Firewall request #1 status = 11111111 11111111
    Firewall Id = 12
    Firewall region number = 2
    Start Address = 0x502f0000
    End Address = 0x502f0fff
    Aid Config = 0x10
    Supervisor Read = 1
    Supervisor Write = 1
    Supervisor Execute = 1
    User Read = 1
    User Write = 1
    User Execute = 1
    Non Secure Access = 1
    Emulation = 1
    
    Firewall Id = 13
    Firewall region number = 2

    I was able to reproduce this on SDK 10.1 HSFS, but there was no issue in HSSE SDK 10.1. There were multiple fixes on the HSFS firmware that went in from SDK 10.1 to SDK 11.0 most prominant ones including some firewall fixes.

    I would suggest using the latest SDK at your end. Do let me know if you are facing any issues in the same.

    Thanks and Regards,

    Nikhil Dasan