WelcomeWelcome | FAQFAQ | DownloadsDownloads | WikiWiki

Author Topic: Bluetooth PAN on rpi0W and piCore 9.0.3  (Read 787 times)

Offline gjm

  • WikiUser
  • *
  • Posts: 6
Bluetooth PAN on rpi0W and piCore 9.0.3
« on: May 24, 2018, 11:54:53 AM »
Hi all,

I've been trying to setup Bluetooth on a rpi0W following various posts on here, but all seem to relate either to piCore 8.x.x and/or rpi3 so I'm really struggling to get it all working as I can't. 

Ultimately I'd like to be able to set up the rpi0W as a PAN (either GN or NAP) so that clients can access HTML files from an HTTPD running on the rpi0W but would be happy just to get the Bluetooth working in any capacity.

Device: rpi0W
OS: piCore 9.0.3

Other forum threads talk about tce firmware-rpi3-bt and bluez but I can't find anything in the TCZ's other than bluetooth-4.9.22-piCore.

Any help gratefully received.

Offline Juanito

  • Administrator
  • Hero Member
  • *****
  • Posts: 10111
Re: Bluetooth PAN on rpi0W and piCore 9.0.3
« Reply #1 on: May 24, 2018, 11:00:00 PM »
there's a bluez extension in the piCore 9.x armv7 repo - this might also work for armv6?

Offline gjm

  • WikiUser
  • *
  • Posts: 6
Re: Bluetooth PAN on rpi0W and piCore 9.0.3
« Reply #2 on: May 25, 2018, 03:41:04 AM »
Hi and many thanks for your reply.

I've taken your advice and installed the ARM7 version of BlueZ.  tce-load -i bluez returns an OK so I assume that's all good.

