Before logging an issue, please update to the latest release of Visual Micro from the Downloads Page.

When Logging a Support Issue in the Forum, please ensure you have also:-

  • Enabled vMicro > Compiler > Show Build Properties
  • Re-Compile your program with these settings enabled
 
Save the new Output to a Text File and....
  • Click the Reply button and attach as .txt file OR
  • Click here to Email us with the file attached, and a link to your post
Support requests without the output above may be impossible to answer, so please help us to help you
 
Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic Build date insertion into source code (Read 1007 times)
Turbotronics
Newbies
*
Offline


Posts: 3
Location: Cape Town
Joined: May 3rd, 2022
Build date insertion into source code
May 3rd, 2022 at 1:38pm
Print Post  
I have been using VM with VS Studio 2017 for a number of years with ESP32 and have had few issues. On AVR projects I can insert after the fact a buildate into the binary. This does not work with ESP as the changed file is rejected by the loader. Probably a good thing.
In my code I have:
char builddate[] = {"220414100604"};
Is there a way for VM (via make file maybe?) to do this automatically when I compile? It will need my custom formatting from somewhere?
Thanx
Andre
  
Back to top
 
IP Logged
 
Simon@Visual Micro
Administrator
*****
Offline


Posts: 2697
Joined: Feb 13th, 2019
Re: Build date insertion into source code
Reply #1 - May 3rd, 2022 at 2:18pm
Print Post  
Thanks for the report.

One option is to simply add in the below #defines which will be automatically populated by GCC when compiling:
Code
Select All
#define VAL_DATE __DATE__
#define VAL_TIME __TIME__ 



And can be written out to Serial for example as below:
Code
Select All
	Serial.println(F("---------------------------------------------------"));
	Serial.println(F("Firmware Build"));
	Serial.println(F("---------------------------------------------------"));
	// Output our Validation from GCC Variables
	Serial.print(F("Date:\t"));
	Serial.println(VAL_DATE);
	Serial.print(F("Time:\t"));
	Serial.println(VAL_TIME); 




This approach, and an alternative approach using the prebuild hooks to inject any required information into your code in a Version.h file, are both explained in the below video with an example project linked:
https://www.youtube.com/watch?v=jQ8O9Hi3cDA

Note that for the ESP32 the prebuild.1 and prebuild.2 hooks are already in use, so for safety you would need to amend the board.txt file to be .7 and .8 respectively.
  
Back to top
IP Logged
 
Turbotronics
Newbies
*
Offline


Posts: 3
Location: Cape Town
Joined: May 3rd, 2022
Re: Build date insertion into source code
Reply #2 - May 3rd, 2022 at 8:42pm
Print Post  
Thanx, exactly what I needed!
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint