bluez5: move common files to a common folder for both v5.41 and v5.50

This way, we avoid having to duplicate changes.

https://jira.digi.com/browse/DEL-6448

Signed-off-by: Gabriel Valcazar <gabriel.valcazar@digi.com>
This commit is contained in:
Gabriel Valcazar 2019-06-25 11:42:56 +02:00
parent 69cb3d6dac
commit 8569d4da9e
21 changed files with 2 additions and 512 deletions

View File

@ -1,93 +0,0 @@
#!/bin/sh
#===============================================================================
#
# Copyright (C) 2012-2017 by Digi International Inc.
# All rights reserved.
#
# This program is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License version 2 as published by
# the Free Software Foundation.
#
#
# !Description: Initialize bluetooth hardware
#
#===============================================================================
# Bluetooth power GPIO
BT_EN_QCA_GPIO_NR="244"
# set_gpio_value <gpio_nr> <value>
set_gpio_value() {
local SG_GPIONR="${1}"
local SG_GPIOVAL="${2}"
local SG_GPIOPATH="/sys/class/gpio/gpio${SG_GPIONR}"
[ -d "${SG_GPIOPATH}" ] || printf "%s" "${SG_GPIONR}" > /sys/class/gpio/export
printf out > "${SG_GPIOPATH}/direction" && sleep .2
printf "${SG_GPIOVAL}" > "${SG_GPIOPATH}/value" && sleep .2
[ -d "${SG_GPIOPATH}" ] && printf "%s" "${SG_GPIONR}" > /sys/class/gpio/unexport
}
# powercycle_gpio <gpio_nr>
powercycle_gpio() {
set_gpio_value "${1}" 0
set_gpio_value "${1}" 1
}
error() {
echo ${1}
exit 1
}
bluetooth_init() {
# Get MAC address from the device tree. Use a default value if it has not been set.
BT_MACADDR="$(hexdump -ve '1/1 "%02X" ":"' /proc/device-tree/bluetooth/mac-address 2>/dev/null | sed 's/:$//g')"
if [ -z "${BT_MACADDR}" ] || [ "${BT_MACADDR}" = "00:00:00:00:00:00" ]; then
BT_MACADDR="00:04:F3:FF:FF:BB"
fi
# Start the Bluetooth driver and bring up the interface
HCIATTACH_LOG="/var/log/hciattach.log"
for RETRY in $(seq 1 5)
do
killproc hciattach
powercycle_gpio "${BT_EN_QCA_GPIO_NR}"
if hciattach ttyBt qca ${BT_RATE:-3000000} -t30 ${BT_FLOW:-flow} unused ${BT_MACADDR} >${HCIATTACH_LOG} 2>&1; then
return
fi
sleep 1
done
BT_ERROR="FAIL (hciattach)"
}
# Source function library
. /etc/init.d/functions
case "$1" in
start)
if [ -d "/proc/device-tree/bluetooth" ]; then
echo -n "Starting bluetooth hardware: "
bluetooth_init
echo "${BT_ERROR:-done.}"
fi
;;
stop)
if [ -d "/sys/class/bluetooth/hci0" ]; then
echo -n "Stopping bluetooth hardware: "
killproc hciattach
# Power down bluetooth
set_gpio_value "${BT_EN_QCA_GPIO_NR}" 0
echo "done."
fi
;;
restart)
$0 stop
sleep 1
$0 start
;;
*)
echo "Usage: $0 {start|stop|restart}"
exit 1
;;
esac

View File

