summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarcel Ziswiler <marcel.ziswiler@toradex.com>2022-02-17 11:23:46 +0100
committerMarcel Ziswiler <marcel.ziswiler@toradex.com>2022-02-23 11:38:34 +0100
commit691c4f3f9fa5b350f54d94f0db10552a2d96d76a (patch)
tree6151a0b0ed5a614f33708a9ab583dbdbbfb8baa9
parente888365bcb116e73103d7fae3d2a9879409b7f7d (diff)
btuart: support bluetooth uart initialization
Support Bluetooth UART initialization as well as different firmware required by linking/renaming that one in a postinst script. BT UART baudrate configuration taken from the following website: http://docker.hd-wireless.com/Support/GettingStartedwiththeSPB228onPCIeUART Signed-off-by: Marcel Ziswiler <marcel.ziswiler@toradex.com>
-rw-r--r--recipes-support/btuart/btuart.bb45
-rw-r--r--recipes-support/btuart/files/COPYING5
-rw-r--r--recipes-support/btuart/files/btuart.service13
-rwxr-xr-xrecipes-support/btuart/files/btuart.sh8
4 files changed, 71 insertions, 0 deletions
diff --git a/recipes-support/btuart/btuart.bb b/recipes-support/btuart/btuart.bb
new file mode 100644
index 0000000..d59f6e4
--- /dev/null
+++ b/recipes-support/btuart/btuart.bb
@@ -0,0 +1,45 @@
+SUMMARY = "Initialize Bluetooth UART"
+DESCRIPTION = "At runtime on target make sure appropriate firmware is used and initialize Bluetooth UART"
+LICENSE = "PD"
+
+PACKAGE_ARCH = "${MACHINE_ARCH}"
+
+RRECOMMENDS_${PN} = "bluez5"
+
+SRC_URI = " \
+ file://btuart.sh \
+ file://btuart.service \
+ file://COPYING \
+"
+
+LIC_FILES_CHKSUM = "file://${WORKDIR}/COPYING;md5=1c3a7fb45253c11c74434676d84fe7dd"
+
+do_install () {
+ install -d ${D}/${sbindir}
+ install -m 0755 ${WORKDIR}/*.sh ${D}/${sbindir}
+
+ install -d ${D}${systemd_unitdir}/system/
+ install -m 0644 ${WORKDIR}/btuart.service ${D}${systemd_unitdir}/system
+}
+
+SYSTEMD_PACKAGES = "${PN}"
+SYSTEMD_SERVICE_${PN} = "btuart.service"
+
+inherit allarch systemd
+
+pkg_postinst_ontarget_${PN}_verdin-imx8mp () {
+ # only BT UART modules need our service
+ if fgrep -q V1.0 /proc/device-tree/toradex,board-rev || ! fgrep -q toradex,verdin-imx8mp-wifi /proc/device-tree/compatible; then
+ /bin/systemctl disable btuart.service
+ /bin/systemctl stop btuart.service
+ exit 0
+ fi
+
+ # V1.1A and later require sdiouart Wi-Fi/BT firmware
+ mv -f ${nonarch_base_libdir}/firmware/mrvl/sdsd8997_combo_v4.bin ${nonarch_base_libdir}/firmware/mrvl/sdsd8997_combo_v4.bin.orig
+ ln -s ${nonarch_base_libdir}/firmware/nxp/sdiouart8997_combo_v4.bin ${nonarch_base_libdir}/firmware/mrvl/sdsd8997_combo_v4.bin
+ # power-cycle Wi-Fi/BT module
+ echo -n "30b40000.mmc" > /sys/bus/platform/drivers/sdhci-esdhc-imx/unbind
+ sleep 1
+ echo -n "30b40000.mmc" > /sys/bus/platform/drivers/sdhci-esdhc-imx/bind
+}
diff --git a/recipes-support/btuart/files/COPYING b/recipes-support/btuart/files/COPYING
new file mode 100644
index 0000000..040e990
--- /dev/null
+++ b/recipes-support/btuart/files/COPYING
@@ -0,0 +1,5 @@
+This piece is software is provided by Toradex AG as sample code.
+There is no warranty for the program.
+Toradex AG put this program in public domain, uncopyrighted.
+
+Renens, Swizterland, 2008-10-23
diff --git a/recipes-support/btuart/files/btuart.service b/recipes-support/btuart/files/btuart.service
new file mode 100644
index 0000000..547f6be
--- /dev/null
+++ b/recipes-support/btuart/files/btuart.service
@@ -0,0 +1,13 @@
+[Unit]
+Description=Initialize Bluetooth UART
+Wants=bluetooth.service
+Before=bluetooth.service
+After=sys-subsystem-net-devices-mlan0.device
+After=dev-ttymxc3.device
+
+[Service]
+Type=forking
+ExecStart=/usr/sbin/btuart.sh
+
+[Install]
+WantedBy=multi-user.target
diff --git a/recipes-support/btuart/files/btuart.sh b/recipes-support/btuart/files/btuart.sh
new file mode 100755
index 0000000..c4f53c1
--- /dev/null
+++ b/recipes-support/btuart/files/btuart.sh
@@ -0,0 +1,8 @@
+#!/bin/sh
+sleep 5
+/usr/bin/hciattach /dev/ttymxc3 any 115200 flow
+/usr/sbin/rfkill unblock bluetooth
+/usr/bin/hciconfig hci0 up
+# Change BT UART baudrate to a higher speed, for example 921600
+/usr/bin/hcitool -i hci0 cmd 0x3F 0x09 0x00 0x10 0x0e 0x00
+/bin/stty -F /dev/ttymxc3 921600