Using TCP in CLI Example with nRF52840dk

I am using the Connect SDK v2.0.0 and attempting to use TCP in the stock CLI example to mimic the demo shown here. When I flash the v2.0.0 CLI sample on my nRF52840dk, "$ ot tcp init" is not a valid command. In fact, when I run "$ ot help" I do not see "tcp" as one of the available subcommands.

I see "nrfxlib/openthread/include/openthread/tcp.h" and "nrfxlib/openthread/include/openthread/tcp_ext.h" in the v2.0.0 SDK, so I assume that this release includes the TCP-enabling commits to the main Openthread project in late 2021/early 2022. If this is true, then I assume that I must specifically enable Openthread's TCP submodule via the CLI project's "prj.conf" file. I have tried adding the last three lines in the CLI project's "prj.conf" (and other configurations based on the tickets here and here) but receive the error further below. 

#
# Copyright (c) 2020 Nordic Semiconductor
#
# SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
#

# Network shell
CONFIG_SHELL=y
CONFIG_OPENTHREAD_SHELL=y
CONFIG_SHELL_ARGC_MAX=26
CONFIG_SHELL_CMD_BUFF_SIZE=416

# Enable OpenThread features set
CONFIG_OPENTHREAD_NORDIC_LIBRARY_MASTER=y

CONFIG_NET_L2_OPENTHREAD=y

# Generic networking options
CONFIG_NETWORKING=y

CONFIG_ASSERT=y
CONFIG_ASSERT_NO_COND_INFO=y
CONFIG_MBEDTLS_SHA1_C=n
CONFIG_FPU=y

CONFIG_GPIO_SHELL=y

CONFIG_NET_TCP=y
CONFIG_NET_IPV6=y
CONFIG_NET_IPV4=n

-- Found toolchain: zephyr 0.14.2 (/home/tombrown/zephyr-sdk-0.14.2)
-- Found BOARD.dts: /home/tombrown/ncs/connectSDK/zephyr/boards/arm/nrf52840dk_nrf52840/nrf52840dk_nrf52840.dts
-- Found devicetree overlay: usb.overlay
-- Generated zephyr.dts: /home/tombrown/.local/share/Trash/files/cli.2/build/zephyr/zephyr.dts
-- Generated devicetree_unfixed.h: /home/tombrown/.local/share/Trash/files/cli.2/build/zephyr/include/generated/devicetree_unfixed.h
-- Generated device_extern.h: /home/tombrown/.local/share/Trash/files/cli.2/build/zephyr/include/generated/device_extern.h
-- Including generated dts.cmake file: /home/tombrown/.local/share/Trash/files/cli.2/build/zephyr/dts.cmake

warning: MBEDTLS_MAC_MD5_ENABLED (defined at modules/mbedtls/Kconfig.tls-generic:302, modules/mbedtls/Kconfig.tls-generic:302) has direct dependencies (!(NRF_SECURITY || NORDIC_SECURITY_BACKEND) && MBEDTLS_BUILTIN && MBEDTLS_CFG_FILE = "config-tls-generic.h" && MBEDTLS) || (!(NRF_SECURITY || NORDIC_SECURITY_BACKEND) && MBEDTLS_BUILTIN && MBEDTLS_CFG_FILE = "config-tls-generic.h" && MBEDTLS && 0) with value n, but is currently being y-selected by the following symbols:
 - NET_TCP_ISN_RFC6528 (defined at subsys/net/ip/Kconfig:470), with value y, direct dependencies NET_TCP && !NET_RAW_MODE && NETWORKING (value: y), and select condition NET_TCP && !NET_RAW_MODE && NETWORKING (value: y)
Parsing /home/tombrown/.local/share/Trash/files/cli.2/Kconfig
Loaded configuration '/home/tombrown/ncs/connectSDK/zephyr/boards/arm/nrf52840dk_nrf52840/nrf52840dk_nrf52840_defconfig'
Merged configuration '/home/tombrown/.local/share/Trash/files/cli.2/prj.conf'
Merged configuration '/home/tombrown/.local/share/Trash/files/cli.2/overlay-usb.conf'

error: Aborting due to Kconfig warnings

