Can't build Google IOT MQTT Sample for nRF9160 with nRF Connect SDK 2.3.0

Hi there,

I've been trying to build the Google IOT MQTT Sample for the nrf9160dk_nrf9160_ns board with nRF Connect SDK 2.3.0, and I cannot get it to compile and/or link.  I tried a number of different configuration options, but I believe there may be a conflict with the SDK and/or toolchain and the mbedtls library.

When I create the keys with create_keys.py then try to build exactly what's checked into zephyr/samples/net/cloud/google_iot_mqtt with west build -p auto -b nrf9160dk_nrf9160_ns I get these errors:

check_config.h:465:2: error: #error "MBEDTLS_PLATFORM_STD_EXIT defined, but not all prerequisites"
465 | #error "MBEDTLS_PLATFORM_STD_EXIT defined, but not all prerequisites"
| ^~~~~
check_config.h:476:2: error: #error "MBEDTLS_PLATFORM_STD_FPRINTF defined, but not all prerequisites"
476 | #error "MBEDTLS_PLATFORM_STD_FPRINTF defined, but not all prerequisites"
| ^~~~~
check_config.h:481:2: error: #error "MBEDTLS_PLATFORM_STD_PRINTF defined, but not all prerequisites"
481 | #error "MBEDTLS_PLATFORM_STD_PRINTF defined, but not all prerequisites"
| ^~~~~
check_config.h:486:2: error: #error "MBEDTLS_PLATFORM_STD_SNPRINTF defined, but not all prerequisites"
486 | #error "MBEDTLS_PLATFORM_STD_SNPRINTF defined, but not all prerequisites"
| ^~~~~

I tried changing prj.conf to remove the CONFIG_MBEDTLS options and use this instead:

CONFIG_NRF_SECURITY_ADVANCED=y
CONFIG_NORDIC_SECURITY_BACKEND=y
CONFIG_NRF_SECURITY=y

And got the same errors.  I also tried using this:


CONFIG_MBEDTLS_USER_CONFIG_ENABLE=y
CONFIG_MBEDTLS_USER_CONFIG_FILE="user-tls-conf.h"

And defined the missing prerequisites in user-tls-conf.h:

#define MBEDTLS_HAVE_TIME
#define MBEDTLS_HAVE_TIME_DATE
#define MBEDTLS_PLATFORM_TIME_ALT
#define MBEDTLS_PLATFORM_FPRINTF_ALT
#define MBEDTLS_PLATFORM_EXIT_ALT
#define MBEDTLS_PLATFORM_PRINTF_ALT
#define MBEDTLS_PLATFORM_SNPRINTF_ALT

But then hit other link errors like this: multiple definition of `mbedtls_calloc'; modules/nrfxlib/nrfxlib/nrf_security/src/zephyr/libmbedtls_zephyr.a(platform.c.obj):


Can someone help me figure out how to build this sample for nrf9160 with nRF Connect SDK 2.3.0 ?

  • Hi,

    I will look into this and return with more information tomorrow.

    Regards,
    Sigurd Hellesvik

  • This sample is not built specifically for the nRF9160. You technically can still use it with the nRF9160, but

    one of the large bonuses with the nRF9160 is that it has a TLS driver integrated in the modem.
    So when you do TLS with the nRF9160, you can either use the TLS driver in the modem (offloaded TLS)
    or you can do TLS from the application (native TLS).

    Offloaded TLS is both more secure (because of the isolation from the application), and it is likely faster (because it uses specialized hardware).

    If you do Offloaded TLS, you can have a look at our MQTT sample.
    In this case, the work you have to do is to code the interface to Google IOT.

    As an alternative for Offloaded TLS, you can also have a look at the MQTT sample and its overlay-tls-native_posix.conf to see how to do native TLS.

    Regards,
    Sigurd Hellesvik

Related