Not able to compile my SPI device

Hi,

I encountered the following 3 issues in 1 single build: 

error: 'DT_N_S_soc_S_peripheral_40000000_S_spi_b000_S_hartmodem_0_P_spi_max_frequency' undeclared here (not in a function); did you mean 'DT_N_S_soc_S_peripheral_40000000_S_spi_b000_S_hartmodem_0_P_compatible_LEN'?

error: 'DT_N_S_soc_S_peripheral_40000000_S_spi_b000_S_hartmodem_0_P_frame_format' undeclared here (not in a function); did you mean 'DT_N_S_soc_S_peripheral_40000000_S_spi_b000_S_hartmodem_0_P_reg_IDX_0'?

'DT_N_S_soc_S_peripheral_40000000_S_spi_b000_S_hartmodem_0_P_duplex' undeclared here (not in a function); did you mean 'DT_N_S_soc_S_peripheral_40000000_S_spi_b000_S_hartmodem_0_P_reg'?

The full error message is shown here:

*  Executing task: nRF Connect: Build: h2ok_hart_spi_device/build (active) 

Building h2ok_hart_spi_device
west build --build-dir /Users/hairuosun/nordic/myapps/h2ok_hart_spi_device/build /Users/hairuosun/nordic/myapps/h2ok_hart_spi_device

