bluetooth-init: consolidate common scripts
Consolidate the init script for platforms based on the same driver with the same logic. The btbmc and hciuart drivers are used in the ccmp1 and cc95. The btnxpuart driver is used in the cc91 and cc93. The btdigi driver is used in the cc8 platforms with the qca65x4 driver. https://onedigi.atlassian.net/browse/DEL-9949 Signed-off-by: Isaac Hermida <isaac.hermida@digi.com>
This commit is contained in:
parent
575377d922
commit
3408f8c4ed
|
|
@ -4,8 +4,16 @@ SUMMARY = "Bluetooth init scripts"
|
|||
LICENSE = "GPL-2.0-only"
|
||||
LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/GPL-2.0-only;md5=801f80980d171dd6425610833a22dbe6"
|
||||
|
||||
BT_INIT_FILE = "bluetooth-init"
|
||||
BT_INIT_FILE:ccimx8m = "bluetooth-init_btdigi_qca65x4"
|
||||
BT_INIT_FILE:ccimx8x = "bluetooth-init_btdigi_qca65x4"
|
||||
BT_INIT_FILE:ccimx91 = "bluetooth-init_btnxpuart"
|
||||
BT_INIT_FILE:ccimx93 = "bluetooth-init_btnxpuart"
|
||||
BT_INIT_FILE:ccimx95 = "bluetooth-init_btbcm_hciuart"
|
||||
BT_INIT_FILE:ccmp1 = "bluetooth-init_btbcm_hciuart"
|
||||
|
||||
SRC_URI = " \
|
||||
file://bluetooth-init \
|
||||
file://${BT_INIT_FILE} \
|
||||
file://bluetooth-init.service \
|
||||
"
|
||||
|
||||
|
|
@ -18,7 +26,7 @@ inherit update-rc.d systemd
|
|||
do_install() {
|
||||
# INITSCRIPT
|
||||
install -d ${D}${sysconfdir}/init.d/
|
||||
install -m 0755 ${WORKDIR}/bluetooth-init ${D}${sysconfdir}/bluetooth-init
|
||||
install -m 0755 ${WORKDIR}/${BT_INIT_FILE} ${D}${sysconfdir}/bluetooth-init
|
||||
ln -sf /etc/bluetooth-init ${D}${sysconfdir}/init.d/bluetooth-init
|
||||
# SYSTEMD
|
||||
install -d ${D}${systemd_unitdir}/system/
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
#!/bin/sh
|
||||
#===============================================================================
|
||||
#
|
||||
# Copyright (C) 2025 by Digi International Inc.
|
||||
# Copyright (C) 2025,2026, Digi International Inc.
|
||||
# All rights reserved.
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify it
|
||||
|
|
@ -22,10 +22,14 @@ if grep -qs '\<digi,ccmp13\>' /proc/device-tree/compatible; then
|
|||
# CCMP13 - BT_REG_EN - GPIO PD13
|
||||
GPIO_CHIP="GPIOD"
|
||||
GPIO_NUMBER="13"
|
||||
else
|
||||
elif grep -qs '\<digi,ccmp15\>' /proc/device-tree/compatible; then
|
||||
# CCMP15 - BT_REG_EN - GPIO PZ6
|
||||
GPIO_CHIP="GPIOZ"
|
||||
GPIO_NUMBER="6"
|
||||
elif grep -qs '\<digi,ccimx95\>' /proc/device-tree/compatible; then
|
||||
# CCIMX95
|
||||
GPIO_CHIP="1"
|
||||
GPIO_NUMBER="18"
|
||||
fi
|
||||
|
||||
log() {
|
||||
|
|
@ -1,69 +0,0 @@
|
|||
#!/bin/sh
|
||||
#===============================================================================
|
||||
#
|
||||
# Copyright (C) 2018,2019 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_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
|
||||
modprobe btdigi
|
||||
if hciattach ttyBt qca ${BT_RATE:-3000000} -t30 ${BT_FLOW:-flow} unused ${BT_MACADDR} >${HCIATTACH_LOG} 2>&1; then
|
||||
return
|
||||
fi
|
||||
rmmod btdigi
|
||||
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
|
||||
if [ "$(tr -d '\0' 2>/dev/null </proc/device-tree/bluetooth/status)" != "disabled" ]; then
|
||||
echo -n "Starting bluetooth hardware: "
|
||||
bluetooth_init
|
||||
echo "${BT_ERROR:-done.}"
|
||||
fi
|
||||
fi
|
||||
;;
|
||||
stop)
|
||||
if [ -d "/sys/class/bluetooth/hci0" ]; then
|
||||
echo -n "Stopping bluetooth hardware: "
|
||||
killproc hciattach
|
||||
rmmod btdigi
|
||||
echo "done."
|
||||
fi
|
||||
;;
|
||||
restart)
|
||||
$0 stop
|
||||
sleep 1
|
||||
$0 start
|
||||
;;
|
||||
*)
|
||||
echo "Usage: $0 {start|stop|restart}"
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
Loading…
Reference in New Issue