Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
236 changes: 121 additions & 115 deletions sld131-bluetooth-getting-started-demos-examples/index.md

Large diffs are not rendered by default.

439 changes: 216 additions & 223 deletions sld596-bluetooth-network-coprocessor-mode/03-ncp-host-development.md

Large diffs are not rendered by default.

98 changes: 53 additions & 45 deletions sld596-bluetooth-network-coprocessor-mode/04-secure-ncp.md
Original file line number Diff line number Diff line change
@@ -1,45 +1,53 @@
# Secure NCP

Secure NCP secures communication between the NCP Host and target by encrypting the commands, events, and any data transmitted between the target and the host.

## Target Side

To enable this feature on the target side, install the NCP Security Interface component.

![NCP Security Interface](resources/an1259-secure-ncp-target.png)

By default, the NCP target boots without using this encryption. It will be requested by the Host part, and after the security is increased, only encrypted messages are sent and accepted by the target.

## Host Side

To build the NCP Host project with secure mode, use the following command:

```C
make SECURITY=1
```

This requires the openssl package to be installed. Install it to your MSYS2 environment with:

```C
pacman -S mingw-w64-x86_64-openssl
```

After the project is built, the encryption can be enabled by calling the .exe file with the command line parameter `-s`:

```C
.\empty.exe -s
```

```C
$ ./empty.exe -u COM21 -s
[I] NCP host initialised.
[I] Resetting NCP target...
[I] Press Ctrl+C to quit
[I] Start encryption
[I] Communication encrypted
[I] Bluetooth stack booted: v3.2.1-b216
[I] Bluetooth public device address: 00:0B:57:A7:84:15
[I] Started advertising.
```

Running the exe file without this option will start a normal NCP Host application without encryption.
# Secure NCP

Secure NCP secures communication between the NCP Host and target by encrypting the commands, events, and any data transmitted between the target and the host.

## Target Side

To enable this feature on the target side, install the NCP Security Interface component.

![NCP Security Interface](resources/an1259-secure-ncp-target.png)

By default, the NCP target boots without using this encryption. It will be requested by the Host part, and after the security is increased, only encrypted messages are sent and accepted by the target.

## Host Side

1. Create a new **Bluetooth - Host Empty** project in Simplicity Studio 6

![studio6 host app generation](resources/an1259-studio6-host-app-generation.png)

2. At the *Target Device* select the option *Part* and the desired OS
![studio6 select os](resources/an1259-studio6-select-os.png)

3. Add `Secure NCP communication layer for host projects` component to the project
4. Secure mode requires the openssl package to be installed. It can be installed to the MSYS2 environment if necessary with:

```C
pacman -S mingw-w64-x86_64-openssl
```