[0/24] Performing build step for 'tfm'
ninja: no work to do.
[2/16] Building C object CMakeFiles/app.dir/src/main.c.obj
FAILED: CMakeFiles/app.dir/src/main.c.obj 
ccache /opt/nordic/ncs/toolchains/v2.2.0/opt/zephyr-sdk/arm-zephyr-eabi/bin/arm-zephyr-eabi-gcc -DKERNEL -DMBEDTLS_CONFIG_FILE=\"nrf-config.h\" -DMBEDTLS_USER_CONFIG_FILE=\"nrf-config-user.h\" -DNRF9160_XXAA -DNRF_SKIP_FICR_NS_COPY_TO_RAM -DNRF_TRUSTZONE_NONSECURE -DTFM_PSA_API -DUSE_PARTITION_MANAGER=1 -D_ANSI_SOURCE -D_FORTIFY_SOURCE=1 -D__LINUX_ERRNO_EXTENSIONS__ -D__PROGRAM_START -D__ZEPHYR__=1 -I/opt/nordic/ncs/v2.2.0/zephyr/include -Izephyr/include/generated -I/opt/nordic/ncs/v2.2.0/zephyr/soc/arm/nordic_nrf/nrf91 -I/opt/nordic/ncs/v2.2.0/zephyr/lib/libc/newlib/include -I/opt/nordic/ncs/v2.2.0/zephyr/soc/arm/nordic_nrf/common/. -I/opt/nordic/ncs/v2.2.0/nrf/include -I/opt/nordic/ncs/v2.2.0/nrf/include/tfm -I/opt/nordic/ncs/v2.2.0/nrf/tests/include -Itfm/generated/interface/include -I/opt/nordic/ncs/v2.2.0/modules/hal/cmsis/CMSIS/Core/Include -I/opt/nordic/ncs/v2.2.0/modules/hal/nordic/nrfx -I/opt/nordic/ncs/v2.2.0/modules/hal/nordic/nrfx/drivers/include -I/opt/nordic/ncs/v2.2.0/modules/hal/nordic/nrfx/mdk -I/opt/nordic/ncs/v2.2.0/zephyr/modules/hal_nordic/nrfx/. -I/opt/nordic/ncs/v2.2.0/nrfxlib/nrf_modem/include -Itfm/install/interface/include -Imodules/nrfxlib/nrfxlib/nrf_security/src/include/generated -I/opt/nordic/ncs/v2.2.0/nrfxlib/nrf_security/include -I/opt/nordic/ncs/v2.2.0/nrfxlib/nrf_security/include/mbedtls -I/opt/nordic/ncs/v2.2.0/mbedtls/include -I/opt/nordic/ncs/v2.2.0/mbedtls/include/mbedtls -I/opt/nordic/ncs/v2.2.0/mbedtls/include/psa -I/opt/nordic/ncs/v2.2.0/mbedtls/library -I/opt/nordic/ncs/v2.2.0/nrfxlib/crypto/nrf_oberon/include/mbedtls -I/opt/nordic/ncs/v2.2.0/nrfxlib/crypto/nrf_oberon/include -fno-strict-aliasing -Os -imacros /Users/hairuosun/nordic/myapps/h2ok_hart_spi_device/build/zephyr/include/generated/autoconf.h -ffreestanding -fno-common -g -gdwarf-4 -fdiagnostics-color=always -mcpu=cortex-m33 -mthumb -mabi=aapcs -mfp16-format=ieee --sysroot=/opt/nordic/ncs/toolchains/v2.2.0/opt/zephyr-sdk/arm-zephyr-eabi/arm-zephyr-eabi -imacros /opt/nordic/ncs/v2.2.0/zephyr/include/zephyr/toolchain/zephyr_stdint.h -Wall -Wformat -Wformat-security -Wno-format-zero-length -Wno-main -Wno-pointer-sign -Wpointer-arith -Wexpansion-to-defined -Wno-unused-but-set-variable -Werror=implicit-int -fno-pic -fno-pie -fno-asynchronous-unwind-tables -fno-reorder-functions --param=min-pagesize=0 -fno-defer-pop -fmacro-prefix-map=/Users/hairuosun/nordic/myapps/h2ok_hart_spi_device=CMAKE_SOURCE_DIR -fmacro-prefix-map=/opt/nordic/ncs/v2.2.0/zephyr=ZEPHYR_BASE -fmacro-prefix-map=/opt/nordic/ncs/v2.2.0=WEST_TOPDIR -ffunction-sections -fdata-sections -specs=nano.specs -std=c99 -MD -MT CMakeFiles/app.dir/src/main.c.obj -MF CMakeFiles/app.dir/src/main.c.obj.d -o CMakeFiles/app.dir/src/main.c.obj -c ../src/main.c
In file included from /opt/nordic/ncs/v2.2.0/zephyr/include/zephyr/arch/arm/aarch32/arch.h:20,
                 from /opt/nordic/ncs/v2.2.0/zephyr/include/zephyr/arch/cpu.h:19,
                 from /opt/nordic/ncs/v2.2.0/zephyr/include/zephyr/kernel_includes.h:33,
                 from /opt/nordic/ncs/v2.2.0/zephyr/include/zephyr/kernel.h:17,
                 from /Users/hairuosun/nordic/myapps/h2ok_hart_spi_device/src/main.c:1:
/Users/hairuosun/nordic/myapps/h2ok_hart_spi_device/build/zephyr/include/generated/devicetree_generated.h:12762:34: error: 'DT_N_S_soc_S_peripheral_40000000_S_spi_b000_S_hartmodem_0_P_spi_max_frequency' undeclared here (not in a function); did you mean 'DT_N_S_soc_S_peripheral_40000000_S_spi_b000_S_hartmodem_0_P_compatible_LEN'?
12762 | #define DT_N_ALIAS_hartmodem     DT_N_S_soc_S_peripheral_40000000_S_spi_b000_S_hartmodem_0
      |                                  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/opt/nordic/ncs/v2.2.0/zephyr/include/zephyr/devicetree.h:3892:29: note: in definition of macro 'DT_CAT3'
 3892 | #define DT_CAT3(a1, a2, a3) a1 ## a2 ## a3
      |                             ^~
/opt/nordic/ncs/v2.2.0/zephyr/include/zephyr/drivers/spi.h:345:30: note: in expansion of macro 'DT_PROP'
  345 |                 .frequency = DT_PROP(node_id, spi_max_frequency),       \
      |                              ^~~~~~~
