Build error with Nordic Zephyr SPI example

I'm trying to build one of the Nordic Zephyr SPI examples shown here:

https://github.com/too1/ncs-spi-master-slave-example/blob/master/src/main.c#L43C32-L43C39

https://github.com/too1/ncs-spi-master-slave-example/blob/master/nrf52840dk_nrf52840.overlay#L46

I have the PCA10040 version 3.0.0 dev board with the nRF52832 and my nRF Connect tool chain version is 2.3.0

I created a fresh application in NRF Connect from the Hello_world template and replaced the main.c and overlay with the files referenced above. I created a build configuration based on nrf52dk_nrf52832. The build encountered a number of device tree errors like this:

C:\ncs\v2.3.0\zephyr\include\zephyr\device.h:83:41: error: '__device_dts_ord_DT_N_NODELABEL_reg_my_spi_master_BUS_P_cs_gpios_IDX_DT_N_NODELABEL_reg_my_spi_master_REG_IDX_0_VAL_ADDRESS_PH_ORD' undeclared here (not in a function)
83 | #define DEVICE_NAME_GET(dev_id) _CONCAT(__device_, dev_id)

How can I fix this Nordic SPI example to build for my Nordic dev board?

Parents Reply
  • Good idea. I copied the entire folder from Github (Github SPI Example) and did two builds, the first for the nRF52 DK (which worked) and the second for my Laird BL652 module (which failed).

    There exists a dts file for the Laird module, but the build has trouble with this line in that file:

    compatible = "laird,bl652_dvk";
    Which generates the error: Unknown node type "laird,bl652_dvk"
     
    I'm not sure how the "compatible" keyword works. There is a folder in C:\ncs\v2.3.0\zephyr\boards\arm\ called bl652_dvk. But nothing in there seems to be tagged with the manufacturer name, Laird. Where should the name/node "laird,bl652_dvk" exist?
    From my research (Zephyr Doc), it seems that the node should be called out in the file bl652_dvk.yaml, but it's not. Here's what's in that file:
    identifier: bl652_dvk
    name: bl652_dvk
    type: mcu
    arch: arm
    toolchain:
      - zephyr
      - gnuarmemb
      - xtools
    ram: 64
    flash: 512
    supported:
      - adc
      - nvs
      - i2c
      - pwm
      - spi
      - watchdog
    
    As you can see, no sign of the manufacturer's name. Where should it go?
Children
  • Bret Foreman said:
    and the second for my Laird BL652 module (which failed

    And then, as the only change in this projecy, copy the nRF52dk_nrf52832.overlay  to bl652_dvk.overlay.

    The project should build now:

    ~/git/ncs-spi-master-slave-example$ west build -p -b bl652_dvk
    -- west build: making build dir /home/sihe/git/ncs-spi-master-slave-example/build pristine
    -- west build: generating a build system
    Loading Zephyr default modules (Zephyr base).
    -- Application: /home/sihe/git/ncs-spi-master-slave-example
    -- Found Python3: /usr/bin/python3.8 (found suitable exact version "3.8.10") found components: Interpreter 
    -- Cache files will be written to: /home/sihe/.cache/zephyr
    -- Zephyr version: 3.1.99 (/home/sihe/ncs/zephyr)
    -- Found west (found suitable version "0.13.1", minimum required is "0.7.1")
    -- Board: bl652_dvk
    -- ZEPHYR_TOOLCHAIN_VARIANT not set, trying to locate Zephyr SDK
    -- Found host-tools: zephyr 0.15.2 (/home/sihe/zephyr-sdk-0.15.2)
    -- Found dtc: /usr/bin/dtc (found suitable version "1.5.0", minimum required is "1.4.6")
    -- Found toolchain: zephyr 0.15.2 (/home/sihe/zephyr-sdk-0.15.2)
    -- Found BOARD.dts: /home/sihe/ncs/zephyr/boards/arm/bl652_dvk/bl652_dvk.dts
    -- Found devicetree overlay: /home/sihe/git/ncs-spi-master-slave-example/bl652_dvk.overlay
    -- Generated zephyr.dts: /home/sihe/git/ncs-spi-master-slave-example/build/zephyr/zephyr.dts
    -- Generated devicetree_unfixed.h: /home/sihe/git/ncs-spi-master-slave-example/build/zephyr/include/generated/devicetree_unfixed.h
    -- Generated device_extern.h: /home/sihe/git/ncs-spi-master-slave-example/build/zephyr/include/generated/device_extern.h
    -- Including generated dts.cmake file: /home/sihe/git/ncs-spi-master-slave-example/build/zephyr/dts.cmake
    Parsing /home/sihe/ncs/zephyr/Kconfig
    Loaded configuration '/home/sihe/ncs/zephyr/boards/arm/bl652_dvk/bl652_dvk_defconfig'
    Merged configuration '/home/sihe/git/ncs-spi-master-slave-example/prj.conf'
    Configuration saved to '/home/sihe/git/ncs-spi-master-slave-example/build/zephyr/.config'
    Kconfig header saved to '/home/sihe/git/ncs-spi-master-slave-example/build/zephyr/include/generated/autoconf.h'
    
    warning: Experimental symbol SPI_SLAVE is enabled.
    
    -- The C compiler identification is GNU 12.1.0
    -- The CXX compiler identification is GNU 12.1.0
    -- The ASM compiler identification is GNU
    -- Found assembler: /home/sihe/zephyr-sdk-0.15.2/arm-zephyr-eabi/bin/arm-zephyr-eabi-gcc
    -- Configuring done (2.0s)
    -- Generating done (0.0s)
    -- Build files have been written to: /home/sihe/git/ncs-spi-master-slave-example/build
    -- west build: building application
    [1/180] Preparing syscall dependency handling
    
    [2/180] Generating include/generated/version.h
    -- Zephyr version: 3.1.99 (/home/sihe/ncs/zephyr), build: v3.1.99-ncs1
    [103/180] Building C object zephyr/arch/arch/arm/core/aarch32/mpu/CMakeFiles/arch__arm__core__aarch32__mpu.dir/arm_core_mpu.c.obj
    /home/sihe/ncs/zephyr/arch/arm/core/aarch32/mpu/arm_core_mpu.c: In function 'z_arm_configure_dynamic_mpu_regions':
    /home/sihe/ncs/zephyr/arch/arm/core/aarch32/mpu/arm_core_mpu.c:311:9: warning: 'arm_core_mpu_configure_dynamic_mpu_regions' reading 12 bytes from a region of size 0 [-Wstringop-overread]
      311 |         arm_core_mpu_configure_dynamic_mpu_regions(dynamic_regions,
          |         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      312 |                                                    region_num);
          |                                                    ~~~~~~~~~~~
    /home/sihe/ncs/zephyr/arch/arm/core/aarch32/mpu/arm_core_mpu.c:311:9: note: referencing argument 1 of type 'const struct z_arm_mpu_partition[0]'
    In file included from /home/sihe/ncs/zephyr/arch/arm/core/aarch32/mpu/arm_core_mpu.c:12:
    /home/sihe/ncs/zephyr/arch/arm/core/aarch32/mpu/arm_core_mpu_dev.h:187:6: note: in a call to function 'arm_core_mpu_configure_dynamic_mpu_regions'
      187 | void arm_core_mpu_configure_dynamic_mpu_regions(
          |      ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    /home/sihe/ncs/zephyr/arch/arm/core/aarch32/mpu/arm_core_mpu.c:311:9: warning: 'arm_core_mpu_configure_dynamic_mpu_regions' reading 12 bytes from a region of size 0 [-Wstringop-overread]
      311 |         arm_core_mpu_configure_dynamic_mpu_regions(dynamic_regions,
          |         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      312 |                                                    region_num);
          |                                                    ~~~~~~~~~~~
    /home/sihe/ncs/zephyr/arch/arm/core/aarch32/mpu/arm_core_mpu.c:311:9: note: referencing argument 1 of type 'const struct z_arm_mpu_partition[0]'
    /home/sihe/ncs/zephyr/arch/arm/core/aarch32/mpu/arm_core_mpu_dev.h:187:6: note: in a call to function 'arm_core_mpu_configure_dynamic_mpu_regions'
      187 | void arm_core_mpu_configure_dynamic_mpu_regions(
          |      ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    /home/sihe/ncs/zephyr/arch/arm/core/aarch32/mpu/arm_core_mpu.c:311:9: warning: 'arm_core_mpu_configure_dynamic_mpu_regions' reading 12 bytes from a region of size 0 [-Wstringop-overread]
      311 |         arm_core_mpu_configure_dynamic_mpu_regions(dynamic_regions,
          |         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      312 |                                                    region_num);
          |                                                    ~~~~~~~~~~~
    /home/sihe/ncs/zephyr/arch/arm/core/aarch32/mpu/arm_core_mpu.c:311:9: note: referencing argument 1 of type 'const struct z_arm_mpu_partition[0]'
    /home/sihe/ncs/zephyr/arch/arm/core/aarch32/mpu/arm_core_mpu_dev.h:187:6: note: in a call to function 'arm_core_mpu_configure_dynamic_mpu_regions'
      187 | void arm_core_mpu_configure_dynamic_mpu_regions(
          |      ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    [142/180] Building C object modules/hal_nordic/nrfx/CMakeFiles/modules__hal_nordic__nrfx.dir/home/sihe/ncs/modules/hal/nordic/nrfx/drivers/src/nrfx_clock.c.obj
    In file included from /home/sihe/ncs/modules/hal/nordic/nrfx/drivers/include/nrfx_clock.h:38,
                     from /home/sihe/ncs/modules/hal/nordic/nrfx/drivers/src/nrfx_clock.c:38:
    In function 'nrf_clock_is_running',
        inlined from 'nrfx_clock_is_running' at /home/sihe/ncs/modules/hal/nordic/nrfx/drivers/include/nrfx_clock.h:326:12,
        inlined from 'clock_stop' at /home/sihe/ncs/modules/hal/nordic/nrfx/drivers/src/nrfx_clock.c:223:5,
        inlined from 'clock_stop' at /home/sihe/ncs/modules/hal/nordic/nrfx/drivers/src/nrfx_clock.c:187:13:
    /home/sihe/ncs/modules/hal/nordic/nrfx/hal/nrf_clock.h:784:51: warning: array subscript 'nrf_clock_lfclk_t[0]' is partly outside array bounds of 'nrf_clock_hfclk_t[1]' [-Warray-bounds]
      784 |                 (*(nrf_clock_lfclk_t *)p_clk_src) =
          |                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
      785 |                     (nrf_clock_lfclk_t)((p_reg->LFCLKSTAT & CLOCK_LFCLKSTAT_SRC_Msk)
          |                     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      786 |                                         >> CLOCK_LFCLKSTAT_SRC_Pos);
          |                                         ~~~~~~~~~~~~~~~~~~~~~~~~~~~
    /home/sihe/ncs/modules/hal/nordic/nrfx/drivers/src/nrfx_clock.c: In function 'clock_stop':
    /home/sihe/ncs/modules/hal/nordic/nrfx/drivers/src/nrfx_clock.c:221:23: note: object 'clk_src' of size 1
      221 |     nrf_clock_hfclk_t clk_src = NRF_CLOCK_HFCLK_HIGH_ACCURACY;
          |                       ^~~~~~~
    [170/180] Linking C executable zephyr/zephyr_pre0.elf
    
    [174/180] Linking C executable zephyr/zephyr_pre1.elf
    
    [180/180] Linking C executable zephyr/zephyr.elf
    Memory region         Used Size  Region Size  %age Used
               FLASH:       27916 B       512 KB      5.32%
                SRAM:        7016 B        64 KB     10.71%
            IDT_LIST:          0 GB         2 KB      0.00%
    

Related