Skip to content

Commit 64ee2a5

Browse files
adamoajohannbg
authored andcommitted
feat(bluetooth): implement bluetooth support in initrd
- Included a bluetooth module that installs modules, firmware, udev rules and bluetoothd. - systemd and dbus are required by bluetoothd - Include bluetooth by default if BT keyboard or combo found
1 parent 4baedd0 commit 64ee2a5

File tree

2 files changed

+75
-0
lines changed

2 files changed

+75
-0
lines changed

dracut.spec

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -343,6 +343,7 @@ echo 'dracut_rescue_image="yes"' > $RPM_BUILD_ROOT%{dracutlibdir}/dracut.conf.d/
343343
%{dracutlibdir}/modules.d/45url-lib
344344
%{dracutlibdir}/modules.d/50drm
345345
%{dracutlibdir}/modules.d/50plymouth
346+
%{dracutlibdir}/modules.d/62bluetooth
346347
%{dracutlibdir}/modules.d/80lvmmerge
347348
%{dracutlibdir}/modules.d/90btrfs
348349
%{dracutlibdir}/modules.d/90crypt
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
#!/bin/sh
2+
# This file is part of dracut.
3+
# SPDX-License-Identifier: GPL-2.0-or-later
4+
5+
# Prerequisite check(s) for module.
6+
check() {
7+
# If the binary(s) requirements are not fulfilled the module can't be installed
8+
require_any_binary /usr/lib/bluetooth/bluetoothd /usr/libexec/bluetooth/bluetoothd || return 1
9+
# Include by default if a Peripheral (0x500) is found of minor class:
10+
# * Keyboard (0x40)
11+
# * Keyboard/pointing (0xC0)
12+
grep -qiE 'Class=0x[0-9a-f]{3}5[4c]0' /var/lib/bluetooth/*/*/info 2> /dev/null && return 0
13+
14+
return 255
15+
}
16+
17+
# Module dependency requirements.
18+
depends() {
19+
# This module has external dependencies on the systemd and dbus modules.
20+
echo systemd dbus
21+
# Return 0 to include the dependent modules in the initramfs.
22+
return 0
23+
}
24+
25+
installkernel() {
26+
instmods bluetooth btrtl btintel btbcm bnep ath3k btusb rfcomm hidp
27+
inst_multiple -o \
28+
/usr/lib/firmware/ar3k/AthrBT* \
29+
/usr/lib/firmware/ar3k/ramps* \
30+
/usr/lib/firmware/ath3k-1.fw \
31+
/usr/lib/firmware/BCM2033-MD.hex \
32+
/usr/lib/firmware/bfubase.frm \
33+
/usr/lib/firmware/BT3CPCC.bin \
34+
/usr/lib/firmware/brcm/*.hcd \
35+
/usr/lib/firmware/mediatek/mt7622pr2h.bin \
36+
/usr/lib/firmware/qca/nvm* \
37+
/usr/lib/firmware/qca/crnv* \
38+
/usr/lib/firmware/qca/rampatch* \
39+
/usr/lib/firmware/qca/crbtfw* \
40+
/usr/lib/firmware/rtl_bt/* \
41+
/usr/lib/firmware/intel/ibt* \
42+
/usr/lib/firmware/ti-connectivity/TIInit_* \
43+
/usr/lib/firmware/nokia/bcmfw.bin \
44+
/usr/lib/firmware/nokia/ti1273.bin
45+
46+
}
47+
48+
# Install the required file(s) for the module in the initramfs.
49+
install() {
50+
inst_multiple \
51+
$(find /usr/libexec/bluetooth/bluetoothd /usr/lib/bluetooth/bluetoothd 2> /dev/null || :) \
52+
"${systemdsystemunitdir}/bluetooth.target" \
53+
"${systemdsystemunitdir}/bluetooth.service" \
54+
bluetoothctl
55+
56+
if [[ $hostonly ]]; then
57+
inst_multiple \
58+
/etc/bluetooth/main.conf \
59+
/etc/dbus-1/system.d/bluetooth.conf
60+
fi
61+
62+
inst_multiple $(find /var/lib/bluetooth)
63+
64+
inst_rules 69-btattach-bcm.rules 60-persistent-input.rules
65+
66+
sed -i -e \
67+
'/^\[Unit\]/aDefaultDependencies=no\
68+
Conflicts=shutdown.target\
69+
Before=shutdown.target\
70+
After=dbus.service' \
71+
"${initdir}/${systemdsystemunitdir}/bluetooth.service"
72+
73+
$SYSTEMCTL -q --root "$initdir" enable bluetooth.service
74+
}

0 commit comments

Comments
 (0)