This library is no longer being maintained, and there are no plans for a successor to this library. While it will remain accessible for existing nRF5 SDK users, it will not receive further updates or support. We recommend refraining from initiating new projects with this library, as the firmware (.hex files) available uses outdated SoftDevice binaries.
pc-ble-driver
provides C/C++ libraries for Bluetooth Low Energy nRF5 SoftDevice serialization.
- Overview
- Architecture
- Supported environments
- Installing device drivers
- Installing tools
- Installing dependencies
- Compiling pc-ble-driver from source
- Compiling connectivity HEX files
- Programming connectivity HEX files
- Examples
- Known issues
- License
pc-ble-driver
consists of a set of static and shared libraries that provide SoftDevice functionality to the application via serial port communication with an nRF5 connectivity chip running the SoftDevice and connectivity software, included as a single .hex file here. For more information on SoftDevice serialization see Serialization.
The C/C++ libraries can be interfaced with directly, but are also provided as higher-level bindings that ease development at the cost of reduced control (acceptable in most cases):
Where the 'Application chip' is just generic hardware (i.e. a Windows, Linux or macOS device), although it could also be an Arduino or Raspberry Pi for example.
- Windows 7, 8 and 10, 32 and 64-bit (tested on Windows 7)
- Ubuntu Linux LTS 64-bit (tested on Ubuntu 18.04)
- macOS 64-bit (tested on 10.14 Mojave)
To use pc-ble-driver, your Development Kit needs to have the correct firmware. The needed firmwares are found in the hex/sd_api_v<x>
folder and contain the SoftDevice and connectivity firmware required to communicate with pc-ble-driver
.
The generated libraries are compatible with the following SoftDevice API versions and nRF5x ICs:
- SoftDevice s130 API version 2:
connectivity_<version>_1m_with_s130_2.x.x
(nRF51 and nRF52 series ICs) - SoftDevice s132 API version 3:
connectivity_<version>_<1m|*usb>_with_s132_3.x.x
(only for nRF52 series ICs) - SoftDevice s132 API version 5:
connectivity_<version>_<1m|*usb>_with_s132_5.x.x
(only for nRF52 series ICs) - SoftDevice s132 API version 6:
connectivity_<version>_<1m|*usb>_with_s132_6.x.x
(only for nRF52 series ICs) - SoftDevice s140 API version 6:
connectivity_<version>_<1m|*usb>_with_s140_6.x.x
(only for nRF52 series ICs)
*usb) only for nRF52 series ICs with USBD peripheral
PCA | Official name | Article number | Notes |
---|---|---|---|
PCA10028 | nRF51 DEVELOPMENT KIT | nRF6824 | |
PCA10031 | nRF51 DONGLE | nRF6825 | |
PCA10040 | nRF52 DEVELOPMENT KIT | nRF6827 | |
PCA10056 | nRF52840 { Development Kit } | nRF6828 | *) |
PCA10059 | nRF52840 { Dongle } | nRF6829 | Can only use connectivity firmware with Nordic USB CDC serial port support |
*) Can use both Nordic USB CDC serial port version and SEGGER J-Link-OB (VCOM) version. Using Nordic USB CDC serial port version on PCA10056 requires that you connect pins P0.18 and P0.24. The pins to QSPI chip must also be in place (they are by default). The algorithm for detecting if it is PCA10056 or PCA10059 is to check if it is possible to communicate with the QSPI chip. PCA10059 does not have a QSPI chip. The detection is used by nRF Connect DFU trigger to determine what pin to use for resetting the device when changing between DFU and application mode.
This communication library works over any kind of serial port (UART), but it is most often used over a Segger J-Link USB CDC UART. To set up the required J-Link drivers simply download and install the version matching you operating system:
After you have installed the required drivers and connected a J-Link enabled board (such as the Nordic Development Kits) the port should be available.
In addition, you have to disable the Mass Storage Device
in order to use pc-ble-driver
to communicate with the device, see data corruption or drops issue
.
The serial port will appear as COMxx
.
Simply check the "Ports (COM & LPT)" section in the Device Manager.
The serial port will appear as /dev/ttyACMx
.
By default the port is not accessible to all users. Type the command below to add your user to the dialout
group to give it access to the serial port. Note that re-login is required for this to take effect.
$ sudo usermod -a -G dialout <username>
To prevent the modemmanager service from trying to connect to the CDC ACM serial port:
$ systemctl stop ModemManager.service
$ systemctl disable ModemManager.service
The serial port will appear as /dev/tty.usbmodemXXXX
.
There is a known issue, check it here if you met any problems.
To program the connectivity firmware you will need nrfjprog
which is bundled with the nRF5x Command-Line Tools, which can be downloaded from:
- nRF5x Command-Line Tools for Windows
- nRF5x Command-Line Tools for Linux 32-bit
- nRF5x Command-Line Tools for Linux 64-bit
- nRF5x Command-Line Tools for macOS
Add nrfjprog
and mergehex
to PATH
on Linux and macOS.
Alternatively, nRF Connect Programmer
can help you to program the connectivty firmware with UI support.
Download
nRF Connect Desktop
and install nRF Connect Programmer
there.
To compile pc-ble-driver
you will need the following tools:
To compile connectivity
HEX files you will need additional tools:
Follow the steps to install dependencies on a specific platform:
-
Download
Visual Studio 15
or later version and install. -
Install Chocolatey. Install with
cmd.exe
(Run as administrator)# Copy everything below @"%SystemRoot%\System32\WindowsPowerShell\v1.0\powershell.exe" -NoProfile -InputFormat None -ExecutionPolicy Bypass -Command "iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))" && SET "PATH=%PATH%;%ALLUSERSPROFILE%\chocolatey\bin"
If
Chocolatey
has already been installed as described above but has not been added to PATH, run:$ SET "PATH=%PATH%;%ALLUSERSPROFILE%\chocolatey\bin"
-
Install
Git
.$ choco install -y git
-
Install
CMake
.$ choco install -y cmake
-
Install vcpkg.
$ git clone https://github.com/Microsoft/vcpkg.git $ cd vcpkg $ git checkout tags/2020.04 $ .\bootstrap-vcpkg.bat
Then add the vcpkg location to the
PATH
and set it asVCPKG_ROOT
environment variable.
The following steps are needed only if you want to compile your own connectivity
HEX files.
-
Install
ninja
.$ choco install -y ninja
-
Download and install
GNU Embedded Toolchain for Arm
version 7-2018q2Download from this location.
Follow the install instructions.
Set its installation path as
GNUARMEMB_TOOLCHAIN_PATH
in environment variables. For example:$ set GNUARMEMB_TOOLCHAIN_PATH=c:\gccarmemb
-
Install
Python
andpip
, and then installnrfutil
$ pip install nrfutil # Reboot if installation succeeds but validation fails
-
Install
build-essential
.$ sudo apt-get -y install build-essential
-
Install
Git
$ sudo apt-get -y install git
If the installed version of
Git
is lower than required, then:$ sudo add-apt-repository ppa:git-core/ppa $ sudo apt update $ sudo apt install git
-
Install
CMake
.$ sudo apt-get -y install cmake
Install
CMake
from source if the version is lower than required. -
Install vcpkg.
$ git clone https://github.com/Microsoft/vcpkg.git $ cd vcpkg $ git checkout tags/2020.04 $ ./bootstrap-vcpkg.sh
Then add the vcpkg location to the
PATH
andVCPKG_ROOT
environment variable. -
Install
Ninja
.$ sudo apt-get install ninja-build
The following steps are needed only if you want to compile your own connectivity
HEX files.
-
Install
GNU Embedded Toolchain for Arm
version 7-2018q2.- Download from here
- Extract
- Set its location as
GNUARMEMB_TOOLCHAIN_PATH
in environment variables.
-
Install
Python
andpip
, and then installnrfutil
.$ pip install nrfutil # Reboot if installation succeeds but validation fails # If errors persist, try updating pip itself.
-
Install
Xcode (>=10.1)
. -
Install
gcc6
using HomeBrew.$ brew install gcc6
-
Install
CMake
using HomeBrew.$ brew install cmake $ brew upgrade cmake
Install
CMake
from source if the version is lower than required. -
Install vcpkg.
$ git clone https://github.com/Microsoft/vcpkg/ $ cd vcpkg $ git checkout tags/2020.04 $ ./bootstrap-vcpkg.sh
Then add the vcpkg location to the
PATH
andVCPKG_ROOT
environment variable.
The following steps are needed only if you want to compile your own connectivity
HEX files.
-
Install
GNU Embedded Toolchain for Arm
version 7-2018q2.- Download from here
- Extract
- Set its location as
GNUARMEMB_TOOLCHAIN_PATH
in environment variables.
-
Install
Python
andpip
, and then installnrfutil
$ pip install nrfutil # Reboot if installation succeeds but validation fails
Go to install dependencies if you have not done that yet.
-
Install vcpkg dependencies.
# cd <pc-ble-driver-root-folder> # Make sure %VCPKG_ROOT% is set and added to %PATH% $ mkdir build && cd build $ vcpkg install asio catch2 spdlog
-
CMake Select the Visual Studio compiler to use according to this article: Build C/C++ code on the command line
$ cmake -G Ninja ..
-
Compile
$ cmake --build .
Optionally select the build configuration with the
--config
option. TypicallyDebug
,Release
,MinSizeRel
andRelWithDebInfo
are available. For example:$ cmake --build . --config Debug
-
Install vcpkg dependencies.
# cd <pc-ble-driver-root-folder> # Make sure $VCPKG_ROOT is set and added to $PATH $ mkdir build && cd build $ vcpkg install asio catch2 spdlog
-
CMake
$ cmake \ -G Ninja \ ..
Optionally Select the build configuration with the
-DCMAKE_BUILD_TYPE
option. TypicallyDebug
,Release
,MinSizeRel
andRelWithDebInfo
are available.Optionally select the target architecture (32 or 64-bit) using the
-DARCH
option. The values can bex86_32
,x86_64
,x86_32,x86_64
. For example:$ cmake \ -G Ninja \ -DCMAKE_BUILD_TYPE=Debug \ -DARCH=x86_32,x86_64 \ ..
-
Compile
$ cmake --build .
Go to install dependencies if you have not done that yet.
Go to compile pc-ble-driver
from source if you have not done that yet.
Make sure the following environment variables are set:
VCPKG_ROOT
GNUARMEMB_TOOLCHAIN_PATH
Make sure the following paths have been added to PATH:
VCPKG_ROOT
mergehex
Follow the steps to install dependencies on a specific platform:
-
Set environment
# cd <pc-ble-driver-root-folder> $ SET "PATH=%PATH%;%ALLUSERSPROFILE%\chocolatey\bin" # Make sure environment variables have been set # as described at beginning of this section
-
CMake
$ mkdir build && cd build # Modify -DCONNECTIVITY_VERSION=a.b.c $ cmake -G Ninja -DCOMPILE_CONNECTIVITY=1 -DCONNECTIVITY_VERSION=1.0.0 ..
COMPILE_CONNECTIVITY
is set to 1 to enable compiling connectivity firmware.CONNECTIVITY_VERSION
defines a version for the compiled connectivity firmware.Check more options at compiling pc-ble-driver on Windows
-
Compile
$ cmake --build . --target compile_connectivity
The HEX files are available in the
hex/sd_api_v<x>
folder after compilation. They include the SoftDevice and the connectivity application.
-
Set environment
# cd <pc-ble-driver-root-folder> $ export TMP=/tmp # Make sure environment variables have been set # as described at beginning of this section
-
CMake
$ mkdir build && cd build # Modify -DCONNECTIVITY_VERSION=a.b.c $ cmake \ -G Ninja \ -DCOMPILE_CONNECTIVITY=1 \ -DCONNECTIVITY_VERSION=1.0.0 \ ..
COMPILE_CONNECTIVITY
is set to 1 to enable compiling connectivity firmware.CONNECTIVITY_VERSION
defines a version for the compiled connectivity firmware.Check more options at compiling pc-ble-driver on Ubuntu Linux or macOS
-
Compile
$ cmake --build . --target compile_connectivity
The HEX files are available in the
hex/sd_api_v<x>
folder after compilation. They include the SoftDevice and the connectivity application.
Go to install tools if the nRF5x Command-Line Tools have not been installed yet.
To use this library you will need to program the connectivity firmware on a nRF5x IC
Use nRF5x Command-Line Tools to erase and program the IC:
$ nrfjprog -f NRF5<x> -e
$ nrfjprog -f NRF5<x> --program hex/sd_api_v<x>/connectivity_<ver>_<baudrate>_with_s<x>_<a>.<b>.<c>.hex
Alternatively, use nRF Connect Programmer to erase and program the IC.
Some kits, like the pca10059 nRF52 dongle, do not have onboard debugger and will have to be programmed via serial DFU. On Windows, device drivers are required for the kits to be detected correctly by the operating system. To install the required drivers, please make sure you have the latest nRF Connect for Desktop installed.
Programming the connectivity firmware via serial DFU can be done from command line or from nRF Connect for Desktop.
Device Firmware Upgrade with nrfutil is normally done in two steps: 1: generating the DFU zip package, and 2: performing the DFU procedure. A DFU zip package has been pre-made and is included in this repository. To run the DFU procedure with nrfutil with the pre-made DFU package:
nrfutil dfu usb-serial -pkg connectivity_x.x.x_usb_with_s<x>_<a>.<b>.<c>_dfu_pkg.zip -p <serial port>
The examples serve as a great starting point for development with pc-ble-driver
. Examples include a heart rate monitor (BLE peripheral) and heart rate collector (BLE master) and show the basic structure of an application built on pc-ble-driver
.
To quickly get the examples up and running, see examples/README.md.
If you meet problems during installation of pc-ble-driver, please see Issues.md.
Feel free to propose changes by creating a pull request.
If you plan to make any non-trivial changes, please start out small and ask seek an agreement before putting too much work in it. A pull request can be declined if it does not fit well within the current product roadmap.
In order to accept your pull request, we need you to sign our Contributor License Agreement (CLA). You will see instructions for doing this after having submitted your first pull request.
If you find any bugs, or have questions or other feedback in general, please submit a post on the Nordic DevZone portal. Note that bug reports should describe in sufficient detail how to reproduce the bug.
See the license file for details.