This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

How to configure and setup an SPI device to nRF5340

Hello,

I am trying to setup a device (Semtech LR1110) connected to SPI 1 peripheral on the nRF5340pdk.

I have a driver code for it. My question is this.

How can I set it up in the .dts file and keep the code that drives it with my source code on my local drive without having to put it the C:\Zypher\v1.3.0\zephyr\drivers\LR1110?

Q1/ Will the proposed Device Tree fragment do the job?
...
...
spi1: spi@9000 {
   compatible = "nordic,nrf5340";
   status = "okay";
   reg = < 0x9000 0x1000 >;
   interrupts = < 0x9 0x1 >;
   label = "SPI_1";
   sck-pin = < 0x?? >;
   mosi-pin = < 0x?? >;
   miso-pin = < 0x?? >;
};      
Q2/ How do I get the device binding to work?
Will this work?
device_get_binding( DT_PROP( DT_NODELABEL(spi1), label );

Thank you.

Kind regards

Parents Reply
  • Hi,

     

    Learner said:
    I re-instated the line CONFIG_BOARD_ENABLE_CPUNET=n in prj.conf again in prj.conf but I still cannot reload the project. Below is the error.

     Could you click on "OK" and paste the full output from the build-window in SES? I can see that the failure is in line 35 of ZephyrConfig.cmake, but it would be good to see if there's anything interesting before that.

     

    Kind regards,

    Håkon

Children
  • As I said in my previous post, SES v5.10d is very moody. Guess what? I can open and build the solution now. This is with the line CONFIG_BOARD_ENABLE_CPUNET=n enabled. However, when I commented it out I could not open the project. Below is the error log.

    Creating solution spi_test.emProject
    cmake -GNinja -DBOARD=nrf5340pdk_nrf5340_cpuapp -DBOARD_DIR=C:\Zypher\v1.3.0\zephyr\boards\arm\PID4_nRF5340 -BC:\Dev\NCS_projects\spi_example\spi_test\build_SESv510d_nrf5340pdk_nrf5340_cpuapp -SC:\Dev\NCS_projects\spi_example\spi_test -DZEPHYR_TOOLCHAIN_VARIANT=gnuarmemb -DGNUARMEMB_TOOLCHAIN_PATH=C:\Zypher\v1.3.0\toolchain\opt -DDTC_OVERLAY_FILE=C:\Dev\NCS_projects\spi_example\spi_test/nrf5340pdk_nrf5340_cpuapp.overlay -DEXTRA_KCONFIG_TARGETS=menuconfig_ses -DEXTRA_KCONFIG_TARGET_COMMAND_FOR_menuconfig_ses=C:\Program Files\SEGGER_V5.10c\arm_segger_embedded_studio_v510d_win_x64_nordic/html/configure_nordic_project_menuconfig.py
    -- Application: C:/Dev/NCS_projects/spi_example/spi_test
    -- Zephyr version: 2.3.0-rc1 (C:/Zypher/v1.3.0/zephyr)
    -- Found Python3: C:/Program Files/WindowsApps/PythonSoftwareFoundation.Python.3.8_3.8.1776.0_x64__qbz5n2kfra8p0/python3.8.exe (found suitable version "3.8.6", minimum required is "3.6") found components: Interpreter
    -- Board: nrf5340pdk_nrf5340_cpuapp
    -- Found west: C:/Zypher/v1.3.0/toolchain/opt/bin/Scripts/west.exe (found suitable version "0.7.3", minimum required is "0.7.1")
    -- Found toolchain: gnuarmemb (C:/Zypher/v1.3.0/toolchain/opt)
    -- Found BOARD.dts: C:/Zypher/v1.3.0/zephyr/boards/arm/PID4_nRF5340/nrf5340pdk_nrf5340_cpuapp.dts
    -- Found devicetree overlay: C:\Dev\NCS_projects\spi_example\spi_test/nrf5340pdk_nrf5340_cpuapp.overlay
    -- Configuring incomplete, errors occurred!
    Including boilerplate (Zephyr base): C:/Zypher/v1.3.0/zephyr/cmake/app/boilerplate.cmake
    In file included from C:/Zypher/v1.3.0/zephyr/boards/arm/PID4_nRF5340/nrf5340pdk_nrf5340_cpuapp.dts:9,
    from <command-line>:
    C:/Zypher/v1.3.0/zephyr/boards/arm/PID4_nRF5340/nrf5340_cpuapp_common.dts:179:10: fatal error: nrf5340_cpuapp_partition_conf.dts: No such file or directory
    179 | #include "nrf5340_cpuapp_partition_conf.dts"
    | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    compilation terminated.
    CMake Error at C:/Zypher/v1.3.0/zephyr/cmake/dts.cmake:146 (message):
    command failed with return code: 1
    Call Stack (most recent call first):
    C:/Zypher/v1.3.0/zephyr/cmake/app/boilerplate.cmake:505 (include)
    C:/Zypher/v1.3.0/zephyr/share/zephyr-package/cmake/ZephyrConfig.cmake:24 (include)
    C:/Zypher/v1.3.0/zephyr/share/zephyr-package/cmake/ZephyrConfig.cmake:35 (include_boilerplate)
    CMakeLists.txt:13 (find_package)

    error: cmake failed
    create_nordic_project.py failed (1)

    Thank you

    Kind regards

    Mohamed

  • Hi,

     

    Learner said:
    -- Found BOARD.dts: C:/Zypher/v1.3.0/zephyr/boards/arm/PID4_nRF5340/nrf5340pdk_nrf5340_cpuapp.dts

    Is this a board that you have defined?

    Learner said:
    C:/Zypher/v1.3.0/zephyr/boards/arm/PID4_nRF5340/nrf5340_cpuapp_common.dts:179:10: fatal error: nrf5340_cpuapp_partition_conf.dts: No such file or directory
    179 | #include "nrf5340_cpuapp_partition_conf.dts"

    Does this file exist in your PID4_nRF5340/ folder?

     

    Kind regards,

    Håkon 

  • Hi Hakon,

    Learner said:
    -- Found BOARD.dts: C:/Zypher/v1.3.0/zephyr/boards/arm/PID4_nRF5340/nrf5340pdk_nrf5340_cpuapp.dts

    Is this a board that you have defined?

    It is a board that is being defined but not complete yet.  It is work in progress and I was not expecting this board to be picked up. The board intended to be used is the nRF5340pdk_nRF5340.                     C:\Zypher\v1.3.0\zephyr\boards\arm\nrf5340pdk_nrf5340

    Learner said:
    C:/Zypher/v1.3.0/zephyr/boards/arm/PID4_nRF5340/nrf5340_cpuapp_common.dts:179:10: fatal error: nrf5340_cpuapp_partition_conf.dts: No such file or directory
    179 | #include "nrf5340_cpuapp_partition_conf.dts"

    Does this file exist in your PID4_nRF5340/ folder?

    No, it does not exist.

    Kind regards

    Mohamed

  • Hi,

     

    Do you still get the same issue if you move this board out of the boards/arm folder? If it is work-in-progress, it might be that the build system picks it up, especially if the names within the folder isn't changed.

     

    Kind regards,

    Håkon

  • Hi Hakon,

    Both SES v452c and v510d are behaving themselves now :), meaning I can open and build the project with this commented out line 

    #CONFIG_BOARD_ENABLE_CPUNET=n

    However, I am having other problems with SES when sometimes, at random times, SES (v452c and v510d) cannot open a project that has not been changed for a while and was working fine before. If I keep trying few times it eventually works. See pictures and error log below.

    Have you come across this problem before?

    What am I doing wrong?

    Could it be something to do with my laptop because I have not restarted it for over a week now?

    Loading solution light_controller-Pot.emProject
    Executing load commands
    cmake -GNinja -DBOARD=nrf5340pdk_nrf5340_cpuapp -DBOARD_DIR=C:/Zypher/v1.3.0/zephyr/boards/arm/nrf5340pdk_nrf5340 -DZEPHYR_TOOLCHAIN_VARIANT=gnuarmemb -DGNUARMEMB_TOOLCHAIN_PATH=C:/Zypher/v1.3.0/toolchain/opt -BC:/Dev/NCS_projects/light_controller-Pot/build_nrf5340pdk_nrf5340_cpuapp -HC:/Dev/NCS_projects/light_controller-Pot -DEXTRA_KCONFIG_TARGETS=menuconfig_ses -DEXTRA_KCONFIG_TARGET_COMMAND_FOR_menuconfig_ses=C:/Zypher/v1.3.0/toolchain/segger_embedded_studio/html/configure_nordic_project_menuconfig.py
    Including boilerplate (Zephyr base (cached)): C:/Zypher/v1.3.0/zephyr/cmake/app/boilerplate.cmake
    -- Application: C:/Dev/NCS_projects/light_controller-Pot
    -- Zephyr version: 2.3.0-rc1 (C:/Zypher/v1.3.0/zephyr)
    CMake Error at C:/Zypher/v1.3.0/zephyr/cmake/extensions.cmake:926 (file):
      file failed to open for writing (Permission denied):
    
        C:/Dev/NCS_projects/light_controller-Pot/build_nrf5340pdk_nrf5340_cpuapp/zephyr/include/generated/snippets-sections.ld
    Call Stack (most recent call first):
      C:/Zypher/v1.3.0/zephyr/cmake/app/boilerplate.cmake:134 (zephyr_linker_sources)
      C:/Zypher/v1.3.0/zephyr/share/zephyr-package/cmake/ZephyrConfig.cmake:24 (include)
      C:/Zypher/v1.3.0/zephyr/share/zephyr-package/cmake/ZephyrConfig.cmake:40 (include_boilerplate)
      CMakeLists.txt:3 (find_package)
    
    
    CMake Error at C:/Zypher/v1.3.0/zephyr/cmake/extensions.cmake:927 (file):
      file failed to open for writing (Permission denied):
    
        C:/Dev/NCS_projects/light_controller-Pot/build_nrf5340pdk_nrf5340_cpuapp/zephyr/include/generated/snippets-ram-sections.ld
    Call Stack (most recent call first):
      C:/Zypher/v1.3.0/zephyr/cmake/app/boilerplate.cmake:134 (zephyr_linker_sources)
      C:/Zypher/v1.3.0/zephyr/share/zephyr-package/cmake/ZephyrConfig.cmake:24 (include)
      C:/Zypher/v1.3.0/zephyr/share/zephyr-package/cmake/ZephyrConfig.cmake:40 (include_boilerplate)
      CMakeLists.txt:3 (find_package)
    
    
    CMake Error at C:/Zypher/v1.3.0/zephyr/cmake/extensions.cmake:928 (file):
      file failed to open for writing (Permission denied):
    
        C:/Dev/NCS_projects/light_controller-Pot/build_nrf5340pdk_nrf5340_cpuapp/zephyr/include/generated/snippets-rom-start.ld
    Call Stack (most recent call first):
      C:/Zypher/v1.3.0/zephyr/cmake/app/boilerplate.cmake:134 (zephyr_linker_sources)
      C:/Zypher/v1.3.0/zephyr/share/zephyr-package/cmake/ZephyrConfig.cmake:24 (include)
      C:/Zypher/v1.3.0/zephyr/share/zephyr-package/cmake/ZephyrConfig.cmake:40 (include_boilerplate)
      CMakeLists.txt:3 (find_package)
    
    
    CMake Error at C:/Zypher/v1.3.0/zephyr/cmake/extensions.cmake:929 (file):
      file failed to open for writing (Permission denied):
    
        C:/Dev/NCS_projects/light_controller-Pot/build_nrf5340pdk_nrf5340_cpuapp/zephyr/include/generated/snippets-noinit.ld
    Call Stack (most recent call first):
      C:/Zypher/v1.3.0/zephyr/cmake/app/boilerplate.cmake:134 (zephyr_linker_sources)
      C:/Zypher/v1.3.0/zephyr/share/zephyr-package/cmake/ZephyrConfig.cmake:24 (include)
      C:/Zypher/v1.3.0/zephyr/share/zephyr-package/cmake/ZephyrConfig.cmake:40 (include_boilerplate)
      CMakeLists.txt:3 (find_package)
    
    
    CMake Error at C:/Zypher/v1.3.0/zephyr/cmake/extensions.cmake:930 (file):
      file failed to open for writing (Permission denied):
    
        C:/Dev/NCS_projects/light_controller-Pot/build_nrf5340pdk_nrf5340_cpuapp/zephyr/include/generated/snippets-rwdata.ld
    Call Stack (most recent call first):
      C:/Zypher/v1.3.0/zephyr/cmake/app/boilerplate.cmake:134 (zephyr_linker_sources)
      C:/Zypher/v1.3.0/zephyr/share/zephyr-package/cmake/ZephyrConfig.cmake:24 (include)
      C:/Zypher/v1.3.0/zephyr/share/zephyr-package/cmake/ZephyrConfig.cmake:40 (include_boilerplate)
      CMakeLists.txt:3 (find_package)
    
    
    CMake Error at C:/Zypher/v1.3.0/zephyr/cmake/extensions.cmake:931 (file):
      file failed to open for writing (Permission denied):
    
        C:/Dev/NCS_projects/light_controller-Pot/build_nrf5340pdk_nrf5340_cpuapp/zephyr/include/generated/snippets-rodata.ld
    Call Stack (most recent call first):
      C:/Zypher/v1.3.0/zephyr/cmake/app/boilerplate.cmake:134 (zephyr_linker_sources)
    -- Board: nrf5340pdk_nrf5340_cpuapp
      C:/Zypher/v1.3.0/zephyr/share/zephyr-package/cmake/ZephyrConfig.cmake:24 (include)
      C:/Zypher/v1.3.0/zephyr/share/zephyr-package/cmake/ZephyrConfig.cmake:40 (include_boilerplate)
      CMakeLists.txt:3 (find_package)
    
    
    -- Found west: C:/Zypher/v1.3.0/toolchain/opt/bin/Scripts/west.exe (found suitable version "0.7.3", minimum required is "0.7.1")
    -- Found toolchain: gnuarmemb (C:/Zypher/v1.3.0/toolchain/opt)
    CMake Error at C:/Zypher/v1.3.0/zephyr/cmake/dts.cmake:3 (file):
      file problem creating directory:
      C:/Dev/NCS_projects/light_controller-Pot/build_nrf5340pdk_nrf5340_cpuapp/zephyr/include/generated
    Call Stack (most recent call first):
      C:/Zypher/v1.3.0/zephyr/cmake/app/boilerplate.cmake:505 (include)
      C:/Zypher/v1.3.0/zephyr/share/zephyr-package/cmake/ZephyrConfig.cmake:24 (include)
      C:/Zypher/v1.3.0/zephyr/share/zephyr-package/cmake/ZephyrConfig.cmake:40 (include_boilerplate)
      CMakeLists.txt:3 (find_package)
    
    
    -- Found BOARD.dts: C:/Zypher/v1.3.0/zephyr/boards/arm/nrf5340pdk_nrf5340/nrf5340pdk_nrf5340_cpuapp.dts
    cc1.exe: fatal error: opening output file C:/Dev/NCS_projects/light_controller-Pot/build_nrf5340pdk_nrf5340_cpuapp/zephyr/nrf5340pdk_nrf5340_cpuapp.dts.pre.tmp: Permission denied
    compilation terminated.
    CMake Error at C:/Zypher/v1.3.0/zephyr/cmake/dts.cmake:146 (message):
      command failed with return code: 1
    Call Stack (most recent call first):
      C:/Zypher/v1.3.0/zephyr/cmake/app/boilerplate.cmake:505 (include)
      C:/Zypher/v1.3.0/zephyr/share/zephyr-package/cmake/ZephyrConfig.cmake:24 (include)
      C:/Zypher/v1.3.0/zephyr/share/zephyr-package/cmake/ZephyrConfig.cmake:40 (include_boilerplate)
      CMakeLists.txt:3 (find_package)
    
    
    -- Configuring incomplete, errors occurred!
    Project load failed
    Reported error: solution load command failed (1)
    

    Kind regards

    Mohamed

Related