fatal error: mbedtls/bignum.h: No such file or directory

Hello, I've tried a few a few combinations of nrfconnect/sdk-nrf branches, but I can't seem to get `CONFIG_CHIP=y` builds to work.

I'm using the following `prj.conf`:

CONFIG_BOOTLOADER_MCUBOOT=y

# CPP 17 or greater required
CONFIG_CHIP=y
CONFIG_STD_CPP17=y

I'm using ZEPHYR_TOOLCHAIN_VARIANT="gnuarmemb" and running `west build -b particle_xenon`. The build command that is failing (with spaces converted to newlines) is:

/nix/store/4rnf1zlpv24jwgk1hd3m9l2pffjdd3an-gcc-arm-embedded-10.3.1/bin/arm-none-eabi-g++
-MMD
-MF
obj/src/crypto/libChipCrypto.CHIPCryptoPALmbedTLS.cpp.o.d
-Wconversion
-mthumb
-Os
-g2
-fno-common
-ffunction-sections
-fdata-sections
-fno-exceptions
-fno-unwind-tables
-fno-asynchronous-unwind-tables
-Wall
-Werror
-Wstack-usage=8192
-Wextra
-Wshadow
-Wunreachable-code
-Wvla
-Wformat
-Wformat-nonliteral
-Wformat-security
-Wno-deprecated-declarations
-Wno-unknown-warning-option
-Wno-maybe-uninitialized
-Wno-missing-field-initializers
-Wno-unused-parameter
-Wno-unused
-Wno-psabi
-Wno-cast-function-type
-fdiagnostics-color
-fno-strict-aliasing
-D_SYS__PTHREADTYPES_H_
-isystem/home/kenny/src/ncs/zephyr/include/posix
-std=gnu++14
-fno-rtti
-Wnon-virtual-dtor
-isystem/home/kenny/src/ncs/zephyr/include
-isystem/home/kenny/src/ble/matter/build/zephyr/include/generated
-isystem/home/kenny/src/ncs/zephyr/soc/arm/nordic_nrf/nrf52
-isystem/home/kenny/src/ncs/zephyr/lib/libc/newlib/include
-isystem/home/kenny/src/ncs/zephyr/soc/arm/nordic_nrf/common/.
-isystem/home/kenny/src/ncs/nrf/include
-isystem/home/kenny/src/ncs/modules/hal/cmsis/CMSIS/Core/Include
-isystem/home/kenny/src/ncs/modules/hal/nordic/nrfx
-isystem/home/kenny/src/ncs/modules/hal/nordic/nrfx/drivers/include
-isystem/home/kenny/src/ncs/modules/hal/nordic/nrfx/mdk
-isystem/home/kenny/src/ncs/zephyr/modules/hal_nordic/nrfx/.
-DKERNEL
-D__ZEPHYR__=1
-D_FORTIFY_SOURCE=2
-D__LINUX_ERRNO_EXTENSIONS__
-DUSE_PARTITION_MANAGER=1
-D__PROGRAM_START
-DNRF52840_XXAA
-fcheck-new
-std=c++17
-fno-exceptions
-fno-rtti
-imacros
/home/kenny/src/ble/matter/build/zephyr/include/generated/autoconf.h
-ffreestanding
-fdiagnostics-color=always
-mcpu=cortex-m4
-mthumb
-mabi=aapcs
-mfp16-format=ieee
-imacros
/home/kenny/src/ncs/zephyr/include/toolchain/zephyr_stdint.h
-fno-pie
-fno-pic
-fmacro-prefix-map=/home/kenny/src/ble/matter=CMAKE_SOURCE_DIR
-fmacro-prefix-map=/home/kenny/src/ncs/zephyr=ZEPHYR_BASE
-fmacro-prefix-map=/home/kenny/src/ncs=WEST_TOPDIR
-specs=nano.specs
-std=gnu++17
-DNDEBUG
-DCHIP_HAVE_CONFIG_H=1
-I../../../../../ncs/modules/lib/matter/src/include
-I../../../../../ncs/modules/lib/matter/src
-Igen/include
-I../../../../../ncs/modules/lib/matter/zzz_generated/app-common
-I../../../../../ncs/modules/lib/matter/third_party/nlassert/repo/include
-I../../../../../ncs/modules/lib/matter/third_party/nlio/repo/include
-c
../../../../../ncs/modules/lib/matter/src/crypto/CHIPCryptoPALmbedTLS.cpp
-o
obj/src/crypto/libChipCrypto.CHIPCryptoPALmbedTLS.cpp.o

