Skip to content

Commit

Permalink
[package] [bluez-osmc] Add OSMC BlueZ package with transitional dummy…
Browse files Browse the repository at this point in the history
… package. Add patches for Raspberry Pi 3 Bluetooth support

Signed-off-by: Sam Nazarko <email@samnazarko.co.uk>
  • Loading branch information
samnazarko committed Mar 27, 2016
1 parent 4f42fb0 commit 11880c0
Show file tree
Hide file tree
Showing 13 changed files with 260 additions and 0 deletions.
23 changes: 23 additions & 0 deletions package/bluez-osmc/Makefile
@@ -0,0 +1,23 @@
all:
@echo "Specify a target:\nmake trans\nmake armv6l\nmake armv7\nmake i386\n"

trans:
sudo bash build.sh "trans"

armv6l:
sudo bash build.sh "armv6l"

armv7:
sudo bash build.sh "armv7"

i386:
sudo setarch i686 bash build.sh "i386"

amd64:
sudo bash build.sh "amd64"

clean:
sudo rm -f *.deb > /dev/null 2>&1
sudo rm -rf files/usr > /dev/null 2>&1
sudo rm -rf files/lib > /dev/null 2>&1
sudo rm -rf files/etc > /dev/null 2>&1
59 changes: 59 additions & 0 deletions package/bluez-osmc/build.sh
@@ -0,0 +1,59 @@
# (c) 2014-2015 Sam Nazarko
# email@samnazarko.co.uk

#!/bin/bash

. ../common.sh

if [ "$1" == "trans" ]
then
echo -e "Building transitional package"
dpkg_build files-trans ${1}-bluez-osmc.deb
exit 0
fi

VERSION="5.38"
pull_source "https://www.kernel.org/pub/linux/bluetooth/bluez-${VERSION}.tar.xz" "$(pwd)/src"
if [ $? != 0 ]; then echo -e "Error fetching connman source" && exit 1; fi
# Build in native environment
build_in_env "${1}" $(pwd) "bluez-osmc"
build_return=$?
if [ $build_return == 99 ]
then
echo -e "Building package bluez"
out=$(pwd)/files
make clean
update_sources
handle_dep "autoconf"
handle_dep "automake"
handle_dep "autopoint"
handle_dep "autotools-dev"
handle_dep "gettext"
handle_dep "libbison-dev"
handle_dep "libcap-ng-dev"
handle_dep "libdbus-1-dev"
handle_dep "libdbus-glib-1-dev"
handle_dep "libglib2.0-dev"
handle_dep "libical-dev"
handle_dep "python-dev"
handle_dep "libreadline-dev"
handle_dep "${1}-libsqlite-dev-osmc"
handle_dep "libudev-dev"
handle_dep "pkg-config"
sed '/Package/d' -i files/DEBIAN/control
echo "Package: ${1}-bluez-osmc" >> files/DEBIAN/control
pushd src/bluez-$VERSION
install_patch "../../patches" "all"
./configure --prefix=/usr --sysconfdir=/etc --localstatedir=/var
if [ $? != 0 ]; then echo -e "Configure failed!" && umount /proc/ > /dev/null 2>&1 && exit 1; fi
$BUILD
if [ $? != 0 ]; then echo -e "Build failed!" && exit 1; fi
make install DESTDIR=${out}
popd
strip_files "${out}"
fix_arch_ctl "files/DEBIAN/control"
dpkg_build files/ ${1}-bluez-osmc.deb
build_return=$?
fi
teardown_env "${1}"
exit $build_return
9 changes: 9 additions & 0 deletions package/bluez-osmc/files-trans/DEBIAN/control
@@ -0,0 +1,9 @@
Package: bluez
Origin: OSMC
Version: 5.23-3
Section: utils
Essential: No
Priority: optional
Maintainer: Sam G Nazarko <email@samnazarko.co.uk>
Description: bluez transitional package for OSMC
Architecture: all
1 change: 1 addition & 0 deletions package/bluez-osmc/files-trans/DEBIAN/debian-binary
@@ -0,0 +1 @@
2.0
10 changes: 10 additions & 0 deletions package/bluez-osmc/files/DEBIAN/control
@@ -0,0 +1,10 @@
Origin: OSMC
Version: 5.3.8-1
Section: utils
Essential: No
Priority: optional
Maintainer: Sam G Nazarko <email@samnazarko.co.uk>
Description: bluez for OSMC
Depends: dbus, kmod, libdbus-1-3, libglib2.0-0, libreadlne6, libudev1
Replaces: bluez (<< 5.28.2~)
Breaks: bluez (<< 5.28.2~)
1 change: 1 addition & 0 deletions package/bluez-osmc/files/DEBIAN/debian-binary
@@ -0,0 +1 @@
2.0
22 changes: 22 additions & 0 deletions package/bluez-osmc/files/DEBIAN/postinst
@@ -0,0 +1,22 @@
#!/bin/bash

