NCS 2.5.0: CMake Error ... version.cmake:74 (math): math cannot parse the expression

After updating the NCS from 2.4.2 to 2.5.0 my project cannot be created.

The following error occurs:

-- CMake version: 3.20.5
-- Found Python3: D:/Nordic/toolchains/c57af46cb7/opt/bin/python.exe (found suitable version "3.8.2", minimum required is "3.8") found components: Interpreter
-- Cache files will be written to: D:/Nordic/v2.5.0/zephyr/.cache
-- Zephyr version: 3.4.99 (D:/Nordic/v2.5.0/zephyr)
CMake Error at D:/Nordic/v2.5.0/zephyr/cmake/modules/version.cmake:74 (math):
  math cannot parse the expression: "( << 16) + ( << 8) + ()": syntax error,
  unexpected exp_SHIFTLEFT (4).
Call Stack (most recent call first):
  D:/Nordic/v2.5.0/zephyr/cmake/modules/zephyr_default.cmake:129 (include)
  D:/Nordic/v2.5.0/zephyr/share/zephyr-package/cmake/ZephyrConfig.cmake:66 (include)
  D:/Nordic/v2.5.0/zephyr/share/zephyr-package/cmake/ZephyrConfig.cmake:92 (include_boilerplate)
  CMakeLists.txt:11 (find_package)


CMake Error at D:/Nordic/v2.5.0/zephyr/cmake/modules/version.cmake:75 (math):
  math cannot parse the expression: "( << 24) + ( << 16) + ( << 8) + ()":
  syntax error, unexpected exp_SHIFTLEFT (4).
Call Stack (most recent call first):
  D:/Nordic/v2.5.0/zephyr/cmake/modules/zephyr_default.cmake:129 (include)
  D:/Nordic/v2.5.0/zephyr/share/zephyr-package/cmake/ZephyrConfig.cmake:66 (include)
  D:/Nordic/v2.5.0/zephyr/share/zephyr-package/cmake/ZephyrConfig.cmake:92 (include_boilerplate)
  CMakeLists.txt:11 (find_package)

How can I fix this?

Parents Reply Children
  • Hi Jonathan,

    i'm not able to recall all the samples tested because a lot of experiments, but i spent a bit of time to prepare something you can test on:

    Here the samples/configurations i tested:

    - "hello world" for both nrf5340dk_cpuapp and nrf5340dk_cpuapp_ns target --> ERROR on version.cmake (the same Marko W made the post for)

    - "peripheral_hr" for both nrf5340dk_cpuapp and nrf5340dk_cpuapp_ns target --> WORKING

    Toolchain: 2.5.0

    SDK: 2.5.0

    I hope this helps,

    Frax

  • Hi Jonathan,

    any news about this issue? I read the posts following this one, but i am not able to come out of this error, even with the last 2.5.2 (2.4.2 working).

    I tried to fix this error adding the VERSION file (filled as docs says) to the same folder of prj.conf together with #include <app_version.h> but absolutely nothing changed.

  • did you add the spaces like Marko W did ?

    I am not able to replicate the issue as you describe here in this post. 

    Regards,
    Jonathan

  • I was able to fix the issue by changing how/when my mcuboot.conf was included.

    In previous NCS versions I appended my mcuboot.conf in app/CMakeLists.txt:

    ...
    list(APPEND mcuboot_OVERLAY_CONFIG "${CMAKE_CURRENT_SOURCE_DIR}/mcuboot.conf")


    SET(mcuboot_CONFIG_BOOT_SIGNATURE_KEY_FILE "\"${CMAKE_CURRENT_SOURCE_DIR}/keys/private/boot-ecdsa-p256.pem\"")

    find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE})
    ...

    It think appending the conf file before finding the Zephyr package was causing the issue. I changed my app/CMakeLists.txt to this:

    ...
    SET(mcuboot_CONFIG_BOOT_SIGNATURE_KEY_FILE "\"${CMAKE_CURRENT_SOURCE_DIR}/keys/private/boot-ecdsa-p256.pem\"")

    SET(mcuboot_CONFIG_BOOT_SIGNATURE_TYPE_ECDSA_P256 "y")

    find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE})
    ...


    and I moved my mcuboot.conf file to app/child_image/mcuboot.conf so West knows it belongs to the MCUBoot child image.

    Now MCUBoot builds without issue.

Related