0, order
BlueZ is the official Linux Bluetooth protocol stack. This article introduces how to build a Bluetooth development environment based on Bluez in the Jetson nano development platform. Mainly refer to the "Developer Study Guide-How to Deploy BlueZ on a Raspberry Pi Board as a Bluetooth Mesh Provisioner" provided by the SIG Alliance, and also involve the update of the Linux kernel of the Jetson nano platform. Portal for the above information: https://www.bluetooth.com/bluetooth-resources/
1. Relevant dependency library installation
1.1, library installation
sudo apt-get install libglib2.0-dev libdbus-1-dev libdbus-c++-dev libudev-dev libical-dev libreadline-dev
1.2, json-c installation
wget https://s3.amazonaws.com/json-c_releases/releases/json-c-0.13.tar.gz
tar -xvf json-c-0.13.tar.gz
cd json-c-0.13/
./configure --prefix=/usr --disable-static && make
sudo make install
2. Installation of Bluez
2.1, compile and install
wget http://www.kernel.org/pub/linux/bluetooth/bluez-5.54.tar.xz
tar -xvf bluez-5.54.tar.xz
cd bluez-5.54/
./configure --enable-mesh --enable-testing --enable-tools --prefix=/usr --mandir=/usr/share/man -- sysconfdir=/etc --localstatedir=/var
sudo make
sudo make install
2.2, check the configuration file
Check the Bluez service configuration file, make sure the value of ExecStart in the service configuration file is " /usr/libexec/bluetooth/bluetoothd "
vim /lib/systemd/system/bluetooth.service
2.3, environment configuration
Back up the original executable program and create the following symlink.
sudo cp /usr/lib/bluetooth/bluetoothd /usr/lib/bluetooth/bluetoothd-550.orig
sudo ln -sf /usr/libexec/bluetooth/bluetoothd /usr/lib/bluetooth/bluetoothd
sudo systemctl daemon-reload
cd ~/.config/
mkdir meshctl
cp ~/bluez-5.54/tools/mesh-gatt/local_node.json ~/.config/meshctl/
cp ~/bluez-5.54/tools/mesh-gatt/prov_db.json ~/.config/meshctl/
2.4. Check the version of Bluez installed
bluetoothd -v
meshctl -v
mesh-cfgclient -v
After installing the above-mentioned related tools, when running mesh-cfgctl, there is an error that is defined as a symbol. You can replace the dynamic library in the compilation chain with a dynamic library of json-c generated by self-compilation and installation.
3, update Linux Kernel
But the following error occurred when running meshctl:
Failed to parse provisioning database file /home/colin/.config/meshctl/prov_db.json
free(): double free detected in tcache 2
Aborted
The above problem occurs because the Linux kernel does not install the AEAD-AES_CCM package correctly. Reconfigure the kernel: Download the relevant kernel and component source code from the NVIDIA Jetson download center. Note that you need to download the same version as the current one. Kernel download portal: https://developer.nvidia.com/embedded/downloads , as shown in the figure below, pay attention to download the source code of the same version as the system you are running to avoid failure to boot after replacing the kernel.
After downloading L4T Sources, enter the kernel directory and configure the kernel
1) Output the kernel configuration of the original system to .config
zcat /proc/config.gz > .config
2) Kernel configuration
make menuconfig
After running the command make menuconfig, if the following error occurs, it means that the relevant dependency library is missing and not installed, just install it.
colin@Blanc:~/works/Linux_for_Tegra/source/public/kernel/kernel-4.9$ make menuconfig
HOSTCC scripts/basic/fixdep
HOSTCC scripts/kconfig/mconf.o
<command-line>:0:12: fatal error: curses.h: No such file or directory
compilation terminated.
scripts/Makefile.host:118: recipe for target 'scripts/kconfig/mconf.o' failed
make[1]: *** [scripts/kconfig/mconf.o] Error 1
Makefile:565: recipe for target 'menuconfig' failed
make: *** [menuconfig] Error 2
Install dependent libraries
sudo apt-get install libncurses5-dev
Okay, formally enter the kernel configuration:
3.1, kernel configuration
1) Enable Networking support
2) Enable Crytographic API
3) Enter Crytographic API ->, enable CCM support, CMAC support, User-space interface for hash algorithms, User-space interface for symmetric key cipher algorithms, User-space interface for AEAD cipher algorithms, as shown in the following picture:
3.2, compile the kernel
1) make prepare
2) make modules_prepare
jetson nano是4核的,故:
3) make -j4
3.3, install modules
make modules// 模块编译
sudo make modules_install // 安装模块到/lib/modules
3.4, replace the new kernel
sudo cp ./arch/arm64/boot/zImage /boot/zImage
sudo cp ./arch/arm64/boot/Image /boot/Image
3.5, restart and check
sudo reboot
After restarting, check the version of the system, and you can find that the kernel print time is new. In the above picture, I recompile and replace the new kernel at 2020-12-20-15:33, and at the same time correctly install the AEAD-AES_CCM package. Running meshctl can load the database file and run it normally, and it's done-OK! .