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.

Parents
  • Yes, this should be possible, but you have to format it as a string, so CONFIG_BT_DIS_FW_REV_STR="0.0.1" for example. 

    What kind of build failures/error messages are you seeing exactly? They usually provide a hint towards what exactly is wrong or a suggestion on what to do, so please follow that, or upload the build log here if you're confused.

    Best regards,

    Simon

Reply
  • Yes, this should be possible, but you have to format it as a string, so CONFIG_BT_DIS_FW_REV_STR="0.0.1" for example. 

    What kind of build failures/error messages are you seeing exactly? They usually provide a hint towards what exactly is wrong or a suggestion on what to do, so please follow that, or upload the build log here if you're confused.

    Best regards,

    Simon

Children
  • Hi Simon. Thanks for your time. Your example shows a hardcoded string "0.0.1" but I want to substitute the values of the $(VERSION_MAJOR) and $(VERSION_MINOR) variables into the CONFIG_BT_DIS_FW_REV_STR macro.
    If I do something like CONFIG_BT_DIS_FW_REV_STR="$(VERSION_MAJOR).$(VERSION_MINOR)", it will be treated literally:

    so I was wondering, if there's some special syntax for using $(variables) in prj.conf. I searched online but unfortunately couldn't find anything concrete on this, other than the Kconfig language reference which details the syntax for Kconfig, not prj.conf. 

    When I try using the unquoted variables like in my original post: CONFIG_BT_DIS_FW_REV_STR=$(VERSION_MAJOR).$(VERSION_MINOR), I get the below logs on build failure:

    c:/Users/91833/Documents/NordicSemiconductor/myApps/RedSOS-Touch/prj.conf:70: warning: malformed string literal in assignment to BT_DIS_FW_REV_STR (defined at C:/ncs/v2.6.0__/nrf\subsys\bluetooth\services\fast_pair/Kconfig.fast_pair:36, C:/ncs/v2.6.0__/zephyr/subsys/bluetooth/services\Kconfig.dis:117, C:/ncs/v2.6.0__/zephyr/subsys/bluetooth/host\../services\Kconfig.dis:117, subsys/bluetooth\host\../services\Kconfig.dis:117). Assignment ignored.
    
    error: Aborting due to Kconfig warnings
    
    Parsing C:/Users/91833/Documents/NordicSemiconductor/myApps/RedSOS-Touch/Kconfig
    Loaded configuration 'C:/ncs/v2.6.0__/zephyr/boards/arm/nrf52dk_nrf52832/nrf52dk_nrf52832_defconfig'
    Merged configuration 'c:/Users/91833/Documents/NordicSemiconductor/myApps/RedSOS-Touch/prj.conf'
    CMake Error at C:/ncs/v2.6.0__/zephyr/cmake/modules/kconfig.cmake:358 (message):
      command failed with return code: 1
    Call Stack (most recent call first):
      C:/ncs/v2.6.0__/nrf/cmake/modules/kconfig.cmake:29 (include)
      C:/ncs/v2.6.0__/zephyr/cmake/modules/zephyr_default.cmake:129 (include)
      C:/ncs/v2.6.0__/zephyr/share/zephyr-package/cmake/ZephyrConfig.cmake:66 (include)
      C:/ncs/v2.6.0__/zephyr/share/zephyr-package/cmake/ZephyrConfig.cmake:92 (include_boilerplate)
      CMakeLists.txt:8 (find_package)

    Any thoughts?

    EDIT: A small addendum - I read the Image Versions doc and it specifies two related macros: CONFIG_FW_INFO_FIRMWARE_VERSION and CONFIG_MCUBOOT_IMGTOOL_SIGN_VERSION. The latter, as the document states, is an alternative to using the VERSION file. So I'm a little confused as to whether I should set these or not if I already have a VERSION file? particularly the first one - CONFIG_FW_INFO_FIRMWARE_VERSION?

Related