autoincreasing build number

Posts: 1
Joined: Sun Mar 25, 2018 7:51 pm

autoincreasing build number

Postby aixakt » Sun Mar 25, 2018 7:58 pm

Hi everybody,

I work with the ESP32 IDF in several IoT-Projects. Most I use over the air updates and I need to know which build is running.

Has anyone an idea how I can get automatically increasing build number with every build. I need the number in my program.


User avatar
Posts: 1329
Joined: Mon Nov 16, 2015 4:43 pm
Location: Texas, USA

Re: autoincreasing build number

Postby kolban » Mon Mar 26, 2018 6:06 pm

What about using the C macros __date__ and __time__ which produce string representations of the date and time. Instead of creating a "build number" create a "build date/time"?
Free book on ESP32 available here:

Posts: 1618
Joined: Tue Dec 01, 2015 7:35 am

Re: autoincreasing build number

Postby WiFive » Mon Mar 26, 2018 8:52 pm

You should be able to do this in makefile try googling "makefile automatic build number" for examples

Posts: 71
Joined: Tue Mar 08, 2016 5:03 am

Re: autoincreasing build number

Postby markwj » Thu Mar 29, 2018 6:10 am

Have a look here for how we do it on ESP32: ... MS.V3/main

Look in and ovms_version.{h,cpp}.

We don't use incrementing build numbers (but wouldn't be hard to adapt to that), but instead the output of:

git describe --always --tags --dirty

That comes out looking like this:


We get the version, the incremental commit number, the hash of the last commit, an indication of whether that commit is dirty or not, and then finally we add on whether we are factory/ota and which stream (for ota updates).

We also make sure the code has the version number embedded surrounded by '########' style markers, so we can search through flash to find out the version number.

Who is online

Users browsing this forum: Bing [Bot] and 5 guests