@ -1,138 +0,0 @@
#!/bin/sh
#===============================================================================
#
# Copyright (C) 2012-2018 by Digi International Inc.
# All rights reserved.
#
# This program is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License version 2 as published by
# the Free Software Foundation.
#
#
# !Description: Initialize bluetooth hardware
#
#===============================================================================
# Bluetooth power GPIO
BT_PWR_GPIO_NR="244"
# set_gpio_value <gpio_nr> <value>
set_gpio_value() {
local SG_GPIONR="${1}"
local SG_GPIOVAL="${2}"
local SG_GPIOPATH="/sys/class/gpio/gpio${SG_GPIONR}"
[ -d "${SG_GPIOPATH}" ] || printf "%s" "${SG_GPIONR}" > /sys/class/gpio/export
printf out > "${SG_GPIOPATH}/direction" && sleep .2
printf "${SG_GPIOVAL}" > "${SG_GPIOPATH}/value" && sleep .2
[ -d "${SG_GPIOPATH}" ] && printf "%s" "${SG_GPIONR}" > /sys/class/gpio/unexport
}
# powercycle_gpio <gpio_nr>
powercycle_gpio() {
set_gpio_value "${1}" 0
set_gpio_value "${1}" 1
}
error() {
echo ${1}
exit 1
}
bluetooth_init() {
# Get MAC address from the device tree. Use a default value if it has not been set.
BT_MACADDR="$(hexdump -ve '1/1 "%02X" ":"' /proc/device-tree/bluetooth/mac-address 2>/dev/null | sed 's/:$//g')"
if [ -z "${BT_MACADDR}" ] || [ "${BT_MACADDR}" = "00:00:00:00:00:00" ]; then
BT_MACADDR="00:04:F3:FF:FF:BB"
fi
# Use a sub-shell here to change to firmware directory
(
cd /lib/firmware/ar3k/1020200
# Update the MAC address file only if it has changed.
FW_MAC="ar3kbdaddr.pst"
[ -f "${FW_MAC}" ] && [ "$(cat ${FW_MAC})" = "${BT_MACADDR}" ] || echo ${BT_MACADDR} > ${FW_MAC}
# Symlink the correct firmware file depending on region code
JPN_REGCODE="0x2"
REGCODE="$(cat /proc/device-tree/digi,hwid,cert 2>/dev/null | tr -d '\0')"
BT_CLASS_LINK="PS_ASIC.pst"
BT_CLASS_FILE="PS_ASIC_class_1.pst"
if [ -n "${REGCODE}" ] && [ "${JPN_REGCODE}" = "${REGCODE}" ]; then
BT_CLASS_FILE="PS_ASIC_class_2.pst"
fi
if ! cmp -s ${BT_CLASS_FILE} ${BT_CLASS_LINK}; then
ln -sf ${BT_CLASS_FILE} ${BT_CLASS_LINK}
fi
# Remove not used configuration and readme files
# -- Do not quote the subcommand to avoid leading/trailing whitespace
# -- being part of the file name.
rm -f $(echo PS_ASIC_class_?.pst | sed -e "s,${BT_CLASS_FILE},,g") readme.txt
)
# Start the Bluetooth driver and bring up the interface
HCIATTACH_LOG="/var/log/hciattach.log"
BT_CMD="HCIATTACH"
RETRIES="5"
while [ "${RETRIES}" -gt "0" ]; do
case "${BT_CMD}" in
HCIATTACH)
# Reset BT
killproc hciattach
powercycle_gpio "${BT_PWR_GPIO_NR}"
if hciattach ttyBt ath3k 4000000 >${HCIATTACH_LOG} 2>&1; then
BT_CMD="HCICONFIG_UP"
else
BT_ERROR="FAILED (hciattach)"
BT_CMD="BT_INIT_FAIL"
fi
;;
HCICONFIG_UP)
if hciconfig hci0 up; then
break
else
BT_ERROR="FAILED (hciconfig up)"
BT_CMD="BT_INIT_FAIL"
fi
;;
BT_INIT_FAIL)
RETRIES="$((RETRIES - 1))"
BT_CMD="HCIATTACH"
;;
esac
done
[ "${RETRIES}" = "0" ] && error "${BT_ERROR}"
}
# Source function library
. /etc/init.d/functions
case "$1" in
start)
if [ -d "/proc/device-tree/bluetooth" ]; then
echo -n "Starting bluetooth hardware: "
bluetooth_init
echo "done."
fi
;;
stop)
if [ -d "/sys/class/bluetooth/hci0" ]; then
echo -n "Stopping bluetooth hardware: "
hciconfig hci0 down || BT_ERROR="FAILED (hciconfig down)"
killproc hciattach
# Power down bluetooth
set_gpio_value "${BT_PWR_GPIO_NR}" 0
echo "${BT_ERROR:-done.}"
fi
;;
restart)
$0 stop
sleep 1
$0 start
;;
*)
echo "Usage: $0 {start|stop|restart}"
exit 1
;;
esac

View File

