Bluetooth hciattach on FX30S

Hi Forum,

Following the instructions for the mangoh yocto bluetooth driver build, I can get the bluetooth drivers to load and initialize correctly on my FX30S running legato 16.10.1:

[   14.882191] Bluetooth: Core ver 2.18
[   14.889913] Bluetooth: HCI device and connection manager initialized
[   14.890004] Bluetooth: HCI socket layer initialized
[   14.890035] Bluetooth: L2CAP socket layer initialized
[   14.890218] Bluetooth: SCO socket layer initialized
[   15.029360] Bluetooth: HCI UART driver ver 2.2
[   15.029421] Bluetooth: HCI H4 protocol initialized
[   15.029421] Bluetooth: HCI BCSP protocol initialized
[   15.029452] Bluetooth: HCILL protocol initialized
[   15.029452] Bluetooth: HCIATH3K protocol initialized
[   15.029482] Bluetooth: HCI Three-wire UART (H5) protocol initialized
[   17.238974] Bluetooth: RFCOMM TTY layer initialized
[   17.239066] Bluetooth: RFCOMM socket layer initialized
[   17.239157] Bluetooth: RFCOMM ver 1.11
[   18.304898] Bluetooth: HIDP (Human Interface Emulation) ver 1.2
[   18.304990] Bluetooth: HIDP socket layer initialized
[   19.335602] Bluetooth: BNEP (Ethernet Emulation) ver 1.3
[   19.335632] Bluetooth: BNEP filters: protocol multicast
[   19.335693] Bluetooth: BNEP socket layer initialized

But I can’t get the WL1831 IOT card to show up: hciattach times out trying to attach any of the available devices.

Does anyone know how to attach to the bluetooth driver on the FX30S?

The FX30S has /dev/ttyHS0 as it’s serial port and /dev/ttyHSL1 as it’s other multiplexed UART port: I’ve tried mapping both UARTs to legato applications ( AT!MAPUART? gives 17,17 ):

./hciattach -r /dev/ttyHS0 bcsp 115200
BCSP initialization timed out

You mean HSL0 not HS0 right?

Also, how did you manage to get the bluetooth driver activated on the FX30? I tried by following but when I execute the application, I get

| =ERR= |[1754] | modprobe: module bluetooth not found in modules.dep

Did you use the fx30_wp85* package?

Thank you.

yes, it was HSL0…if you get that modprobe error, try doing

dmesg | grep -i 'bluetooth'

and see if the bluetooth drivers show up. That error means that the bluetooth drivers didn’t get built in to the yocto image. If you followed the guide you made have run into this problem here . It will require rebuilding the image but this time with a -f (minus f) in the first bitbake command:

bitbake linux-yocto -c kernel_configme -f

Hi mahtab,
Can you try the hciattach using /dev/ttyHSL1 instead of 0? The FX30 differs from the mangOH and has UART1 to the IOT slot.

hi @cchenry,

I tried that but no luck. But I am using an FX30S which is not the same as the FX30 as far as UART mappings go, surely ? And also, there is an issue with the FX30/ FX30S and tiwifi, so that may have something to do with it (but I don’t know for sure). I’ll try an FX30 tomorrow instead of an FX30S.

The FX30 and FX30S are identical for the IOT slot routing (UART1). The FX30S uses UART0 to the DB9 serial port while the FX30 doesn’t route UART0.

What issue are you having with tiwifi? Are you calling it manually or as part of the wlan0 pre-up like the mangOH?

tiwifi - as pre-installed - is configured for mangoh. It has to be changed as per this post .

I don’t know if that also affects the bluetooth driver, I’ve just started looking at it, but they are on the same card so maybe that could be relevant to this problem.

First, thank you @mahtab
I tried the same on my FX30 and I got the same initialization error when I start the application:
=ERR= |[5492] | Initialization timed out.
=ERR= |[5492] | Can't get device info: No such device

My UART is configured in mode 17:
root@fx30:~# microcom -E /dev/ttyAT
!MAPUART: 17,17


And I connect on HSL1.

I did not make any change regarding twifi on my FX30 if that is of importance.

About the bluetooth util app, I commented the following lines:
if [ ! -d "/sys/class/gpio/gpio13" ]; then
echo 13 > /sys/class/gpio/export
echo up > /sys/class/gpio/gpio13/pull
sleep 1

mux 1 # UART1 to IoT slot 0
mux 15 # Take IoT slot 0 out of reset
sleep 1
Because there is no mux command on the FX30 and there is only 1 IoT Card port. So maybe there is an issue related to this part I had to comment. @mahtab, did you do the same?

Hi @GabiSRC,

Yeah I’m basically at the same place you are…and stuck too. The configuration has to be different for the FX30 than it is for mangOH, more than just using a different /dev/tty* to attach to. I notice that gpio47 is no longer available on the FX30 when it has that cwe flashed on it, I think that’s a clue that somewhere some tweaking needs to be done. Changing the tiwifi script hasn’t helped, I will try to investigate but if anyone else has any solutions it would be really helpful.

I think you should keep the GPIO13 configuration, the IOT card may need that pin pulled high, but mux1 and mux15 can definitely be removed.

As an experiment, could you please try this: Boot up the FX30S without the IOT card inserted, log in, then insert the card and run the script?

@cchenry I’ve done that, and something does happen - the firmware file gets picked up. The subsequent error is a different one, as below:

root@fx30:/legato/systems/current/appsWriteable/bluetoothUtil/bin# sh ./ 
PWD is: /legato/systems/current/appsWriteable/bluetoothUtil/bin
Found a Texas Instruments' chip!
Firmware file : /legato/systems/current/apps/bluetoothUtil/read-only/bin/TIInit_11.8.32.bts
Loaded BTS script version 1
texas: changing baud rate to 3000000, flow control to 1
Can't init device hci0: Cannot assign requested address (99)Can't initialize device: Cannot assign requested address
Can't get device info: No such device: 

