Installation of NCS 2.3.0 under macOS

Hi,

I first installed the command line tools (nrfjprog + JLink ARM), followed by nRF Connect for Desktop v4.1.1. I then installed nRF Connect SDK v2.3.0 using Toolchain Manager v1.2.4 on two computers: 1. Apple x86, macOS 11.x and 2. Apple M1, macOS 13.x. I let Toolchain Manager install nRF Connect extension v2023.4.179 for VS Code (v1.78.2 Universal). On both computers I had some issues:

  1. I manually installed the C/C++ extension v1.15.4 for Apple M1; this required deleting the extension folder for the non-universal version that had been installed by Toolchain Manager
  2. From Toolchain Manager I had to run the option "Generate environment script" and run this in the macOS Terminal with the sh command from inside the workspace repo folder
  3. I edited the include and browse paths in c_cpp_settings.json, explicitly adding the include path for NRFXLIB NRF_MODEM
  4. I edited the include path in nrf connect extension (partly because it does not recognize all legal VS Code syntax from c_cpp_settings.json)
  5. I added "NRF9160_XXAA" in the "defines" section of c_cpp_settings.json
  6. I installed nrfjprog version 10.21.0 external for macOS 13.x & version 10.15.x for macOS 11
  7. I installed JLinkARM.dll v7.88b (Universal) for all versions of macOS
I have some remaining issues:
  1. The west command runs successfully after a build configuration, but west is not recognized in the macOS or VS Code terminals
  2. newlib.h refers to picolibc.h, which is not included in NCS 2.3.0 - everything builds OK, but it causes distracting red squiggles in VS Code
  3. Flashing larger merged hex files to the nRF9160 DK fails frequently with varying errors
