cancel
Showing results for 
Search instead for 
Did you mean: 

Get Build Number ??

RBV
Associate II

Hi

I would like to get buildnumber in stm32 controller and using STM32 cube ide. I can get date and time but not build number. Any suggestions.

__BUILD__,__DATE__,__TIME__

I am getting error on getting buildnumber using __BUILD__.

Any suggestions on how to get it??

5 REPLIES 5
Cartu38 OpenDev
Lead II

Is __BUILD__ supported ? Predefined Macros (The C Preprocessor) (gnu.org)

Maybe have you to build such by your own (based on some PID or ..). Found such which may be interesting: How to store compilation date in the final binary file in order to read it by an external program?

Ozone
Lead

Don't know CubeIDE.

But all modern toolchains have an option to define pre- and post build steps, so one can run e.g. a script to generate those defines with incrementing numbers.

The simplest way is a separate header where you edit the defines manually.

Pre & post build are STM32CubeIDE supported for sure.

Post build is useful for other tasks.

My company uses our own bootloader in a safety environment, so we patch data like checksums into the S19 file after the build.

Paul1
Lead

Would your "build" be your repository version, or are you aiming for something else?

The Keywords __DATE__,__TIME__ are from the compiler, which has no idea what change history you have.

If you are using TortoiseSVN you can under settings set it to run a script when committing, and in TortoiseSVN you can flag a file generated by the script to have select fields updated as part of the commit.

For a group it might be better to put the script on the SVN server to be automatically run for all commits to the repository, it could be similar and create a set of #define accessible in your code.

I just did this Monday: SvnVersion_V01_20210301PR.zip.

Will need a "mid string" function to extract version, and best convert to a numeric to discard any leading spaces.

Paul