5. Build the project in MSYS2 MinGW 64-bit
```C
make -f bt_host_empty.Makefile
```
6. The build output is created in a new *build/debug/* folder. After the project is built, the encryption can be enabled by calling the .exe file with the command line parameter `-s`:

```C
.\bt_host_empty.exe -s
```

```C
$ ./build/debug/bt_host_empty.exe -u COM<*> -s
[D] Timer function intialized
[I] NCP host initialised.
[I] Press Crtl+C to quit

[I] Rebooting NCP target (0)...
[I] Start encryption using OpenSSL 3.0
[I] Communication encrypted
[I] Bluetooth stack booted: v11.0.1+0e13429e
[I] Bluetooth public device address: 04:87:27:E7:07:5D
[I] Started advertising.
```

Running the exe file without `-s` parameter will start a normal NCP Host application without encryption.
129 changes: 74 additions & 55 deletions sld596-bluetooth-network-coprocessor-mode/05-using-ncp-with-cpc.md
Original file line number Diff line number Diff line change
@@ -1,55 +1,74 @@
# Using NCP with CPC (Co-Processor Communication)

## Co-Processor Communication Overview

The purpose of the Co-Processor Communication (CPC) Protocol is to act as a serial link multiplexer that allows data sent from multiple applications to be transported over a secure shared physical link. In CPC, data transfers between processors are segmented in sequential packets over endpoints. Transfers are guaranteed to be error-free and sent in order.

Find more information about the CPC at [https://docs.silabs.com/gecko-platform/4.1/service/cpc/overview](https://docs.silabs.com/gecko-platform/4.1/service/cpc/overview).

## Usage

The CPC daemon acts as a bridge between the host and the target application. It was designed to make a reliable connection between two ends through UART or SPI. Reliability is achieved by an HDLC-like header and CPC. It offers multi-channel communication, and security is turned on by default. It is a connection-based protocol, so that if a message arrives incorrectly, it notifies the other end, which then can re-send that message.

![CPC daemon](resources/an1259-cpc-daemon.png)

The NCP host by default does not contain usage of CPC. You need to build the application with the command line option `CPC=1`.

## Use Cases

Adding the CPC functionality is recommended for the following use cases, as they cannot be used with the simple UART interface:

- Using SPI as the transport layer: SPI communication is only supported with CPC.

- DMP projects: the CPC protocol contains a multiplexer, which makes it possible to use the same interface for different applications.

## Building the Target

To make the target use CPC communication, replace the USART component in the **bt_ncp** sample application with **CPC Secondary - UART (USART)** or **CPC Secondary – SPI (USART)**. This adds all the necessary components to enable CPC communication on the target. Set the pins of the selected communication interface according to the hardware design of the project.

The encryption of the communication is enabled by default. For developing and debugging, Silicon Labs recommends adding the **CPC SECURITY NONE** component so that the packet traces can be easier analyzed.

![Secondary UART](resources/an1259-cpc-secondary-uart.png)

## Host Side

Perform the following steps:

### Step 1: Build the CPC daemon

Download the code for the CPC daemon and follow the instructions to build it from [https://github.com/SiliconLabs/cpc-daemon](https://github.com/SiliconLabs/cpc-daemon).

After the build is finished, open the *cpcd.conf* file and set the **bus_type**, and configure the pins and bitrate according to the settings on the Secondary side.

If the **CPC SECURITY NONE** component was added to the target, set **disable_encryption** to true.

### Step 2: Build the host application

Find the *ncp_host_bt.mk* file in the \<SDK folder>/app/Bluetooth/component_host/ folder, and set `CPC_DIR` to the path of the CPC daemon folder on your machine.

Next, go to the **bt_host_empty** sample application in \<SDK folder>/app/Bluetooth/example_host/bt_host_empty, and build it with this command line option to enable CPC: `make CPC=1`.

### Step 3: Run the application

Start the CPC daemon `cpcd -c ./cpcd.conf`.

Start the host application by passing the **instance_name** set in the *cpcd.conf* file: `./bt_host_empty -C cpcd_0`.
# Using NCP with CPC (Co-Processor Communication)

## Co-Processor Communication Overview

The purpose of the Co-Processor Communication (CPC) Protocol is to act as a serial link multiplexer that allows data sent from multiple applications to be transported over a secure shared physical link. In CPC, data transfers between processors are segmented in sequential packets over endpoints. Transfers are guaranteed to be error-free and sent in order.

Find more information about the CPC at [https://docs.silabs.com/gecko-platform/latest/platform-cpc-overview/](https://docs.silabs.com/gecko-platform/latest/platform-cpc-overview/).

## Usage

The CPC daemon acts as a bridge between the host and the target application. It was designed to make a reliable connection between two ends through UART or SPI. Reliability is achieved by an HDLC-like header and CPC. It offers multi-channel communication, and security is turned on by default. It is a connection-based protocol, so that if a message arrives incorrectly, it notifies the other end, which then can re-send that message.

![CPC daemon](resources/an1259-cpc-daemon.png)

The NCP host by default does not contain usage of CPC. You need to build the application with **Host NCP CPC adapter (Linux only)** component.

>**Note**: The Host NCP CPC adapter (Linux only) component is Experimental currently.

## Use Cases

Adding the CPC functionality is recommended for the following use cases, as they cannot be used with the simple UART interface:

- Using SPI as the transport layer: SPI communication is only supported with CPC.

- DMP projects: the CPC protocol contains a multiplexer, which makes it possible to use the same interface for different applications.

## Building the Target

To make the target use CPC communication, replace the USART component in the **bt_ncp** sample application with **CPC Secondary - UART (USART)** or **CPC Secondary – SPI (USART)**. This adds the necessary components to enable CPC communication on the target. Set the pins of the selected communication interface according to the hardware design of the project.

In NCP setup **Bluetooth NCP Transport over CPC** component is required.

>**Note**: The Bluetooth NCP Transport over CPC component is Experimental currently.

![Add Target NCP CPC](resources/Studio6-target-app-CPC.png)

The encryption of the communication is enabled by default. For developing and debugging, Silicon Labs recommends adding the **CPC SECURITY NONE** component so that the packet traces can be easier analyzed.

![Secondary UART](resources/an1259-cpc-secondary-uart.png)

## Host Side

Perform the following steps:

### Step 1: Build the CPC daemon

Download the code for the CPC daemon and follow the instructions to build it from [https://github.com/SiliconLabs/cpc-daemon](https://github.com/SiliconLabs/cpc-daemon).

After the build is finished, open the *cpcd.conf* file and set the **bus_type**, and configure the pins and bitrate according to the settings on the Secondary side.

If the **CPC SECURITY NONE** component was added to the target, set **disable_encryption** to true.

### Step 2: Build the host application

1. Create a new **Bluetooth - Host empty** project in Simplicity Studio 6
![studio6 host app generation](resources/an1259-studio6-host-app-generation.png)

2. At the *Target Device* select the option *Part* and *Linux*
![studio6 select os](resources/an1259-studio6-select-os.png)

3. Add *Host NCP CPC adapter (Linux only)* component
![Add Host NCP CPC](resources/Studio6-host-app-CPC.png)
>**Note**: The Host NCP CPC adapter (Linux only) component is Experimental currently.
4. Build the project
```C
make -f bt_host_empty.Makefile
```
5. The build output is created in a new *build/debug/* folder.

### Step 3: Run the application

Start the CPC daemon `cpcd -c ./cpcd.conf`.

Start the host application by passing the **instance_name** set in the *cpcd.conf* file: `./bt_host_empty -C cpcd_0`.
Loading
Loading