Cmake Error "Math cannot parse the expression" with NCS > 2.4.2

Hello,

i'm using nrf connect sdk 2.4.2 to develop the firmware for my custom nrf5340 board without issues. I'm trying to upgrade to the the latest release but both 2.5.0 and 2.5.2 gives me this error when trying to compile:

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).

I found THIS issue on DevZone that is extremely similar to my one and posted there some material to test on, but i didn't get any feedback in few months. For this reason, i'm opening a new issue.

The issue is clearly correlated to the Application versioning, but even reading the docs and making some tests i was not able to solve it.

Any suggestion?

Frax

Parents
  • I'm a bit at a loss here. Could you upload your project so I can have a look?

    Just to summarize 

    New version of the SDK

    new sample project with only hello world and no changes? Are you including any file named version in your project folder? I don't believe are you, just need to check. 

    Could you generate the support information from vscode and post it here?

    Regards

    Runar

    NB: Due to public holidays here in Norway, we will be out until the 2. of April. 

  • Hi runsiv,

    Correct, new version of SDK and toolchain. Project with only hellow world and no changes. I am NOT including any file named version in my project folder. 

    Here follows the support information generated from vscode:

    IMPORTANT: The data below could contain sensitive or confidential information about your environment.
    If you do not wish this to be seen by others, please make sure to remove it before sharing.
    
    For help and support, visit the Nordic DevZone at https://devzone.nordicsemi.com/.
    
    {
      "platform": {
        "os": "win32",
        "osVersion": "Windows 10 Home",
        "osKernel": "10.0.19045",
        "vscode": "1.87.2",
        "electron": "27.3.2",
        "node": "v18.17.1"
      },
      "system": {
        "date": "2024-03-27T15:58:04.253Z",
        "vscodeRoot": "c:\\Users\\Frax\\AppData\\Local\\Programs\\Microsoft VS Code\\resources\\app",
        "nrfConnectForDesktopInstalled": true,
        "vscodeUptime": "00:01:26",
        "osUptime": "07:24:04",
        "cpu": "Intel(R) Core(TM) i7-10510U CPU @ 1.80GHz"
      },
      "workspace": {
        "name": "nrf5340_PASTO (Workspace)",
        "workspaceFile": "c:\\nrf5340_PASTO\\nrf5340_PASTO.code-workspace",
        "folders": [
          "c:\\nrf5340_PASTO",
          "c:\\nrf5340dk_projects\\PASTO\\hello_world"
        ]
      },
      "sdks": [
        {
          "version": "v2.6.0",
          "path": "c:\\ncs\\v2.6.0"
        },
        {
          "version": "v2.4.2",
          "path": "c:\\ncs\\v2.4.2"
        }
      ],
      "activeBuild": "c:\\nrf5340_PASTO\\Glass_firmware\\build-DK",
      "apps": [
        {
          "workspace": "c:\\nrf5340_PASTO",
          "uri": "c:\\nrf5340_PASTO\\Glass_firmware",
          "buildConfigurations": [
            {
              "id": "c:\\nrf5340_PASTO\\Glass_firmware\\build_glass_nrf5340",
              "name": "build_glass_nrf5340",
              "boardId": "pasto_glass_nrf5340_cpuapp_ns",
              "type": "Zephyr",
              "isChild": false,
              "isStale": true,
              "taskBindings": {
                "build": [],
                "pristineBuild": [],
                "flash": [],
                "eraseAndFlash": []
              }
            },
            {
              "id": "c:\\nrf5340_PASTO\\Glass_firmware\\build_glass-nrf5340_rev",
              "name": "build_glass-nrf5340_rev",
              "boardId": "pasto_glass_nrf5340_cpuapp_ns",
              "type": "Zephyr",
              "isChild": false,
              "isStale": true,
              "taskBindings": {
                "build": [],
                "pristineBuild": [],
                "flash": [],
                "eraseAndFlash": []
              }
            },
            {
              "id": "c:\\nrf5340_PASTO\\Glass_firmware\\build-DK",
              "name": "build-DK",
              "boardId": "pasto_glass_nrf5340_cpuapp_ns",
              "type": "Zephyr",
              "isChild": false,
              "isStale": false,
              "taskBindings": {
                "build": [],
                "pristineBuild": [],
                "flash": [],
                "eraseAndFlash": []
              }
            }
          ]
        },
        {
          "workspace": "c:\\nrf5340dk_projects\\PASTO\\hello_world",
          "uri": "c:\\nrf5340dk_projects\\PASTO\\hello_world",
          "buildConfigurations": [
            {
              "id": "c:\\nrf5340dk_projects\\PASTO\\hello_world\\hello_world_PASTO_BOARD",
              "name": "hello_world_PASTO_BOARD",
              "boardId": "nrf5340dk_nrf5340_cpuapp_ns",
              "type": "Zephyr",
              "isChild": false,
              "isStale": false,
              "taskBindings": {
                "build": [],
                "pristineBuild": [],
                "flash": [],
                "eraseAndFlash": []
              }
            }
          ]
        }
      ],
      "topdir": "c:\\ncs\\v2.6.0",
      "workspaceState": "freestanding-ready",
      "toolchains": [
        {
          "version": "2.6.0",
          "path": "c:\\ncs\\toolchains\\cf2149caf2"
        },
        {
          "version": "2.4.2",
          "path": "c:\\ncs\\toolchains\\31f4403e35"
        }
      ],
      "connectedDevices": [],
      "deviceProvider": "nrfutil",
      "tools": {
        "C:\\ncs\\toolchains\\cf2149caf2\\opt\\zephyr-sdk\\arm-zephyr-eabi\\bin\\arm-zephyr-eabi-gcc.exe": "0.16.5",
        "C:\\Program Files\\SEGGER\\JLink_V794e\\JLink.exe": "7.94e",
        "C:\\Program Files\\Nordic Semiconductor\\nrf-command-line-tools\\bin\\nrfjprog.exe": "10.24.0",
        "nrfutil": "Not found",
        "C:\\ncs\\toolchains\\cf2149caf2\\opt\\bin\\cmake.exe": "3.21.0",
        "C:\\ncs\\toolchains\\cf2149caf2\\opt\\bin\\Scripts\\west.exe": "1.2.0",
        "C:\\ncs\\toolchains\\cf2149caf2\\opt\\bin\\python.exe": "3.9.13",
        "C:\\ncs\\toolchains\\cf2149caf2\\opt\\bin\\ninja.exe": "1.10.2",
        "C:\\ncs\\toolchains\\cf2149caf2\\opt\\bin\\gperf.exe": "3.1",
        "C:\\ncs\\toolchains\\cf2149caf2\\opt\\bin\\dtc.exe": "1.4.7",
        "C:\\ncs\\toolchains\\cf2149caf2\\opt\\bin\\gn.exe": "2154",
        "C:\\ncs\\toolchains\\cf2149caf2\\mingw64\\bin\\git.exe": "2.37.3.windows.1",
        "gdbPath": "c:\\ncs\\toolchains\\cf2149caf2\\opt\\zephyr-sdk\\arm-zephyr-eabi\\bin\\arm-zephyr-eabi-gdb.exe"
      },
      "nrfutil": {
        "nrfutil-device": {
          "version": "2.0.0",
          "binPath": "c:\\Users\\Frax\\.vscode\\extensions\\nordic-semiconductor.nrf-connect-2024.3.25-win32-x64\\platform\\nrfutil\\bin\\nrfutil-device"
        },
        "nrfutil-toolchain-manager": {
          "version": "0.14.1",
          "binPath": "c:\\Users\\Frax\\.vscode\\extensions\\nordic-semiconductor.nrf-connect-2024.3.25-win32-x64\\platform\\nrfutil\\bin\\nrfutil-toolchain-manager"
        }
      },
      "environment": {
        "westEnv": {
          "ELECTRON_RUN_AS_NODE": "1",
          "HOME": "C:\\Users\\Frax",
          "HOMEDRIVE": "C:",
          "HOMEPATH": "\\Users\\Frax",
          "PATH": "C:\\ncs\\toolchains\\cf2149caf2;C:\\ncs\\toolchains\\cf2149caf2\\mingw64\\bin;C:\\ncs\\toolchains\\cf2149caf2\\bin;C:\\ncs\\toolchains\\cf2149caf2\\opt\\bin;C:\\ncs\\toolchains\\cf2149caf2\\opt\\bin\\Scripts;C:\\ncs\\toolchains\\cf2149caf2\\opt\\nanopb\\generator-bin;C:\\ncs\\toolchains\\cf2149caf2\\opt\\zephyr-sdk\\aarch64-zephyr-elf\\bin;C:\\ncs\\toolchains\\cf2149caf2\\opt\\zephyr-sdk\\x86_64-zephyr-elf\\bin;C:\\ncs\\toolchains\\cf2149caf2\\opt\\zephyr-sdk\\arm-zephyr-eabi\\bin;C:\\ncs\\toolchains\\cf2149caf2\\opt\\zephyr-sdk\\riscv64-zephyr-elf\\bin;c:\\Users\\Frax\\.vscode\\extensions\\nordic-semiconductor.nrf-connect-2024.3.25-win32-x64\\platform\\nrfutil\\lib\\nrfutil-toolchain-manager;C:\\Program Files (x86)\\Common Files\\Oracle\\Java\\javapath;C:\\Program Files (x86)\\NVIDIA Corporation\\PhysX\\Common;C:\\Windows\\system32;C:\\Windows;C:\\Windows\\System32\\Wbem;C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\;C:\\Windows\\System32\\OpenSSH\\;C:\\Program Files\\NVIDIA Corporation\\NVIDIA NvDLISR;C:\\Program Files (x86)\\IVI Foundation\\VISA\\WinNT\\Bin\\;C:\\Program Files\\IVI Foundation\\VISA\\Win64\\Bin\\;C:\\Program Files (x86)\\IVI Foundation\\VISA\\WinNT\\Bin;C:\\WINDOWS\\system32;C:\\WINDOWS;C:\\WINDOWS\\System32\\Wbem;C:\\WINDOWS\\System32\\WindowsPowerShell\\v1.0\\;C:\\WINDOWS\\System32\\OpenSSH\\;C:\\Program Files (x86)\\PuTTY\\;C:\\Program Files (x86)\\Windows Kits\\8.1\\Windows Performance Toolkit\\;C:\\Users\\Frax\\AppData\\Local\\Packages\\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\\LocalCache\\local-packages\\Python310\\Scripts;C:\\bin;C:\\Program Files\\Git\\cmd;C:\\Program Files\\Nordic Semiconductor\\nrf-command-line-tools\\bin\\;C:\\Users\\Frax\\AppData\\Local\\Microsoft\\WindowsApps;;C:\\Program Files\\JetBrains\\PhpStorm 2019.3.3\\bin;;C:\\Program Files\\JetBrains\\PyCharm Community Edition 2021.2.3\\bin;;C:\\Program Files\\JetBrains\\IntelliJ IDEA Community Edition 2021.3\\bin;;C:\\Users\\Frax\\AppData\\Local\\Programs\\Microsoft VS Code\\bin;C:\\Users\\Frax\\go\\bin",
          "ZEPHYR_BASE": "c:\\ncs\\v2.6.0\\zephyr",
          "ZEPHYR_TOOLCHAIN_VARIANT": "zephyr",
          "ZEPHYR_SDK_INSTALL_DIR": "C:\\ncs\\toolchains\\cf2149caf2\\opt\\zephyr-sdk",
          "PYTHONPATH": "C:\\ncs\\toolchains\\cf2149caf2\\opt\\bin;C:\\ncs\\toolchains\\cf2149caf2\\opt\\bin\\Lib;C:\\ncs\\toolchains\\cf2149caf2\\opt\\bin\\Lib\\site-packages"
        },
        "inherited": {
          "ELECTRON_RUN_AS_NODE": "1",
          "HOME": "C:\\Users\\Frax",
          "HOMEDRIVE": "C:",
          "HOMEPATH": "\\Users\\Frax",
          "Path": "C:\\Program Files (x86)\\Common Files\\Oracle\\Java\\javapath;C:\\Program Files (x86)\\NVIDIA Corporation\\PhysX\\Common;C:\\Windows\\system32;C:\\Windows;C:\\Windows\\System32\\Wbem;C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\;C:\\Windows\\System32\\OpenSSH\\;C:\\Program Files\\NVIDIA Corporation\\NVIDIA NvDLISR;C:\\Program Files (x86)\\IVI Foundation\\VISA\\WinNT\\Bin\\;C:\\Program Files\\IVI Foundation\\VISA\\Win64\\Bin\\;C:\\Program Files (x86)\\IVI Foundation\\VISA\\WinNT\\Bin;C:\\WINDOWS\\system32;C:\\WINDOWS;C:\\WINDOWS\\System32\\Wbem;C:\\WINDOWS\\System32\\WindowsPowerShell\\v1.0\\;C:\\WINDOWS\\System32\\OpenSSH\\;C:\\Program Files (x86)\\PuTTY\\;C:\\Program Files (x86)\\Windows Kits\\8.1\\Windows Performance Toolkit\\;C:\\Users\\Frax\\AppData\\Local\\Packages\\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\\LocalCache\\local-packages\\Python310\\Scripts;C:\\bin;C:\\Program Files\\Git\\cmd;C:\\Program Files\\Nordic Semiconductor\\nrf-command-line-tools\\bin\\;C:\\Users\\Frax\\AppData\\Local\\Microsoft\\WindowsApps;;C:\\Program Files\\JetBrains\\PhpStorm 2019.3.3\\bin;;C:\\Program Files\\JetBrains\\PyCharm Community Edition 2021.2.3\\bin;;C:\\Program Files\\JetBrains\\IntelliJ IDEA Community Edition 2021.3\\bin;;C:\\Users\\Frax\\AppData\\Local\\Programs\\Microsoft VS Code\\bin;C:\\Users\\Frax\\go\\bin",
          "PATH": "C:\\Program Files (x86)\\Common Files\\Oracle\\Java\\javapath;C:\\Program Files (x86)\\NVIDIA Corporation\\PhysX\\Common;C:\\Windows\\system32;C:\\Windows;C:\\Windows\\System32\\Wbem;C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\;C:\\Windows\\System32\\OpenSSH\\;C:\\Program Files\\NVIDIA Corporation\\NVIDIA NvDLISR;C:\\Program Files (x86)\\IVI Foundation\\VISA\\WinNT\\Bin\\;C:\\Program Files\\IVI Foundation\\VISA\\Win64\\Bin\\;C:\\Program Files (x86)\\IVI Foundation\\VISA\\WinNT\\Bin;C:\\WINDOWS\\system32;C:\\WINDOWS;C:\\WINDOWS\\System32\\Wbem;C:\\WINDOWS\\System32\\WindowsPowerShell\\v1.0\\;C:\\WINDOWS\\System32\\OpenSSH\\;C:\\Program Files (x86)\\PuTTY\\;C:\\Program Files (x86)\\Windows Kits\\8.1\\Windows Performance Toolkit\\;C:\\Users\\Frax\\AppData\\Local\\Packages\\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\\LocalCache\\local-packages\\Python310\\Scripts;C:\\bin;C:\\Program Files\\Git\\cmd;C:\\Program Files\\Nordic Semiconductor\\nrf-command-line-tools\\bin\\;C:\\Users\\Frax\\AppData\\Local\\Microsoft\\WindowsApps;;C:\\Program Files\\JetBrains\\PhpStorm 2019.3.3\\bin;;C:\\Program Files\\JetBrains\\PyCharm Community Edition 2021.2.3\\bin;;C:\\Program Files\\JetBrains\\IntelliJ IDEA Community Edition 2021.3\\bin;;C:\\Users\\Frax\\AppData\\Local\\Programs\\Microsoft VS Code\\bin;C:\\Users\\Frax\\go\\bin"
        },
        "toolchainPath": "c:\\ncs\\toolchains\\cf2149caf2",
        "toolchainBinPath": "c:\\ncs\\toolchains\\cf2149caf2\\opt\\zephyr-sdk\\arm-zephyr-eabi\\bin",
        "toolchainVersion": "2.6.0"
      },
      "terminal": {
        "defaultProfile": null
      },
      "config": {
        "nordic-semiconductor.nrf-connect": {
          "topdir": "${nrf-connect.sdk:2.6.0}",
          "toolchain": {
            "path": "${nrf-connect.toolchain:2.6.0}"
          },
          "ozonePath": "",
          "applications": [
            "${workspaceFolder}\\Glass_firmware"
          ],
          "applicationOptions": {},
          "kconfig": {
            "interface": "kconfig"
          },
          "west": {
            "env": {
              "$base": "terminal"
            }
          },
          "boardRoots": [],
          "taskBindings": {},
          "buildTerminal": {
            "condensedProgress": true
          },
          "debugging": {
            "flash": true,
            "bindings": {},
            "justMyCode": true
          },
          "activeAppFollowActiveEditor": true,
          "deviceProvider": "",
          "flash": {
            "softreset": false,
            "erase": false,
            "recover": false
          },
          "enableTelemetry": false,
          "thirdpartyIntegration": {},
          "toolchainManager": {
            "indexURL": null,
            "installDirectory": null
          },
          "nrfutil": {
            "home": null
          },
          "defaultOpenAction": "ask",
          "welcome": {
            "showOnStartup": true
          }
        },
        "nordic-semiconductor.nrf-terminal": {
          "terminalMode": "character"
        }
      },
      "extensions": {
        "internal": {
          "nordic-semiconductor.nrf-connect": {
            "version": "2024.3.25",
            "path": "c:\\Users\\Frax\\.vscode\\extensions\\nordic-semiconductor.nrf-connect-2024.3.25-win32-x64",
            "isActive": true
          },
          "nordic-semiconductor.nrf-terminal": {
            "version": "2024.3.15",
            "path": "c:\\Users\\Frax\\.vscode\\extensions\\nordic-semiconductor.nrf-terminal-2024.3.15",
            "isActive": true
          },
          "nordic-semiconductor.nrf-devicetree": {
            "version": "2024.3.78",
            "path": "c:\\Users\\Frax\\.vscode\\extensions\\nordic-semiconductor.nrf-devicetree-2024.3.78",
            "isActive": true
          },
          "nordic-semiconductor.nrf-kconfig": {
            "version": "2024.3.21",
            "path": "c:\\Users\\Frax\\.vscode\\extensions\\nordic-semiconductor.nrf-kconfig-2024.3.21",
            "isActive": true
          }
        },
        "external": {
          "marus25.cortex-debug": null,
          "ms-vscode.cpptools": "1.19.9",
          "ms-vscode.js-debug": "1.87.0",
          "ms-vscode.js-debug-companion": "1.1.2",
          "ms-vscode.vscode-js-profile-table": "1.0.8",
          "alexnesnes.teleplot": "1.1.3",
          "esbenp.prettier-vscode": "10.4.0",
          "GitHub.codespaces": "1.16.17",
          "GitHub.remotehub": "0.62.0",
          "Gruntfuggly.todo-tree": "0.0.226",
          "mintlify.document": "2.2.1",
          "MS-CEINTL.vscode-language-pack-it": "1.87.2024031309",
          "ms-vscode.azure-repos": "0.38.0",
          "ms-vscode.cpptools-extension-pack": "1.3.0",
          "ms-vscode.cpptools-themes": "2.0.0",
          "ms-vscode.remote-repositories": "0.40.0",
          "PKief.material-icon-theme": "4.34.0",
          "redhat.vscode-yaml": "1.14.0",
          "tomoki1207.pdf": "1.2.2",
          "trond-snekvik.gnu-mapfiles": "1.1.0"
        }
      }
    }

    No problem for the holydays, please enjoy them Slight smile

    It's important i solve the issue but i'm not in hurry.

    Thanks,

    Frax

  • Hi,
    Just started to take a look.
    I wonder why there is a double `VERSION/VERSION` here:

    -- west build: generating a build system
    ERRORC:/ncs/v2.6.0/zephyr/VERSION/VERSION

    This indicates to me that the problem might be related to `VERSION` somehow being appended twice to that setting and therefore not found during build, which again causes values for the match operation to be empty and therefore fail.

    It would be a big help if you can provide a CMake trace file for further investigation as to what exactly happens.
    Run the `west build ...` command as printed in your last comment and then add:

    -- --trace-expand 2> cmake.trace

    and attach the cmake.trace file to this thread.

  • Reason for the `/VERSION/VERSION` printing is found.
    It happens because the VERSION_FILE variable is a CMake lists of two elements, which in CMake is separated by a `;`.

    But when you're printed the message, that list is concatenated into a single string, and the `;` disappears in that process, so this part actually looks correct.

    But a cmake.trace file is still valuable for further investigations.

  •  Would you by any chance have a stray `VERSION` file at the root of your system, like `c:\VERSION` ?

    If you do, can you try to remove it, and see if that is the cause of the error.

  • Oh, my, god!

    Finally! That was the issue...i suppose that VERSION file is related to a totally different software (probably "Go" programming).

    Thank you very much for your support. I could not be able to solve it alone even in one month! Slight smile

  • Thank you for confirming the issue and for your patience while troubleshooting it! This was a difficult one. 

Reply Children
No Data
Related