CMake Error at /home/tombrown/ncs/connectSDK/zephyr/cmake/modules/kconfig.cmake:290 (message):
  command failed with return code: 1
Call Stack (most recent call first):
  /home/tombrown/ncs/connectSDK/zephyr/cmake/modules/zephyr_default.cmake:121 (include)
  /home/tombrown/ncs/connectSDK/zephyr/share/zephyr-package/cmake/ZephyrConfig.cmake:51 (include)
  /home/tombrown/ncs/connectSDK/zephyr/share/zephyr-package/cmake/ZephyrConfig.cmake:76 (include_boilerplate)
  CMakeLists.txt:8 (find_package)


-- Configuring incomplete, errors occurred!
FATAL ERROR: command exited with status 1: /usr/bin/cmake -DWEST_PYTHON=/usr/bin/python3 -B/home/tombrown/.local/share/Trash/files/cli.2/build -S/home/tombrown/.local/share/Trash/files/cli.2 -GNinja -DBOARD=nrf52840dk_nrf52840 -DOVERLAY_CONFIG=overlay-usb.conf -DDTC_OVERLAY_FILE=usb.overlay

I can't seem to find documentation on the configuration I need to get Openthread's TCP submodule working, but I might just be looking in the wrong places. Could you please point me in the right direction to get TCP working in the CLI example? Am I not adding the right lines to the CLI sample's "prj.conf" or is more work required?

