From a20aadbeec692cfaffe9a71a2068cd5450bc90cf Mon Sep 17 00:00:00 2001 From: Arturo Buzarra Date: Fri, 6 Jun 2025 13:26:03 +0200 Subject: [PATCH] bluez5-init: add Bluetooth init script for CCMP1x platforms The HCI_UART Bluetooth driver does not support suspend-to-RAM operation, so the driver must be loaded and unloaded manually. This commit adds support for the Bluetooth initialization script used across Digi platforms, specifically for ConnectCore MP13 and MP15. https://onedigi.atlassian.net/browse/DEL-9650 Signed-off-by: Arturo Buzarra --- meta-digi-arm/conf/machine/ccmp13-dvk.conf | 3 - meta-digi-arm/conf/machine/ccmp15-dvk.conf | 3 - .../recipes-kernel/linux/linux-dey_6.6.bb | 4 + .../recipes-connectivity/bluez/bluez5-init.bb | 8 +- .../bluez/bluez5-init/ccmp1/bluetooth-init | 93 +++++++++++++++++++ .../{stm32mpcommon => ccmp2}/bluetooth-init | 0 6 files changed, 102 insertions(+), 9 deletions(-) create mode 100644 meta-digi-dey/recipes-connectivity/bluez/bluez5-init/ccmp1/bluetooth-init rename meta-digi-dey/recipes-connectivity/bluez/bluez5-init/{stm32mpcommon => ccmp2}/bluetooth-init (100%) diff --git a/meta-digi-arm/conf/machine/ccmp13-dvk.conf b/meta-digi-arm/conf/machine/ccmp13-dvk.conf index 9302b5215..0fad3d8de 100644 --- a/meta-digi-arm/conf/machine/ccmp13-dvk.conf +++ b/meta-digi-arm/conf/machine/ccmp13-dvk.conf @@ -146,9 +146,6 @@ HAS_WIFI_VIRTWLANS = "true" # Set this platform without graphical support IS_HEADLESS = "true" -# Remove additional bluetooth packages -MACHINE_BLUETOOTH_EXTRA_INSTALL = "" - # XBee XBEE_RESET_N_GPIO ?= "GPIOG@15" XBEE_TTY ?= "ttySTM2" diff --git a/meta-digi-arm/conf/machine/ccmp15-dvk.conf b/meta-digi-arm/conf/machine/ccmp15-dvk.conf index 0462335ac..1f30afb6a 100644 --- a/meta-digi-arm/conf/machine/ccmp15-dvk.conf +++ b/meta-digi-arm/conf/machine/ccmp15-dvk.conf @@ -159,9 +159,6 @@ MKUBIFS_ARGS ?= "-m 2048 -e 126976 -c 8191" # Wireless external module HAS_WIFI_VIRTWLANS = "true" -# Remove additional bluetooth packages -MACHINE_BLUETOOTH_EXTRA_INSTALL = "" - # XBee XBEE_RESET_N_GPIO ?= "GPIOZ@2" XBEE_TTY ?= "ttySTM2" diff --git a/meta-digi-arm/recipes-kernel/linux/linux-dey_6.6.bb b/meta-digi-arm/recipes-kernel/linux/linux-dey_6.6.bb index 99764725b..835092307 100644 --- a/meta-digi-arm/recipes-kernel/linux/linux-dey_6.6.bb +++ b/meta-digi-arm/recipes-kernel/linux/linux-dey_6.6.bb @@ -46,6 +46,10 @@ do_compile:append:stm32mpcommon() { fi } +# Blacklist hci_uart module. It will be managed by the bluetooth-init script +KERNEL_MODULE_PROBECONF:ccmp1 += "hci_uart" +module_conf_hci_uart:ccmp1 = "blacklist hci_uart" + do_install:append:stm32mpcommon() { if ${@bb.utils.contains('MACHINE_FEATURES','gpu','true','false',d)}; then # when ACCEPT_EULA are filled diff --git a/meta-digi-dey/recipes-connectivity/bluez/bluez5-init.bb b/meta-digi-dey/recipes-connectivity/bluez/bluez5-init.bb index fe596bbab..f6633b090 100644 --- a/meta-digi-dey/recipes-connectivity/bluez/bluez5-init.bb +++ b/meta-digi-dey/recipes-connectivity/bluez/bluez5-init.bb @@ -1,4 +1,4 @@ -# Copyright (C) 2022-2024, Digi International Inc. +# Copyright (C) 2022-2025, Digi International Inc. SUMMARY = "Bluetooth init scripts" LICENSE = "GPL-2.0-only" @@ -60,7 +60,9 @@ RDEPENDS:${PN} = "initscripts-functions" # IW61x Bluetooth support requires the WiFi FW support RDEPENDS:${PN}:append:ccimx9 = " firmware-nxp-wifi-nxpiw612-sdio" -RDEPENDS:${PN}:append:ccmp25 = " firmware-murata-infineon" +# Murata - Infineon combo chip requires both WiFi and Bluetooth firmware +RDEPENDS:${PN}:append:ccmp1 = " firmware-murata-infineon" +RDEPENDS:${PN}:append:ccmp2 = " firmware-murata-infineon" PACKAGE_ARCH = "${MACHINE_ARCH}" -COMPATIBLE_MACHINE = "(ccimx6$|ccimx6ul|ccimx8m|ccimx8x|ccimx9|ccmp25)" +COMPATIBLE_MACHINE = "(ccimx6$|ccimx6ul|ccimx8m|ccimx8x|ccimx9|ccmp1|ccmp2)" diff --git a/meta-digi-dey/recipes-connectivity/bluez/bluez5-init/ccmp1/bluetooth-init b/meta-digi-dey/recipes-connectivity/bluez/bluez5-init/ccmp1/bluetooth-init new file mode 100644 index 000000000..1971a47c4 --- /dev/null +++ b/meta-digi-dey/recipes-connectivity/bluez/bluez5-init/ccmp1/bluetooth-init @@ -0,0 +1,93 @@ +#!/bin/sh +#=============================================================================== +# +# Copyright (C) 2025 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 interface +# +#=============================================================================== + +SCRIPTNAME="$(basename ${0})" +RETRIES=3 +HCI_IFACE="hci0" +MODULE_NAME="hci_uart" + +if grep -qs '\' /proc/device-tree/compatible; then + # CCMP13 - BT_REG_EN - GPIO PD13 + GPIO_CHIP="GPIOD" + GPIO_NUMBER="13" +else + # CCMP15 - BT_REG_EN - GPIO PZ6 + GPIO_CHIP="GPIOZ" + GPIO_NUMBER="6" +fi + +log() { + if type "systemd-cat" >/dev/null 2>/dev/null; then + systemd-cat -p "${1}" -t "${SCRIPTNAME}" printf "%s" "${2}" + else + logger -p "${1}" -t "${SCRIPTNAME}" "${2}" + fi +} + +bt_power() { + gpioset "${GPIO_CHIP}" "${GPIO_NUMBER}"="${1}" +} + +is_kernel_module_loaded() { + lsmod | grep -qs -w "^${MODULE_NAME}" +} + +bt_init() { + # If module is already loaded, skip + is_kernel_module_loaded && log info "kernel module already present, skipping" && return 1 + + for i in $(seq ${RETRIES}); do + # Perform a power cycle + bt_power 0 + sleep 0.5 + bt_power 1 + + # Load manually the kernel module + modprobe "${MODULE_NAME}" + sleep 1 + is_kernel_module_loaded && log info "Bluetooth activated" && return 0 + + log err "Cannot initialize Bluetooth, retrying..." + done + + log err "Failed to initialize Bluetooth interface" + return 1 +} + +bt_stop() { + hciconfig ${HCI_IFACE} down + # Unload HCI driver instance + rmmod hci_uart + rmmod btbcm + # Disable Bluetooth chip + bt_power 0 && log info "Bluetooth disabled" && return 0 +} + +case "$1" in + start) + bt_init + ;; + stop) + bt_stop + ;; + restart) + $0 stop + $0 start + ;; + *) + echo "Usage: $0 {start|stop|restart}" + exit 1 + ;; +esac diff --git a/meta-digi-dey/recipes-connectivity/bluez/bluez5-init/stm32mpcommon/bluetooth-init b/meta-digi-dey/recipes-connectivity/bluez/bluez5-init/ccmp2/bluetooth-init similarity index 100% rename from meta-digi-dey/recipes-connectivity/bluez/bluez5-init/stm32mpcommon/bluetooth-init rename to meta-digi-dey/recipes-connectivity/bluez/bluez5-init/ccmp2/bluetooth-init