I know of other users who have encountered similar issues with macOS. Does anyone have a template, or link(s) to documentation, showing the required settings ("defines", include & browse paths, nRF Connect extension, project workspace and macOS $PATH)? Thanks,
Paul
  • Hi Øyvind,

    Manual installation of C/C++ extension: VS Code complained that the version of the C/C++ extension that I had was not the universal version. It directed me to delete the extension folder, re-install and retry if it didn't work properly the first time. I tried twice before it worked. It's probably a VS Code issue, there have been pull requests.

    Adding settings to c_cpp_settings.json: I found that I had to: 1. add more include & browse paths, and 2. add some "defines" to get VS Code's intellisense to find SDK files.

    Cryptography binaries: Python 3.9.6 is unable to use the file, ~Library/Python/3.9/lib/python/site-packages/cryptography/hazmat/bindings/_rust.abi3.so. I created a build configuration for the nRF9160 HTTP application update sample and it runs a Python script to generate zephyr/autogen-pubkey.c. Strange, becauseI thought this issue had been fixed in Python 3.9.1. The build error output is below.

    Perhaps, from your Apple M2 machine, you could share the support log for nRF Connect extension and snippets of the c_cpp_settings.json and a workspace settings JSON? My machine has a lot of development environments and it only takes one little thing for an installation script like Toolchain Manager to go wrong silently. Otherwise I think we can close the ticket. To save time I'll buy a clean Windows 10 Pro PC since it has Tier 1 support and install from scratch.

    Thanks,

    Paul

    FAILED: zephyr/autogen-pubkey.c 
    cd /opt/nordic/ncs/v2.3.0/nrf/samples/nrf9160/http_update/application_update/build_dk/mcuboot && /opt/nordic/ncs/toolchains/v2.3.0/bin/python3.9 /opt/nordic/ncs/v2.3.0/bootloader/mcuboot/scripts/imgtool.py getpub -k /opt/nordic/ncs/v2.3.0/bootloader/mcuboot/root-ec-p256.pem > /opt/nordic/ncs/v2.3.0/nrf/samples/nrf9160/http_update/application_update/build_dk/mcuboot/zephyr/autogen-pubkey.c
    Traceback (most recent call last):
      File "/opt/nordic/ncs/v2.3.0/bootloader/mcuboot/scripts/imgtool.py", line 19, in <module>
        from imgtool import main
      File "/opt/nordic/ncs/v2.3.0/bootloader/mcuboot/scripts/imgtool/main.py", line 23, in <module>
        import imgtool.keys as keys
      File "/opt/nordic/ncs/v2.3.0/bootloader/mcuboot/scripts/imgtool/keys/__init__.py", line 22, in <module>
        from cryptography.hazmat.primitives import serialization
      File "/Users/paul/Library/Python/3.9/lib/python/site-packages/cryptography/hazmat/primitives/serialization/__init__.py", line 7, in <module>
        from cryptography.hazmat.primitives._serialization import (
      File "/Users/paul/Library/Python/3.9/lib/python/site-packages/cryptography/hazmat/primitives/_serialization.py", line 11, in <module>
        from cryptography.hazmat.primitives.hashes import HashAlgorithm
      File "/Users/paul/Library/Python/3.9/lib/python/site-packages/cryptography/hazmat/primitives/hashes.py", line 10, in <module>
        from cryptography.hazmat.bindings._rust import openssl as rust_openssl
    ImportError: dlopen(/Users/paul/Library/Python/3.9/lib/python/site-packages/cryptography/hazmat/bindings/_rust.abi3.so, 0x0002): tried: '/Users/paul/Library/Python/3.9/lib/python/site-packages/cryptography/hazmat/bindings/_rust.abi3.so' (mach-o file, but is an incompatible architecture (have 'x86_64', need 'arm64')), '/System/Volumes/Preboot/Cryptexes/OS/Users/paul/Library/Python/3.9/lib/python/site-packages/cryptography/hazmat/bindings/_rust.abi3.so' (no such file), '/Users/paul/Library/Python/3.9/lib/python/site-packages/cryptography/hazmat/bindings/_rust.abi3.so' (mach-o file, but is an incompatible architecture (have 'x86_64', need 'arm64'))

  • Hi Øyvind,

    Would it be possible to share the support log for nRF Connect extension and snippets of the c_cpp_settings.json and a workspace settings JSON from your Apple M2 machine?

    Thanks,

    Paul

  • Hi Paul, sorry the late reply.

    Here is the support log from my Macbook Air M2

    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": "darwin",
        "osVersion": "Darwin Kernel Version 22.4.0: Mon Mar  6 21:01:02 PST 2023; root:xnu-8796.101.5~3/RELEASE_ARM64_T8112",
        "osKernel": "22.4.0",
        "vscode": "1.78.2",
        "electron": "22.5.2",
        "node": "v16.17.1"
      },
      "system": {
        "date": "2023-06-16T08:28:03.627Z",
        "vscodeRoot": "/Applications/Visual Studio Code.app/Contents/Resources/app",
        "nrfConnectForDesktopInstalled": true,
        "vscodeUptime": "00:01:03",
        "osUptime": "880:13:42",
        "cpu": {
          "model": "Apple M2",
          "speed": "24 MHz",
          "count": 4
        },
        "memory": {
          "total": "8.00 GB",
          "free": "0.12 GB"
        }
      },
      "workspace": {
        "name": "v2.3.0",
        "workspaceFile": null,
        "folders": [
          "/opt/nordic/ncs/v2.3.0"
        ]
      },
      "extensions": {
        "internal": {
          "nordic-semiconductor.nrf-connect": {
            "version": "2023.4.179",
            "path": "/Users/oysa/.vscode/extensions/nordic-semiconductor.nrf-connect-2023.4.179-darwin-arm64",
            "isActive": true
          },
          "nordic-semiconductor.nrf-terminal": {
            "version": "2023.4.15",
            "path": "/Users/oysa/.vscode/extensions/nordic-semiconductor.nrf-terminal-2023.4.15",
            "isActive": true
          },
          "nordic-semiconductor.nrf-devicetree": {
            "version": "2023.4.61",
            "path": "/Users/oysa/.vscode/extensions/nordic-semiconductor.nrf-devicetree-2023.4.61",
            "isActive": true
          },
          "nordic-semiconductor.nrf-kconfig": {
            "version": "2023.4.17",
            "path": "/Users/oysa/.vscode/extensions/nordic-semiconductor.nrf-kconfig-2023.4.17",
            "isActive": true
          }
        },
        "external": {
          "marus25.cortex-debug": "1.12.0",
          "ms-vscode.cpptools": "1.15.4",
          "ms-vscode.js-debug": "1.78.0",
          "ms-vscode.js-debug-companion": "1.0.18",
          "ms-vscode.vscode-js-profile-table": "1.0.3",
          "mcu-debug.debug-tracker-vscode": "0.0.15",
          "mcu-debug.memory-view": "0.0.21",
          "mcu-debug.peripheral-viewer": "1.4.6",
          "mcu-debug.rtos-views": "0.0.7",
          "trond-snekvik.gnu-mapfiles": "1.1.0",
          "twxs.cmake": "0.0.17"
        }
      },
      "tools": {
        "/opt/nordic/ncs/toolchains/v2.3.0/opt/zephyr-sdk/arm-zephyr-eabi/bin/arm-zephyr-eabi-gcc": "0.15.2",
        "/Applications/SEGGER/JLink/JLinkExe": "7.80c",
        "/usr/local/bin/nrfjprog": "10.19.0",
        "nrfutil": "Not found",
        "/opt/nordic/ncs/toolchains/v2.3.0/bin/cmake": "3.20.5",
        "/opt/nordic/ncs/toolchains/v2.3.0/bin/west": "0.14.0",
        "/opt/nordic/ncs/toolchains/v2.3.0/bin/python3": "3.9.6",
        "/opt/nordic/ncs/toolchains/v2.3.0/bin/ninja": "1.10.2",
        "/opt/nordic/ncs/toolchains/v2.3.0/bin/gperf": "3.1",
        "/opt/nordic/ncs/toolchains/v2.3.0/bin/dtc": "1.6.1",
        "/opt/nordic/ncs/toolchains/v2.3.0/bin/gn": "2082",
        "/opt/nordic/ncs/toolchains/v2.3.0/bin/git": "2.37.3",
        "gdbPath": "/opt/nordic/ncs/toolchains/v2.3.0/opt/zephyr-sdk/arm-zephyr-eabi/bin/arm-zephyr-eabi-gdb"
      },
      "sdks": [
        {
          "version": "2.2.0",
          "path": "/opt/nordic/ncs/v2.2.0"
        },
        {
          "version": "2.1.0",
          "path": "/opt/nordic/ncs/v2.1.0"
        },
        {
          "version": "2.1.2",
          "path": "/opt/nordic/ncs/v2.1.2"
        },
        {
          "version": "2.1.1",
          "path": "/opt/nordic/ncs/v2.1.1"
        },
        {
          "version": "2.3.0",
          "path": "/opt/nordic/ncs/v2.3.0"
        },
        {
          "version": "1.9.1",
          "path": "/opt/nordic/ncs/v1.9.1"
        }
      ],
      "toolchains": [
        {
          "version": "1.9.1",
          "path": "/opt/nordic/ncs/v1.9.1/toolchain"
        },
        {
          "version": "2.1.0",
          "path": "/opt/nordic/ncs/toolchains/v2.1.0"
        },
        {
          "version": "2.1.1",
          "path": "/opt/nordic/ncs/toolchains/v2.1.1"
        },
        {
          "version": "2.1.2",
          "path": "/opt/nordic/ncs/toolchains/v2.1.2"
        },
        {
          "version": "2.2.0",
          "path": "/opt/nordic/ncs/toolchains/v2.2.0"
        },
        {
          "version": "2.3.0",
          "path": "/opt/nordic/ncs/toolchains/v2.3.0"
        }
      ],
      "connectedDevices": [],
      "deviceProvider": "nrfutil",
      "config": {
        "nordic-semiconductor.nrf-connect": {
          "topdir": "${nrf-connect.sdk:2.3.0}",
          "toolchain": {
            "path": "${nrf-connect.toolchain:2.3.0}"
          },
          "ozonePath": "",
          "applications": [],
          "applicationOptions": {},
          "kconfig": {
            "interface": "kconfig",
            "executeInDefaultShell": false
          },
          "welcome": {
            "showOnStartup": true
          },
          "west": {
            "env": {
              "$base": "terminal"
            }
          },
          "boardRoots": [
            "Support/298989/Q3Iot_NCS220_230105/boards"
          ],
          "enableTelemetry": true,
          "taskBindings": {},
          "debugging": {
            "backend": "nRF Debug",
            "flash": true,
            "bindings": {}
          },
          "activeAppFollowActiveEditor": false,
          "deviceProvider": "nrfutil"
        },
        "nordic-semiconductor.nrf-terminal": {
          "terminalMode": "character"
        },
        "marus25.cortex-debug": {
          "variableUseNaturalFormat": true,
          "liveWatchRefreshRate": "300",
          "armToolchainPath": null,
          "armToolchainPrefix": "arm-none-eabi",
          "gdbPath": null,
          "objdumpPath": null,
          "JLinkGDBServerPath": null,
          "openocdPath": null,
          "pyocdPath": null,
          "PEGDBServerPath": null,
          "stutilPath": null,
          "stlinkPath": null,
          "stm32cubeprogrammer": null,
          "enableTelemetry": true,
          "dbgServerLogfile": null
        }
      },
      "environment": {
        "westExe": "west",
        "westEnv": {
          "ELECTRON_RUN_AS_NODE": "1",
          "GIT_EXEC_PATH": "/opt/nordic/ncs/toolchains/v2.3.0/Cellar/git/2.37.3/libexec/git-core",
          "HOME": "/Users/oysa",
          "PATH": "/opt/nordic/ncs/toolchains/v2.3.0/bin:/opt/nordic/ncs/toolchains/v2.3.0/opt/bin:/opt/nordic/ncs/toolchains/v2.3.0/opt/zephyr-sdk/arm-zephyr-eabi/bin:/opt/nordic/ncs/toolchains/v2.3.0/arm-zephyr-eabi/bin:/opt/homebrew/sbin:/opt/homebrew/bin:/usr/local/bin:/System/Cryptexes/App/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin:/opt/X11/bin:/Applications/Wireshark.app/Contents/MacOS:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/local/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/appleinternal/bin",
          "ZEPHYR_BASE": "/opt/nordic/ncs/v2.3.0/zephyr",
          "ZEPHYR_TOOLCHAIN_VARIANT": "zephyr",
          "ZEPHYR_SDK_INSTALL_DIR": "/opt/nordic/ncs/toolchains/v2.3.0/opt/zephyr-sdk",
          "USER": "oysa"
        },
        "inherited": {
          "ELECTRON_RUN_AS_NODE": "1",
          "HOME": "/Users/oysa",
          "PATH": "/opt/homebrew/sbin:/opt/homebrew/bin:/usr/local/bin:/System/Cryptexes/App/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin:/opt/X11/bin:/Applications/Wireshark.app/Contents/MacOS:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/local/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/appleinternal/bin",
          "USER": "oysa"
        },
        "toolchainPath": "/opt/nordic/ncs/toolchains/v2.3.0",
        "toolchainBinPath": "/opt/nordic/ncs/toolchains/v2.3.0/opt/zephyr-sdk/arm-zephyr-eabi/bin",
        "toolchainVersion": "2.3.0"
      },
      "terminal": {
        "shell": null,
        "defaultProfile": null
      }
    }
    
    

    paul.lander said:
    snippets of the c_cpp_settings.json

    The closest on my side is modules/lib/loramac-node/.vscode/c_cpp_properties.json

    {
        "configurations": [
            {
                "name": "ARM",
                "compileCommands": "${workspaceRoot}/build/compile_commands.json",
                "intelliSenseMode": "clang-x64",
                "browse": {
                    "path": [
                        "${workspaceFolder}"
                    ]
                },
                "cStandard": "c11",
                "cppStandard": "c++17",
                "configurationProvider": "ms-vscode.cmake-tools"
            }
        ],
        "version": 4
    }

    paul.lander said:
    a workspace settings JSON

    ~/Library/Application Support/Code/User/settings.json

    {
        "nrf-connect.welcome.showOnStartup": true,
        "nrf-connect.enableTelemetry": true,
        "nrf-connect.topdir": "${nrf-connect.sdk:2.3.0}",
        "nrf-connect.toolchain.path": "${nrf-connect.toolchain:2.3.0}",
        "nrf-connect.activeAppFollowActiveEditor": false,
        "nrf-connect.boardRoots": [
            "Support/<removed>/boards"
        ]
    }

    Let me know what more you would like me to provide

  • Hi Øyvind,

    That's very helpful, thanks. It's nice how you can type "nrf-.." in the workspace settings file and VS Code will prompt for options - very useful. There are only 3 significant differences between our setups. My c_cpp_settings.json has:

    1. "configurations": configurationProvider: "nrf-connect"
    2. "intelliSenseMode": "macos-clang-arm64
    3. "defines": [ "NRF9160_XXAA" ]

    I have VS Code 1.79 (you have 1.78), and that's where on Apple M1/M2 it started to complain about clang-x64, which necessitated deleting the C/C++ extension folder and installing the ARM version. "NRF9160_XXAA" seemed to be necessary to resolve NRF driver include paths. I asked ChatGPT, "What does configurationProvider in visual studio code's configurations in c_cpp_settings.json do?" The answer is interesting.

    There's a lot going on under the hood. I appreciate that you guys are trying to keep up with 3 platforms and hide the details in Toolchain Manager. My "3 remianing issues", detailed in the original post, are still present, but I can work around them.

    Thanks again for your help,

    Paul

  • Paul, even with v1.79.2 I'm not able to reproduce your issue I'm afraid. 

    I hope you have been able to work around the other issues. Let me know if there is anything else I can help with. 

    Kind regards,
    Øyvind

Related