diff --git a/config/sources/rk3328.conf b/config/sources/rk3328.conf index 96f5ba43b..4d78840e6 100644 --- a/config/sources/rk3328.conf +++ b/config/sources/rk3328.conf @@ -108,5 +108,18 @@ family_tweaks() echo "ttyFIQ0" >> $SDCARD/etc/securetty if [[ $BOARD == z28pro ]]; then echo "fdtfile=rockchip/rk3328-z28pro.dtb" >> $SDCARD/boot/armbianEnv.txt + chroot $SDCARD /bin/bash -c "systemctl --no-reload enable z28pro-bluetooth.service >/dev/null 2>&1" fi } + +family_tweaks_bsp() +{ + if [[ $BOARD == z28pro ]]; then + mkdir -p $destination/usr/local/bin + # Bluetooth + install -m 755 $SRC/packages/bsp/rk3328/z28pro/8822b_hciattach $destination/usr/bin + install -m 755 $SRC/packages/bsp/rk3328/z28pro/start_bt.sh $destination/usr/local/bin + cp $SRC/packages/bsp/rk3328/z28pro/z28pro-bluetooth.service $destination/lib/systemd/system/ + fi +} + diff --git a/packages/bsp/rk3328/z28pro/8822b_hciattach b/packages/bsp/rk3328/z28pro/8822b_hciattach new file mode 100755 index 000000000..42115b339 Binary files /dev/null and b/packages/bsp/rk3328/z28pro/8822b_hciattach differ diff --git a/packages/bsp/rk3328/z28pro/start_bt.sh b/packages/bsp/rk3328/z28pro/start_bt.sh new file mode 100644 index 000000000..31dbb369b --- /dev/null +++ b/packages/bsp/rk3328/z28pro/start_bt.sh @@ -0,0 +1,26 @@ +#!/bin/bash + +function die_on_error { + if [ ! $? = 0 ]; then + echo $1 + exit 1 + fi +} + + +# Kill any rtk_hciattach actually running. +# Do not complain if we didn't kill anything. +killall -q -SIGTERM 8822b_hciattach + +echo "We must stop getty now, You must physically disconnect your USB-UART-Adapter!" +systemctl stop serial-getty@ttyS2 || die_on_error "Could not stop getty" + +echo "Using /dev/ttyS2 for Bluetooth" + +echo "Power cycle 8822BS BT-section" +rfkill block bluetooth +sleep 2 +rfkill unblock bluetooth +echo "Start attaching" + +/usr/bin/8822b_hciattach -n -s 115200 /dev/ttyS2 rtk_h5 || die_on_error "Could not create hci0 through rtk_hciattach. Did you remove your USB-UART-Adapter?" diff --git a/packages/bsp/rk3328/z28pro/z28pro-bluetooth.service b/packages/bsp/rk3328/z28pro/z28pro-bluetooth.service new file mode 100644 index 000000000..9fbf5ecb5 --- /dev/null +++ b/packages/bsp/rk3328/z28pro/z28pro-bluetooth.service @@ -0,0 +1,11 @@ +[Unit] +Description=Realtek H5 bluetooth support +Before=bluetooth.service + +[Service] +Type=oneshot +ExecStart=/bin/bash /usr/local/bin/start_bt.sh +Restart=no + +[Install] +WantedBy=multi-user.target