How would you go about adding the version and 8 characters of the git hash to the hexfile name so we can also access it in the program?
Say we have a STM32 project called Foo. When it is compiled, it generates an intel hex file called Foo.hex that we can use to upgrade the file in the field. That is easy.
What we would like to do as add the version say 10.1 or 10_1 and the last 8 digits of the git hash. And the number of compiles since the last git commit to the file name. We can do that;
So we commit say version 10.1 with the last 8 digits of the commit being 63245699.
We want the name of the file to be Foo10_1_0_63245699.hex. And when asked for the version over I2C the Foo program provides 10_1_0 or 10_1_0_63245699. If the file on the computer is a newer version than on the STM32 board, we activate the boot loader and update the software over I2C. (That part is working) .
If we compile the program again, the name adds 1 to the number of files since last commit. so the name changes to Foo10_1_1_63245699.hex
If we compile again Foo10_1_2_63245699.hex
When we commit we up the version and the number of compiles since the last commit goes back to zero. So the name is Foo10_2_0_23798241.hex (the hash also changes when we commit)
How do we get that name into the program so when the program is asked for the version we can output it on the I2C?
Someone else has done this with the Microchip compiler/IDE and now I have been asked to add the same capabilities to the STM32CubeIDE for when we compile.
How do I start? For the microchip IDE they modified the makefile, but the STM32CubeIDE makefile says "Automatically-generated file. Do not edit" so if I did edit it, somewhere down the line, an update could change it and wipe out my modifications?
What is the recommendation?

