currantlabs / ble

BSD 3-Clause "New" or "Revised" License
209 stars 177 forks source link

linux: Intel Edison with Yocto cannot initialize device #27

Open deadprogram opened 7 years ago

deadprogram commented 7 years ago

When trying to run the latest ble on an Intel Edison running the latest Yocto, the ble scanner fails when trying to connect. The reason for this is that the Yocto's bluetooth does not support HCI_CHANNEL_USER

root@howtocode:~# ./scanner 
2017/01/15 13:56:00 can't new device : can't init hci: no devices available: (hci0: can't bind socket to hci user channel: invalid argument)

I had already reported this, but it was mixed in with another issue. Here is a clean report.

roylee17 commented 7 years ago

I was against the use of RAW channel with ble package as we described that kernel will also trying to manage the device and cause the behavior inconsistent.

After a second thought, if the usage is only involved scanning and advertising, without connection, it might make sense to support RAW channel.

I don't have much at this moment, but I'm open to PR if Edison wants to take on this. Recommended implementation will start with adding an additional HCI Option, which changes the default Socket Type to RAW, and the Apps (e.g. scanner) can add a flag to use this add Device().

https://github.com/currantlabs/ble/blob/master/linux/hci/option.go

Socket package will also need to a support for RAW socket, with with an new API NewRawSocket(), or ad the existing NewSocket() take a Socket Type parameter.

roylee17 commented 7 years ago

The upstream meta-intel-edison sticks to the 3.10 stable branch for a while.

http://git.yoctoproject.org/cgit/cgit.cgi/meta-intel-edison

Back porting the patch set for that kernel should work, and is recommend approach.

Bluetooth: Introduce new HCI socket channel for user operation
Bluetooth: Introduce user channel flag for HCI devices
Bluetooth: Refactor raw socket filter into more readable code

What's the complete/customized build instructions to produce your image from scratch? If you're using some public yocto meta layer, we can try patch that, too.

Quick Start
===========

1- Prepare your workspace:
$ mkdir my_Edison_Workspace

2- Get this layer:
$ git clone git://git.yoctoproject.org/meta-intel-edison

3- Make things easier with 'make':
$ ln -s meta-intel-edison/utils/Makefile.mk Makefile

4- Download all the needed dependencies:
$ make setup

5- Build Intel Edison Yocto distribution:
$ make edison-image

6- Flash the board:
deadprogram commented 7 years ago

Hi @roylee17 I use the download from https://software.intel.com/en-us/iot/hardware/edison/downloads not even building a specific image, due to trying to maintain compatibility with the main line of Intel dev tools.

roylee17 commented 7 years ago

@deadprogram Created a PR 01org/edison-linux#23. If it got merged, more recent image will reflect that change.

deadprogram commented 7 years ago

Hi @roylee17 thanks for that PR. I pinged some people in that org to see what is needed to get that merged/released.

In the meantime, can you point me to more specific instructions to how to get the patchset you used for the updated Yocto build? That will let me put a custom build on a test board and try things out.

Thanks!

roylee17 commented 7 years ago

See if the images has the kernel version, c94f772c8326db7b2529c7fdacc52f51939850a6

https://drive.google.com/file/d/0B6ksExuY43q8emxiZFNrYWZwamc/view?usp=sharing Ping me once you downloaded, so I can un-share.

deadprogram commented 7 years ago

Downloaded it, thanks.

In the meantime, the "word on the street" is that the next Edison OS update will be based on 4.2.3.x kernel.

Furthermore, seems like work might be going on over in https://github.com/ostroproject/ostro-os applies.

I am going to investigate more, and will update this issue.

bamoo456 commented 6 years ago

Hi @roylee17 Is the link https://drive.google.com/file/d/0B6ksExuY43q8emxiZFNrYWZwamc/view?usp=sharing

include patches:

Bluetooth: Introduce new HCI socket channel for user operation
Bluetooth: Introduce user channel flag for HCI devices
Bluetooth: Refactor raw socket filter into more readable code
roylee17 commented 6 years ago

No idea. Those patches are included in v3.14+. But Edison has been around for quite a while now. You may have to find out by yourself.

bamoo456 commented 6 years ago

Got it, Thanks

htot commented 6 years ago

Intel has made Edison obsolete, no new versions will come from them. However a log of work has been done to upstream. You can find my (Rocko) Yocto recipes using linux 4.16 here: https://github.com/htot/meta-intel-edison and kernel here: https://github.com/htot/linux/tree/eds-4.16.0-unified.