<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
	<channel>
		<atom:link href="https://dev1galaxy.org/extern.php?action=feed&amp;tid=2716&amp;type=rss" rel="self" type="application/rss+xml" />
		<title><![CDATA[Dev1 Galaxy Forum / HOW TO:  Raspberry 3B Pi Internal Bluetooth]]></title>
		<link>https://dev1galaxy.org/viewtopic.php?id=2716</link>
		<description><![CDATA[The most recent posts in HOW TO:  Raspberry 3B Pi Internal Bluetooth.]]></description>
		<lastBuildDate>Tue, 26 Mar 2019 11:51:43 +0000</lastBuildDate>
		<generator>FluxBB</generator>
		<item>
			<title><![CDATA[Re: HOW TO:  Raspberry 3B Pi Internal Bluetooth]]></title>
			<link>https://dev1galaxy.org/viewtopic.php?pid=15081#p15081</link>
			<description><![CDATA[<p><strong>CapsLock Workaround Revistied</strong></p><p>It seems that changing the key mapping for the CapsLock key is not sufficient and may not be necessary:<br />I used a new installation to SD to check my notes and found I had a poor Bluetooth connection and unacceptable behaviour from the CapsLock key.</p><p>What had I not done this time around that had produced the right result last time around ?<br />I don&#039;t like the answer.&#160; It is the kind of thing that I mistrust for it smacks of &#039;magic&#039; rather than &#039;understanding&#039;.<br />Your mileage may vary, but for what it is worth ...</p><p>I used <em>bluetoothctl</em> to delete the keyboard device and rebooted the Pi.<br />I then used <em>bluetoothctl</em> to scan for the keyboard, paired with it, connect to it and then set is as trusted and rebooted the Pi once more.<br />No trouble since then.</p>]]></description>
			<author><![CDATA[dummy@example.com (NewForester)]]></author>
			<pubDate>Tue, 26 Mar 2019 11:51:43 +0000</pubDate>
			<guid>https://dev1galaxy.org/viewtopic.php?pid=15081#p15081</guid>
		</item>
		<item>
			<title><![CDATA[Re: HOW TO:  Raspberry 3B Pi Internal Bluetooth]]></title>
			<link>https://dev1galaxy.org/viewtopic.php?pid=14721#p14721</link>
			<description><![CDATA[<p><strong>CapsLock Workaround</strong></p><p>I don&#039;t use CapsLock but I do hit the key by mistake from time to time, especially on a keyboard I have not yet grown used to.</p><p>This appears to cause the Pi to lock up and accept no more input from the Bluetooth keyboard. If I waited long enough, it would accept a few more keys before appearing to lock up again. If I persisted, eventually a key would &#039;stick&#039; and I&#039;d get the same letter repeated hundreds of times. The key remained stuck even after powering off the Bluetooth keyboard. I had the same with the return key and also backspace (this ate my entire document backwards, one character at a time).</p><p><a href="https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=776363" rel="nofollow">Debian Bug report logs - #776363</a> suggests the problem has been around since 2015. The third post in this thread <a href="https://www.raspberrypi.org/forums/viewtopic.php?p=985457" rel="nofollow">CapsLock LED not working in Raspbian</a> spells out the problem and suggests a solution. It suggests the problem is Debian, not Bluetooth specific. Software rot perhaps.</p><p>First you need to ensure the Linux command line keyboard utilities are installed:</p><div class="codebox"><pre><code>    sudo apt-get install kbd</code></pre></div><p>Then add:</p><div class="codebox"><pre><code>   /usr/bin/dumpkeys | /bin/fgrep &amp;#39; 58 &amp;#39; | /bin/sed &amp;#39;s/CtrlL_Lock/Caps_Lock/g&amp;#39; | /usr/bin/loadkeys -</code></pre></div><p>to the script <em>/etc/rc.local</em> and make sure the script is executable.</p><p>This restores the &#039;default&#039;, non-Debian, behaviour of the CapsLock key and I have had no problems with keys doing the unexpected since.</p><p>Note the use of full pathnames here: <em>/etc/rc.local</em> runs without a PATH.</p>]]></description>
			<author><![CDATA[dummy@example.com (NewForester)]]></author>
			<pubDate>Sun, 10 Mar 2019 12:01:28 +0000</pubDate>
			<guid>https://dev1galaxy.org/viewtopic.php?pid=14721#p14721</guid>
		</item>
		<item>
			<title><![CDATA[Re: HOW TO:  Raspberry 3B Pi Internal Bluetooth]]></title>
			<link>https://dev1galaxy.org/viewtopic.php?pid=14720#p14720</link>
			<description><![CDATA[<p><strong>Device Pairing</strong></p><p>I have only paired a Bluetooth keyboard (with touchpad): it is all I need.</p><p>There are a lot of posts on the Internet complaining Bluetooth is not working that turn out to have been posted by folk who somehow have not learnt that Bluetooth devices require pairing.</p><p>I used <em>bluetoothctl</em> from the command line. Since I wanted to substitute the Bluetooth keyboard for the conventional keyboard, I used the &#039;trust&#039; command.</p><p>I had some trouble with this. It goes better when the internal WIFI is down (or disabled). The dialogue should go something like this:</p><div class="codebox"><pre><code>pi@devuan:~/keep/etc$ sudo bluetoothctl
[NEW] Controller B8:27:EB:2C:68:67 BlueZ 5.43 [default]

[bluetooth]# agent on
Agent registered

[bluetooth]# default-agent
Default agent request successful

[bluetooth]# scan on
Discovery started
[CHG] Controller B8:27:EB:2C:68:67 Discovering: yes</code></pre></div><p>Press the connect button on the Bluetooth keyboard, Press its return key for good measure. Wait.</p><div class="codebox"><pre><code>[NEW] Device 20:20:01:00:4D:F8 Bluetooth 3.0 Keyboard

[bluetooth]# pair 20:20:01:00:4D:F8
Attempting to pair with 20:20:01:00:4D:F8
[CHG] Device 20:20:01:00:4D:F8 Connected: yes
[agent] PIN code: 772158</code></pre></div><p>Enter the PIN code on the Bluetooth keyboard.</p><div class="codebox"><pre><code>[CHG] Device 20:20:01:00:4D:F8 Paired: yes
Pairing successful

[bluetooth]# connect 20:20:01:00:4D:F8
Attempting to connect to 20:20:01:00:4D:F8
[CHG] Device 20:20:01:00:4D:F8 Connected: yes
Connection successful
[CHG] Device 20:20:01:00:4D:F8 ServicesResolved: yes

[Bluetooth 3.0 Keyboard]# trust 20:20:01:00:4D:F8
[CHG] Device 20:20:01:00:4D:F8 Trusted: yes
Changing 20:20:01:00:4D:F8 trust succeeded

[Bluetooth 3.0 Keyboard]# quit
Agent unregistered
[DEL] Controller B8:27:EB:2C:68:67 BlueZ 5.43 [default]</code></pre></div>]]></description>
			<author><![CDATA[dummy@example.com (NewForester)]]></author>
			<pubDate>Sun, 10 Mar 2019 11:55:33 +0000</pubDate>
			<guid>https://dev1galaxy.org/viewtopic.php?pid=14720#p14720</guid>
		</item>
		<item>
			<title><![CDATA[Re: HOW TO:  Raspberry 3B Pi Internal Bluetooth]]></title>
			<link>https://dev1galaxy.org/viewtopic.php?pid=14719#p14719</link>
			<description><![CDATA[<p><strong>System Startup</strong></p><p>Here you convert a small set of files designed for systemd into a (smaller) set of files that do not. This is the fun part.</p><p>There is one file that hasn&#039;t been downloaded yet. Get it with:</p><div class="codebox"><pre><code>    wget https://raw.githubusercontent.com/RPi-Distro/raspberrypi-sys-mods/master/etc.armhf/udev/rules.d/99-com.rules</code></pre></div><p>This SUBSYSTEM rules in this file are not required:</p><div class="codebox"><pre><code>    sed -e &amp;#39;/KERNEL/,$!d&amp;#39; -i 99-com.rules</code></pre></div><p>The KERNEL rules create <em>/dev/serial0</em> and/or <em>/dev/seria11</em> apparently so that you can rewrite your now broken apps that relied on <em>/dev/ttyAMA0</em> being a console portably.</p><div class="codebox"><pre><code>    sudo cp -p 99-com.rules /etc/udev/rules.d</code></pre></div><p>There are two scripts in the <em>pi-bluetooth-0.1.10/</em> package that are required:</p><div class="codebox"><pre><code>    sudo cp -p pi-bluetooth-0.1.10/usr/bin/* /usr/bin/</code></pre></div><p>A quick sanity check is in order at this point. First that the device firmware can be loaded:</p><div class="codebox"><pre><code>    sudo modprobe hci_uart
    sudo /usr/bin/btuart
bcm43xx_init
Set Controller UART speed to 3000000 bit/s
Flash firmware /etc/firmware/brcm/BCM4345C0.hcd
Set BDADDR UART: b8:27:eb:2c:68:67
Set Controller UART speed to 3000000 bit/s
Device setup complete</code></pre></div><p>Then check the device is up and running:</p><div class="codebox"><pre><code>    hciconfig
hci0:   Type: Primary  Bus: UART
        BD Address: B8:27:EB:2C:68:67  ACL MTU: 1021:8  SCO MTU: 64:1
        UP RUNNING
        RX bytes:785 acl:0 sco:0 events:49 errors:0
        TX bytes:2256 acl:0 sco:0 commands:49 errors:0</code></pre></div><p>If things are not right, this command will show nothing.</p><p>So that these two scripts are run automatically during startup, create your own <em>90-pi-bluetooth.rules</em> and place it in <em>/etc/udev/rules.d/</em>:</p><div class="codebox"><pre><code>    # Attach hci uart
    ACTION==&amp;quot;add&amp;quot;, SUBSYSTEM==&amp;quot;module&amp;quot;, KERNEL==&amp;quot;hci_uart&amp;quot;, RUN+=&amp;quot;/usr/bin/btuart&amp;quot;

    # Raspberry Pi bluetooth module: enable routing of SCO packets to the HCI interface
    ACTION==&amp;quot;add&amp;quot;, SUBSYSTEM==&amp;quot;bluetooth&amp;quot;, KERNEL==&amp;quot;hci[0-9]&amp;quot;, RUN+=&amp;quot;/usr/bin/bthelper %k&amp;quot;</code></pre></div><p>Finally, add to <em>/etc/modules</em> a line to load <em>hci_uart</em>.</p><p>Note: the copied and edited files may not end up owned by &#039;root:root&#039;. Fix using <em>chown(1)</em></p>]]></description>
			<author><![CDATA[dummy@example.com (NewForester)]]></author>
			<pubDate>Sun, 10 Mar 2019 11:49:45 +0000</pubDate>
			<guid>https://dev1galaxy.org/viewtopic.php?pid=14719#p14719</guid>
		</item>
		<item>
			<title><![CDATA[Re: HOW TO:  Raspberry 3B Pi Internal Bluetooth]]></title>
			<link>https://dev1galaxy.org/viewtopic.php?pid=14718#p14718</link>
			<description><![CDATA[<p><strong>Building bluez</strong></p><p>There is a short cut I recommend you take first time around. All you need do is add a symbolic link:</p><div class="codebox"><pre><code>    sudo ln -s /lib/firmware /etc</code></pre></div><p>and go on to the next post.</p><p>The scenic route takes quite a while and involves some jiggery-pokery. I did it mostly because learning and being through are part of my nature but, until a serious patch for the Raspberry Pi Bluetooth comes along, rebuilding <em>bluez</em> seems unnecessary.</p><p>Installing the Devuan ascii <em>bluetooth</em> package gives you <em>bluez</em> revision <em>5.43-2+deb9u1.</em> Rebuilding gives you revision <em>5.43-2+rpt2+deb9u2</em>. That is three small patches, one of which changes the firmware directory from <em>/etc/firmware</em> to <em>/lib/firmware</em>.</p><p>There are prerequisite dependencies that need to be installed. See <em>bluez_5.43-2+rpt2+deb9u2.dsc</em>. Ignore systemd and dh-systemd:</p><div class="codebox"><pre><code>    sudo apt-get install flex bison libdbus-glib-1-dev libglib2.0-dev
    sudo apt-get install libcap-ng-dev libudev-dev libreadline-dev libical-dev check</code></pre></div><p>The <em>bluez</em> source package is, as expected, geared to building a binary package with systemd support. I downloaded the Devuan <em>bluez</em> source package but that too was geared to systemd. Odd. I tried to find notes in the Devuan documentation on how approach removing systemd from a source packages but all I found were references to script named <em>d1h</em> whose description sounded like it need a lot of set up and didn&#039;t admit to doing what I wanted.</p><p>So I used a sledgehammer approach. I changed/removed four lines in three files. You may be able to do better:</p><div class="codebox"><pre><code>--- ../raspian/bluez-5.43/debian/rules  2017-09-13 07:16:27.000000000 +0000
+++ bluez-5.43/debian/rules     2019-02-17 15:34:37.565937194 +0000

@@ -17,13 +17,13 @@
        --enable-udev \
        --enable-obex \
        --enable-client \
 -       --enable-systemd \
 +       --disable-systemd \
        --enable-threads \
        --enable-sixaxis \
        --enable-experimental

 %:
 -       dh $@ --with systemd,autoreconf
 +       dh $@ --with autoreconf

 override_dh_install:
        dh_install --list-missing</code></pre></div><div class="codebox"><pre><code>--- ../raspian/bluez-5.43/debian/bluez.install  2017-09-13 07:16:27.000000000 +0000
+++ bluez-5.43/debian/bluez.install     2019-02-17 16:12:19.313738258 +0000
@@ -26,7 +26,7 @@
 lib/udev/rules.d/97-hid2hci.rules
 attrib/gatttool usr/bin
 #-- for systemd
-lib/systemd/system/bluetooth.service
+#lib/systemd/system/bluetooth.service
 etc/dbus-1/system.d/bluetooth.conf
 usr/share/dbus-1/system-services/org.bluez.service</code></pre></div><div class="codebox"><pre><code>--- ../raspian/bluez-5.43/debian/bluez-obexd.install    2017-09-13 07:16:27.000000000 +0000
+++ bluez-5.43/debian/bluez-obexd.install       2019-02-17 16:12:57.522554333 +0000
@@ -1,3 +1,3 @@
 usr/lib/bluetooth/obexd
 usr/share/dbus-1/services/org.bluez.obex.service
-usr/lib/systemd/user/obex.service
+#usr/lib/systemd/user/obex.service</code></pre></div><p>After changing these three files, build and install the <em>bluez</em> package with:</p><div class="codebox"><pre><code>    cd bluez-5.43
    dpkg-buildpackage -b -uc -d
    cd -
    sudo dpkg -i bluez_5.43-2+rpt2+deb9u2_arm64.deb</code></pre></div><p>The build produces 12 binary packages. Depending on your specific (e.g. GUI) needs, you may need to install more than just the <em>bluez</em> binary package.</p>]]></description>
			<author><![CDATA[dummy@example.com (NewForester)]]></author>
			<pubDate>Sun, 10 Mar 2019 11:43:40 +0000</pubDate>
			<guid>https://dev1galaxy.org/viewtopic.php?pid=14718#p14718</guid>
		</item>
		<item>
			<title><![CDATA[Re: HOW TO:  Raspberry 3B Pi Internal Bluetooth]]></title>
			<link>https://dev1galaxy.org/viewtopic.php?pid=14717#p14717</link>
			<description><![CDATA[<p><strong>Building bluez-firmware</strong></p><p>The first source download includes new firmware not shipped with Devuan. To rebuild and install the <em>bluez_firmware</em> package:</p><div class="codebox"><pre><code>    cd bluez-firmware-1.2
    dpkg-buildpackage -b -uc
    cd -
    sudo dpkg -i bluez-firmware_1.2-3+rpt7_all.deb</code></pre></div>]]></description>
			<author><![CDATA[dummy@example.com (NewForester)]]></author>
			<pubDate>Sun, 10 Mar 2019 11:34:03 +0000</pubDate>
			<guid>https://dev1galaxy.org/viewtopic.php?pid=14717#p14717</guid>
		</item>
		<item>
			<title><![CDATA[Re: HOW TO:  Raspberry 3B Pi Internal Bluetooth]]></title>
			<link>https://dev1galaxy.org/viewtopic.php?pid=14716#p14716</link>
			<description><![CDATA[<p><strong>Packages</strong></p><p>Installing the Devuan binary packages should ensure packages needed for Bluetooth are installed:</p><div class="codebox"><pre><code>sudo apt-get install bluetooth bluez-firmware</code></pre></div><p>Building (even downloading) source packages requires a large number of prerequisite packages be installed first:</p><div class="codebox"><pre><code>sudo apt-get install build-essential
sudo apt-get install debhelper</code></pre></div><p>The &#039;reference&#039; distribution has several packages that are pertinent. I recommend downloading the source (not the binary) versions. They are not where you might expect to find them.</p><p>This works but is not pretty</p><div class="codebox"><pre><code>mkdir somewheretidy &amp;&amp; cd somewheretidy

# alter repository access
echo &quot;deb-src http://archive.raspberrypi.org/debian/ stretch main ui&quot; | sudo tee /etc/apt/sources.list.d/raspian-sources.list
sudo apt-get update

# download the sources
apt-get --allow-unauthenticated source bluez-firmware
apt-get --allow-unauthenticated source bluez
apt-get --allow-unauthenticated source pi-bluetooth

# restore repository access
sudo rm /etc/apt/sources.list.d/raspian-sources.list
sudo apt-get update</code></pre></div><p>There is one other file of interest but that lives in a different source repository. We&#039;ll come back to that later.</p>]]></description>
			<author><![CDATA[dummy@example.com (NewForester)]]></author>
			<pubDate>Sun, 10 Mar 2019 11:16:28 +0000</pubDate>
			<guid>https://dev1galaxy.org/viewtopic.php?pid=14716#p14716</guid>
		</item>
		<item>
			<title><![CDATA[Re: HOW TO:  Raspberry 3B Pi Internal Bluetooth]]></title>
			<link>https://dev1galaxy.org/viewtopic.php?pid=14715#p14715</link>
			<description><![CDATA[<p><strong>Preliminaries</strong></p><p>So that you do not waste a lot of time by starting out the wrong place.</p><p>What you don&#039;t need to do is use <em>/boot/overlays/pi3-disable-wifi.dtbo</em> to disable the internal WIFI device on your Pi (it might help) but you do need to make sure <em>/boot/overlays/pi3-disable-bt.dtbo</em> has not been used to disable the internal Bluetooth (by default, it isn&#039;t). If unsure where to look, try <em>/boot/config.txt</em></p><p>You should use an external WIFI USB dongle and alter your Pi&#039;s <em>/etc/network/interfaces</em> to use <em>wlan1</em> by default (change to &#039;allow-hotplug&#039;) and not <em>wlan0</em> (change to &#039;allow-manual&#039;). You could use a wired Ethernet instead but you still need to check the <em>wlan0</em> is not brought up automatically during system startup.</p><p>What is absolutely essential is to ensure <em>/etc/inittab</em> is not trying to initialise <em>/dev/ttyAMA0</em> as a serial console. That should mean adding a # to the beginning of the last line in order to comment it out. It now reads:</p><div class="codebox"><pre><code>    #T0:23:respawn:/sbin/agetty -L ttyAMA0 115200 vt100</code></pre></div><p>Reboot.</p><p>I haven&#039;t (yet) used a serial console with a Raspberry Pi (I prefer <em>ssh</em> over <em>minicom</em> and both over <em>PuTTY</em>). If you do, you may want to use <em>ttyS0</em> and you may need to change the baud rate. I recommend you read up on this first and make sure your new console arrangement is working before going any further.</p><p>Check <em>/boot/cmdline.txt</em> on your Pi. It may contain something like:</p><div class="codebox"><pre><code>    console=ttyAMA0,115200 kgdboc=ttyAMA0,115200</code></pre></div><p>You may want to change these <em>ttyS0</em> but, if you check <em>/proc/cmdline</em>, you may find system startup does this for you.</p>]]></description>
			<author><![CDATA[dummy@example.com (NewForester)]]></author>
			<pubDate>Sun, 10 Mar 2019 11:10:53 +0000</pubDate>
			<guid>https://dev1galaxy.org/viewtopic.php?pid=14715#p14715</guid>
		</item>
		<item>
			<title><![CDATA[Re: HOW TO:  Raspberry 3B Pi Internal Bluetooth]]></title>
			<link>https://dev1galaxy.org/viewtopic.php?pid=14714#p14714</link>
			<description><![CDATA[<p><strong>One-time Installation and Configuration</strong></p><p>The installation and configuration is as for the &#039;reference&#039; platform without the systemd bits.<br />This means:</p><ul><li><p>preliminary changes to the Devuan startup on your Pi</p></li><li><p>installation of firmware</p></li><li><p>building and installation bluez software (optional)</p></li><li><p>adapting some simple system startup scripts/files</p></li></ul>]]></description>
			<author><![CDATA[dummy@example.com (NewForester)]]></author>
			<pubDate>Sun, 10 Mar 2019 11:02:16 +0000</pubDate>
			<guid>https://dev1galaxy.org/viewtopic.php?pid=14714#p14714</guid>
		</item>
		<item>
			<title><![CDATA[HOW TO:  Raspberry 3B Pi Internal Bluetooth]]></title>
			<link>https://dev1galaxy.org/viewtopic.php?pid=14713#p14713</link>
			<description><![CDATA[<p>Some models of the Raspberry Pi come with <strong>internal</strong> WIFI and Bluetooth. The internal WIFI works &#039;out of the box&#039; with the Devuan ascii image for Raspberry Pi 3 but not the Bluetooth.</p><p>This how to is not about how to get external Bluetooth dongles working (I believe these should work &#039;out of the box&#039;). It describes how to install and configuration the necessary firmware and software to get the internal Bluetooth working on Devuan ascii. No GUI required.</p><p>The essential technical read is: <a href="https://github.com/raspberrypi/linux/issues/1314" rel="nofollow">How to get BT working on Pi3B</a>. By that discussion&#039;s definition, I am not &#039;clever&#039;. The notes below are hopefully simple enough for anyone to digest: just bring your own spoon. Consider them a work in progress and feel free to suggest improvements.</p><p>The essential user read is: <a href="https://www.raspberrypi.org/forums/viewtopic.php?p=1104854" rel="nofollow">RPi3 Bluetooth and Wifi don&#039;t play well together</a>. That discussion there suggests strongly that you will not be able to get the best of both worlds. This was the case in March 2016 and, sadly, is still the case in March 2019. It seems most folk use the internal WIFI and (continue) to use an external Bluetooth dongle. If that isn&#039;t for you, read on.</p><p>I used (or made reference to) the most up to date hardware / firmware / software at the time:</p><ul><li><p>Raspberry Pi 3B+</p></li><li><p>devuan_ascii_2.0.0_arm64_raspi3.img.xz (6090bec93b5b887988af0acf92e1d511)</p></li><li><p>for &#039;reference&#039;: 2018-11-13-raspbian-stretch.zip (5c5afb1448a7037be109fd69c8578a5c)</p></li></ul><p>I actually found the internal Bluetooth worked better with the Deuvan image than with the &#039;reference&#039; although I have no idea why. I was able to &#039;solve&#039; the CapsLock issue. The result is quite usable provided you don&#039;t use the internal WIFI at the same time.</p>]]></description>
			<author><![CDATA[dummy@example.com (NewForester)]]></author>
			<pubDate>Sun, 10 Mar 2019 11:00:18 +0000</pubDate>
			<guid>https://dev1galaxy.org/viewtopic.php?pid=14713#p14713</guid>
		</item>
	</channel>
</rss>
