EBYTE E73-TBB Development Board (based on nRF52) provisioned into a Bluetooth Mesh by running meshctl on Raspberry Pi 4
Install meshctl on Raspberry Pi
Follow these
instructions to install the Bluetooth Mesh provisioning tool meshctl
for Raspberry Pi for the article “Bluetooth Mesh with nRF52 and Apache Mynewt”
1. Install BlueZ
meshctl
is part of the open-source BlueZ software suite (which
doesn’t run on Windows and macOS, that’s why we are using a Pi). BlueZ may be preinstalled on Pi but
the default installation lacks the meshctl
utility. We’ll
install BlueZ now with the meshctl
option…
Refer to the
official guide by Bluetooth SIG:
“Developer Study
Guide: Deploying BlueZ v5.50 on Raspberry Pi3, Part 1 — Deployment”
Follow the instructions in the sections…
“0. Prerequisite”
“1. Install BlueZ v5.50”
BUT stop before “2. Rebuilding the kernel for BlueZ v5.50”
2. Download Pi Kernel Source Files
We shall
rebuild the Pi kernel now. Why? Because meshctl
needs
AEAD-AES_CCM encryption, which runs as a secure service in the kernel. This may take an hour or more
to complete.
Enter the following at a command prompt…
cd ~
sudo apt-get install -y git bc bison flex libssl-dev
uname -a
You should see a message like…
Linux raspberrypi 4.19.75-v7l+ #1270 SMP Tue Sep 24 18:51:41 BST 2019 armv7l GNU/Linux
See the 4.19
part? This is important — it’s the Version Number for your Pi kernel. We need to fetch the kernel source files
for our kernel version, or our Pi won’t boot after rebuilding the kernel.
Enter this command…
git clone --depth=1 --branch rpi-4.19.y https://github.com/raspberrypi/linux
BUT replace 4.19
by your Pi
Kernel Version Number.
3. Initialise Pi Kernel Settings
We shall now initialise the new Pi kernel to the default settings…
For Raspberry Pi 1, Pi Zero, Pi Zero W, and Compute Module, enter…
cd linux
KERNEL=kernel
make bcmrpi_defconfig
For Raspberry Pi 2, Pi 3, Pi 3+, and Compute Module 3, enter…
cd linux
KERNEL=kernel7
make bcm2709_defconfig
For Raspberry Pi 4, enter…
cd linux
KERNEL=kernel7l
make bcm2711_defconfig
4. Configure Pi Kernel
Let’s configure
the kernel and select the AEAD-AES_CCM encryption needed by meshctl
. Enter…
make menuconfig
Press the arrow
keys to move the cursor to Cryptographic API.
Press Enter
Press the arrow
keys to move the cursor to each of these modules. Press S
to
select…
1️⃣ Hash Modes → CMAC support
2️⃣ Random Number Generation → User-space interface for hash algorithms
3️⃣ Random Number Generation → User-space interface for symmetric key cipher algorithms
You should see
(*)
when the module is selected.
Press Esc
a few times until you see the prompt Do you wish to save your new configuration
…
Select Yes
and the command prompt reappears.
Here’s a video that shows the steps…
AEAD-AES_CCM encryption for meshctl on Raspberry Pi
5. Build Pi Kernel
Before building
the kernel, we’ll backup the old kernel into /OLDboot
in case
the new kernel fails. Enter…
sudo cp -r /boot /OLDboot
Now we build and install the kernel. Enter…
make -j4 zImage modules dtbs
sudo make modules_install
sudo cp arch/arm/boot/dts/*.dtb /boot/
sudo cp arch/arm/boot/dts/overlays/*.dtb* /boot/overlays/
sudo cp arch/arm/boot/dts/overlays/README /boot/overlays/
sudo cp arch/arm/boot/zImage /boot/$KERNEL.img
sudo sync
sudo reboot
This kernel build may take an hour or more to complete. When it’s done our Pi should reboot with the new kernel.
6. Test meshctl
After rebooting, open a command prompt and enter…
meshctl
Press Enter
to see the [meshctl]#
prompt.
If you don’t
see any errors, congratulations you have installed meshctl
!
Enter this to
exit meshctl
…
exit
Remember:
Always exit meshctl
properly, otherwise it will lock on to the
Bluetooth driver and you would need to reboot the Pi to fix this.
If you see this message instead…
Failed to parse provisioning database file prov_db.json
It means that your kernel still doesn’t have AEAD-AES_CCM encryption installed. Carefully redo each step from the top of this article.
References
If you have problems configuring and building the Pi kernel, refer to the official guides…
If you have problems provisioning the Bluetooth Mesh, refer to the official guide by Bluetooth SIG…
“How to Deploy BlueZ v5.50 on Raspberry Pi 3 and Use It, Part 2 — Provisioning”
Here is an excellent series of articles on Bluetooth Mesh for Zephyr embedded OS…