@ -1,119 +0,0 @@
#!/bin/sh
#===============================================================================
#
# Copyright (C) 2012-2018 by Digi International Inc.
# All rights reserved.
#
# This program is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License version 2 as published by
# the Free Software Foundation.
#
#
# !Description: Initialize bluetooth hardware
#
#===============================================================================
# Bluetooth power GPIO
BT_EN_QCA_GPIO_NR="137"
# set_gpio_value <gpio_nr> <value>
set_gpio_value() {
local SG_GPIONR="${1}"
local SG_GPIOVAL="${2}"
local SG_GPIOPATH="/sys/class/gpio/gpio${SG_GPIONR}"
[ -d "${SG_GPIOPATH}" ] || printf "%s" "${SG_GPIONR}" > /sys/class/gpio/export
printf out > "${SG_GPIOPATH}/direction" && sleep .2
printf "${SG_GPIOVAL}" > "${SG_GPIOPATH}/value" && sleep .2
[ -d "${SG_GPIOPATH}" ] && printf "%s" "${SG_GPIONR}" > /sys/class/gpio/unexport
}
# powercycle_gpio <gpio_nr>
powercycle_gpio() {
set_gpio_value "${1}" 0
set_gpio_value "${1}" 1
}
error() {
echo ${1}
exit 1
}
bluetooth_init() {
# Get MAC address from the device tree. Use a default value if it has not been set.
BT_MACADDR="$(hexdump -ve '1/1 "%02X" ":"' /proc/device-tree/bluetooth/mac-address 2>/dev/null | sed 's/:$//g')"
if [ -z "${BT_MACADDR}" ] || [ "${BT_MACADDR}" = "00:00:00:00:00:00" ]; then
BT_MACADDR="00:04:F3:FF:FF:BB"
fi
# Module version older than revision 4 has swapped TX and RX lines
MOD_VERSION="$(($(cat /proc/device-tree/digi,hwid,hv 2>/dev/null | tr -d '\0' || true)))"
if [ "${MOD_VERSION}" -lt "4" ]; then
# Ignore the CTS flow control
BT_CTS_QCA_GPIO_NR="18"
set_gpio_value "${BT_CTS_QCA_GPIO_NR}" 0
# Reduce the rate to avoid the need for HW flow control
BT_RATE="115200"
BT_RATE_CODE="00" # 115200 bps
BT_FLOW="noflow"
# Modify the baudrate in the firmware file
BT_FW_FILE="/lib/firmware/qca/nvm_tlv_3.2.bin"
if [ "$(hexdump -s 56 -n 1 -ve '1/1 "%.2x"' ${BT_FW_FILE})" != "${BT_RATE_CODE}" ]; then
printf "\x${BT_RATE_CODE}" | dd of="${BT_FW_FILE}" bs=1 seek=56 count=1 conv=notrunc,fsync 2>/dev/null
fi
fi
# Start the Bluetooth driver and bring up the interface
HCIATTACH_LOG="/var/log/hciattach.log"
for RETRY in $(seq 1 5)
do
killproc hciattach
powercycle_gpio "${BT_EN_QCA_GPIO_NR}"
if hciattach ttyBt qca ${BT_RATE:-3000000} -t30 ${BT_FLOW:-flow} unused ${BT_MACADDR} >${HCIATTACH_LOG} 2>&1; then
# hciattach performs a reset to load the new firmware and needs some time to be ready
sleep 1
return
fi
sleep 1
if [ $RETRY -ge 3 ]; then
# Retry at default firmware baudrate
BT_RATE="115200"
fi
done
BT_ERROR="FAIL (hciattach)"
}
# Source function library
. /etc/init.d/functions
case "$1" in
start)
if [ -d "/proc/device-tree/bluetooth" ]; then
echo -n "Starting bluetooth hardware: "
bluetooth_init
echo "${BT_ERROR:-done.}"
fi
;;
stop)
if [ -d "/sys/class/bluetooth/hci0" ]; then
echo -n "Stopping bluetooth hardware: "
killproc hciattach
# Power down bluetooth
set_gpio_value "${BT_EN_QCA_GPIO_NR}" 0
echo "done."
fi
;;
restart)
$0 stop
sleep 1
$0 start
;;
*)
echo "Usage: $0 {start|stop|restart}"
exit 1
;;
esac

View File

