Skip to main content
RBV
Associate II
March 3, 2021
Question

Get Build Number ??

  • March 3, 2021
  • 3 replies
  • 2323 views

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??

This topic has been closed for replies.

3 replies

Cartu38 OpenDev
Graduate II
March 3, 2021

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
Principal
March 3, 2021

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.

Cartu38 OpenDev
Graduate II
March 3, 2021

Pre & post build are STM32CubeIDE supported for sure.

Ozone
Principal
March 3, 2021

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
Senior III
March 3, 2021

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