App version usage in code and configuration

Hi there,

Zephyr has ability for an Application version management. Based on this, I have created a "Version" file, without any file name extension (like .txt).

Now I would like to display the version in the "Device Information Service" defined in my prj.conf like:

CONFIG_BT_DIS_FW_REV_STR=$(APP_VERSION_TWEAK_STRING)

But, this gives me: "Assignment ignored. error: Aborting due to Kconfig warnings".

How can I use the firmware version in the device information service?

Thanks for your answer in advance.

Kind regards,

Patrick

Parents
  • Hi,

     

    You need to set this in your CMakeLists.txt file. Kconfig cannot take in variables.

    set(CONFIG_SOME_CONFIG \"${APP_VERSION_TWEAK_STRING}\" CACHE INTERNAL "")

    Make sure to set this before the find_package line.

     

    Could you try this and see if that works as expected?

     

    Kind regards,

    Håkon

  • Dear Håkon,

    While testing with nRF Connect Android application, the value of the Firmware Revision String remains empty.

    Any other ideas?

    Kind regards,

    Patrick

  • Hi Patrick,

     

    You do not need to check with the android app, you can just go into build-folder/zephyr/.config and search for the CONFIG_.

    Or even easier; add a message in cmake:

    include(CMakePrintHelpers)
    cmake_print_variables(APP_VERSION_TWEAK_STRING)

     

    This will not print unless my_project/VERSION file is present. Here's an example of the content of such file:

    VERSION_MAJOR = 2
    VERSION_MINOR = 6
    PATCHLEVEL = 0
    VERSION_TWEAK = 99
    EXTRAVERSION =
    

     

    Which will print:

    -- APP_VERSION_TWEAK_STRING="2.6.0+99"

     

    Kind regards,

    Håkon

  • Dear Håkon,

    I have the following in the cmake:

    # SPDX-License-Identifier: Apache-2.0
    
    cmake_minimum_required(VERSION 3.20.0)
    
    include(CMakePrintHelpers)
    cmake_print_variables(APP_VERSION_TWEAK_STRING)
    
    set(CONFIG_BT_DIS_FW_REV_STR \"${APP_VERSION_TWEAK_STRING}\" CACHE INTERNAL "")
    
    find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE})
    project(new)
    
    zephyr_include_directories(include)
    
    target_sources(app PRIVATE include/main_init.c)
    target_sources(app PRIVATE include/bluetooth.c)
    
    target_sources(app PRIVATE src/main.c)

    The build output in the terminal is:

    -- APP_VERSION_TWEAK_STRING=""

    Therefore the same as in the app.

    Kind regards,

    Patrick

  • Dear Patrick,

     

    What is the content of your VERSION file?

    edit: I see what you mean, one is set after the other, so ordering of when the CONFIG_BT_DIS_FW_REV_STR is set will make it either to be '' or the content of the prj.conf. I'll see if I can find another way around.

     

    Kind regards,

    Håkon

  • Dear Håkon,

    The VERSION file looks like this:

    VERSION_MAJOR = 5
    VERSION_MINOR = 9
    PATCHLEVEL = 8
    VERSION_TWEAK = 7
    EXTRAVERSION = dev

     The folder structure looks like this:

    It seems that the version can be read, as tried to do some DFU's yesterday, where the version was displayed in the Android application as I defined it in the file.

    Kind regards,

    Patrick

Reply Children
  • Dear Patrick,

     

    Try to create a Kconfig file in your project, containing this:

    config BT_DIS_FW_REV_STR
        default "$(APP_VERSION_TWEAK_STRING)" if "$(APP_VERSION_EXTENDED_STRING)" != ""
    
    source "Kconfig.zephyr"

    And see if this configures things as expected now? 

    Please note that any settings in your prj.conf / $board.conf that also sets CONFIG_BT_DIS_FW_REV_STR must be removed.

     

    Kind regards,

    Håkon

Related