According to the TI wilink website, the chip looks for the firmware file in the /lib/firmware directory, is there any way to put it there by default ( putting the card in and out is a tad impractical :wink: )

I also tried building the TI_ST driver in to the yocto build, but I don’t think it’s worked

OK, a bit of further investigation reveals that hciattach is complaining about initializing the MAC address of the bluetooth part of the TI wl1832 IOT card. I suspect the problem is a bit deeper than that though because trying to manually set the MAC address with, for example:

./hcitool cmd 0x3f 0x0006 0x01 0x23 0x45 0x67 0x89 0xab

doesn’t work; hcitool complains about ‘a bad file descriptor’. Rebuilding the binaries in the bluetoothUtils project by dpfrey with the latest versions also doesn’t work.

I also tried but still the same
root@fx30:/legato/systems/current/appsWriteable/bluetoothUtil/bin# ./
PWD is: /legato/systems/current/appsWriteable/bluetoothUtil/bin
Initialization timed out.
Can't get device info: No such device

I do not have a texas sensor but I have another bluetooth sensor, maybe it could explain why I do not have anything even if I suppose the bluetoothUtil should be universal for all bluetooth sensors

If I get anything else, I’ll let you know :wink:

If you don’t have a texas sensor, you may have to change the bletoothUtil app. The TIInit_11.8.32.bts file in the bluetoothUtil/bin directory is specifically for TI Wilink chips and even then a specific subset of them. Also I guess you’d need to change the ‘texas’ in

hciattach /dev/ttyHS0 texas 115200 flow

to whichever your device is ( you can check this man page here or search further for your device…i think ‘any’ is an acceptable parameter as well

There should be a patch (bluez-00-custom_ti_firmware_directory.patch) that changes the location of the firmware file to:

The build_bluez_util script doesn’t work. I have tried it on different legato versions. On 16.10.1 it builds but hciattach doesn’t run. On 17.6.0 it doesn’t build, crashes out with the error:

config.status: error: cannot find input file: `'
Failed in

But anyway, the versions of the bluez binaries packaged in the demo are already patched ones aren’t they ?

Yes, the binaries should be patched already. Try installing “libtool” and then run the build script (if you need to build the tools).

Could you post the HSL1 settings?
stty -F /dev/ttyHSL1 -a

Maybe try with no flow control?
stty -F /dev/ttyHSL1 -crtscts
hciattach /dev/ttyHSL1 texas 115200 noflow

PS, you’re actually ahead of me as well. My hciattach is failing with the Initialization timed out.

Hi @cchenry,

this is what stty gives:

root@fx30:/legato/apps/2f2481778f965a2d93e088c30eb25ece/read-only/bin# stty -F /dev/ttyHSL1 -a
speed 9600 baud;stty: /dev/ttyHSL1
line = 0;
intr = ^C; quit = ^\; erase = ^?; kill = ^U; eof = ^D; eol = <undef>; eol2 = <undef>; swtch = <undef>; start = ^Q; stop = ^S;    s usp = ^Z; rprnt = ^R; werase = ^W; lnext = ^V;
flush = ^O; min = 1; time = 0;
-parenb -parodd cs8 hupcl -cstopb cread clocal crtscts
-ignbrk -brkint -ignpar -parmrk -inpck -istrip -inlcr -igncr icrnl ixon -ixoff -iuclc -ixany -imaxbel -iutf8
opost -olcuc -ocrnl onlcr -onocr -onlret -ofill -ofdel nl0 cr0 tab0 bs0 vt0 ff0
isig icanon iexten echo echoe echok -echonl -noflsh -xcase -tostop -echoprt echoctl echoke

but I don’t think that’s the issue…

I had a look at the patch, where it changed the firmware directory location, in …/bluez/tools/hciattach_ti.c, the line

sprintf(firmware_file_name, FIRMWARE_DIRECTORY "TIInit_%d.%d.%d.bts", chip, maj_ver, min_ver);

that’s missing a comma - and there’s a compiler warning, but it goes ahead and builds anyway. I changed it and hardcoded the string to the directory and filename, the warning goes away and it builds, but I still have some either shell issues or compile issues on my system, because I get errors like

 ./hciattach: line 1: syntax error: unexpected ")"
 ./hciconfig: line 4: syntax error: unexpected ")"

I’d like to fix those and get the hci tools going with everything up to date.

Update: with the demo hci- binaries, patched, and using

 hciattach /dev/ttyHSL1 any 115200 flow

with any instead of texas, I can get hci0 up.

So the conclusion I make from all this is that the patch needs to be patched.

So, I finally get the time to try with any, and I get an error at the end:
root@fx30:/legato/apps/e0d0a1631b75f51c01a659e398b5c876/read-only/bin# ./
PWD is: /legato/apps/e0d0a1631b75f51c01a659e398b5c876/read-only/bin
Device setup complete
hci0: Type: BR/EDR Bus: UART
BD Address: 00:00:00:00:00:00 ACL MTU: 0:0 SCO MTU: 0:0
RX bytes:0 acl:0 sco:0 events:0 errors:0
TX bytes:4 acl:0 sco:0 commands:1 errors:0
Can't init device hci0: Connection timed out (110)

I do not know if this is due to my bluetooth device requiring some action or something else to be attached.

I will try with another bluetooth device tomorrow.

And after hci0 get initialized, I am not sure how to talk with the bluetooth device…

Anyway, I’ll keep you posted