/opt/nordic/ncs/v2.2.0/zephyr/include/zephyr/drivers/spi.h:407:27: note: in expansion of macro 'SPI_CONFIG_DT'
  407 |                 .config = SPI_CONFIG_DT(node_id, operation_, delay_) \
      |                           ^~~~~~~~~~~~~
/Users/hairuosun/nordic/myapps/h2ok_hart_spi_device/src/main.c:13:46: note: in expansion of macro 'SPI_DT_SPEC_GET'
   13 | const struct spi_dt_spec hartmodem_spi_dev = SPI_DT_SPEC_GET(DT_ALIAS(hartmodem), SPI_OP, 0);
      |                                              ^~~~~~~~~~~~~~~
/opt/nordic/ncs/v2.2.0/zephyr/include/zephyr/devicetree.h:3890:24: note: in expansion of macro 'DT_N_ALIAS_hartmodem'
 3890 | #define DT_CAT(a1, a2) a1 ## a2
      |                        ^~
/opt/nordic/ncs/v2.2.0/zephyr/include/zephyr/devicetree.h:230:25: note: in expansion of macro 'DT_CAT'
  230 | #define DT_ALIAS(alias) DT_CAT(DT_N_ALIAS_, alias)
      |                         ^~~~~~
/Users/hairuosun/nordic/myapps/h2ok_hart_spi_device/src/main.c:13:62: note: in expansion of macro 'DT_ALIAS'
   13 | const struct spi_dt_spec hartmodem_spi_dev = SPI_DT_SPEC_GET(DT_ALIAS(hartmodem), SPI_OP, 0);
      |                                                              ^~~~~~~~
/Users/hairuosun/nordic/myapps/h2ok_hart_spi_device/build/zephyr/include/generated/devicetree_generated.h:12762:34: error: 'DT_N_S_soc_S_peripheral_40000000_S_spi_b000_S_hartmodem_0_P_duplex' undeclared here (not in a function); did you mean 'DT_N_S_soc_S_peripheral_40000000_S_spi_b000_S_hartmodem_0_P_reg'?
12762 | #define DT_N_ALIAS_hartmodem     DT_N_S_soc_S_peripheral_40000000_S_spi_b000_S_hartmodem_0
      |                                  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/opt/nordic/ncs/v2.2.0/zephyr/include/zephyr/devicetree.h:3892:29: note: in definition of macro 'DT_CAT3'
 3892 | #define DT_CAT3(a1, a2, a3) a1 ## a2 ## a3
      |                             ^~
/opt/nordic/ncs/v2.2.0/zephyr/include/zephyr/drivers/spi.h:347:25: note: in expansion of macro 'DT_PROP'
  347 |                         DT_PROP(node_id, duplex) |                      \
      |                         ^~~~~~~
/opt/nordic/ncs/v2.2.0/zephyr/include/zephyr/drivers/spi.h:407:27: note: in expansion of macro 'SPI_CONFIG_DT'
  407 |                 .config = SPI_CONFIG_DT(node_id, operation_, delay_) \
      |                           ^~~~~~~~~~~~~
/Users/hairuosun/nordic/myapps/h2ok_hart_spi_device/src/main.c:13:46: note: in expansion of macro 'SPI_DT_SPEC_GET'
   13 | const struct spi_dt_spec hartmodem_spi_dev = SPI_DT_SPEC_GET(DT_ALIAS(hartmodem), SPI_OP, 0);
      |                                              ^~~~~~~~~~~~~~~
/opt/nordic/ncs/v2.2.0/zephyr/include/zephyr/devicetree.h:3890:24: note: in expansion of macro 'DT_N_ALIAS_hartmodem'
 3890 | #define DT_CAT(a1, a2) a1 ## a2
      |                        ^~