In one of your threads (http://forum.tinycorelinux.net/index.php/topic,20854.msg133929.html#msg133929) I follow your instructions as far as the dmesg command which completes as per your example but when I move onto the next part running dbus start I get an error "not found".  The same for trying to run bluetoothd -nd... "not found"

I'm obviously missing something here but not sure what exactly?

Offline Juanito

  • Administrator
  • Hero Member
  • *****
  • Posts: 10111
Re: Bluetooth PAN on rpi0W and piCore 9.0.3
« Reply #3 on: May 25, 2018, 04:55:58 AM »
Does the following show that dbus is loaded:
Code: [Select]
$ tce-status -i | grep dbus

Offline gjm

  • WikiUser
  • *
  • Posts: 6
Re: Bluetooth PAN on rpi0W and piCore 9.0.3
« Reply #4 on: May 25, 2018, 05:42:49 AM »
It responds with
Code: [Select]
tc@box:/mnt/mmcblk0p2/tce/optional$ tce-status -i | grep dbus
dbus
dbus-dev
dbus-glib

    [EDIT]: Replaced  tt  tags with  code  tags.  Rich
« Last Edit: May 25, 2018, 06:11:48 AM by Rich »

Offline Juanito

  • Administrator
  • Hero Member
  • *****
  • Posts: 10111
Re: Bluetooth PAN on rpi0W and piCore 9.0.3
« Reply #5 on: May 25, 2018, 05:53:01 AM »
..and this doesn't work:
Code: [Select]
$ sudo /usr/local/etc/init.d/dbus start
$ ps aux | grep dbus

Offline gjm

  • WikiUser
  • *
  • Posts: 6
Re: Bluetooth PAN on rpi0W and piCore 9.0.3
« Reply #6 on: May 25, 2018, 05:58:59 AM »
.... and that gives

Code: [Select]
tc@box:/mnt/mmcblk0p2/tce/optional$ sudo /usr/local/etc/init.d/dbus start
tc@box:/mnt/mmcblk0p2/tce/optional$ ps aux | grep dbus
 1620 tc       /usr/local/bin/dbus-daemon --system
 1622 tc       grep dbus

 dbus  didn't work previously and the only thing I've done since it didn't work is install BlueZ!

    [EDIT]: Replaced  tt  tags with  code  tags.  Rich
« Last Edit: May 25, 2018, 06:13:25 AM by Rich »

Offline gjm

  • WikiUser
  • *
  • Posts: 6
Re: Bluetooth PAN on rpi0W and piCore 9.0.3
« Reply #7 on: May 25, 2018, 06:08:43 AM »
If i then continue with your instructions and issue  sudo /usr/local/lib/bluetooth/bluetoothd -nd  I get

Code: [Select]
tc@box:/mnt/mmcblk0p2/tce/optional$ sudo /usr/local/lib/bluetooth/bluetoothd -nd
bluetoothd[1623]: Bluetooth daemon 5.43
bluetoothd[1623]: src/main.c:parse_config() parsing main.conf
bluetoothd[1623]: src/main.c:parse_config() Key file does not have key “DiscoverableTimeout” in group “General”
bluetoothd[1623]: src/main.c:parse_config() Key file does not have key “PairableTimeout” in group “General”
bluetoothd[1623]: src/main.c:parse_config() Key file does not have key “AutoConnectTimeout” in group “General”
bluetoothd[1623]: src/main.c:parse_config() Key file does not have key “Privacy” in group “General”
bluetoothd[1623]: src/main.c:parse_config() name=Rpi
bluetoothd[1623]: src/main.c:parse_config() Key file does not have key “Class” in group “General”
bluetoothd[1623]: src/main.c:parse_config() Key file does not have key “DeviceID” in group “General”
bluetoothd[1623]: src/main.c:parse_config() Key file does not have key “ReverseServiceDiscovery” in group “General”
bluetoothd[1623]: src/adapter.c:adapter_init() sending read version command
bluetoothd[1623]: Starting SDP server
bluetoothd[1623]: src/sdpd-service.c:register_device_id() Adding device id record for 0002:1d6b:0246:052b
bluetoothd[1623]: src/plugin.c:plugin_init() Loading builtin plugins
bluetoothd[1623]: src/plugin.c:add_plugin() Loading hostname plugin
bluetoothd[1623]: src/plugin.c:add_plugin() Loading wiimote plugin
bluetoothd[1623]: src/plugin.c:add_plugin() Loading autopair plugin
bluetoothd[1623]: src/plugin.c:add_plugin() Loading policy plugin
bluetoothd[1623]: src/plugin.c:add_plugin() Loading a2dp plugin
bluetoothd[1623]: src/plugin.c:add_plugin() Loading avrcp plugin
bluetoothd[1623]: src/plugin.c:add_plugin() Loading network plugin
bluetoothd[1623]: src/plugin.c:add_plugin() Loading input plugin
bluetoothd[1623]: src/plugin.c:add_plugin() Loading hog plugin
bluetoothd[1623]: src/plugin.c:add_plugin() Loading gap plugin
bluetoothd[1623]: src/plugin.c:add_plugin() Loading scanparam plugin
bluetoothd[1623]: src/plugin.c:add_plugin() Loading deviceinfo plugin
bluetoothd[1623]: src/plugin.c:plugin_init() Loading plugins /usr/local/lib/bluetooth/plugins
bluetoothd[1623]: profiles/input/suspend-none.c:suspend_init()
bluetoothd[1623]: profiles/network/manager.c:read_config() /usr/local/etc/bluetooth/network.conf: Key file does not have key “DisableSecurity” in group “General”
bluetoothd[1623]: profiles/network/manager.c:read_config() Config options: Security=true
bluetoothd[1623]: src/main.c:main() Entering main loop
bluetoothd[1623]: src/rfkill.c:rfkill_event() RFKILL event idx 0 type 1 op 0 soft 0 hard 0
bluetoothd[1623]: Bluetooth management interface 1.14 initialized
bluetoothd[1623]: src/adapter.c:read_version_complete() sending read supported commands command
bluetoothd[1623]: src/adapter.c:read_version_complete() sending read index list command
bluetoothd[1623]: src/adapter.c:read_commands_complete() Number of commands: 65
bluetoothd[1623]: src/adapter.c:read_commands_complete() Number of events: 35
bluetoothd[1623]: src/adapter.c:read_commands_complete() enabling kernel-side connection control
bluetoothd[1623]: src/adapter.c:read_index_list_complete() Number of controllers: 0

If I open up a separate terminal window and issue
Code: [Select]
hciattach /dev/ttyAMA0 bcm43xx 921600 noflowI get:
Code: [Select]
bcm43xx_init
Failed to reset chip, invalid HCI event
Can't initialize device: Success

Back in the original terminal window nothing happens until several minutes have elapsed and then I get

Code: [Select]
bluetoothd[1623]: Terminating
bluetoothd[1623]: src/adapter.c:adapter_shutdown()
bluetoothd[1623]: src/plugin.c:plugin_cleanup() Cleanup plugins
bluetoothd[1623]: profiles/input/suspend-none.c:suspend_exit()
bluetoothd[1623]: Stopping SDP server
bluetoothd[1623]: Exit

    [EDIT]: Replaced  tt  tags with  code  tags.  Rich
« Last Edit: May 25, 2018, 06:31:20 AM by Rich »

Offline Juanito

  • Administrator
  • Hero Member
  • *****
  • Posts: 10111
Re: Bluetooth PAN on rpi0W and piCore 9.0.3
« Reply #8 on: May 25, 2018, 06:35:17 AM »
My guideline was for an RPi3 - I guess an RPi0w must require slightly different commands, but I don't have one to play with..

Online Rich

  • TinyCore Moderator
  • Hero Member
  • *****
  • Posts: 5936
Re: Bluetooth PAN on rpi0W and piCore 9.0.3
« Reply #9 on: May 25, 2018, 06:40:25 AM »
Hi gjm
....  dbus  didn't work previously and the only thing I've done since it didn't work is install BlueZ!

I'm guessing you probably didn't install  dbus  previously. Installing  bluez  resulted in  dbus  being installed since it's a
dependency of  bluez.

Instead of using  tt  tags please use  code  tags. This will still preserve spacing as it too uses a monotype font in addition to
adding scroll bars for longer printouts.

Offline gjm

  • WikiUser
  • *
  • Posts: 6
Re: Bluetooth PAN on rpi0W and piCore 9.0.3
« Reply #10 on: May 25, 2018, 06:46:57 AM »
Thanks for you help Juanito, I think I'm going to go back to my base image and start afresh to see if that yields different results probably due to the install order and dependencies etc.  I will post back my findings here regardless.  Thanks again.

Rich:  Yes, sorry about the incorrect tags, point noted and taken on board for future. ;-)  And yes I think you're right about the dependencies, hence going back and starting from scratch in what, hopefully, will be the correct order.  Watch this space.