remove_divert ()
{
if dpkg-divert --listpackage "$2" | grep -q "$DPKG_MAINTSCRIPT_PACKAGE"; then
dpkg-divert --remove --package "$DPKG_MAINTSCRIPT_PACKAGE" --rename --divert "$1" "$2"
EXIT=$?; if [ $EXIT -ne 0 ]; then exit $EXIT; fi
fi
}

if [ -z "$DPKG_MAINTSCRIPT_PACKAGE" ]; then exit 1; fi
if [ "$1" = "configure" ]; then

# remove only diverts that prior versions of this package added which are no longer needed:
# remove_divert PATH_DIV PATH_ORIG

systemctl daemon-reload
systemctl enable bluez.service >/dev/null 2>&1

if ischroot; then exit 0; fi
systemctl restart bluez.service
fi
16 changes: 16 additions & 0 deletions package/bluez-osmc/files/DEBIAN/postrm
@@ -0,0 +1,16 @@
#!/bin/bash

remove_divert ()
{
if dpkg-divert --listpackage "$2" | grep -q "$DPKG_MAINTSCRIPT_PACKAGE"; then
dpkg-divert --remove --package "$DPKG_MAINTSCRIPT_PACKAGE" --rename --divert "$1" "$2"
EXIT=$?; if [ $EXIT -ne 0 ]; then exit $EXIT; fi
fi
}

if [ -z "$DPKG_MAINTSCRIPT_PACKAGE" ]; then exit 1; fi
#if [ "$1" = "remove" ]; then

# remove all diverts that this version _and_ all prior versions of the package once added:
# remove_divert PATH_DIV PATH_ORIG
#fi
20 changes: 20 additions & 0 deletions package/bluez-osmc/files/DEBIAN/preinst
@@ -0,0 +1,20 @@
#!/bin/bash

install_divert ()
{
if ! dpkg-divert --listpackage "$2" | grep -q "$DPKG_MAINTSCRIPT_PACKAGE"; then
dpkg-divert --add --package "$DPKG_MAINTSCRIPT_PACKAGE" --rename --divert "$1" "$2"
EXIT=$?; if [ $EXIT -ne 0 ]; then exit $EXIT; fi
fi
}

if [ -z "$DPKG_MAINTSCRIPT_PACKAGE" ]; then exit 1; fi
if [ "$1" = "upgrade" ]; then touch "/var/run/${DPKG_MAINTSCRIPT_PACKAGE}_upgrade"; else rm -f "/var/run/${DPKG_MAINTSCRIPT_PACKAGE}_upgrade"; fi
if [ "$1" = "install" -o "$1" = "upgrade" ]; then

# install all diverts needed by this version of the package:
# install_divert PATH_DIV PATH_ORIG

systemctl stop bluez.service >/dev/null 2>&1
exit 0
fi
7 changes: 7 additions & 0 deletions package/bluez-osmc/files/DEBIAN/prerm
@@ -0,0 +1,7 @@
#!/bin/bash