/opt/nordic/ncs/v2.2.0/zephyr/include/zephyr/devicetree.h:230:25: note: in expansion of macro 'DT_CAT'
  230 | #define DT_ALIAS(alias) DT_CAT(DT_N_ALIAS_, alias)
      |                         ^~~~~~
/Users/hairuosun/nordic/myapps/h2ok_hart_spi_device/src/main.c:13:62: note: in expansion of macro 'DT_ALIAS'
   13 | const struct spi_dt_spec hartmodem_spi_dev = SPI_DT_SPEC_GET(DT_ALIAS(hartmodem), SPI_OP, 0);
      |                                                              ^~~~~~~~
/Users/hairuosun/nordic/myapps/h2ok_hart_spi_device/build/zephyr/include/generated/devicetree_generated.h:12762:34: error: 'DT_N_S_soc_S_peripheral_40000000_S_spi_b000_S_hartmodem_0_P_frame_format' undeclared here (not in a function); did you mean 'DT_N_S_soc_S_peripheral_40000000_S_spi_b000_S_hartmodem_0_P_reg_IDX_0'?
12762 | #define DT_N_ALIAS_hartmodem     DT_N_S_soc_S_peripheral_40000000_S_spi_b000_S_hartmodem_0
      |                                  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/opt/nordic/ncs/v2.2.0/zephyr/include/zephyr/devicetree.h:3892:29: note: in definition of macro 'DT_CAT3'
 3892 | #define DT_CAT3(a1, a2, a3) a1 ## a2 ## a3
      |                             ^~
/opt/nordic/ncs/v2.2.0/zephyr/include/zephyr/drivers/spi.h:348:25: note: in expansion of macro 'DT_PROP'
  348 |                         DT_PROP(node_id, frame_format),                 \
      |                         ^~~~~~~
/opt/nordic/ncs/v2.2.0/zephyr/include/zephyr/drivers/spi.h:407:27: note: in expansion of macro 'SPI_CONFIG_DT'
  407 |                 .config = SPI_CONFIG_DT(node_id, operation_, delay_) \
      |                           ^~~~~~~~~~~~~
/Users/hairuosun/nordic/myapps/h2ok_hart_spi_device/src/main.c:13:46: note: in expansion of macro 'SPI_DT_SPEC_GET'
   13 | const struct spi_dt_spec hartmodem_spi_dev = SPI_DT_SPEC_GET(DT_ALIAS(hartmodem), SPI_OP, 0);
      |                                              ^~~~~~~~~~~~~~~
/opt/nordic/ncs/v2.2.0/zephyr/include/zephyr/devicetree.h:3890:24: note: in expansion of macro 'DT_N_ALIAS_hartmodem'
 3890 | #define DT_CAT(a1, a2) a1 ## a2
      |                        ^~
/opt/nordic/ncs/v2.2.0/zephyr/include/zephyr/devicetree.h:230:25: note: in expansion of macro 'DT_CAT'
  230 | #define DT_ALIAS(alias) DT_CAT(DT_N_ALIAS_, alias)
      |                         ^~~~~~
/Users/hairuosun/nordic/myapps/h2ok_hart_spi_device/src/main.c:13:62: note: in expansion of macro 'DT_ALIAS'
   13 | const struct spi_dt_spec hartmodem_spi_dev = SPI_DT_SPEC_GET(DT_ALIAS(hartmodem), SPI_OP, 0);
      |                                                              ^~~~~~~~
ninja: build stopped: subcommand failed.
FATAL ERROR: command exited with status 1: /opt/nordic/ncs/toolchains/v2.2.0/bin/cmake --build /Users/hairuosun/nordic/myapps/h2ok_hart_spi_device/build

 *  The terminal process failed to launch (exit code: 1). 
 *  Terminal will be reused by tasks, press any key to close it. 

My overlay file:

My main.c file:

My proj.conf file: 

Do you mind sharing with me how I can fix this issue?

Best Regards,

Hairuo

Related