SPI for nrf5340dk in ncsv2.8

nrfConnectSDK V2.8

Toolchain

Board: nrf5340dk

Hi, while compiling ncs-spi-master-slave-example , I am getting below errors

In function 'spi_init':
C:/Users/hello/spi/src/main.c:34:8: error: macro "GPIO_DT_SPEC_GET_BY_IDX_OR" requires 4 arguments, but only 3 given
34 | struct gpio_dt_spec spim_cs_gpio = MY_SPI_MASTER_CS_DT_SPEC;


In file included from C:/Users/hello/spi/src/main.c:11:
C:/ncs/v2.8.0/zephyr/include/zephyr/drivers/spi.h:213:9: error: 'GPIO_DT_SPEC_GET_BY_IDX_OR' undeclared (first use in this function)
213 | GPIO_DT_SPEC_GET_BY_IDX_OR(DT_BUS(spi_dev), cs_gpios, \

C:/Users/hello/spi/src/main.c:44:8: error: macro "GPIO_DT_SPEC_GET_BY_IDX_OR" requires 4 arguments, but only 3 given
44 | .cs = {.gpio = MY_SPI_MASTER_CS_DT_SPEC, .delay = 0},

C:/ncs/v2.8.0/zephyr/include/zephyr/drivers/spi.h:213:9: error: 'GPIO_DT_SPEC_GET_BY_IDX_OR' undeclared here (not in a function)
213 | GPIO_DT_SPEC_GET_BY_IDX_OR(DT_BUS(spi_dev), cs_gpios, \

Is it related to sdk version? Can anyone help to resolve ?

  • Hi

    Lets start with the ADC sample first. This sample work for at least the supported boards. Lets focus on the adc_sequence sample within zephyr/samples/drivers/adc.

    KTH said:
    Not able to build zephyr ADC examples also

    There are also no nRF5340 board support in the board folder of this sample. It works with any of the boards found within adc_sequence/boards, for instance with nrf52840dk/nrf52840 (below is a result with build from terminal and list of the boards found in the boards folder of this sample. The same can be stated for the VS Code extension).

    If you remove and build for the nrf52840dk, do you see the error as you previously did? If you do, then I believe there is something wrong with your installation. Could you 1: generate support information from vs code by opening command pallette in VS Code, i.e

    1. Open VS Code
    2. Open command pallet by pressing ctrl+***+p
    3. search for "generate support information" 
    4. Select it and press enter and upload the information here

    If we get this working, then we can go back to the spi master sample from too1's git repo

    Kind regards,
    Andreas

  • Hi,

    adc_sequene sample is building with target nrf52840dk

    nrf connect generate support information is as below

    // IMPORTANT: The following data can contain sensitive or confidential information about your environment.
    // If you do not want others to see this information, make sure to remove it before sharing the data.
    
    // For help and support, visit Nordic Semiconductor's DevZone at https://devzone.nordicsemi.com/.
    
    {
      "platform": {
        "os": "win32",
        "osVersion": "Windows 11 Home Single Language",
        "osKernel": "10.0.26100",
        "vscode": "1.97.2",
        "electron": "32.2.7",
        "node": "v20.18.1"
      },
      "system": {
        "date": "2025-02-28T08:51:25.141Z",
        "vscodeRoot": "c:\\Users\\hello\\AppData\\Local\\Programs\\Microsoft VS Code\\resources\\app",
        "nrfConnectForDesktopInstalled": false,
        "vscodeUptime": "00:00:15",
        "osUptime": "98:35:17",
        "cpu": "11th Gen Intel(R) Core(TM) i3-1115G4 @ 3.00GHz"
      },
      "workspace": {
        "name": null,
        "workspaceFile": null,
        "folders": []
      },
      "sdks": [
        {
          "version": "v2.8.0",
          "path": "c:\\ncs\\v2.8.0"
        }
      ],
      "apps": [],
      "toolchains": [
        {
          "version": "2.8.0",
          "path": "c:\\ncs\\toolchains\\2d382dcd92"
        }
      ],
      "connectedDevices": [],
      "tools": {
        "C:\\ncs\\toolchains\\2d382dcd92\\opt\\zephyr-sdk\\arm-zephyr-eabi\\bin\\arm-zephyr-eabi-gcc.exe": "0.16.8",
        "C:\\Program Files\\SEGGER\\JLink_V794e\\JLink.exe": "7.94e",
        "C:\\Program Files\\Nordic Semiconductor\\nrf-command-line-tools\\bin\\nrfjprog.exe": "10.24.2",
        "C:\\ncs\\toolchains\\2d382dcd92\\cmake": "3.21.0",
        "C:\\ncs\\toolchains\\2d382dcd92\\opt\\bin\\Scripts\\west.exe": "1.2.0",
        "C:\\ncs\\toolchains\\2d382dcd92\\opt\\bin\\python.exe": "3.12.4",
        "C:\\ncs\\toolchains\\2d382dcd92\\opt\\bin\\ninja.exe": "1.10.2",
        "C:\\ncs\\toolchains\\2d382dcd92\\opt\\bin\\gperf.exe": "3.1",
        "C:\\ncs\\toolchains\\2d382dcd92\\opt\\bin\\dtc.exe": "1.4.7",
        "C:\\ncs\\toolchains\\2d382dcd92\\opt\\bin\\gn.exe": "2201",
        "C:\\ncs\\toolchains\\2d382dcd92\\mingw64\\bin\\git.exe": "2.37.3.windows.1",
        "arm-gdbPath": "c:\\ncs\\toolchains\\2d382dcd92\\opt\\zephyr-sdk\\arm-zephyr-eabi\\bin\\arm-zephyr-eabi-gdb.exe",
        "riscv-gdbPath": "C:\\ncs\\toolchains\\2d382dcd92\\opt\\zephyr-sdk\\riscv64-zephyr-elf\\bin\\riscv64-zephyr-elf-gdb.exe"
      },
      "nrfutil": {
        "nrfutil-device": {
          "version": "2.7.9",
          "binPath": "c:\\Users\\hello\\.vscode\\extensions\\nordic-semiconductor.nrf-connect-2025.1.127-win32-x64\\platform\\nrfutil\\bin\\nrfutil-device",
          "jlinkInfo": {
            "description": "This version of SEGGER J-Link is different from the J-Link version that was used to test nrfutil device commands",
            "expectedVersion": {
              "version": "JLink_V7.94i",
              "versionFormat": "string"
            },
            "name": "JlinkARM",
            "version": "JLink_V7.94e",
            "versionFormat": "string"
          }
        },
        "nrfutil-toolchain-manager": {
          "version": "0.14.4",
          "binPath": "c:\\Users\\hello\\.vscode\\extensions\\nordic-semiconductor.nrf-connect-2025.1.127-win32-x64\\platform\\nrfutil\\bin\\nrfutil-toolchain-manager"
        }
      },
      "environment": {
        "westEnv": {
          "HOME": "C:\\Users\\hello",
          "HOMEDRIVE": "C:",
          "HOMEPATH": "\\Users\\hello",
          "PATH": "C:\\ncs\\toolchains\\2d382dcd92;C:\\ncs\\toolchains\\2d382dcd92\\mingw64\\bin;C:\\ncs\\toolchains\\2d382dcd92\\bin;C:\\ncs\\toolchains\\2d382dcd92\\opt\\bin;C:\\ncs\\toolchains\\2d382dcd92\\opt\\bin\\Scripts;C:\\ncs\\toolchains\\2d382dcd92\\opt\\nanopb\\generator-bin;C:\\ncs\\toolchains\\2d382dcd92\\opt\\zephyr-sdk\\arm-zephyr-eabi\\bin;C:\\ncs\\toolchains\\2d382dcd92\\opt\\zephyr-sdk\\riscv64-zephyr-elf\\bin;c:\\Users\\hello\\.vscode\\extensions\\nordic-semiconductor.nrf-connect-2025.1.127-win32-x64\\platform\\nrfutil\\lib\\nrfutil-toolchain-manager;C:\\TwinCAT\\Common64;C:\\TwinCAT\\Common32;C:\\Program Files (x86)\\Common Files\\Oracle\\Java\\javapath;C:\\WINDOWS\\system32;C:\\WINDOWS;C:\\WINDOWS\\System32\\Wbem;C:\\WINDOWS\\System32\\WindowsPowerShell\\v1.0\\;C:\\WINDOWS\\System32\\OpenSSH\\;C:\\Program Files\\dotnet\\;C:\\Program Files\\Microsoft SQL Server\\150\\Tools\\Binn\\;C:\\Program Files\\Git\\cmd;C:\\Program Files\\usbipd-win\\;C:\\Program Files\\Microchip\\xc32\\v4.30\\bin;C:\\Program Files (x86)\\dotnet\\;C:\\Program Files\\Microsoft SQL Server\\130\\Tools\\Binn\\;C:\\Program Files\\Microsoft SQL Server\\Client SDK\\ODBC\\170\\Tools\\Binn\\;C:\\Program Files (x86)\\GnuWin32\\bin;C:\\Program Files\\PowerShell\\7\\;C:\\Program Files\\PuTTY\\;C:\\Program Files\\Nordic Semiconductor\\nrf-command-line-tools\\bin\\;C:\\Users\\hello\\AppData\\Local\\Programs\\Python\\Python312\\Scripts\\;C:\\Users\\hello\\AppData\\Local\\Programs\\Python\\Python312\\;C:\\Users\\hello\\AppData\\Local\\Programs\\Python\\Python311\\Scripts\\;C:\\Users\\hello\\AppData\\Local\\Programs\\Python\\Python311\\;C:\\Users\\hello\\AppData\\Local\\Programs\\Python\\Launcher\\;C:\\Users\\hello\\AppData\\Local\\Microsoft\\WindowsApps;C:\\Users\\hello\\AppData\\Local\\GitHubDesktop\\bin;C:\\Users\\hello\\AppData\\Local\\JetBrains\\PyCharm Community Edition 2023.1.2\\bin;;C:\\Users\\hello\\AppData\\Local\\Programs\\Microsoft VS Code\\bin",
          "ZEPHYR_BASE": "c:\\ncs\\v2.8.0\\zephyr",
          "ZEPHYR_TOOLCHAIN_VARIANT": "zephyr",
          "ZEPHYR_SDK_INSTALL_DIR": "C:\\ncs\\toolchains\\2d382dcd92\\opt\\zephyr-sdk",
          "PYTHONPATH": "C:\\ncs\\toolchains\\2d382dcd92\\opt\\bin;C:\\ncs\\toolchains\\2d382dcd92\\opt\\bin\\Lib;C:\\ncs\\toolchains\\2d382dcd92\\opt\\bin\\Lib\\site-packages"
        },
        "inherited": {
          "HOME": "C:\\Users\\hello",
          "HOMEDRIVE": "C:",
          "HOMEPATH": "\\Users\\hello",
          "Path": "C:\\TwinCAT\\Common64;C:\\TwinCAT\\Common32;C:\\Program Files (x86)\\Common Files\\Oracle\\Java\\javapath;C:\\WINDOWS\\system32;C:\\WINDOWS;C:\\WINDOWS\\System32\\Wbem;C:\\WINDOWS\\System32\\WindowsPowerShell\\v1.0\\;C:\\WINDOWS\\System32\\OpenSSH\\;C:\\Program Files\\dotnet\\;C:\\Program Files\\Microsoft SQL Server\\150\\Tools\\Binn\\;C:\\Program Files\\Git\\cmd;C:\\Program Files\\usbipd-win\\;C:\\Program Files\\Microchip\\xc32\\v4.30\\bin;C:\\Program Files (x86)\\dotnet\\;C:\\Program Files\\Microsoft SQL Server\\130\\Tools\\Binn\\;C:\\Program Files\\Microsoft SQL Server\\Client SDK\\ODBC\\170\\Tools\\Binn\\;C:\\Program Files (x86)\\GnuWin32\\bin;C:\\Program Files\\PowerShell\\7\\;C:\\Program Files\\PuTTY\\;C:\\Program Files\\Nordic Semiconductor\\nrf-command-line-tools\\bin\\;C:\\Users\\hello\\AppData\\Local\\Programs\\Python\\Python312\\Scripts\\;C:\\Users\\hello\\AppData\\Local\\Programs\\Python\\Python312\\;C:\\Users\\hello\\AppData\\Local\\Programs\\Python\\Python311\\Scripts\\;C:\\Users\\hello\\AppData\\Local\\Programs\\Python\\Python311\\;C:\\Users\\hello\\AppData\\Local\\Programs\\Python\\Launcher\\;C:\\Users\\hello\\AppData\\Local\\Microsoft\\WindowsApps;C:\\Users\\hello\\AppData\\Local\\GitHubDesktop\\bin;C:\\Users\\hello\\AppData\\Local\\JetBrains\\PyCharm Community Edition 2023.1.2\\bin;;C:\\Users\\hello\\AppData\\Local\\Programs\\Microsoft VS Code\\bin;",
          "PATH": "C:\\TwinCAT\\Common64;C:\\TwinCAT\\Common32;C:\\Program Files (x86)\\Common Files\\Oracle\\Java\\javapath;C:\\WINDOWS\\system32;C:\\WINDOWS;C:\\WINDOWS\\System32\\Wbem;C:\\WINDOWS\\System32\\WindowsPowerShell\\v1.0\\;C:\\WINDOWS\\System32\\OpenSSH\\;C:\\Program Files\\dotnet\\;C:\\Program Files\\Microsoft SQL Server\\150\\Tools\\Binn\\;C:\\Program Files\\Git\\cmd;C:\\Program Files\\usbipd-win\\;C:\\Program Files\\Microchip\\xc32\\v4.30\\bin;C:\\Program Files (x86)\\dotnet\\;C:\\Program Files\\Microsoft SQL Server\\130\\Tools\\Binn\\;C:\\Program Files\\Microsoft SQL Server\\Client SDK\\ODBC\\170\\Tools\\Binn\\;C:\\Program Files (x86)\\GnuWin32\\bin;C:\\Program Files\\PowerShell\\7\\;C:\\Program Files\\PuTTY\\;C:\\Program Files\\Nordic Semiconductor\\nrf-command-line-tools\\bin\\;C:\\Users\\hello\\AppData\\Local\\Programs\\Python\\Python312\\Scripts\\;C:\\Users\\hello\\AppData\\Local\\Programs\\Python\\Python312\\;C:\\Users\\hello\\AppData\\Local\\Programs\\Python\\Python311\\Scripts\\;C:\\Users\\hello\\AppData\\Local\\Programs\\Python\\Python311\\;C:\\Users\\hello\\AppData\\Local\\Programs\\Python\\Launcher\\;C:\\Users\\hello\\AppData\\Local\\Microsoft\\WindowsApps;C:\\Users\\hello\\AppData\\Local\\GitHubDesktop\\bin;C:\\Users\\hello\\AppData\\Local\\JetBrains\\PyCharm Community Edition 2023.1.2\\bin;;C:\\Users\\hello\\AppData\\Local\\Programs\\Microsoft VS Code\\bin;"
        }
      },
      "terminal": {
        "defaultProfile": null
      },
      "config": {
        "nordic-semiconductor.nrf-connect": {
          "topdir": "",
          "toolchain": {
            "path": ""
          },
          "ozonePath": "",
          "applications": [],
          "applicationOptions": {},
          "kconfig": {
            "interface": "kconfig"
          },
          "west": {
            "env": {
              "$base": "terminal"
            }
          },
          "boardRoots": [],
          "taskBindings": {},
          "buildTerminal": {
            "condensedProgress": true
          },
          "debugging": {
            "flash": true,
            "bindings": {},
            "justMyCode": false
          },
          "activeAppFollowActiveEditor": true,
          "flash": {
            "softreset": false,
            "erase": false,
            "recover": false
          },
          "enableTelemetry": null,
          "thirdpartyIntegration": {},
          "toolchainManager": {
            "indexURL": null,
            "installDirectory": null
          },
          "nrfutil": {
            "home": null
          },
          "defaultOpenAction": "ask",
          "terminalProfile": {
            "shell": null
          }
        },
        "nordic-semiconductor.nrf-terminal": {
          "terminalMode": "character"
        }
      },
      "extensions": {
        "internal": {
          "nordic-semiconductor.nrf-connect": {
            "version": "2025.1.127",
            "path": "c:\\Users\\hello\\.vscode\\extensions\\nordic-semiconductor.nrf-connect-2025.1.127-win32-x64",
            "isActive": true
          },
          "nordic-semiconductor.nrf-terminal": {
            "version": "2024.9.14",
            "path": "c:\\Users\\hello\\.vscode\\extensions\\nordic-semiconductor.nrf-terminal-2024.9.14",
            "isActive": true
          },
          "nordic-semiconductor.nrf-devicetree": {
            "version": "2024.12.15",
            "path": "c:\\Users\\hello\\.vscode\\extensions\\nordic-semiconductor.nrf-devicetree-2024.12.15",
            "isActive": true
          },
          "nordic-semiconductor.nrf-kconfig": {
            "version": "2024.12.13",
            "path": "c:\\Users\\hello\\.vscode\\extensions\\nordic-semiconductor.nrf-kconfig-2024.12.13",
            "isActive": true
          }
        },
        "external": {
          "marus25.cortex-debug": null,
          "ms-vscode.cpptools": "1.23.6",
          "ms-vscode.js-debug": "1.97.1",
          "ms-vscode.js-debug-companion": "1.1.3",
          "ms-vscode.vscode-js-profile-table": "1.0.10",
          "trond-snekvik.gnu-mapfiles": "1.1.0",
          "twxs.cmake": "0.0.17"
        }
      }
    }
    
    

  • KTH said:
    adc_sequene sample is building with target nrf52840dk

    Thats good to hear. This indicates that the SDK is properly set up and that building an in-tree application works.

    KTH said:
    nrf connect generate support information is as below

    Everything here looks fine and your setup is as good as identical to mine.

    W.r.t the spi sample. 

    Here's a new, unmodified version of the same sample from here https://github.com/too1/ncs-spi-master-slave-example/tree/master 

     spi_m_s.zip

    I've verified with multiple colleagues that this sample builds out of the box for the following configuration

    • NCS 2.8.0
    • nrf5340dk/nrf5340/cpuapp
    • with and without sysbuild

    I see that you've previously built the SPI sample from c:\Users\hello\Music\ncs-spi-master-slave-example-master. Could you shorten the name of the sample and preferably place it closer to C:\? Windows has an issue with path length when building any project.

    Place the sample for instance within ncs/my_projects

    and build for the configuration I mentioned.

    Kind regards,
    Andreas

  • Built the sample for given configuration, still it is giving errors

  • I must admit I'm baffled. I can't see anything but there being something faulty with the installation or that something has been modified in the SDK

    1. Could you try with a different work station
    2. Could you uninstall NCS and all tools completely and reinstall them per https://docs.nordicsemi.com/bundle/ncs-latest/page/nrf/installation/install_ncs.html

    I've tried building with multiple different work stations myself, as well as different OS and none give the faults you're seeing. Since you were able to build the adc sample out of tree, I am expecting you to be able to build the zip I sent you with the exact same steps as you successfully built the adc sample with.

    Kind regards,
    Andreas

Related