How do I access VERSION file parameters from prj.conf?

Hi, basically I want to expose my firmware's version through the GATT DIS (Device Information Service) to client applications.

I have gone through:

  1. the VERSION file documentation
  2. the peripheral_dis sample

And they were both useful: I have a DIS service up and running but I wish to generate the Firmware Revision String characteristics's value from the VERSION file. The documentation says for use in kconfig files, the following variables are available:

My question is: can I use these in the prj.conf file (since it is a Kconfig fragment), where I already have the configuration options for DIS:

CONFIG_BT_DIS=y
CONFIG_BT_DIS_SETTINGS=y
CONFIG_BT_DIS_STR_MAX=21

CONFIG_BT_DIS_PNP=n
CONFIG_BT_DIS_MODEL="TODO"
CONFIG_BT_DIS_MANUF="TODO"
CONFIG_BT_DIS_SERIAL_NUMBER=y
CONFIG_BT_DIS_FW_REV=y
CONFIG_BT_DIS_HW_REV=y
CONFIG_BT_DIS_SERIAL_NUMBER_STR="TODO"
CONFIG_BT_DIS_FW_REV_STR=$(VERSION_MAJOR).$(VERSION_MINOR)
CONFIG_BT_DIS_HW_REV_STR="TODO"

As per my requirments, I can only provide a major.minor version string but the above causes a build time failure. Can Kconfig variables be used in prj.conf files? If I can somehow use these variables in my prj.conf I can populate my DIS's  firmware string revision characteristic using my VERSION file which would be very convenient.

  • one last follow up: does the VERSION file have anything to do with git tags ? What I mean for example is: is it common practice to somehow derive the VERSION file's contents from the latest tag like "v1.0.0" (using a script or a git hook perhaps leveraging git describe)? It would be nice to use git tags to mark stable releases in my repo but if it's too much of a hassle I won't bother.

    Currently, it seems that there is a macro APP_BUILD_VERSION but it does not use anything from the VERSION file and only uses the output from a git describe command. 

  • Hi

    The APP_BUILD_VERSION is a string that can refer to the git description, but you choose yourself in reality. It's usually used for the git tag, but can be used as whatever to describe your build version.

    Best regards,

    Simon

  • Thanks Simon. Here's a video I found on YouTube that addresses using git tags for what I need. I'm going to leave this for anyone reading this thread in the future as a reference, if they're interested.

    That's all for now, you can close the case. Really appreciate your time.

    Regards,

    Shovnik

Related