I was wondering if anyone could shed some light on an elegant way to discover the application version from within the application. When using the http_update example, we populate CONFIG_APPLICATION_VERSION with an application version number. If that value is different from the application currently running, mcuboot updates the firmware.

Presumably mcuboot holds this value somewhere - does anyone know the mechanics of how this is accomplished? I would like to have access to this value in the application, but I don’t love the idea of having to keep track of it manually in a define somewhere as well as in the prj.conf since I’m bound to forget to update it at some point. Are the CONFIG values available to the compilation process somehow, like you would do for compile-time defines? If so, is there an easy way to get these values from within application code?

Thanks for any help, I’m having difficulty getting my head around everything at the same time.

    TrivialSolution I believe that there is a APPLICATION_VERSION config variable which then gets populated so NCS can sign binaries correctly.

    https://docs.zephyrproject.org/latest/develop/west/sign.html

    You can actually see what Nordic does to sign in

    nrf/modules/mcuboot/CMakeLists.txt

    They use CONFIG_MCUBOOT_IMAGE_VERSION instead though:

        set(sign_cmd
          ${PYTHON_EXECUTABLE}
          ${ZEPHYR_MCUBOOT_MODULE_DIR}/scripts/imgtool.py
          sign
          --key ${mcuboot_key_file}
          --header-size $<TARGET_PROPERTY:partition_manager,PM_MCUBOOT_PAD_SIZE>
          --align       ${CONFIG_MCUBOOT_FLASH_WRITE_BLOCK_SIZE}
          --version     ${CONFIG_MCUBOOT_IMAGE_VERSION}
          --pad-header
          )

    Which is defined here: /Users/jaredwolff/Git/sigmavista/nrf/modules/mcuboot/Kconfig

    config MCUBOOT_IMAGE_VERSION
    	string "Image version"
    	default "0.0.0+0"
    	help
    	  Value to be passed as 'version' argument to 'imgtool.py' when
    	  creating signed image. Note that no semantics are connected to
    	  this variable. It does not provide downgrade prevention, and is only
    	  valuable for debugging purposes. Format: maj.min.rev+build with
    	  latter parts optional.

    I did a video on it previously on how I do it.

    https://www.youtube.com/watch?v=kRqkIdKOkkg&t=1s

    Terms and Conditions | Privacy Policy