System ECID Information#

NVIDIA provides the interfaces to get ECID from system with device nodes and NvSys API.

ECID information has 512bit data size to store system information from the manufacturer. They are stored with 128 hex characters at device node under /dev/nvsys/tegra_fuse_ecid.

Precondition:

pct/drive_av/guest_config.h has the configuration for ECID readability defined with can_read_ecid_hash.

…
struct guest_conf gconf[] __attribute__ ((section("guestcfg"))) = {
    [GID_GUEST0_VM] = {
     .magic = GUEST_CFG_MAGIC,
     .guest_start_offset = GOS0_START_OFFSET,
     .guest_phys_mem_size = GOS0_PHYS_MEM_SIZE,
     .guest_dtb_offset = GOS0_DTB_START_OFFSET,
     .guest_name_buffer = GOS0_NAME_BUFFER,
     .guest_phys_mem_growth_factor =
         GOS0_GROWTH_FACTOR,
     .load_using_pl = 1,
     .smmu_cbanks = {39, 39},
     .can_read_ecid_hash = 1,
     .ram_alignment = SZ_8MB,
…

Check if can_read_ecid_hash is 1. If it is not 1, then update to 1.

ECID Information with File I/O at Application#

Note

This method is applicable on system state at initialize or deinitialize; it cannot be applicable on operational or runtime system state.

ECID information can be read with standard file I/O functions at the application level. Example:

#include <sys/types.h>
#include <fcntl.h>
#include <unistd.h>
#include <stdlib.h>
#include <stdio.h>

int main( void )
{
    int fd;
    int size_read;
    /* ecid stored as hexa printout composed with 0x00000000 + ‘\n’ + ‘\0’ */
    char ecid[128];

    /* Open a file for input */
    fd = open( "/dev/nvsys/tegra_fuse_ecid", O_RDONLY );

    /* Read the text */
    size_read = read( fd, ecid,
                      sizeof(ecid) );

    /* Test for error */
    if( size_read == -1 ) {
        perror( "Error reading myfile.dat" );
        return EXIT_FAILURE;
    }

   /*check ecid data & utilize for application */

    /* Close the file */
    close( fd );

    return EXIT_SUCCESS;
}

ECID Information with NvSys API at Application#

Makefile for applications must add the NvSys interface header and library path.

Makefile example:

TARGETS = nvsys_lib_test_qnx

CFLAGS = $(NV_PLATFORM_OPT) $(NV_PLATFORM_CFLAGS)
CPPFLAGS = $(NV_PLATFORM_SDK_INC) $(NV_PLATFORM_CPPFLAGS)
LDFLAGS = $(NV_PLATFORM_SDK_LIB) $(NV_PLATFORM_LDFLAGS)

OBJS = nvsys_test_qnx.o
LDLIBS = -lnvsocsys -lnvos_s3_safety

include ../../../make/nvdefs.mk

ifeq ($(NV_PLATFORM_SAFETY), 1)
    CFLAGS += -DNV_IS_SAFETY
endif

$(TARGETS): $(OBJS)
    $(LD) $(LDFLAGS) -o $@ $^ $(LDLIBS)

clean clobber:
    rm -rf $(OBJS) $(TARGETS)

Sample application:

#include <sys/types.h>
#include <fcntl.h>
#include <unistd.h>
#include <stdlib.h>
#include <stdio.h>
#include "nvsocsysapi_qnx.h"

int main( void )
{
     NvSysTegraECID ecid = {0U,};
     NvSocSysErrCode ret = NvSocSysError;

     /* Initialize NvSys library */
     ret = NvTegraSysInit(NvSysSocAutoDetect);
     if (ret == NvSocSysError) {
         perror( "Error reading myfile.dat" );
         return EXIT_FAILURE;
     }

     /* Get ECID bits */
     ret = NvTegraSysGetFuseHashedECID(&ecid);
     if (ret == NvSocSysError) {
         test_result = NvSocSysError;
     } else {
         test_result = NvSocSysSuccess;
         for (i = 0U; i < ECID_DATA_ARRAY_SIZE; i++) {
             if ((ecid.data[i] == (NvU32)NvSocSysErrUnavailable)) {
                 test_result = NvSocSysError;
             }
         }
     }

     /* Deinitialize NvSys library */
     (void)NvTegraSysDeInit();

     return EXIT_SUCCESS;
}