Any idea why this isn't working?

  • Hello, 

    Could you please elaborate on what you are trying to achieve? What version of nRF Connect SDK are you working with? When using CONFIG_CHIP it selects CONFIG_CPLUSPLUS as well.

    Kind regards,
    Øyvind

  • Hello, thank you for looking at this.

    I've attempted this compile with both main@920dab1c6868f1dca331b1d0babf79aaebcd6b31, and with v1.9.1@126fad0e2e5cbe5b965a45efc6a5e31f40d6020c, with the same result for both.

    I've simply cloned the sdk repo, set the above configs, and attempted to build a program with an empty main function.

    The CPP17 option was set because without it I get errors due to it compiling with ` -std=gnu++11` and the sdk using newer standards. For example:

    .../ncs/modules/lib/matter/src/lib/core/NodeId.h:34:42: error: multi-character character constant [-Werror=multichar]
       34 | constexpr NodeId kMinGroupNodeId = 0xFFFF'FFFF'FFFF'0000ULL;



    It would be nice the CHIP config would select this standard, but I did manage to work around that particular issue.

    As for what I'm trying to achieve: I'm looking to replace a deprecated particle.io mesh network with a matter network instead. I've compiled and tested other modules on the particle xenon board without issue.So far I've only gotten as far as adding the CHIP config and fixing the c++ standard issue. (To throw a another suggestion out there, I'd love to see a sample openthread border router that used one of the featherwing ethernet adapters to bridge the networks.)

    I did notice the matter/examples don't actually set CONFIG_CHIP. I tried a compile with CONFIG_CHIP_PW_RPC and that one works fine. I found the CONFIG_CHIP from developer.nordicsemi.com/.../ug_matter_configuring_protocol.html

  • kenmacd said:
    The CPP17 option was set because without it I get errors due to it compiling with ` -std=gnu++11` and the sdk using newer standards

    Our samples uses the following in nRF Connect SDK v1.9.1 - CONFIG_STD_CPP14=y


    Remember to go through our Matter documentation

    It is important to configure your project correctly, the Matter protocol is an application layer on top of OpenThread. . I recommend looking at our samples found under nrf\samples\matter, and start your development from there.

    For example, the light bulb sample has the following configuration

    #
    # Copyright (c) 2021 Nordic Semiconductor ASA
    #
    # SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
    #
    
    # Enable CHIP
    CONFIG_CHIP=y
    CONFIG_CHIP_PROJECT_CONFIG="src/chip_project_config.h"
    CONFIG_STD_CPP14=y
    
    # Enable CHIP pairing automatically on application start.
    CONFIG_CHIP_ENABLE_PAIRING_AUTOSTART=y
    
    # General networking settings
    CONFIG_NETWORKING=y
    CONFIG_NET_IPV6_NBR_CACHE=n
    CONFIG_NET_IPV6_MLD=n
    CONFIG_NET_SOCKETS_POLL_MAX=5
    
    # Enable OpenThread MTD
    CONFIG_NET_L2_OPENTHREAD=y
    
    CONFIG_OPENTHREAD_MTD=y
    CONFIG_OPENTHREAD_FTD=n
    CONFIG_OPENTHREAD_SLAAC=y
    CONFIG_OPENTHREAD_MTD_NETDIAG=y
    CONFIG_OPENTHREAD_MANUAL_START=y
    CONFIG_OPENTHREAD_THREAD_STACK_SIZE=6144
    CONFIG_OPENTHREAD_NUM_MESSAGE_BUFFERS=64
    
    CONFIG_OPENTHREAD_PANID=4660
    CONFIG_OPENTHREAD_CHANNEL=15
    CONFIG_OPENTHREAD_NETWORK_NAME="OpenThread"
    CONFIG_OPENTHREAD_XPANID="11:11:11:11:22:22:22:22"
    
    # Enable Thread 1.2 features
    CONFIG_OPENTHREAD_THREAD_VERSION_1_2=y
    CONFIG_OPENTHREAD_DUA=y
    CONFIG_OPENTHREAD_MLR=y
    
    # Enable Bluetooth Low Energy
    CONFIG_BT=y
    CONFIG_BT_PERIPHERAL=y
    CONFIG_BT_PERIPHERAL_PREF_MIN_INT=12
    CONFIG_BT_PERIPHERAL_PREF_MAX_INT=12
    CONFIG_BT_GAP_AUTO_UPDATE_CONN_PARAMS=y
    CONFIG_BT_GATT_DYNAMIC_DB=y
    CONFIG_BT_DEVICE_APPEARANCE=0
    CONFIG_BT_DEVICE_NAME_DYNAMIC=y
    CONFIG_BT_DEVICE_NAME_MAX=15
    CONFIG_BT_DEVICE_NAME="MatterLight"
    CONFIG_BT_MAX_CONN=1
    CONFIG_BT_L2CAP_TX_MTU=247
    CONFIG_BT_BUF_ACL_RX_SIZE=251
    CONFIG_BT_BUF_ACL_TX_SIZE=251
    
    # Use NFC to share commissioning information
    CONFIG_CHIP_NFC_COMMISSIONING=y
    
    # Use nrf_security
    CONFIG_OPENTHREAD_NRF_SECURITY_CHOICE=y
    
    CONFIG_CC3XX_BACKEND=n
    CONFIG_OBERON_BACKEND=y
    
    CONFIG_MBEDTLS_ENABLE_HEAP=y
    CONFIG_MBEDTLS_HEAP_SIZE=15360
    CONFIG_MBEDTLS_TLS_LIBRARY=y
    CONFIG_NRF_SECURITY_ADVANCED=y
    
    CONFIG_MBEDTLS_AES_C=y
    CONFIG_MBEDTLS_ECP_C=y
    CONFIG_MBEDTLS_ECP_DP_SECP256R1_ENABLED=y
    CONFIG_MBEDTLS_CTR_DRBG_C=y
    CONFIG_MBEDTLS_CIPHER_MODE_CTR=y
    CONFIG_MBEDTLS_ECJPAKE_C=y
    CONFIG_MBEDTLS_SHA256_C=y
    CONFIG_MBEDTLS_PK_C=y
    CONFIG_MBEDTLS_PK_WRITE_C=y
    CONFIG_MBEDTLS_X509_CREATE_C=y
    CONFIG_MBEDTLS_X509_CSR_WRITE_C=y
    
    # Disable unneeded crypto operations
    CONFIG_MBEDTLS_SHA384_C=n
    CONFIG_MBEDTLS_SHA512_C=n
    CONFIG_MBEDTLS_CIPHER_MODE_XTS=n
    CONFIG_MBEDTLS_CHACHA20_C=n
    CONFIG_MBEDTLS_POLY1305_C=n
    CONFIG_MBEDTLS_CHACHAPOLY_C=n
    CONFIG_MBEDTLS_GCM_C=n
    CONFIG_MBEDTLS_RSA_C=n
    
    # Add support for LEDs and buttons on Nordic development kits
    CONFIG_DK_LIBRARY=y
    CONFIG_PWM=y
    
    # Other settings
    CONFIG_LOG=y
    CONFIG_LOG_MODE_MINIMAL=y
    CONFIG_MATTER_LOG_LEVEL_DBG=y
    CONFIG_PRINTK_SYNC=y
    CONFIG_MAIN_STACK_SIZE=8192
    CONFIG_INIT_STACKS=y
    CONFIG_HW_STACK_PROTECTION=y
    CONFIG_HWINFO=y
    CONFIG_THREAD_NAME=y
    CONFIG_SHELL=y
    CONFIG_ASSERT=y
    

    And for the light switch the following configuration is used:

    #
    # Copyright (c) 2021 Nordic Semiconductor ASA
    #
    # SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
    #
    
    # Enable CHIP
    CONFIG_CHIP=y
    CONFIG_CHIP_PROJECT_CONFIG="src/chip_project_config.h"
    CONFIG_CHIP_ENABLE_DNSSD_SRP=n
    CONFIG_STD_CPP14=y
    
    # General networking settings
    CONFIG_NETWORKING=y
    CONFIG_NET_IPV6_NBR_CACHE=n
    CONFIG_NET_IPV6_MLD=n
    CONFIG_NET_SOCKETS_POLL_MAX=5
    
    # Enable OpenThread MTD
    CONFIG_NET_L2_OPENTHREAD=y
    
    CONFIG_OPENTHREAD_FTD=y
    CONFIG_OPENTHREAD_SLAAC=y
    CONFIG_OPENTHREAD_MTD_NETDIAG=y
    CONFIG_OPENTHREAD_MANUAL_START=y
    CONFIG_OPENTHREAD_THREAD_STACK_SIZE=6144
    CONFIG_OPENTHREAD_NUM_MESSAGE_BUFFERS=64
    
    CONFIG_OPENTHREAD_PANID=4660
    CONFIG_OPENTHREAD_CHANNEL=15
    CONFIG_OPENTHREAD_NETWORK_NAME="OpenThread"
    CONFIG_OPENTHREAD_XPANID="11:11:11:11:22:22:22:22"
    
    # Enable Thread 1.2 features
    CONFIG_OPENTHREAD_THREAD_VERSION_1_2=y
    CONFIG_OPENTHREAD_DUA=y
    CONFIG_OPENTHREAD_MLR=y
    
    # Use nrf_security
    CONFIG_OPENTHREAD_NRF_SECURITY_CHOICE=y
    
    CONFIG_CC3XX_BACKEND=n
    CONFIG_OBERON_BACKEND=y
    
    CONFIG_MBEDTLS_ENABLE_HEAP=y
    CONFIG_MBEDTLS_HEAP_SIZE=15360
    CONFIG_MBEDTLS_TLS_LIBRARY=y
    CONFIG_NRF_SECURITY_ADVANCED=y
    
    CONFIG_MBEDTLS_AES_C=y
    CONFIG_MBEDTLS_ECP_C=y
    CONFIG_MBEDTLS_ECP_DP_SECP256R1_ENABLED=y
    CONFIG_MBEDTLS_CTR_DRBG_C=y
    CONFIG_MBEDTLS_CIPHER_MODE_CTR=y
    CONFIG_MBEDTLS_ECJPAKE_C=y
    CONFIG_MBEDTLS_SHA256_C=y
    CONFIG_MBEDTLS_PK_C=y
    CONFIG_MBEDTLS_PK_WRITE_C=y
    CONFIG_MBEDTLS_X509_CREATE_C=y
    CONFIG_MBEDTLS_X509_CSR_WRITE_C=y
    CONFIG_MBEDTLS_X509_CSR_PARSE_C=y
    
    # Disable unneeded crypto operations
    CONFIG_MBEDTLS_SHA384_C=n
    CONFIG_MBEDTLS_SHA512_C=n
    CONFIG_MBEDTLS_CIPHER_MODE_XTS=n
    CONFIG_MBEDTLS_CHACHA20_C=n
    CONFIG_MBEDTLS_POLY1305_C=n
    CONFIG_MBEDTLS_CHACHAPOLY_C=n
    CONFIG_MBEDTLS_GCM_C=n
    CONFIG_MBEDTLS_RSA_C=n
    
    # Add support for LEDs and buttons on Nordic development kits
    CONFIG_DK_LIBRARY=y
    
    # Other settings
    CONFIG_LOG=y
    CONFIG_LOG_MODE_MINIMAL=y
    CONFIG_MATTER_LOG_LEVEL_DBG=y
    CONFIG_PRINTK_SYNC=y
    CONFIG_MAIN_STACK_SIZE=8192
    CONFIG_INIT_STACKS=y
    CONFIG_HW_STACK_PROTECTION=y
    CONFIG_HWINFO=y
    CONFIG_THREAD_NAME=y
    CONFIG_SHELL=y
    CONFIG_ASSERT=y
    

    Kind regards,
    Øyvind

  • Thanks. I wanted to build this by building up from nothing and adding what's needed, but I guess I'll start with the light bulb one and delete what's not needed.

    It would be nice if this is made more robust over time. For example if adding CONFIG_CHIP requires at least CPP 14+ then it would be helpful if the kconfig was set to make this required (or at least fail with a proper error).

    I suspect something in the set of configs is allowing the bulb example to work, whereas just CONFIG_CHIP alone doesn't, but without proper dependencies in the configs I can't easily figure out what exactly is needed.

  • Hello, 

    I reached out to our Matter team and got some answers. 

    kenmacd said:
    It would be nice if this is made more robust over time. For example if adding CONFIG_CHIP requires at least CPP 14+ then it would be helpful if the kconfig was set to make this required (or at least fail with a proper error).

    You should be able to change CONFIG_STD_CPP14 to e.g CONFIG_STD_CPP17. The reason for the use was due to other Matter community members using CPP 14, and by including this avoiding any problems.

    kenmacd said:
    I suspect something in the set of configs is allowing the bulb example to work, whereas just CONFIG_CHIP alone doesn't, but without proper dependencies in the configs I can't easily figure out what exactly is needed.

    Our developers confirm that the Matter: Mandatory Configuration is missing some important steps in regards to starting from scratch. (This is reported internally as a bug). The error you see is a result of lacking crypto backend for Matter. Matter cannot work without proper network layer protocol and crypto libraries that are OpenThread and mbedTLS in this case. They inform that the minimal config that can be used to build Matter is:

    # Enable CHIP
    CONFIG_CHIP=y
    
    CONFIG_CHIP_PROJECT_CONFIG="src/chip_project_config.h"
    CONFIG_STD_CPP14=y
    # General networking settings
    CONFIG_NETWORKING=y
    # Use nrf_security
    CONFIG_OPENTHREAD_NRF_SECURITY_CHOICE=y
    CONFIG_CC3XX_BACKEND=n
    CONFIG_OBERON_BACKEND=y
    CONFIG_MBEDTLS_ENABLE_HEAP=y
    CONFIG_MBEDTLS_HEAP_SIZE=15360
    CONFIG_MBEDTLS_TLS_LIBRARY=y
    CONFIG_NRF_SECURITY_ADVANCED=y
    CONFIG_MBEDTLS_AES_C=y
    CONFIG_MBEDTLS_ECP_C=y
    CONFIG_MBEDTLS_ECP_DP_SECP256R1_ENABLED=y
    CONFIG_MBEDTLS_CTR_DRBG_C=y
    CONFIG_MBEDTLS_CIPHER_MODE_CTR=y
    CONFIG_MBEDTLS_ECJPAKE_C=y
    CONFIG_MBEDTLS_SHA256_C=y
    CONFIG_MBEDTLS_PK_C=y
    CONFIG_MBEDTLS_PK_WRITE_C=y
    CONFIG_MBEDTLS_X509_CREATE_C=y
    CONFIG_MBEDTLS_X509_CSR_WRITE_C=y

    But please note that it will not function properly without Bluetooth LE included. This is the reason for why we encourage our customers to start with copying our existing samples and start from there, modifying this to your use.
    You can also start with our Matter Template sample, which is intended for this use.

    Kind regards,
    Øyvind
Related