if [ "$1" = "remove" ]; then
systemctl disable bluez.service >/dev/null 2>&1
systemctl stop bluez.service >/dev/null 2>&1
exit 0
fi
27 changes: 27 additions & 0 deletions package/bluez-osmc/patches/all-001-add-bcm43xx-3wire-variant.patch
@@ -0,0 +1,27 @@
From 9e530065e466f423c8f0efbf0ed88aaac52a6f2a Mon Sep 17 00:00:00 2001
From: Phil Elwell <phil@raspberrypi.org>
Date: Tue, 16 Feb 2016 16:40:46 +0000
Subject: [PATCH 1/4] bcm43xx: Add bcm43xx-3wire variant

---
tools/hciattach.c | 3 +++
1 file changed, 3 insertions(+)

diff --git a/tools/hciattach.c b/tools/hciattach.c
index 59a76a7..5861d33 100644
--- a/tools/hciattach.c
+++ b/tools/hciattach.c
@@ -1144,6 +1144,9 @@ struct uart_t uart[] = {
{ "bcm43xx", 0x0000, 0x0000, HCI_UART_H4, 115200, 3000000,
FLOW_CTL, DISABLE_PM, NULL, bcm43xx, NULL },

+ { "bcm43xx-3wire", 0x0000, 0x0000, HCI_UART_3WIRE, 115200, 3000000,
+ 0, DISABLE_PM, NULL, bcm43xx, NULL },
+
{ "ath3k", 0x0000, 0x0000, HCI_UART_ATH3K, 115200, 115200,
FLOW_CTL, DISABLE_PM, NULL, ath3k_ps, ath3k_pm },

--
2.1.4


@@ -0,0 +1,39 @@
From e22b98809f8f28fd1ab47be247f1549295e430bc Mon Sep 17 00:00:00 2001
From: Phil Elwell <phil@raspberrypi.org>
Date: Tue, 16 Feb 2016 16:39:09 +0000
Subject: [PATCH 2/4] bcm43xx: The UART speed must be reset after the firmware
download

---
tools/hciattach_bcm43xx.c | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/tools/hciattach_bcm43xx.c b/tools/hciattach_bcm43xx.c
index 81f38cb..0b792e0 100644
--- a/tools/hciattach_bcm43xx.c
+++ b/tools/hciattach_bcm43xx.c
@@ -366,11 +366,8 @@ int bcm43xx_init(int fd, int def_speed, int speed, struct termios *ti,
return -1;

if (bcm43xx_locate_patch(FIRMWARE_DIR, chip_name, fw_path)) {
- fprintf(stderr, "Patch not found, continue anyway\n");
+ fprintf(stderr, "Patch not found for %s, continue anyway\n", chip_name);
} else {
- if (bcm43xx_set_speed(fd, ti, speed))
- return -1;
-
if (bcm43xx_load_firmware(fd, fw_path))
return -1;

@@ -380,6 +377,7 @@ int bcm43xx_init(int fd, int def_speed, int speed, struct termios *ti,
return -1;
}

+ sleep(1);
if (bcm43xx_reset(fd))
return -1;
}
--
2.1.4


26 changes: 26 additions & 0 deletions package/bluez-osmc/patches/all-003-increase-fw-timeout.patch
@@ -0,0 +1,26 @@
From a628ea602b58a026c35c2795d996c3668b4a0f66 Mon Sep 17 00:00:00 2001
From: Phil Elwell <phil@raspberrypi.org>
Date: Wed, 20 Jan 2016 16:00:37 +0000
Subject: [PATCH 3/4] Increase firmware load timeout to 30s

---
tools/hciattach.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/hciattach.c b/tools/hciattach.c
index 5861d33..4141796 100644
--- a/tools/hciattach.c
+++ b/tools/hciattach.c
@@ -1293,7 +1293,7 @@ int main(int argc, char *argv[])
{
struct uart_t *u = NULL;
int detach, printpid, raw, opt, i, n, ld, err;
- int to = 10;
+ int to = 30;
int init_speed = 0;
int send_break = 0;
pid_t pid;
--
2.1.4


0 comments on commit 11880c0

Please sign in to comment.