Copying images, version numbering

Hello,

I have a question regarding copying the generated images to a dedicated location after the build has finished.

I need to copy:

  • build/merged_CPUNET.hex
  • build/merged.hex
  • build/signed_by_mcuboot_and_b0_ipc_radio.bin
  • build/project_name/zephyr/zephyr.signed.encrypted.bin

Total 4 images. The hex files to be used for factory programming and bin files for bootloader. 

After a bit of struggling, I found that sysbuild/CMakeLists is the place to put the copy commands. As there are targets merged_hex and merged_CPUNET_hex available. I.e. depnding on those two targets assures all the images are done, right?

I get the files copied. But the question is how to get the version string, to change the name of the copied file to include the version? 

https://docs.zephyrproject.org/latest/build/version/index.html

states that I could use APP_VERSION_STRING in cmake. But the variable is not populated yet, seems to be.

In short, the question is: how to get the APP_VERSION_NUMBER in systbuild/CMakeLists? So I could copy the files and change the names to include the version number.

I got a recommendation from AI before posting to use:

sysbuild_get(app_version_string IMAGE ${DEFAULT_IMAGE} VAR APP_VERSION_EXTENDED_STRING CACHE)

but it return empty variable. The DEFAULT_IMAGE is correct, checked.

I have "VERSION" file available in root dir, as required.

ncs version 3.0.2

BR, Madis

  • I managed to read the version number:

    defined additional Kconfig variable in my project

    config APPLICATION_VERSION_STRING
    depends on "$(APP_VERSION_EXTENDED_STRING)" != ""
    string "$(APP_VERSION_EXTENDED_STRING)"
    default "$(APP_VERSION_EXTENDED_STRING)"

    And then, querying it from sysbuild/CMakeLists:

    sysbuild_get(version_string IMAGE ${DEFAULT_IMAGE} VAR CONFIG_APPLICATION_VERSION_STRING KCONFIG)

    after the query, variable ${version_string} is populated and usable. Content comes from "VERSION" file, as it should. All good.

    Thanks,

    Madis

Related