Nios® V/II Embedded Design Suite (EDS)
Support for Embedded Development Tools, Processors (SoCs and Nios® V/II processor), Embedded Development Suites (EDSs), Boot and Configuration, Operating Systems, C and C++
12610 Discussions

System ID and creation timestamp (sysid)

Altera_Forum
Honored Contributor II
1,389 Views

Hi: 

 

Perhaps this is very simple but.... 

 

I'd like to use the SysId component timestamp field for system validation purposes, but not as simple as the long lvalue compare the HAL does, what I want is to convert this timestamp value (seconds elapsed from january 1st, 1970) to year, month, day,... 

 

Has anyone done it before? Is there any code available for doing this convertion? 

 

Thanks,
0 Kudos
1 Reply
Altera_Forum
Honored Contributor II
602 Views

Hi VLorenzo, 

 

> I want is to convert this timestamp value (seconds elapsed from january 1st, 1970) to 

> year, month, day, 

<<snip>> 

> Has anyone done it before? Is there any code available for doing this convertion? 

 

Yes, the u-boot code supports this. Here&#39;s a snip of code from cpu/nios2/sysid.c (code 

is available at: http://www.psyent.com/download (http://www.psyent.com/download) ) 

void display_sysid (void) {        struct nios_sysid_t *sysid = (struct nios_sysid_t *)CFG_NIOS_SYSID_BASE;        struct tm t;        char asc;        time_t stamp;        stamp = readl (&sysid->timestamp);        localtime_r (&stamp, &t);        asctime_r (&t, asc);        printf ("SYSID : %08x, %s", readl (&sysid->id), asc); } 

I believe the hal has support for asctime_r and localtime_r ... if not, you can just 

hoist the code from the u-boot sources. 

 

Regards, 

--Scott
0 Kudos
Reply