-->
Page 1 of 1

How to get date and time of uploaded firmware?

PostPosted: Mon Sep 14, 2020 5:04 am
by Arthur Khusnutdinov
Hello.

I have some kind of smart home on multiple esp8266, and I periodically update code of their firmwares via OTA.
And sometimes I forget to upload actual code on them. For example, I don't remember, if I uploaded a new version of firmware to esp8266, that serves in toilet :) .

Each of esp8266 firmware is *.bin file, if I understood it correctly. Each of file has time of creation.
And question is - does esp8266 stores date and time of firmware, uploaded via OTA (or update) and is there any Arduino program method to get that date and time?

Re: How to get date and time of uploaded firmware?

PostPosted: Wed Sep 16, 2020 3:21 am
by quackmore
The gcc option -D NAME defines a preprocessor macro NAME from the command line

I use it to generate the firmware version at compile time

the following example works on linux, and I'm not using Arduino, so checkout if you can adapt it to your environment

Code: Select allthe following compiler flag defines a preprocessor macro with the git version

-DAPP_RELEASE=\"$($(shell git --no-pager describe --tags --always --dirty))\"

changing it to
-DFILE_DATE=\"$($(shell date))\"

it's like you define the following
#define FILE_DATE "current_date"
and you can then use the macro FILE_DATE inside your code

Re: How to get date and time of uploaded firmware?

PostPosted: Wed Sep 16, 2020 9:32 am
by martinayotte
GCC has builtin variables to do the same thing, example :
Code: Select allsprintf(str, "Build Version : %s %s \r\n", __DATE__, __TIME__ );

Re: How to get date and time of uploaded firmware?

PostPosted: Wed Sep 16, 2020 9:40 am
by quackmore
Code: Select allGCC has builtin variables to do the same thing, example :
CODE: SELECT ALL
sprintf(str, "Build Version : %s %s \r\n", __DATE__, __TIME__ );


Ya, easier and without the extra flags...