How to enable I2C1 on NRF9160

Hello,

I’m currently working on a project using the nRF9160 DK, Zephyr RTOS, and nRF Connect SDK. I’m trying to enable the I2C1 interface on the nRF9160 DK, but I’m encountering compilation errors.

Here’s the relevant part of my DTS overlay file:

&i2c1{
	status = "okay";
	compatible = "nordic,nrf-twim";
	clock-frequency = <I2C_BITRATE_STANDARD>;
	#address-cells = <1>;
	#size-cells = <0>;
	pinctrl-0 = < &i2c1_default >;
	aux_display_gpio_controller: pcf8574@27 {
		status = "okay";
		compatible = "nxp,pcf8574";
		reg = <0x27>;
		gpio-controller;
		ngpios = <8>;
		#gpio-cells = <2>;
	};
};

And here’s the relevant part of my prj.conf file:

#display
CONFIG_I2C=y
CONFIG_SPI=n
CONFIG_NRFX_SPI1=n
CONFIG_NRFX_TWIM1=y
CONFIG_DISPLAY=y
CONFIG_AUXDISPLAY=y

# Enable the UART driver
CONFIG_UART_ASYNC_API=y
CONFIG_NRFX_UARTE0=y
CONFIG_UART_3_INTERRUPT_DRIVEN=n 
CONFIG_UART_3_ASYNC=y


Despite this, I’m getting compilation errors related to the i2c_nrfx_twim.c file in the zephyr/drivers/i2c directory.
This is the compilation error:

[0/60] Performing build step for 'tfm'
ninja: no work to do.
[6/52] Building C object zephyr/drivers/i2c/CMakeFiles/drivers__i2c.dir/i2c_nrfx_twim.c.obj
FAILED: zephyr/drivers/i2c/CMakeFiles/drivers__i2c.dir/i2c_nrfx_twim.c.obj 
C:\ncs\toolchains\c57af46cb7\opt\zephyr-sdk\arm-zephyr-eabi\bin\arm-zephyr-eabi-gcc.exe -DAPP_VERSION=v2.5.0 -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 -DUSE_PARTITION_MANAGER=1 -D_ANSI_SOURCE -D_FORTIFY_SOURCE=1 -D__LINUX_ERRNO_EXTENSIONS__ -D__PROGRAM_START -D__ZEPHYR_SUPERVISOR__ -D__ZEPHYR__=1 -IC:/ncs/v2.5.0/zephyr/include -Izephyr/include/generated -IC:/ncs/v2.5.0/zephyr/soc/arm/nordic_nrf/nrf91 -IC:/ncs/v2.5.0/zephyr/lib/libc/newlib/include -IC:/ncs/v2.5.0/zephyr/soc/arm/nordic_nrf/common/. -IC:/ncs/v2.5.0/zephyr/subsys/bluetooth -IC:/ncs/v2.5.0/zephyr/subsys/net/lib/sockets/. -IC:/ncs/v2.5.0/zephyr/subsys/net/lib/tls_credentials/. -IC:/ncs/v2.5.0/zephyr/subsys/net/ip -IC:/ncs/v2.5.0/zephyr/subsys/net/conn_mgr/. -IC:/ncs/v2.5.0/zephyr/subsys/settings/include -IC:/ncs/v2.5.0/nrf/include -IC:/ncs/v2.5.0/nrf/lib/at_cmd_parser/include -Itfm/install/interface/include -IC:/ncs/v2.5.0/nrf/include/tfm -IC:/ncs/v2.5.0/nrf/tests/include -Itfm/generated/interface/include -IC:/ncs/v2.5.0/modules/hal/cmsis/CMSIS/Core/Include -IC:/ncs/v2.5.0/zephyr/modules/cmsis/. -IC:/ncs/v2.5.0/modules/hal/nordic/nrfx -IC:/ncs/v2.5.0/modules/hal/nordic/nrfx/drivers/include -IC:/ncs/v2.5.0/modules/hal/nordic/nrfx/mdk -IC:/ncs/v2.5.0/zephyr/modules/hal_nordic/nrfx/. -IC:/ncs/v2.5.0/modules/debug/segger/SEGGER -IC:/ncs/v2.5.0/modules/debug/segger/Config -IC:/ncs/v2.5.0/modules/crypto/tinycrypt/lib/include -IC:/ncs/v2.5.0/nrfxlib/nrf_modem/include -Imodules/nrf/subsys/nrf_security/src/include/generated -IC:/ncs/v2.5.0/nrf/subsys/nrf_security/include -IC:/ncs/v2.5.0/nrf/ext/oberon/psa/core/include -IC:/ncs/v2.5.0/nrf/ext/oberon/psa/core/library -IC:/ncs/v2.5.0/modules/crypto/mbedtls/include -IC:/ncs/v2.5.0/modules/crypto/mbedtls/library -IC:/ncs/v2.5.0/nrfxlib/crypto/nrf_oberon/include/mbedtls -IC:/ncs/v2.5.0/nrfxlib/crypto/nrf_oberon/include -IC:/ncs/v2.5.0/nrfxlib/softdevice_controller/include -Wshadow -fno-strict-aliasing -Os -imacros D:/OneDriveUL/Root/Github_projects/LiveConnectorFirmware/LiveConnector/build/zephyr/include/generated/autoconf.h -fno-common -g -gdwarf-4 -fdiagnostics-color=always -mcpu=cortex-m33 -mthumb -mabi=aapcs -mfpu=fpv5-sp-d16 -mfloat-abi=hard -mfp16-format=ieee --sysroot=C:/ncs/toolchains/c57af46cb7/opt/zephyr-sdk/arm-zephyr-eabi/arm-zephyr-eabi -imacros C:/ncs/v2.5.0/zephyr/include/zephyr/toolchain/zephyr_stdint.h -Wall -Wformat -Wformat-security -Wno-format-zero-length -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=D:/OneDriveUL/Root/Github_projects/LiveConnectorFirmware/LiveConnector=CMAKE_SOURCE_DIR -fmacro-prefix-map=C:/ncs/v2.5.0/zephyr=ZEPHYR_BASE -fmacro-prefix-map=C:/ncs/v2.5.0=WEST_TOPDIR -ffunction-sections -fdata-sections -specs=nano.specs -D_POSIX_THREADS -std=c99 -MD -MT zephyr/drivers/i2c/CMakeFiles/drivers__i2c.dir/i2c_nrfx_twim.c.obj -MF zephyr\drivers\i2c\CMakeFiles\drivers__i2c.dir\i2c_nrfx_twim.c.obj.d -o zephyr/drivers/i2c/CMakeFiles/drivers__i2c.dir/i2c_nrfx_twim.c.obj -c C:/ncs/v2.5.0/zephyr/drivers/i2c/i2c_nrfx_twim.c
In file included from C:/ncs/v2.5.0/zephyr/include/zephyr/sys/util_macro.h:34,
                 from C:/ncs/v2.5.0/zephyr/include/zephyr/sys/util.h:17,
                 from C:/ncs/v2.5.0/zephyr/include/zephyr/devicetree.h:25,
                 from C:/ncs/v2.5.0/zephyr/include/zephyr/device.h:12,
                 from C:/ncs/v2.5.0/zephyr/include/zephyr/drivers/i2c.h:25,
                 from C:/ncs/v2.5.0/zephyr/drivers/i2c/i2c_nrfx_twim.c:8:
C:/ncs/v2.5.0/zephyr/include/zephyr/drivers/pinctrl.h:91:17: error: 'PINCTRL_STATE_DT_N_S_soc_S_peripheral_40000000_S_i2c_9000_PINCTRL_IDX_0_UPPER_TOKEN' undeclared here (not in a function); did you mean 'DT_N_S_soc_S_peripheral_40000000_S_i2c_a000_PINCTRL_IDX_0_UPPER_TOKEN'?
   91 |         _CONCAT(PINCTRL_STATE_,                                                \
      |                 ^~~~~~~~~~~~~~
C:/ncs/v2.5.0/zephyr/include/zephyr/sys/util_internal.h:72:26: note: in definition of macro '__DEBRACKET'
   72 | #define __DEBRACKET(...) __VA_ARGS__
      |                          ^~~~~~~~~~~
C:/ncs/v2.5.0/zephyr/include/zephyr/sys/util_internal.h:64:9: note: in expansion of macro '__GET_ARG2_DEBRACKET'
   64 |         __GET_ARG2_DEBRACKET(one_or_two_args _if_code, _else_code)
      |         ^~~~~~~~~~~~~~~~~~~~
C:/ncs/v2.5.0/zephyr/include/zephyr/sys/util_internal.h:59:9: note: in expansion of macro '__COND_CODE'
   59 |         __COND_CODE(_XXXX##_flag, _if_1_code, _else_code)
      |         ^~~~~~~~~~~
C:/ncs/v2.5.0/zephyr/include/zephyr/sys/util_macro.h:180:9: note: in expansion of macro 'Z_COND_CODE_1'
  180 |         Z_COND_CODE_1(_flag, _if_1_code, _else_code)
      |         ^~~~~~~~~~~~~
C:/ncs/v2.5.0/zephyr/include/zephyr/drivers/pinctrl.h:156:9: note: in expansion of macro 'COND_CODE_1'
  156 |         COND_CODE_1(Z_PINCTRL_SKIP_STATE(state_idx, node_id), (),              \
      |         ^~~~~~~~~~~
C:/ncs/v2.5.0/zephyr/include/zephyr/toolchain/common.h:133:23: note: in expansion of macro '_DO_CONCAT'
  133 | #define _CONCAT(x, y) _DO_CONCAT(x, y)
      |                       ^~~~~~~~~~
C:/ncs/v2.5.0/zephyr/include/zephyr/drivers/pinctrl.h:91:9: note: in expansion of macro '_CONCAT'
   91 |         _CONCAT(PINCTRL_STATE_,                                                \
      |         ^~~~~~~
C:/ncs/v2.5.0/zephyr/include/zephyr/drivers/pinctrl.h:158:23: note: in expansion of macro 'Z_PINCTRL_STATE_ID'
  158 |                 .id = Z_PINCTRL_STATE_ID(state_idx, node_id),                  \
      |                       ^~~~~~~~~~~~~~~~~~
C:/ncs/v2.5.0/zephyr/include/zephyr/sys/util_loops.h:1086:9: note: in expansion of macro 'Z_PINCTRL_STATE_INIT'
 1086 |         F(0, __VA_ARGS__)
      |         ^
C:/ncs/v2.5.0/zephyr/include/zephyr/sys/util_loops.h:1089:9: note: in expansion of macro 'Z_UTIL_LISTIFY_1'
 1089 |         Z_UTIL_LISTIFY_1(F, sep, __VA_ARGS__) __DEBRACKET sep \
      |         ^~~~~~~~~~~~~~~~
C:/ncs/v2.5.0/zephyr/include/zephyr/sys/util_internal.h:105:36: note: in expansion of macro 'Z_UTIL_LISTIFY_2'
  105 | #define UTIL_PRIMITIVE_CAT(a, ...) a##__VA_ARGS__
      |                                    ^
C:/ncs/v2.5.0/zephyr/include/zephyr/drivers/pinctrl.h:172:17: note: in expansion of macro 'LISTIFY'
  172 |                 LISTIFY(DT_NUM_PINCTRL_STATES(node_id),                        \
      |                 ^~~~~~~
C:/ncs/v2.5.0/zephyr/include/zephyr/drivers/pinctrl.h:242:9: note: in expansion of macro 'Z_PINCTRL_STATES_DEFINE'
  242 |         Z_PINCTRL_STATES_DEFINE(node_id)                                       \
      |         ^~~~~~~~~~~~~~~~~~~~~~~
C:/ncs/v2.5.0/zephyr/drivers/i2c/i2c_nrfx_twim.c:404:9: note: in expansion of macro 'PINCTRL_DT_DEFINE'
  404 |         PINCTRL_DT_DEFINE(I2C(idx));                                           \
      |         ^~~~~~~~~~~~~~~~~
C:/ncs/v2.5.0/zephyr/drivers/i2c/i2c_nrfx_twim.c:437:1: note: in expansion of macro 'I2C_NRFX_TWIM_DEVICE'
  437 | I2C_NRFX_TWIM_DEVICE(1);
      | ^~~~~~~~~~~~~~~~~~~~
C:/ncs/v2.5.0/zephyr/include/zephyr/drivers/pinctrl.h:91:17: error: 'PINCTRL_STATE_DT_N_S_soc_S_peripheral_40000000_S_i2c_9000_PINCTRL_IDX_1_UPPER_TOKEN' undeclared here (not in a function); did you mean 'DT_N_S_soc_S_peripheral_40000000_S_i2c_a000_PINCTRL_IDX_1_UPPER_TOKEN'?
   91 |         _CONCAT(PINCTRL_STATE_,                                                \
      |                 ^~~~~~~~~~~~~~
C:/ncs/v2.5.0/zephyr/include/zephyr/sys/util_internal.h:72:26: note: in definition of macro '__DEBRACKET'
   72 | #define __DEBRACKET(...) __VA_ARGS__
      |                          ^~~~~~~~~~~
C:/ncs/v2.5.0/zephyr/include/zephyr/sys/util_internal.h:64:9: note: in expansion of macro '__GET_ARG2_DEBRACKET'
   64 |         __GET_ARG2_DEBRACKET(one_or_two_args _if_code, _else_code)
      |         ^~~~~~~~~~~~~~~~~~~~
C:/ncs/v2.5.0/zephyr/include/zephyr/sys/util_internal.h:59:9: note: in expansion of macro '__COND_CODE'
   59 |         __COND_CODE(_XXXX##_flag, _if_1_code, _else_code)
      |         ^~~~~~~~~~~
C:/ncs/v2.5.0/zephyr/include/zephyr/sys/util_macro.h:180:9: note: in expansion of macro 'Z_COND_CODE_1'
  180 |         Z_COND_CODE_1(_flag, _if_1_code, _else_code)
      |         ^~~~~~~~~~~~~
C:/ncs/v2.5.0/zephyr/include/zephyr/drivers/pinctrl.h:156:9: note: in expansion of macro 'COND_CODE_1'
  156 |         COND_CODE_1(Z_PINCTRL_SKIP_STATE(state_idx, node_id), (),              \
      |         ^~~~~~~~~~~
C:/ncs/v2.5.0/zephyr/include/zephyr/toolchain/common.h:133:23: note: in expansion of macro '_DO_CONCAT'
  133 | #define _CONCAT(x, y) _DO_CONCAT(x, y)
      |                       ^~~~~~~~~~
C:/ncs/v2.5.0/zephyr/include/zephyr/drivers/pinctrl.h:91:9: note: in expansion of macro '_CONCAT'
   91 |         _CONCAT(PINCTRL_STATE_,                                                \
      |         ^~~~~~~
C:/ncs/v2.5.0/zephyr/include/zephyr/drivers/pinctrl.h:158:23: note: in expansion of macro 'Z_PINCTRL_STATE_ID'
  158 |                 .id = Z_PINCTRL_STATE_ID(state_idx, node_id),                  \
      |                       ^~~~~~~~~~~~~~~~~~
C:/ncs/v2.5.0/zephyr/include/zephyr/sys/util_loops.h:1090:9: note: in expansion of macro 'Z_PINCTRL_STATE_INIT'
 1090 |         F(1, __VA_ARGS__)
      |         ^
C:/ncs/v2.5.0/zephyr/include/zephyr/sys/util_internal.h:105:36: note: in expansion of macro 'Z_UTIL_LISTIFY_2'
  105 | #define UTIL_PRIMITIVE_CAT(a, ...) a##__VA_ARGS__
      |                                    ^
C:/ncs/v2.5.0/zephyr/include/zephyr/drivers/pinctrl.h:172:17: note: in expansion of macro 'LISTIFY'
  172 |                 LISTIFY(DT_NUM_PINCTRL_STATES(node_id),                        \
      |                 ^~~~~~~
C:/ncs/v2.5.0/zephyr/include/zephyr/drivers/pinctrl.h:242:9: note: in expansion of macro 'Z_PINCTRL_STATES_DEFINE'
  242 |         Z_PINCTRL_STATES_DEFINE(node_id)                                       \
      |         ^~~~~~~~~~~~~~~~~~~~~~~
C:/ncs/v2.5.0/zephyr/drivers/i2c/i2c_nrfx_twim.c:404:9: note: in expansion of macro 'PINCTRL_DT_DEFINE'
  404 |         PINCTRL_DT_DEFINE(I2C(idx));                                           \
      |         ^~~~~~~~~~~~~~~~~
C:/ncs/v2.5.0/zephyr/drivers/i2c/i2c_nrfx_twim.c:437:1: note: in expansion of macro 'I2C_NRFX_TWIM_DEVICE'
  437 | I2C_NRFX_TWIM_DEVICE(1);
      | ^~~~~~~~~~~~~~~~~~~~

I’ve tried disabling other peripherals (SPI1, SPI3, UART1, and I2C2) to ensure there’s no conflict, but the issue persists.

I’m attaching the full DTS overlay file and the compiled DTS file for reference.

Any help or guidance on how to resolve this issue would be greatly appreciated.

Thank you!


5432.prj.conf7651.app.overlay1307.zephyr.dtscompiled_config.txt

Parents Reply Children
No Data
Related