The Nordic Thingy:91X board has a Nordic nmp1300 pmic device, but the samples do not support the board (a lot of time would be saved it they did);
Attempting to modify sample npm1300_fuel_gauge to work with the Thingy-91X
Added boards/thingy91x_nrf5340_cpuapp.overlay with;
&npm1300_charger {
compatible = "nordic,npm1300-charger";
status = "okay";
};
&pmic_main {
compatible = "nordic,npm1300";
status = "okay";
};
Side question - is the 'compatible' statement needed? - appears to be redundant but was a suggestion in one of the many searches.
And build with;
npm1300_fuel_gauge$ west build --build-dir build_thingy91x_nrf5340_cpuapp --board thingy91x/nrf5340/cpuapp
The overlay is picked up for this build target and enables these two drivers defined in ncs/v3.0.2/nrf/boards/nordic/thingy91x/thingy91x_common.dtsi which are disabled by default.
BTW, seems you cant rely on prj.conf:CONFIG_NRF_FUEL_GAUGE=y to enable the dependent I2C & npm1300 & pmic drivers like it seems to do for the supported boards.
That is confirmed in the generated files;
npm1300_fuel_gauge/build_thingy91x_nrf5340_cpuapp/npm1300_fuel_gauge/zephyr/include/generated/zephyr/devicetree_generated.h
and
npm1300_fuel_gauge/build_nrf5340dk_nrf5340_cpuapp/npm1300_fuel_gauge/zephyr/zephyr.dts
However, the build still fails with the following errors which I'm having difficultly troubleshooting after much research on this site and generally;
It's probably something simple, just like the overlay file is simple when you've figured out which SOC on the board to use, the correct filename, location in the tree and the correct contents.
<snip>
-- west build: building application
[0/78] Creating public key from private key used for signing
[31/78] Performing build step for 'npm1300_fuel_gauge'
[0/1] Re-running CMake...
Loading Zephyr default modules (Zephyr base (cached)).
-- Application: /home/rgjones/nordic/npm1300_fuel_gauge
-- CMake version: 3.21.0
-- Cache files will be written to: /home/rgjones/.cache/zephyr
-- Zephyr version: 4.0.99 (/home/rgjones/ncs/v3.0.2/zephyr)
-- Found west (found suitable version "1.2.0", minimum required is "0.14.0")
-- Board: thingy91x, qualifiers: nrf5340/cpuapp
-- Found host-tools: zephyr 0.17.0 (/home/rgjones/ncs/toolchains/7cbc0036f4/opt/zephyr-sdk)
-- Found toolchain: zephyr 0.17.0 (/home/rgjones/ncs/toolchains/7cbc0036f4/opt/zephyr-sdk)
-- Found BOARD.dts: /home/rgjones/ncs/v3.0.2/nrf/boards/nordic/thingy91x/thingy91x_nrf5340_cpuapp.dts
-- Found devicetree overlay: /home/rgjones/nordic/npm1300_fuel_gauge/boards/thingy91x_nrf5340_cpuapp.overlay
-- Generated zephyr.dts: /home/rgjones/nordic/npm1300_fuel_gauge/build_thingy91x_nrf5340_cpuapp/npm1300_fuel_gauge/zephyr/zephyr.dts
-- Generated pickled edt: /home/rgjones/nordic/npm1300_fuel_gauge/build_thingy91x_nrf5340_cpuapp/npm1300_fuel_gauge/zephyr/edt.pickle
-- Generated zephyr.dts: /home/rgjones/nordic/npm1300_fuel_gauge/build_thingy91x_nrf5340_cpuapp/npm1300_fuel_gauge/zephyr/zephyr.dts
-- Generated devicetree_generated.h: /home/rgjones/nordic/npm1300_fuel_gauge/build_thingy91x_nrf5340_cpuapp/npm1300_fuel_gauge/zephyr/include/generated/zephyr/devicetree_generated.h
-- Including generated dts.cmake file: /home/rgjones/nordic/npm1300_fuel_gauge/build_thingy91x_nrf5340_cpuapp/npm1300_fuel_gauge/zephyr/dts.cmake
warning: Deprecated symbol SOC_DCDC_NRF53X_APP is enabled.
warning: Deprecated symbol SOC_DCDC_NRF53X_NET is enabled.
warning: Deprecated symbol NFCT_PINS_AS_GPIOS is enabled.
warning: Deprecated symbol DEPRECATED_UART_NRFX_UARTE_LEGACY_SHIM is enabled.
Parsing /home/rgjones/ncs/v3.0.2/zephyr/Kconfig
Loaded configuration '/home/rgjones/nordic/npm1300_fuel_gauge/build_thingy91x_nrf5340_cpuapp/npm1300_fuel_gauge/zephyr/.config'
Merged configuration '/home/rgjones/nordic/npm1300_fuel_gauge/build_thingy91x_nrf5340_cpuapp/npm1300_fuel_gauge/zephyr/.config.sysbuild'
No change to configuration in '/home/rgjones/nordic/npm1300_fuel_gauge/build_thingy91x_nrf5340_cpuapp/npm1300_fuel_gauge/zephyr/.config'
No change to Kconfig header in '/home/rgjones/nordic/npm1300_fuel_gauge/build_thingy91x_nrf5340_cpuapp/npm1300_fuel_gauge/zephyr/include/generated/zephyr/autoconf.h'
-- Using ccache: /home/rgjones/ncs/toolchains/7cbc0036f4/usr/bin/ccache
-- Including signing script: /home/rgjones/ncs/v3.0.2/nrf/cmake/sysbuild/image_signing.cmake
-- Configuring done
-- Generating done
-- Build files have been written to: /home/rgjones/nordic/npm1300_fuel_gauge/build_thingy91x_nrf5340_cpuapp/npm1300_fuel_gauge
[1/223] Preparing syscall dependency handling
[5/223] Generating include/generated/zephyr/version.h
-- Zephyr version: 4.0.99 (/home/rgjones/ncs/v3.0.2/zephyr), build: v4.0.99-ncs1-2
[216/223] Building C object zephyr/drivers/mfd/CMakeFiles/drivers__mfd.dir/mfd_npm1300.c.obj
FAILED: zephyr/drivers/mfd/CMakeFiles/drivers__mfd.dir/mfd_npm1300.c.obj
ccache /home/rgjones/ncs/toolchains/7cbc0036f4/opt/zephyr-sdk/arm-zephyr-eabi/bin/arm-zephyr-eabi-gcc -DEXT_API_MAGIC=0x281ee6de,0xb845acea,13570 -DFIRMWARE_INFO_MAGIC=0x281ee6de,0x8fcebb4c,13570 -DKERNEL -DK_HEAP_MEM_POOL_SIZE=0 -DNRF5340_XXAA_APPLICATION -DNRF_SKIP_FICR_NS_COPY_TO_RAM -DPICOLIBC_DOUBLE_PRINTF_SCANF -DUSE_PARTITION_MANAGER=1 -D__LINUX_ERRNO_EXTENSIONS__ -D__PROGRAM_START -D__ZEPHYR_SUPERVISOR__ -D__ZEPHYR__=1 -I/home/rgjones/nordic/npm1300_fuel_gauge/build_thingy91x_nrf5340_cpuapp/npm1300_fuel_gauge/zephyr/include/generated/zephyr -I/home/rgjones/ncs/v3.0.2/zephyr/include -I/home/rgjones/nordic/npm1300_fuel_gauge/build_thingy91x_nrf5340_cpuapp/npm1300_fuel_gauge/zephyr/include/generated -I/home/rgjones/ncs/v3.0.2/zephyr/soc/nordic -I/home/rgjones/ncs/v3.0.2/zephyr/lib/posix/options/getopt -I/home/rgjones/ncs/v3.0.2/zephyr/soc/nordic/nrf53/. -I/home/rgjones/ncs/v3.0.2/zephyr/soc/nordic/common/. -I/home/rgjones/ncs/v3.0.2/zephyr/subsys/shell/modules/kernel_service/thread/.. -I/home/rgjones/ncs/v3.0.2/nrf/include -I/home/rgjones/ncs/v3.0.2/nrf/tests/include -I/home/rgjones/ncs/v3.0.2/modules/hal/cmsis/CMSIS/Core/Include -I/home/rgjones/ncs/v3.0.2/zephyr/modules/cmsis/. -I/home/rgjones/ncs/v3.0.2/nrf/modules/hal_nordic/. -I/home/rgjones/ncs/v3.0.2/modules/hal/nordic/nrfx -I/home/rgjones/ncs/v3.0.2/modules/hal/nordic/nrfx/drivers/include -I/home/rgjones/ncs/v3.0.2/modules/hal/nordic/nrfx/mdk -I/home/rgjones/ncs/v3.0.2/zephyr/modules/hal_nordic/nrfx/. -I/home/rgjones/ncs/v3.0.2/modules/debug/segger/SEGGER -I/home/rgjones/ncs/v3.0.2/modules/debug/segger/Config -I/home/rgjones/ncs/v3.0.2/nrfxlib/nrf_fuel_gauge/include -isystem /home/rgjones/ncs/v3.0.2/zephyr/lib/libc/common/include -isystem /home/rgjones/ncs/v3.0.2/nrfxlib/crypto/nrf_cc312_platform/include -Wshadow -fno-strict-aliasing -Os -imacros /home/rgjones/nordic/npm1300_fuel_gauge/build_thingy91x_nrf5340_cpuapp/npm1300_fuel_gauge/zephyr/include/generated/zephyr/autoconf.h -fno-common -g -gdwarf-4 -fdiagnostics-color=always -mcpu=cortex-m33 -mthumb -mabi=aapcs -mfp16-format=ieee -mtp=soft --sysroot=/home/rgjones/ncs/toolchains/7cbc0036f4/opt/zephyr-sdk/arm-zephyr-eabi/arm-zephyr-eabi -imacros /home/rgjones/ncs/v3.0.2/zephyr/include/zephyr/toolchain/zephyr_stdint.h -Wall -Wformat -Wformat-security -Wno-format-zero-length -Wdouble-promotion -Wno-pointer-sign -Wpointer-arith -Wexpansion-to-defined -Wno-unused-but-set-variable -Werror=implicit-int -fno-pic -fno-pie -fno-asynchronous-unwind-tables -ftls-model=local-exec -fno-reorder-functions --param=min-pagesize=0 -fno-defer-pop -fmacro-prefix-map=/home/rgjones/nordic/npm1300_fuel_gauge=CMAKE_SOURCE_DIR -fmacro-prefix-map=/home/rgjones/ncs/v3.0.2/zephyr=ZEPHYR_BASE -fmacro-prefix-map=/home/rgjones/ncs/v3.0.2=WEST_TOPDIR -ffunction-sections -fdata-sections -specs=picolibc.specs -D_POSIX_THREADS -std=c99 -MD -MT zephyr/drivers/mfd/CMakeFiles/drivers__mfd.dir/mfd_npm1300.c.obj -MF zephyr/drivers/mfd/CMakeFiles/drivers__mfd.dir/mfd_npm1300.c.obj.d -o zephyr/drivers/mfd/CMakeFiles/drivers__mfd.dir/mfd_npm1300.c.obj -c /home/rgjones/ncs/v3.0.2/zephyr/drivers/mfd/mfd_npm1300.c
In file included from /home/rgjones/ncs/v3.0.2/zephyr/include/zephyr/sys/util_macro.h:34,
from /home/rgjones/ncs/v3.0.2/zephyr/include/zephyr/irq_multilevel.h:16,
from /home/rgjones/ncs/v3.0.2/zephyr/include/zephyr/devicetree.h:20,
from /home/rgjones/ncs/v3.0.2/zephyr/include/zephyr/device.h:12,
from /home/rgjones/ncs/v3.0.2/zephyr/include/zephyr/drivers/i2c.h:27,
from /home/rgjones/ncs/v3.0.2/zephyr/drivers/mfd/mfd_npm1300.c:10:
/home/rgjones/ncs/v3.0.2/zephyr/include/zephyr/device.h:96:41: error: '__device_dts_ord_122' undeclared here (not in a function); did you mean '__device_dts_ord_22'?
96 | #define DEVICE_NAME_GET(dev_id) _CONCAT(__device_, dev_id)
| ^~~~~~~~~
/home/rgjones/ncs/v3.0.2/zephyr/include/zephyr/sys/util_internal.h:72:26: note: in definition of macro '__DEBRACKET'
72 | #define __DEBRACKET(...) __VA_ARGS__
| ^~~~~~~~~~~
/home/rgjones/ncs/v3.0.2/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)
| ^~~~~~~~~~~~~~~~~~~~
/home/rgjones/ncs/v3.0.2/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)
| ^~~~~~~~~~~
/home/rgjones/ncs/v3.0.2/zephyr/include/zephyr/sys/util_macro.h:196:9: note: in expansion of macro 'Z_COND_CODE_1'
196 | Z_COND_CODE_1(_flag, _if_1_code, _else_code)
| ^~~~~~~~~~~~~
/home/rgjones/ncs/v3.0.2/zephyr/include/zephyr/devicetree.h:4946:9: note: in expansion of macro 'COND_CODE_1'
4946 | COND_CODE_1(DT_HAS_COMPAT_STATUS_OKAY(DT_DRV_COMPAT), \
| ^~~~~~~~~~~
/home/rgjones/ncs/v3.0.2/zephyr/include/zephyr/sys/util_internal.h:69:53: note: in expansion of macro '__DEBRACKET'
69 | #define __GET_ARG2_DEBRACKET(ignore_this, val, ...) __DEBRACKET val
| ^~~~~~~~~~~
/home/rgjones/ncs/v3.0.2/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)
| ^~~~~~~~~~~~~~~~~~~~
/home/rgjones/ncs/v3.0.2/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)
| ^~~~~~~~~~~
/home/rgjones/ncs/v3.0.2/zephyr/include/zephyr/sys/util_macro.h:196:9: note: in expansion of macro 'Z_COND_CODE_1'
196 | Z_COND_CODE_1(_flag, _if_1_code, _else_code)
| ^~~~~~~~~~~~~
/home/rgjones/ncs/v3.0.2/zephyr/include/zephyr/drivers/i2c.h:122:17: note: in expansion of macro 'COND_CODE_1'
122 | COND_CODE_1(DT_ON_BUS(node_id, i3c), \
| ^~~~~~~~~~~
/home/rgjones/ncs/v3.0.2/zephyr/include/zephyr/toolchain/common.h:138:23: note: in expansion of macro '_DO_CONCAT'
138 | #define _CONCAT(x, y) _DO_CONCAT(x, y)
| ^~~~~~~~~~
/home/rgjones/ncs/v3.0.2/zephyr/include/zephyr/device.h:96:33: note: in expansion of macro '_CONCAT'
96 | #define DEVICE_NAME_GET(dev_id) _CONCAT(__device_, dev_id)
| ^~~~~~~
/home/rgjones/ncs/v3.0.2/zephyr/include/zephyr/device.h:237:37: note: in expansion of macro 'DEVICE_NAME_GET'
237 | #define DEVICE_DT_NAME_GET(node_id) DEVICE_NAME_GET(Z_DEVICE_DT_DEV_ID(node_id))
| ^~~~~~~~~~~~~~~
/home/rgjones/ncs/v3.0.2/zephyr/include/zephyr/device.h:254:34: note: in expansion of macro 'DEVICE_DT_NAME_GET'
254 | #define DEVICE_DT_GET(node_id) (&DEVICE_DT_NAME_GET(node_id))
| ^~~~~~~~~~~~~~~~~~
/home/rgjones/ncs/v3.0.2/zephyr/include/zephyr/drivers/i2c.h:107:16: note: in expansion of macro 'DEVICE_DT_GET'
107 | .bus = DEVICE_DT_GET(DT_BUS(node_id)), \
| ^~~~~~~~~~~~~
/home/rgjones/ncs/v3.0.2/zephyr/include/zephyr/drivers/i2c.h:124:30: note: in expansion of macro 'I2C_DT_SPEC_GET_ON_I2C'
124 | (I2C_DT_SPEC_GET_ON_I2C(node_id))) \
| ^~~~~~~~~~~~~~~~~~~~~~
/home/rgjones/ncs/v3.0.2/zephyr/include/zephyr/drivers/i2c.h:136:9: note: in expansion of macro 'I2C_DT_SPEC_GET'
136 | I2C_DT_SPEC_GET(DT_DRV_INST(inst))
| ^~~~~~~~~~~~~~~
/home/rgjones/ncs/v3.0.2/zephyr/drivers/mfd/mfd_npm1300.c:315:24: note: in expansion of macro 'I2C_DT_SPEC_INST_GET'
315 | .i2c = I2C_DT_SPEC_INST_GET(inst), \
| ^~~~~~~~~~~~~~~~~~~~
/home/rgjones/nordic/npm1300_fuel_gauge/build_thingy91x_nrf5340_cpuapp/npm1300_fuel_gauge/zephyr/include/generated/zephyr/devicetree_generated.h:19822:49: note: in expansion of macro 'MFD_NPM1300_DEFINE'
19822 | #define DT_FOREACH_OKAY_INST_nordic_npm1300(fn) fn(0)
| ^~
/home/rgjones/ncs/v3.0.2/zephyr/include/zephyr/sys/util_internal.h:105:36: note: in expansion of macro 'DT_FOREACH_OKAY_INST_nordic_npm1300'
105 | #define UTIL_PRIMITIVE_CAT(a, ...) a##__VA_ARGS__
| ^
/home/rgjones/ncs/v3.0.2/zephyr/drivers/mfd/mfd_npm1300.c:325:1: note: in expansion of macro 'DT_INST_FOREACH_STATUS_OKAY'
325 | DT_INST_FOREACH_STATUS_OKAY(MFD_NPM1300_DEFINE)
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~
ninja: build stopped: subcommand failed.
FAILED: _sysbuild/sysbuild/images/npm1300_fuel_gauge-prefix/src/npm1300_fuel_gauge-stamp/npm1300_fuel_gauge-build /home/rgjones/nordic/npm1300_fuel_gauge/build_thingy91x_nrf5340_cpuapp/_sysbuild/sysbuild/images/npm1300_fuel_gauge-prefix/src/npm1300_fuel_gauge-stamp/npm1300_fuel_gauge-build
cd /home/rgjones/nordic/npm1300_fuel_gauge/build_thingy91x_nrf5340_cpuapp/npm1300_fuel_gauge && /home/rgjones/ncs/toolchains/7cbc0036f4/usr/local/bin/cmake --build .
ninja: build stopped: subcommand failed.
FATAL ERROR: command exited with status 1: /home/rgjones/ncs/toolchains/7cbc0036f4/usr/local/bin/cmake --build /home/rgjones/nordic/npm1300_fuel_gauge/build_thingy91x_nrf5340_cpuapp