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, I know I have asked before, but could you post the version file located in your ncs/v2.6/zephyr/ folder?
    The developers are asking for it so just running through all steps here

    Regards

    Runar

  • VERSION_MAJOR = 3
    VERSION_MINOR = 5
    PATCHLEVEL = 99
    VERSION_TWEAK = 0
    EXTRAVERSION =
    

    Here you go! Please note that the file is 6 lines, with the 6th line empty

  • Thanks! I have forwarded it. It looks just the same as mine, but just need to verify everything

    Regards

    Runar

  • By the way, Have you tried to delete the build folder after you changed SDK version? It sometimes fixes strange issues. 
    I also got a request for the VERSION file itself, if you could upload and not copy paste it would be great

    Regards

    Runar

Reply Children
  • By the way, Have you tried to delete the build folder after you changed SDK version? It sometimes fixes strange issues.

    Yes, i tried Disappointed No changes.

    Here find attached the VERSION file (i had to zip because no extension file is not supported here)VERSION.zip

  • Hello,

    The CMake script is clearly failing to read the version assignments from the VERSION file, but I don't understand why. I don't encounter this issue when I build a project with your file either. So, this issue doesn't appear to be related to the one discussed in the linked ticket, where the culprit seemed to be an invalid VERSION file (missing whitespaces).

    To see if this might be an issue with the SDK files, please try to open a terminal in VS Code by pressing Ctrl+Shift+P to open the command palette. Then, type nRF Connect SDK: Open Toolchain Terminal Profile followed by Enter to open the terminal.

    From the opened terminal, change the directory to 'nrf', and type git branch to verify you are on the v2.5.x branch. Then, enter west update to ensure all repositories are aligned with the revisions from the west manifest.

  • From the opened terminal, change the directory to 'nrf', and type git branch to verify you are on the v2.5.x branch. Then, enter west update to ensure all repositories are aligned with the revisions from the west manifest.

    Can you please confirm what you mean with "change the directory to "nrf"? I have my sdk branches in "C:/ncs". If i type "cd nrf" i get errors.

  • Did you open the terminal as I explained above? It should open in the current SDK root directory. E.g., C:/ncs/v2.5.2/

  • Hello,

    after some tests i think that something is off. Let's proceed schematically. This is my folder structure (the relevant folders at least):

    C
    ->ncs
      ->downloads
      ->tmp
      ->toolchains
      ->v2.4.2
      ->v2.6.0
    ->nrf5340_PASTO
      ->boards
      ->Glass_firmware
        ->build-DK
        ->src
    ->nrf5340dk_projects
      ->PASTO
        ->hello_world
          ->build
          ->src
        

    Here you can find a short description of each folder:

    - ncs -> It's the folder where toolchains and SDK are

    - nrf5340_PASTO -> It's my main project folder (the one i want to work with at the end of this story). You can notice custom board, source code and build folder.

    - nrf5340dk_projects -> This is the folder where i load sample projects to test on. The "hello_world" you see in it is the one you're supporting me on to test.

    Now, given this structure:

    1) When i open the terminal and digit "cd nrf" i get error because "C:/nrf5340_PASTO/nrf" path does not exist;

    2) If i type "git branch" staying in "C:/nrf5340_PASTO" folder i get "main" as answer

    3) If i manually go to "C:/ncs/v2.6.0" and type "git branch" i get "not a git repository" error

    4) If i manually go to "C:/ncs/v2.4.2" and type "git branch" i get "not a git repository" error

    5) About 3) and 4) please notice that if i try to build using nrf connect 2.4.2 it builds correctly, while if i try to build using nrf connect 2.6.0 i get the error at the origin of the post.

    I hope this helps. Waiting for your feedback,

    Frax

Related