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

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

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

1,665 Views
maoyuanluo
Contributor III

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?

Labels (1)
0 Kudos
3 Replies

1,255 Views
dario200
Contributor I

The MONTH definition won't work for June. It will always match January first.

0 Kudos

1,472 Views
Carlos_Mendoza
NXP Employee
NXP Employee

Hi Maoyuan,

Could you tell us which MCU are you using?

Thanks in advance!

Best Regards,
Carlos Mendoza
Technical Support Engineer

0 Kudos

1,472 Views
maoyuanluo
Contributor III

MPC5605B

0 Kudos