AnsweredAssumed Answered

Does the __DATE__ & __TIME__ how to build in the upgrade file?

Question asked by maoyuan luo on Aug 15, 2018
Latest reply on Aug 15, 2018 by maoyuan luo

Hi:

   I want to use the MACRO __DATE__ & __TIME__ to judge and select whether upgrade application file or not.

 

MEMORY
{
...
imgheader: org=0x0000C400, len=0x00000400
...
}

 

GROUP : {
.imgheader LOAD (ADDR(imgheader)): {
KEEP(*(.imgheader))
}
} > imgheader

 

#pragma section RW ".imgheader" ".imgheader" data_mode=far_abs

 

#define __imgheader __section(.imgheader)

 

struct imgheader {
void *date;
void *time;
};

 

example1:

__imgheader struct bdl_imgheader bdl_image_header = {
.date = __DATE__,
.time = __TIME__,
};

 

example2:

#define YEAR ((((__DATE__ [7] - '0') * 10 + (__DATE__ [8] - '0')) * 10 + (__DATE__ [9] - '0')) * 10 + (__DATE__ [10] - '0'))

#define MONTH (__DATE__ [2] == 'n' ? 0 \
: __DATE__ [2] == 'b' ? 1 \
: __DATE__ [2] == 'r' ? (__DATE__ [0] == 'M' ? 2 : 3) \
: __DATE__ [2] == 'y' ? 4 \
: __DATE__ [2] == 'n' ? 5 \
: __DATE__ [2] == 'l' ? 6 \
: __DATE__ [2] == 'g' ? 7 \
: __DATE__ [2] == 'p' ? 8 \
: __DATE__ [2] == 't' ? 9 \
: __DATE__ [2] == 'v' ? 10 : 11)

#define DAY ((__DATE__ [4] == ' ' ? 0 : __DATE__ [4] - '0') * 10 + (__DATE__ [5] - '0'))

#define VERSION_DATE ((YEAR << 16) | (MONTH << 8) | (DAY << 0))

#define HOUR (((__TIME__ [0]-'0')*16)+(__TIME__ [1]-'0'))

#define MINUTE (((__TIME__ [3]-'0')*16)+(__TIME__ [4]-'0'))

#define SECOND (((__TIME__ [6]-'0')*16)+(__TIME__ [7]-'0'))

#define VERSION_TIME ((HOUR << 16) | (MINUTE << 8) | (SECOND << 0))

__imgheader struct bdl_imgheader bdl_image_header = {
.date = VERSION_DATE,
.time = VERSION_TIME,
};

 

when I used example1,  the value of bdl_image_header.date = 0x40004E58 & bdl_image_header.time = 0x40004E64,

if I debug, I can got the timestamp in RAM address and the string value is Aug 15 2018 and 18:04:30.

I want to got the value in bin file, then I can check the timestamp for upgrading.

But when I used example2, the value of bdl_image_header.date and bdl_image_header.time is equal 0x00000000.

I doubt that the reason why. Is it because __DATE__ & __TIME__ is a variable? 

 

I want to write a timestamp at a fixed address in the bin file.Can you help me to slove it?

Outcomes