Offline Paul_123

  • Sr. Member
  • ****
  • Posts: 430
Re: Bluetooth PAN on rpi0W and piCore 9.0.3
« Reply #11 on: June 08, 2018, 04:35:16 PM »
The ZeroW is definitely a slightly different setup than a pi3.   But the default dbus.tcz works fine, at least for audio setup.  I've not done networking.

You need to grab this firmware from the armv7 repo   http://distro.ibiblio.org/tinycorelinux/9.x/armv7/tcz/firmware-rpi3-bt.tcz   This is a dependency of bluetooth-4.9.22-piCore.tcz.

Make sure you are setting up hciattach like this post.   http://forum.tinycorelinux.net/index.php/topic,20854.msg133929.html#msg133929  You will also need to load the kernel module hci_uart before running hciattach.  After hciattach has loaded the firmware and started, then you can start bluze/dbus by running /usr/local/etc/init.d/bluez start

What I cannot remember is if bluez 5.43 works with the rpi 0W.  I am using bluez 5.48 on my setups.

Note:
The sbc.tcz extension on the armv7 repo is definitely not compatible with the rpi0W, but if your are not trying to use Bluez-Alsa for audio, you should be fine.
« Last Edit: June 08, 2018, 04:39:32 PM by Paul_123 »

Offline milo77

  • WikiUser
  • *
  • Posts: 1
Re: Bluetooth PAN on rpi0W and piCore 9.0.3
« Reply #12 on: July 08, 2018, 05:19:30 PM »
Hi Paul_123,

I was wondering if you could share your setup for the RPi Zero W. I am currently struggling in enabling bluetooth.

I have currently tried those:
$ tce-load -i bluez.tcz dbus.tcz firmware-rpi3-bt.tcz libudev.tcz sbc.tcz bluetooth-4.9.22-piCore.tcz
$ sudo modprobe hci_uart

But then:
$ sudo hciattach /dev/ttyAMA0 bcm43xx 3000000 flow
Gives:
bcm43xx_init
Failed to reset chip, invalid HCI event
Can't initialize device: Success

If I try for second time I get:
Bluetooth Hardware Address:b8:27:eb:4c:9a:6d
bcm43xx_init
Initialization timed out.

Thank you!



Offline Paul_123

  • Sr. Member
  • ****
  • Posts: 430
Re: Bluetooth PAN on rpi0W and piCore 9.0.3
« Reply #13 on: July 08, 2018, 07:30:04 PM »
First, make sure that you have not disabled bluetooth in your boot config.txt

Then this is the official way of starting hciattach for all of the rpi variants.

Code: [Select]
sudo modprobe hci_uart
HCIATTACH=/usr/local/bin/hciattach
SERIAL=`grep Serial /proc/cpuinfo | cut -c19-`
B1=`echo $SERIAL | cut -c3-4`
B2=`echo $SERIAL | cut -c5-6`
B3=`echo $SERIAL | cut -c7-8`
BDADDR=`printf b8:27:eb:%02x:%02x:%02x $((0x$B1 ^ 0xaa)) $((0x$B2 ^ 0xaa)) $((0x$B3 ^ 0xaa))`

# Rpi3 Serial port
SERIAL_DEV="/dev/ttyAMA0"

if [ "$(cat /proc/device-tree/aliases/uart0)" = "$(cat /proc/device-tree/aliases/serial1)" ] ; then
if [ "$(wc -c /proc/device-tree/soc/gpio@7e200000/uart0_pins/brcm\,pins | cut -f 1 -d ' ')" = "16" ] ; then
$HCIATTACH $SERIAL_DEV bcm43xx 3000000 flow - $BDADDR
else
$HCIATTACH $SERIAL_DEV bcm43xx 921600 noflow - $BDADDR
fi
else
$HCIATTACH $SERIAL_DEV bcm43xx 460800 noflow - $BDADDR
fi

If that fails, take a look at dmesg for any clues.