How to config Bluetooth base Ubuntu 18.04 for Nvidia NANO 2G

Posted ccjjll6517

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了How to config Bluetooth base Ubuntu 18.04 for Nvidia NANO 2G相关的知识,希望对你有一定的参考价值。

目录

 

Make kernel

Config Bluetooth

Check the environment

Others


Make kernel

Update linux kernel 4.9.201, and config modules related to bluetooth

Reference links(if need):

https://blog.hypriot.com/post/nvidia-jetson-nano-build-kernel-docker-optimized/
https://blog.csdn.net/qq_33475105/article/details/111995309

Prepare

If sudo get install someting firstly:

$ sudo apt-get update
$ sudo apt-get install -y libncurses5-dev

else

$ sudo apt-get install -y libncurses5-dev

Download kernel 4.9.201

https://developer.nvidia.com/embedded/linux-tegra

Select L4T Driver Package[BSP] Sources

Extrace kernel BSP source file

In download dir

$ cd
$ mkdir -p nano-bsp-sources
$ cd nano-bsp-sources

Then copy BSP resources to nona-bsp-sources, and tar

$ tar xvf public_sources.tbz2
$ mv Linux_for_Tegra/source/public/kernel_src.tbz2 ~/
$ cd

Extrace kernel src

$ cd
$ tar xvf ./kernel_src.tbz2

 Compile the default Linux Kerne

*Below information is updated after I re-config the kernel, maybe your old kernel has the different things, ignore them;

$ cd ~/kernel/kernel-4.9
$ zcat /proc/config.gz > .config
$ head -10 .config
#
# Automatically generated file; DO NOT EDIT.
# Linux/arm64 4.9.201 Kernel Configuration
#
CONFIG_ARM64=y
CONFIG_64BIT=y
CONFIG_ARCH_PHYS_ADDR_T_64BIT=y
CONFIG_MMU=y
CONFIG_DEBUG_RODATA=y
CONFIG_ARM64_PAGE_SHIFT=12

Backup orignal kernel

$ cp .config kernel.config.original

Customizing kernel config

$ make menuconfig

 

 

**Important selections for Bluetooth as below

You need to config this same as mine

 

Some others that need to config as well

In Cryptographic 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 

Then Save and exit

 

Make kernal and module

$ cd ~/kernel/kernel-4.9

# Prepare the kernel build
$ make prepare
$ make modules_prepare

# Compile kernel image and kernel modules
$ time make -j5 Image
$ time make -j5 modules

# Install modules and kernel image
$ sudo make modules_install
$ sudo cp arch/arm64/boot/Image /boot/Image

Then reboot NANO and check if the kernel time is the build time

$ sudo reboot
...
#After restart
$ uname -a
Linux colin-desktop 4.9.201 #1 SMP PREEMPT Fri Apr 9 21:41:19 CST 2021 aarch64 aarch64 aarch64 GNU/Linux

Config Bluetooth

Install libbluetooth

dpkg -l|grep bluetoo 

Check whether libbluetooth lib is installed or not;
if not, 

sudo apt-get install libbluetooth-dev

Edit bluetooth service file, in NANO, the service file is as below:

gedit /lib/systemd/system/bluetooth.service.d/nv-bluetooth-service.conf&

Backup  --noplugin=audio,a2dp,avrcp, and add parameters: -d -C

Automatically add SP protocol in channel 1, then we can use serier port for bluetooth to communicate with other bluetooth device.

[Service]
# systemd needs to reset value first before assigning new one
#--noplugin=audio,a2dp,avrcp
ExecStart=
ExecStart=/usr/lib/bluetooth/bluetoothd -d -C
ExecStartPost=/usr/bin/sdptool add --channel=1 SP

Reboot NANO;

Check the environment

Check bluetoothd

$ ps aux | grep blue
root      4660  0.0  0.1   7108  3144 ?        Ss   14:41   0:00 /usr/lib/bluetooth/bluetoothd -d -C

You will find the bluetooth deamon is running as expected;

Check SP protocol 

$ su
#In root user
$ sdptool browse local
...
Service Name: Serial Port
Service Description: COM Port
Service Provider: BlueZ
Service RecHandle: 0x10001
Service Class ID List:
  "Serial Port" (0x1101)
Protocol Descriptor List:
  "L2CAP" (0x0100)
  "RFCOMM" (0x0003)
    Channel: 1
Language Base Attr List:
  code_ISO639: 0x656e
  encoding:    0x6a
  base_offset: 0x100
Profile Descriptor List:
  "Serial Port" (0x1101)
    Version: 0x0100
...

SP protocol is constructed succesfully.

Others

Check bluetooth status

$  hciconfig hci0
hci0:	Type: Primary  Bus: USB
	BD Address: 00:1A:7D:DA:71:0A  ACL MTU: 310:10  SCO MTU: 64:8
	UP RUNNING PSCAN 
	RX bytes:694 acl:0 sco:0 events:50 errors:0
	TX bytes:3656 acl:0 sco:0 commands:50 errors:0

You will find its status is UP RUNNING PSCAN

You need to use

$ hciconfig hci0 piscan

to change the status as UP RUNNING PSCAN ISCAN

$  hciconfig hci0
hci0:	Type: Primary  Bus: USB
	BD Address: 00:1A:7D:DA:71:0A  ACL MTU: 310:10  SCO MTU: 64:8
	UP RUNNING PSCAN ISCAN 
	RX bytes:706 acl:0 sco:0 events:52 errors:0
	TX bytes:3695 acl:0 sco:0 commands:52 errors:0

Finnally you can use SP protocol to develop your own bluetooth communication feature .

 

 

 

 

 

 

 

 

 

 

 

以上是关于How to config Bluetooth base Ubuntu 18.04 for Nvidia NANO 2G的主要内容,如果未能解决你的问题,请参考以下文章

how to buy ELM327 wifi bluetooth usb obd2 scanner

how to config debian

转载 How to Encrypt connection string in web.config

Siebel Config: How to set Session Timeout?

how to adjust PKG_CONFIG_PATH environment-variable

xbox android 蓝牙,How to Connect the Xbox Series X or S Controller to Android