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 Hakon,

    I've  re-downloaded the zip file and extracted ok. 

    I opened the project spi_example and built it ok.

    I then commented out the line CONFIG_BOARD_ENABLE_CPUNET=n in prj.conf.

    I tried to open the project but failed as with the old SES version.

    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.

    This is very bizarre. SES seems to be very moody, one minute it is happy the next it is not.

    Thank you for your help.

    Kind regards

    Mohamed

Children
  • 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

  • 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

Related