alexf
Posts: 9
Joined: Tue Aug 07, 2012 2:20 pm

hciattach failing

Wed Aug 08, 2012 9:52 pm

Hi,

I'm trying to use hciattach to connect to a bluetooth module over UART but I am getting an error message:

Can't set line discipline: Invalid argument
Can't initialize device: Invalid argument

It looks like this is because /* Set TTY to N_HCI line discipline */ is failing. I think N_HCI is something that the kernel supplies. Can anyone tell me whether this should work under Raspbian?

Thanks

plugwash
Forum Moderator
Forum Moderator
Posts: 3477
Joined: Wed Dec 28, 2011 11:45 pm

Re: hciattach failing

Thu Aug 09, 2012 12:39 am

Can you tell us exactly what configuration you are using and what you are doing when you get the error?

alexf
Posts: 9
Joined: Tue Aug 07, 2012 2:20 pm

Re: hciattach failing

Thu Aug 09, 2012 10:16 am

Hi,

I'm using the Raspbian image on the downloads page of raspberrypi.org. I've installed the bluetooth package with 'aptitude install bluetooth'. I downloaded the bluez libs and tools from the bluez website and have built those (I realise this is unnecessary at this point but I want to tinker later).

I've stopped getty on the UART with the instructions from http://www.raspberrypi.org/phpBB3/viewt ... 45#p139945

I connected a CSR bluetooth module set up for BCSP at 115200 baud to the UART pins (tx and rx).

Then:
> hciattach ttyAMA0 bcsp 115200 noflow
Can't set line discipline: Invalid argument
Can't initialize device: Invalid argument

Thanks

plugwash
Forum Moderator
Forum Moderator
Posts: 3477
Joined: Wed Dec 28, 2011 11:45 pm

Re: hciattach failing

Fri Aug 10, 2012 12:23 am

what user are you running this command as?

alexf
Posts: 9
Joined: Tue Aug 07, 2012 2:20 pm

Re: hciattach failing

Fri Aug 10, 2012 7:55 am

I'm running this as 'pi'. I think I also had a go with using sudo and got the same but I'm not sure.

Wendo
Posts: 142
Joined: Sun Jun 10, 2012 8:27 pm

Re: hciattach failing

Fri Aug 10, 2012 8:29 am

According to this

http://embedded.seattle.intel-research. ... _Bluetooth

you need to be calling it with /dev/ttyAMA0, not just ttyAMA0. I guess it would also make sense to confirm all the modules are laoded or compiled into the kernel too

Although trying it here I get the same result with both which is

BCSP initialization timed out

However that takes 5-10 seconds to return.

If I change bcsp to any I get

Can't set line discipline: Invalid argument
Can't initialize device: Invalid argument

returned immediately. I'm guessing you're getting yours returned immediately too

I should note that I have run a GPS on this UART before so the other processes that are usually setup have been disabled.

alexf
Posts: 9
Joined: Tue Aug 07, 2012 2:20 pm

Re: hciattach failing

Fri Aug 10, 2012 9:19 am

The hciattach man page says you can drop the /dev/ part but it is worth trying anyway, I'll give it a go later.

Checking that the modules are compiled and loaded is definitely something I want to try. It looks (from your link) like I should try modprobe. hci_uart I think is the important one here. Is there anything else that I need to do to check everything is compiled and loaded?

Thanks

Wendo
Posts: 142
Joined: Sun Jun 10, 2012 8:27 pm

Re: hciattach failing

Fri Aug 10, 2012 9:25 am

I don't really know, I've never used any of the bluetooth stuff :)

But, I'm on raspbian and since it at least tries to do stuff here without anything connected I would guess the modules etc are all loaded as required or compiled in. The big question is what do you see if you disconnect your device entirely, do you see the same

BCSP initialization timed out

as I do with nothing connected or do you continue to get the same messages you're getting, and do they appear immediately after you execute the command, or does it take some seconds.

alexf
Posts: 9
Joined: Tue Aug 07, 2012 2:20 pm

Re: hciattach failing

Fri Aug 10, 2012 11:01 pm

It looks like I don't have the hci_uart kernel module. It doesn't appear to be part of Raspbian. I can't work how to add this module. I guess I need to get the source and compile it but I can't find that. Can anyone help me with that?

Sorry Wendo I didn't see the second half of your first post. If I run hciattach with nothing plugged in I get the timeout message after a few seconds. If I do plug in the bluetooth module I get the line discipline error immediately. I've found the hciattach source and the line discipline error means it has got further than the point where I'd get the timeout.

Thanks

geoffhall
Posts: 2
Joined: Thu Sep 27, 2012 1:31 pm

Re: hciattach failing

Mon Oct 22, 2012 8:23 pm

Hi Alex,

Did you get bluetooth over the UART working? I'm interested in trying this myself.
Did you have to do anything special?

Thanks

alexf
Posts: 9
Joined: Tue Aug 07, 2012 2:20 pm

Re: hciattach failing

Tue Nov 20, 2012 10:48 pm

Hi Geoff,

Sorry for the slow reply. I'm afraid I didn't get it going. I got a little further but no success, if anyone else manages I'd be very pleased to hear what they did. I'll detail here what I can remember of what I did to see if it is of any use to anyone else.

I stopped ttyAMA0 being used by getty by following the instructions in viewtopic.php?p=139945#p139945

I compiled the hci_uart module and installed that. To do this you need the kernel headers which don't seem to be generally available so I compiled the kernel on my pi (this takes a long time but isn't difficult and once started can be left to get on with it) then you can compile the module from source.

After this I tried the hciattach function again. I got another error message but I can't remember what it said. Some googling told me that I should check rfkill isn't blocking something or other. rfkill requires an rfkill module which I didn't have built or running so I don't think that is the problem but I tried building and installing the rfkill module anyway. As far as I can remember that is where I gave up. I'm trying to resurrect it all now but I've upgraded everything since then (kernel 3.1.9+ to 3.2.27+) so think I might have to go about recompiling the kernel again.

Hope some of that helps someone.

Geoff, did you get anywhere with it?

Alex

abhishek010
Posts: 1
Joined: Tue Feb 19, 2013 4:01 am

Re: hciattach failing

Tue Feb 19, 2013 4:05 am

Hi
I am using a Bluetooth Bee connected to raspberry Pi on RX, TX pin, I want to transfer some data from Pc to Raspberry Pi through Bluethooth, and then receiving the data, raspberry Pi should then data to andrino through SPI. Where will be the data stored when the raspberry Pi receives data through bluetooth, I mean in which Buffer?

Abhishek Gupta

Return to “Raspbian”