@ -1,22 +0,0 @@
From: Isaac Hermida <isaac.hermida@digi.com>
Date: Fri, 8 Jul 2016 12:19:33 +0200
Subject: [PATCH] hcitool: do not show unsupported refresh option
Signed-off-by: Isaac Hermida <isaac.hermida@digi.com>
---
tools/hcitool.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/tools/hcitool.c b/tools/hcitool.c
index 02c4ebe1b71b..229c22c49909 100644
--- a/tools/hcitool.c
+++ b/tools/hcitool.c
@@ -568,7 +568,7 @@ static struct option scan_options[] = {
static const char *scan_help =
"Usage:\n"
- "\tscan [--length=N] [--numrsp=N] [--iac=lap] [--flush] [--class] [--info] [--oui] [--refresh]\n";
+ "\tscan [--length=N] [--numrsp=N] [--iac=lap] [--flush] [--class] [--info] [--oui]\n";
static void cmd_scan(int dev_id, int argc, char **argv)
{

View File

@ -1,57 +0,0 @@
From: Isaac Hermida <isaac.hermida@digi.com>
Date: Fri, 8 Jul 2016 10:42:57 +0200
Subject: [PATCH] hcitool: increase the shown connection limit to 20
Created a variable to set the number of connections to shown and increase that
value so we can list more current LE connections.
https://jira.digi.com/browse/DEL-2735
Signed-off-by: Isaac Hermida <isaac.hermida@digi.com>
---
tools/hcitool.c | 10 ++++++----
1 file changed, 6 insertions(+), 4 deletions(-)
diff --git a/tools/hcitool.c b/tools/hcitool.c
index 229c22c49909..ae70c9c0d3b4 100644
--- a/tools/hcitool.c
+++ b/tools/hcitool.c
@@ -69,6 +69,8 @@
#define EIR_TX_POWER 0x0A /* transmit power level */
#define EIR_DEVICE_ID 0x10 /* device ID */
+#define MAX_CONNECTIONS_SHOWN 20 /* Max number of "hcitool conn" items to shown */
+
#define for_each_opt(opt, long, short) while ((opt=getopt_long(argc, argv, short ? short:"+", long, NULL)) != -1)
static volatile int signal_received = 0;
@@ -156,12 +158,12 @@ static int conn_list(int s, int dev_id, long arg)
if (id != -1 && dev_id != id)
return 0;
- if (!(cl = malloc(10 * sizeof(*ci) + sizeof(*cl)))) {
+ if (!(cl = malloc(MAX_CONNECTIONS_SHOWN * sizeof(*ci) + sizeof(*cl)))) {
perror("Can't allocate memory");
exit(1);
}
cl->dev_id = dev_id;
- cl->conn_num = 10;
+ cl->conn_num = MAX_CONNECTIONS_SHOWN;
ci = cl->conn_info;
if (ioctl(s, HCIGETCONNLIST, (void *) cl)) {
@@ -190,12 +192,12 @@ static int find_conn(int s, int dev_id, long arg)
struct hci_conn_info *ci;
int i;
- if (!(cl = malloc(10 * sizeof(*ci) + sizeof(*cl)))) {
+ if (!(cl = malloc(MAX_CONNECTIONS_SHOWN * sizeof(*ci) + sizeof(*cl)))) {
perror("Can't allocate memory");
exit(1);
}
cl->dev_id = dev_id;
- cl->conn_num = 10;
+ cl->conn_num = MAX_CONNECTIONS_SHOWN;
ci = cl->conn_info;
if (ioctl(s, HCIGETCONNLIST, (void *) cl)) {

View File

@ -1,12 +0,0 @@
[Unit]
Description=Initialization of the bluetooth chip
ConditionPathIsDirectory=/proc/device-tree/bluetooth
Before=bluetooth.service
[Service]
Type=forking
ExecStart=/etc/bluetooth-init start
ExecStop=/etc/bluetooth-init stop
[Install]
WantedBy=multi-user.target

View File

@ -1,33 +0,0 @@
From: Gabriel Valcazar <gabriel.valcazar@digi.com>
Date: Thu, 7 Feb 2019 13:15:43 +0100
Subject: [PATCH] bluetooth.service: add Digi customizations
These changes include:
* Adding the bluetooth-init service as a soft dependency.
* Having the bluetooth stack start automatically on boot.
Signed-off-by: Gabriel Valcazar <gabriel.valcazar@digi.com>
---
src/bluetooth.service.in | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/src/bluetooth.service.in b/src/bluetooth.service.in
index f799f65..d8b150c 100644
--- a/src/bluetooth.service.in
+++ b/src/bluetooth.service.in
@@ -2,6 +2,7 @@
Description=Bluetooth service
Documentation=man:bluetoothd(8)
ConditionPathIsDirectory=/sys/class/bluetooth
+Wants=bluetooth-init.service
[Service]
Type=dbus
@@ -16,5 +17,5 @@ ProtectHome=true
ProtectSystem=full
[Install]
-WantedBy=bluetooth.target
+WantedBy=multi-user.target
Alias=dbus-org.bluez.service

View File

@ -1,12 +0,0 @@
[General]
# Default adapter name
# Defaults to 'BlueZ X.YZ'
Name = cc6qp
[Policy]
# AutoEnable defines option to enable all controllers when they are found.
# This includes adapters present on start as well as adapters that are plugged
# in later on. Defaults to 'false'.
AutoEnable=true

View File

@ -1,12 +0,0 @@
[General]
# Default adapter name
# Defaults to 'BlueZ X.YZ'
Name = cc6
#[Policy]
# AutoEnable defines option to enable all controllers when they are found.
# This includes adapters present on start as well as adapters that are plugged
# in later on. Defaults to 'false'.
#AutoEnable=true

View File

@ -1,12 +0,0 @@
[General]
# Default adapter name
# Defaults to 'BlueZ X.YZ'
Name = cc6ul
[Policy]
# AutoEnable defines option to enable all controllers when they are found.
# This includes adapters present on start as well as adapters that are plugged
# in later on. Defaults to 'false'.
AutoEnable=true

View File

@ -1,6 +1,6 @@
# Copyright (C) 2015-2018 Digi International.
# Copyright (C) 2015-2019 Digi International.
FILESEXTRAPATHS_prepend := "${THISDIR}/${BP}:"
FILESEXTRAPATHS_prepend := "${THISDIR}/${BPN}:${THISDIR}/${BP}:"
SRC_URI += " \
file://bluetooth-init \