Parents
  • If I add CONFIG_OPENTHREAD_MBEDTLS_CHOICE=y to the prj.conf, I no longer get the MBEDTLS_MAC_MD5_ENABLED warning/error and it compiles. However, I still cannot use the "tcp" subcommand. Here is my new prj.conf, although I should go back and comment out the irrelevant lines that I added from other DevZone tickets related to Openthread and TCP.

    #
    # Copyright (c) 2020 Nordic Semiconductor
    #
    # SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
    #
    
    # Network shell
    CONFIG_SHELL=y
    CONFIG_OPENTHREAD_SHELL=y
    CONFIG_SHELL_ARGC_MAX=26
    CONFIG_SHELL_CMD_BUFF_SIZE=416
    
    # Enable OpenThread features set
    CONFIG_OPENTHREAD_NORDIC_LIBRARY_MASTER=y
    
    CONFIG_NET_L2_OPENTHREAD=y
    
    # Generic networking options
    CONFIG_NETWORKING=y
    
    CONFIG_ASSERT=y
    CONFIG_ASSERT_NO_COND_INFO=y
    CONFIG_MBEDTLS_SHA1_C=n
    CONFIG_FPU=y
    
    CONFIG_GPIO_SHELL=y
    
    CONFIG_OPENTHREAD_THREAD_VERSION_1_2=y
    CONFIG_OPENTHREAD_MBEDTLS_CHOICE=y 
    
    #CONFIG_MBEDTLS=y
    #CONFIG_MBEDTLS_BUILTIN=y
    #CONFIG_MBEDTLS_CFG_FILE="config-tls-generic.h”
    #CONFIG_NRF_SECURITY=n
    #CONFIG_NORDIC_SECURITY_BACKEND=n
    
    ###################################################
    #Following added per https://devzone.nordicsemi.com/f/nordic-q-a/89810/nrf-connect-mqtt-returns--22-invalid-argument
    
    # Generic networking options
    CONFIG_NETWORKING=y
    CONFIG_NET_UDP=y
    CONFIG_NET_TCP=y
    CONFIG_NET_IPV6=y
    CONFIG_NET_IPV4=n
    CONFIG_NET_SOCKETS=y
    CONFIG_NET_SOCKETS_SOCKOPT_TLS=y
    CONFIG_NET_SOCKETS_POSIX_NAMES=y
    CONFIG_NET_SOCKETS_POLL_MAX=4
    # CONFIG_NET_CONNECTION_MANAGER=y
    
    # Kernel options
    CONFIG_MAIN_STACK_SIZE=2048
    CONFIG_ENTROPY_GENERATOR=y
    CONFIG_TEST_RANDOM_GENERATOR=y
    CONFIG_INIT_STACKS=y
    
    # Logging
    CONFIG_NET_LOG=y
    CONFIG_LOG=y
    CONFIG_NET_STATISTICS=y
    CONFIG_PRINTK=y
    
    # Network buffers
    CONFIG_NET_PKT_RX_COUNT=16
    CONFIG_NET_PKT_TX_COUNT=16
    CONFIG_NET_BUF_RX_COUNT=80
    CONFIG_NET_BUF_TX_COUNT=80
    CONFIG_NET_CONTEXT_NET_PKT_POOL=y
    
    # IP address options
    CONFIG_NET_IF_UNICAST_IPV6_ADDR_COUNT=3
    CONFIG_NET_IF_MCAST_IPV6_ADDR_COUNT=4
    CONFIG_NET_MAX_CONTEXTS=10
    
    # Network shell
    CONFIG_NET_SHELL=y
    
    # The addresses are selected so that qemu<->qemu connectivity works ok.
    # For linux<->qemu connectivity, create a new conf file and swap the
    # addresses (so that peer address is ending to 2).
    CONFIG_NET_CONFIG_SETTINGS=y
    CONFIG_NET_CONFIG_NEED_IPV6=y
    CONFIG_NET_CONFIG_NEED_IPV4=n
    CONFIG_SYSTEM_WORKQUEUE_STACK_SIZE=2048
    
    # DNS Settings
    CONFIG_DNS_RESOLVER=y
    CONFIG_DNS_SERVER_IP_ADDRESSES=y
    CONFIG_DNS_SERVER1="FDAA:BB:1::2"
    CONFIG_OPENTHREAD_DNS_CLIENT=y
    
    # disable external crystal
    CONFIG_CLOCK_CONTROL_NRF_K32SRC_XTAL=n
    # enable synth crystal for powered devices
    CONFIG_CLOCK_CONTROL_NRF_K32SRC_SYNTH=y
    # enable RC crystal for battery devices
    # CONFIG_CLOCK_CONTROL_NRF_K32SRC_RC is not set
    
    # NEWLIB C
    CONFIG_NEWLIB_LIBC=y
    
    # Enable MQTT Lib support
    CONFIG_MQTT_LIB=y
    CONFIG_MQTT_LIB_TLS=y
    # MQTT - Maximum MQTT keepalive timeout specified by Azure IoT Hub
    CONFIG_MQTT_KEEPALIVE=1767
    
    # Heap and stacks
    CONFIG_HEAP_MEM_POOL_SIZE=4096
    #4096
    
    # cJSON
    CONFIG_CJSON_LIB=y
    
    #
    # overlay-log.conf
    #
    CONFIG_LOG=y
    # CONFIG_LOG_MODE_IMMEDIATE=y
    CONFIG_LOG_BACKEND_SHOW_COLOR=n
    
    CONFIG_LOG_BUFFER_SIZE=2048
    
    CONFIG_LOG_MODE_MINIMAL=n
    CONFIG_LOG_MODE_DEFERRED=y
    # fix str dup alloc failures
    CONFIG_LOG_STRDUP_MAX_STRING=150
    CONFIG_LOG_STRDUP_BUF_COUNT=48
    
    CONFIG_NET_LOG=y
    
    CONFIG_NET_SOCKETS_LOG_LEVEL_DBG=y
    CONFIG_NET_CONN_LOG_LEVEL_DBG=y
    CONFIG_NET_CONTEXT_LOG_LEVEL_DBG=y
    
    #
    #overlay-ot.conf
    #
    CONFIG_NEWLIB_LIBC=y
    
    # Disable TCP and IPv4 (TCP disabled to avoid heavy traffic)
    CONFIG_NET_TCP=y
    CONFIG_NET_IPV4=n
    
    CONFIG_NET_IPV6_NBR_CACHE=n
    CONFIG_NET_IPV6_MLD=n
    CONFIG_NET_CONFIG_NEED_IPV4=n
    CONFIG_NET_CONFIG_MY_IPV4_ADDR=""
    CONFIG_NET_CONFIG_PEER_IPV4_ADDR=""
    
    CONFIG_SYSTEM_WORKQUEUE_STACK_SIZE=2048
    
    # Enable OpenThread shell
    CONFIG_SHELL=y
    CONFIG_OPENTHREAD_SHELL=y
    CONFIG_SHELL_STACK_SIZE=3072
    
    CONFIG_NET_L2_OPENTHREAD=y
    
    CONFIG_OPENTHREAD_DEBUG=y
    CONFIG_OPENTHREAD_L2_DEBUG=y
    CONFIG_OPENTHREAD_L2_LOG_LEVEL_INF=y
    
    CONFIG_MAIN_STACK_SIZE=4096
    CONFIG_NET_BUF_RX_COUNT=100
    CONFIG_NET_BUF_TX_COUNT=100
    
    # mbedTLS tweaks
    # CONFIG_MBEDTLS_SSL_MAX_CONTENT_LEN=768
    CONFIG_MBEDTLS_DEBUG_C=y
    CONFIG_MBEDTLS_DEBUG=y
    CONFIG_MBEDTLS_DEBUG_LEVEL=4
    
    
    # TLS configuration
    CONFIG_MBEDTLS=y
    CONFIG_MBEDTLS_BUILTIN=y
    CONFIG_MBEDTLS_ENABLE_HEAP=y
    CONFIG_MBEDTLS_HEAP_SIZE=90000
    #100000
    CONFIG_MBEDTLS_SSL_MAX_CONTENT_LEN=10240
    CONFIG_MBEDTLS_PEM_CERTIFICATE_FORMAT=y
    
    CONFIG_NET_SOCKETS_SOCKOPT_TLS=y
    CONFIG_NET_SOCKETS_TLS_MAX_CONTEXTS=4
    CONFIG_NET_SOCKETS_ENABLE_DTLS=y
    CONFIG_POSIX_MAX_FDS=8
    
    ###################################################
    
    CONFIG_NET_MGMT_EVENT_INFO=y
    #^needed per https://github.com/zephyrproject-rtos/zephyr/issues/46594
    
    CONFIG_MBEDTLS=y
    CONFIG_MBEDTLS_BUILTIN=y
    CONFIG_MBEDTLS_TLS_VERSION_1_2=y
    CONFIG_MBEDTLS_KEY_EXCHANGE_PSK_ENABLED=y
    CONFIG_MBEDTLS_KEY_EXCHANGE_DHE_PSK_ENABLED=y
    CONFIG_MBEDTLS_KEY_EXCHANGE_RSA_PSK_ENABLED=y
    #^added per https://devzone.nordicsemi.com/f/nordic-q-a/86632/openthread-and-mqtt-over-tls-is-single-program

    I also notice that "tcp" is included in the OpenThread CLI full commands list at the link below. There must be a reason that it didn't get carried over into this commands list in the Connect SDK? Maybe I would have luck after recompiling the OpenThread library?

    ------------

    EDIT: I think it has something to do with the fact that OPENTHREAD_CONFIG_TCP_ENABLE and OPENTHREAD_CONFIG_CLI_TCP_ENABLE are not defined. If you look at cli.cpp, cli.hpp, and cli_tcp.cpp in the OpenThread CLI repository (linked further up in this reply), they all have the same IF statement containing some TCP-enabling code (two examples from cli.cpp shown below). 

    However, I still do not see "tcp" as a subcommand if I create these two variables in a Kconfig file and set them =y in the prj.conf.

     

    #if OPENTHREAD_CONFIG_TCP_ENABLE && OPENTHREAD_CONFIG_CLI_TCP_ENABLE
        template <> otError Interpreter::Process<Cmd("tcp")>(Arg aArgs[])
        {
             return mTcp.Process(aArgs);
        }
    #endif 
    
    ...
    
    #if OPENTHREAD_CONFIG_TCP_ENABLE && OPENTHREAD_CONFIG_CLI_TCP_ENABLE
            CmdEntry("tcp"),
    #endif

  • Found the issue - I needed to set 

    CONFIG_OPENTHREAD_TCP_ENABLE=y
    CONFIG_OPENTHREAD_CLI_TCP_ENABLE=y

    in my prj.conf instead of CONFIG_OPENTHREAD_CONFIG_TCP_ENABLE and CONFIG_OPENTHREAD_CONFIG_CLI_TCP_ENABLE.

Reply Children
No Data
Related