Using Co-Processor Communication Daemon with wsbrd#

Overview#

Co-Processor Communication (CPC) enables one host system to communicate with a Network co-processor device (NCP), by physical transport (UART, SPI, and so on). In CPC, data transfers between processors are segmented in sequential packets. Transfers are guaranteed to be error-free and sent in order. Multiple applications can send or receive on the same endpoint without worrying about collisions. A CPC daemon (CPCd) is provided to allow applications on Linux to interact with a secondary running CPC.

For the purpose of having Silicon Labs Wi-SUN stack running in harmony with other services such as Bluetooth, ZigBee, or others on the same Co-Processor, Silicon Labs added support of CPCd to wsbrd.

The next sections explain how to install and configure CPCd and wsbrd, and also how to set up an RCP with the CPC Secondary Service component in Simplicity Studio v5. This chapter only covers UART communication between a WSTK and Raspberry Pi.

Diagram showing host to co-processor communicationDiagram showing host to co-processor communication

Setting Up the RCP with CPC Secondary Service#

To use the Wi-SUN – RCP sample application as CPC secondary device, users should enable the Co-Processor Communication components in the Wi-SUN – RCP project in Simplicity Studio v5.

Components Installation#

After creating a Wi-SUN – RCP project, open the slcp file and select the Software Component tab. In the search box, enter ”cpc” to filter the components and install the following components:

  1. Install CPC Secondary – UART, enter a name for the component instance in the Create a Component Instance pop-up, and click Done.

  2. Install Secondary Device (Co-Processor) if it wasn’t installed automatically after installing CPC Secondary.

  3. CPC SECURITY component will be installed automatically after installing the Secondary Device (Co-Processor) component. If you wish to disabled security to reduce memory footprint, install CPC SECURITY NONE.

Secondary Device Configuration#

CPC Secondary - UART Component#

After installing all the components, configure the created instance with the desired Flow control and Baud rate. Select your created instance in the slcp perspective, and then click Configure.

Screenshot showing selection of instanceScreenshot showing selection of instance

In the configuration perspective, the recommended EUSART Baudrate value is 115200. Concerning the Flow Control, it is set by default to CTS/RTS. Silicon Labs recommends this default; do not set it to None.

WSTK Configuration#

The WSTK boards are factory programmed to support 115200bps with no flow control. To align the WSTK configuration with the Chosen component configuration, follow the next steps:

  1. In Debug Adapters, right-click your device and click Launch Console…

  2. On the console, select the Admin tab, and enter the following commands:

serial vcom config handshake rtscts

The following figures shows the resulting console output.

Screenshot of resulting outputScreenshot of resulting output

After finishing these steps, you can Run your project and flash it to the device.

CPCd Installation and Configuration#

CPCd Installation#

CPCd is delivered as a CMake project. The minimum version of CMake required to generate the project is 3.10. CPCd requires MbedTLS to encrypt the endpoints. The minimal version required for Mbed-TLS is 2.7.0. libmbedtls-dev must be installed to compile from sources.

Refer to cpc-deamon readme , sections Compiling CPCd and Installing CPCd and CPC library to install CPCd.

CPCd Configuration#

After installing CPCd, a configuration file can be found under “/usr/local/etc/cpcd.conf”. This file can be accessed using the following command:

sudo nano /usr/local/etc/cpcd.conf

The modifications that need to be applied to this file to configure CPCd for a secured UART communication between a WSTK and Raspberry Pi are:

instance_name: cpcd_0

bus_type: UART

uart_device_file: /dev/ttyACM0

uart_device_baud: 921600

disable_encryption: false

Note that the uart_device_file and uart_device_baud values above are examples and can be changed to suit your use case.

If the security was disabled on the secondary device by installing the CPC SECURITY NONE component, the value of disable_encryption must be set to true.

wsbrd Configuration#

CPC is supported by wsbrd version 1.4 and above. Make sure to update and re-build wsbrd if you are running an older version. In case of reinstalling wsbrd, make sure to delete the file /wisun-br-linux/CMakeCache.txt.

In the wsbrd.conf file that can be found under wisun-br-linux/examples, comment-out cpc_instance and give it the same value as instance_name in cpcd.conf and comment the option uart_device.

Launch CPDC and wsbrd#

Before starting CPCd and wsbrd, connect the RCP to your Raspberry Pi. Then you can start the CPCd using the following command:

$sudo cpcd
.
..
..
Info : Daemon startup was successful. Waiting for client connections

After the line indicating that the deamon startup was successful appears in the logs, use a separate terminal to launch wsbrd using the command:

sudo wsbrd -F examples/wsbrd.conf