Discussion:
How to run up CSR chip without eeprom with BLUEZ ?
skyflame
2008-06-12 05:54:47 UTC
Permalink
Hi

I post this question on bluez-user before , But I think here might be the right place , so I put it here again.

My chip is CSR's bc4 A06 Rom which do not have eeprom and need to send pskey to init after power up.

Thanks to attaboyu and henry , They told me a way to do it with following process :

1. add --enable-bccmd feature while configure the bluez-utils
2. use bccmd after hci0 is up:
3. $bccmd -t hci psload -r /csr.psr

But I try it , and meet some problem:

the bluez-utils/tools/example.psr seems not comply with my chip, so I write another one as:

// PSKEY_ANA_FREQ
&01fe = 0FA0

// PSKEY_UART_BAUD_RATE
&01be = 0EBF

And then after hciconfig hci0 up I use

bccmd -t hci psload -r csr.psr

the two key is write successfully , but if I enable the debug I can see the chip continue to receive messages , seems something wrong with the head.

I remove the debug message so that you can see the log more clear:

~ #
~ # bccmd -t hci psload csr.psr
Loading PSKEY_ANA_FREQ ... done
Loading PSKEY_UART_BAUDRATE ... done

if I using -r in psload the result is :

~ # bccmd -t hci psload -r csr.psr
Loading PSKEY_ANA_FREQ ... done
Loading PSKEY_UART_BAUDRATE ... done
~ #
~ # bcsp_recv: Error in BCSP hdr checksum

both one could not work for hcitool scan:

~ # hcitool -i hci0 scan
Scanning ...
Inquiry failed: Connection timed out

and as long as this bcsp_recv: Error in BCSP hdr checksum happen
the bcsp interface seems dead , type bccmd again will show :

~ # bccmd -t hci psload -r csr.psr
Can't read version info for hci0: Connection timed out (110)

seems after warm reset the connection is bad.

So , I wonder, when using hciattach the baudrate is set to 115200
but after the uart_baudrate is set, the baudrate is set to 921600 it might cause the problem

Then I set &01be = 01d8 to keep the baudrate as 115200

But still the same.

Then if I remove the uart_baud_rate setting from the psr file

the warm reboot is ok:

~ # bccmd -t hci psload -r csr.psr
Loading PSKEY_ANA_FREQ ... done

but the chip seems to lost the sync and go back to the tshy state !

~ # hcitool -i hci0 scan
Scanning ...
bcsp_pkt_cull: Peer acked invalid packet
bcsp_handle_le_pkt: Found a LE sync pkt, card has reset
bcsp_pkt_cull: Peer acked invalid packet
bcsp_handle_le_pkt: Found a LE sync pkt, card has reset
bcsp_pkt_cull: Peer acked invalid packet
.
.
.
.


what is the right process ? Can any one help me out ?
Thanks

Raymond
skyflame
2008-06-13 01:01:22 UTC
Permalink
Raymond,
Have you tried to use psr file from your demo package.
If demo package works then its psr file should be
good.
Hi Heny

the csr's demo do not use bluez , it is so called bchs, and it don't have
psr file , it send the pskey in it's startup function.

I send the same pskey by psr file yesterday, it's not working

And I think the problem is not what kind of pskey I should send :

But , if I set the uart baudrate with pskey, after warm reset, the
connection with the chip is lost.

If I do not set the baudrate pskey, after warm reset, the chip turn to it's
start stat call tshy stat ... and then every thing went wrong.

Do you encounter such things? Can you set the baudrate and after warmreset
the chip still work ?

Thanks.
I only have experience for CSR with eeprom where psr
file is preload.
-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://sourceforge.net/services/buy/index.php
skyflame
2008-06-13 05:42:46 UTC
Permalink
Hi

When I try bccmd pslist and psread on my csr bt chip , I get nothing
output ? why is that ?

~ # bccmd psget -s 0x0 0x01ab
Map SCO over PCM: 0x0002 (2)
~ #
~ # bccmd pslist
~ #
~ # bccmd psread
~ #

Raymond


-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://sourceforge.net/services/buy/index.php
skyflame
2008-06-13 03:43:39 UTC
Permalink
Hi
Raymond,
One year ago, I have a project using CSR wifi and
bluetooth. If demo does not use bluez, that means it
uses CSR bluetooth stack not bluez stack from kernel.
Why do you think you are using bluez stack?
I feel you are using CSR bluetooth stack.
Both the demo and bluez is compiled by myself, I use different software to
test it
So I know exactly what stack I am using.
Can you tell me what you do to invoke kernel
bluetooth?
When I using CSR's BCHS stack, it's build with the demo in a single app and
the only relation with kernel is the uart driver.

While when using bluez, I insert bluetooth.ko and hci_uart.ko

and I use hciattach which will use bluez-libs. So I am for sure it's using
Bluez stack instead of csr's
You need to make it clear how do you bring up bluex
stack.
---henry
-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://sourceforge.net/services/buy/index.php
Sanja Kolundzija
2008-06-13 08:55:19 UTC
Permalink
Post by skyflame
what is the right process ? Can any one help me out ?
Thanks
 
Post by skyflame
Raymond
Hi Raymond,

we are using BC6 ROM, and also had problems initializing it. This is the procedure that works for us:

1. We run bccmd before hciattach!

bccmd -t BCSP -d /dev/ttyS2 psload -r pskeys.psr

Obviously, BC6 is connected to ttyS2.

pskeys.psr looks like this:
 
// PSKEY_BDADDR
&0001 = 0044 5566 0033 1122
// PSKEY_UART_BAUDRATE - 921600
&01be = 0ebf
// PSKEY_ANA_FREQ
&01fe = 6590

Before executing bccmd, chip has baudrate 38400. After executing bccmd, baudrate will be 921600, so hciattach has to use that speed. 

bccmd without -r didn't work for us.
 

2. Now we run hciattach:

hciattach -s 921600 /dev/ttyS2 bcsp 921600 noflow

After this we do hciconfig hci0 reset, and continue working with hci0 device normally from BlueZ.

Regards,
Sanja


-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://sourceforge.net/services/buy/index.php
skyflame
2008-06-16 01:40:33 UTC
Permalink
Hi Sanja

Thanks for your instruction !!
I found it behavior on my board a little different from you :

If I using -r in the bccmd:

~ # bccmd -t bcsp -d /dev/ttyS1 psload -r csr.psr
Loading PSKEY_ANA_FREQ ... done
Loading PSKEY_UART_BAUDRATE ... done
Loading PSKEY_UART_SEQ_WINSIZE ... done
Loading PSKEY_BDADDR ... done
Loading PSKEY_PCM_CONFIG32 ... done
Loading PSKEY_PCM_FORMAT ... done
Loading PSKEY_HOSTIO_MAP_SCO_PCM ... done
Loading PSKEY_HOSTIO_MAP_SCO_CODEC ... done
Loading PSKEY_CODEC_PIO ... done
Loading PSKEY_ANA_FTRIM ... done
~ #
~ # hciattach -s 921600 /dev/ttyS1 bcsp 921600
BCSP initialization timed out

It won't work,
If I don't do reset at the same cmd, but instead do it seperately:

~ # bccmd -t bcsp -d /dev/ttyS1 psload csr.psr
Loading PSKEY_ANA_FREQ ... done
Loading PSKEY_UART_BAUDRATE ... done
Loading PSKEY_UART_SEQ_WINSIZE ... done
Loading PSKEY_BDADDR ... done
Loading PSKEY_PCM_CONFIG32 ... done
Loading PSKEY_PCM_FORMAT ... done
Loading PSKEY_HOSTIO_MAP_SCO_PCM ... done
Loading PSKEY_HOSTIO_MAP_SCO_CODEC ... done
Loading PSKEY_CODEC_PIO ... done
Loading PSKEY_ANA_FTRIM ... done
~ #
~ # bccmd -t bcsp -d /dev/ttyS1 warmreset
~ #
~ # hciattach -s 921600 /dev/ttyS1 bcsp 921600
~ #
~ # hciconfig hci0 up
~ #

Seems it can connect to the chip, but still, pskey don't set right , I can
read it out and see it's still the reset value ......

~ # bccmd psget -s 0x0 0x01be
UART Baud rate: 0x0000 (0)

I try to use following cmd to see whether the cmd is write in to the chip,
but :

~ # bccmd -t bcsp -d /dev/ttyS1 psget -s 0x0 0x1be
UART Baud rate: 0x0000 (0)
~ #
~ # bccmd -t bcsp -d /dev/ttyS1 psset -s 0x0 0x1be 0x0ebf
~ #
~ # bccmd -t bcsp -d /dev/ttyS1 psget -s 0x0 0x1be
UART Baud rate: 0x0000 (0)

seems chip just reset it self between two bccmd with bcsp protocol, and lost
everything write to it.

But if I set up the pskey use hci protocol after hciconfig up, it's ok. but
reset lost the connection:

~ # hciattach -s 38400 /dev/ttyS1 bcsp
~ #
~ # hciconfig hci0 up
~ #
~ # bccmd psget -s 0x0 0x1be
UART Baud rate: 0x0000 (0)
~ #
~ # bccmd psset -s 0x0 0x1be 0x01d8
~ #
~ # bccmd psget -s 0x0 0x1be
UART Baud rate: 0x01d8 (472)

~ # bccmd warmreset
~ # ~ # bcsp_recv: Error in BCSP hdr checksum

Sigh ... Do you have any idea what might be wrong for my operation ?

Raymond


-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://sourceforge.net/services/buy/index.php
Sanja Kolundzija
2008-06-16 19:52:24 UTC
Permalink
Hi Raymond,
Post by skyflame
~ # bccmd -t bcsp -d /dev/ttyS1 psload -r csr.psr
Loading PSKEY_ANA_FREQ ... done
Loading PSKEY_UART_BAUDRATE ... done
Loading PSKEY_UART_SEQ_WINSIZE ... done
Loading PSKEY_BDADDR ... done
Loading PSKEY_PCM_CONFIG32 ... done
Loading PSKEY_PCM_FORMAT ... done
Loading PSKEY_HOSTIO_MAP_SCO_PCM ... done
Loading PSKEY_HOSTIO_MAP_SCO_CODEC ... done
Loading PSKEY_CODEC_PIO ... done
Loading PSKEY_ANA_FTRIM ... done
~ #
~ # hciattach -s 921600 /dev/ttyS1 bcsp 921600
BCSP initialization timed out
Which baud rate do you set in your .psr file? You should use the same
speed in hciattach command, otherwise chip will be initialized to one
speed, and hciattach will try to connect using another one.
Post by skyflame
I try to use following cmd to see whether the cmd is write in to the chip,
~ # bccmd -t bcsp -d /dev/ttyS1 psget -s 0x0 0x1be
UART Baud rate: 0x0000 (0)
~ #
~ # bccmd -t bcsp -d /dev/ttyS1 psset -s 0x0 0x1be 0x0ebf
~ #
~ # bccmd -t bcsp -d /dev/ttyS1 psget -s 0x0 0x1be
UART Baud rate: 0x0000 (0)
seems chip just reset it self between two bccmd with bcsp protocol, and lost
everything write to it.
Yes, I had the same behaviour, and only if I use -r with first bccmd
things worked. Reading the fault code returned FAULT_HOSTIO_INVALID_ACK
(the chip received a BCSP ACK for a message it has not sent) - based on
this I conclude that repeating bccmd messes the chips state machine
during BCHS protocol initialization.

Regards,
Sanja



-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://sourceforge.net/services/buy/index.php
skyflame
2008-06-17 01:34:49 UTC
Permalink
Hi Sanja
Post by skyflame
~ # bccmd -t bcsp -d /dev/ttyS1 psload -r csr.psr
Loading PSKEY_ANA_FREQ ... done
Loading PSKEY_UART_BAUDRATE ... done
Loading PSKEY_UART_SEQ_WINSIZE ... done
Loading PSKEY_BDADDR ... done
Loading PSKEY_PCM_CONFIG32 ... done
Loading PSKEY_PCM_FORMAT ... done
Loading PSKEY_HOSTIO_MAP_SCO_PCM ... done
Loading PSKEY_HOSTIO_MAP_SCO_CODEC ... done
Loading PSKEY_CODEC_PIO ... done
Loading PSKEY_ANA_FTRIM ... done
~ #
~ # hciattach -s 921600 /dev/ttyS1 bcsp 921600
BCSP initialization timed out
Which baud rate do you set in your .psr file? You should use the same
speed in hciattach command, otherwise chip will be initialized to one
speed, and hciattach will try to connect using another one.
I did set it to 0xebf for 921600:
this is my psr file , actually I wirte this psr file according to the value
I used in CSR bchs stack's boot_strap , these setting in bchs's stack can
make the chip working normally :

// PSKEY_ANA_FREQ
&01fe = 0FA0

// PSKEY_UART_BAUD_RATE
&01be = 0EBF


// PSKEY_UART_SEQ_WINSIZE
&0407 = 0006

// BDADDR
&0001 = 1122 3344 5566 7788

// PCM_CONFIG32
&01b3 = 0080 0906

// PCM_FORMAT
&01b6 = 0060

// MAP_SCO_PCM
&01ab = 0001

// MAP_SCO_CODEC
&01b0 = 0000

// CODEC_PIO
&01b9 = 000b

// ANA_FTRIM
&01f6 = 0025
Post by skyflame
I try to use following cmd to see whether the cmd is write in to the chip,
~ # bccmd -t bcsp -d /dev/ttyS1 psget -s 0x0 0x1be
UART Baud rate: 0x0000 (0)
~ #
~ # bccmd -t bcsp -d /dev/ttyS1 psset -s 0x0 0x1be 0x0ebf
~ #
~ # bccmd -t bcsp -d /dev/ttyS1 psget -s 0x0 0x1be
UART Baud rate: 0x0000 (0)
seems chip just reset it self between two bccmd with bcsp protocol, and lost
everything write to it.
Yes, I had the same behaviour, and only if I use -r with first bccmd
things worked. Reading the fault code returned FAULT_HOSTIO_INVALID_ACK
(the chip received a BCSP ACK for a message it has not sent) - based on
this I conclude that repeating bccmd messes the chips state machine
during BCHS protocol initialization.
Thanks god, I finally find something that work the same way as you 8 )
though this is also not so promising...
I had plan to modify the bccmd to set the pskey and read the pskey at one
time, to see what make the bccmd not working for second time. Maybe it help
to understand the stack behavior.

Thanks.

Raymond


-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://sourceforge.net/services/buy/index.php
skyflame
2008-06-17 04:05:12 UTC
Permalink
Hi sanja, attaboyu, henry

Thanks for your help, I can do the hcitool scan now!

It's my bad, I set the ANA_FREQ in worng way,
At first I try bccmd -t bcsp way to set the ana_freq, And find it not
work,
and I use bccmd -t bcsp -d /dev/ttyS1 psget -s 0x0 0x1fe to read the
value
but it says
Can't execute command: No such device or address (6)

So I remove it.

And when I do the following test again , I add it back, But ... shame ,
My chip is using 40M crystal , When I calculate the value I put 4000 in calc
to get 0xfa0 , But it should be 40000 and thus 0x9c40

I check my csr.psr and correct it just now it works now.

And I understand now, why bccmd -t bcsp -d /dev/ttyS1 psget -s 0x0 0x1fe
got nothing at the biginning. This pskey unlike the other pskey say 0x1be ,
they have a "psrom" version value, so before you set it, you can read it out
from "psrom" ( which can be done by -s 0x0 say "default" ) , and after you
setting them , you can also read it out from "psram" , this pskey do not
have default value in "psrom" ( strange ? ) and only after you successfully
setting it , it can be read out.

( However, It is really strange here, without setting this value, why
hciattach can connect the chip for the first time, while do a warmreset , it
won't ? Is csr's chip do a self uart baudrate adjustment to match the host
for the first time ? )

Thanks for all of you's help on this issue!

So My process now is :

boot up the fs

insmod bluetooth.ko
insmod hci_uart.ko
insmod l2cap.ko
insmod rfcomm.ko

bccmd -t bcsp -d /dev/ttyS1 psload -r csr.psr

hciattach -s 921600 /dev/ttyS1 bcsp 921600
hciconfig hci0 up
hciconfig hci0 piscan
hcitool -i hci0 scan

Thanks again

Hope I do not get further problems with those bluez daemons 8 )

Raymond
Post by skyflame
~ # bccmd -t bcsp -d /dev/ttyS1 psload -r csr.psr
Loading PSKEY_ANA_FREQ ... done
Loading PSKEY_UART_BAUDRATE ... done
Loading PSKEY_UART_SEQ_WINSIZE ... done
Loading PSKEY_BDADDR ... done
Loading PSKEY_PCM_CONFIG32 ... done
Loading PSKEY_PCM_FORMAT ... done
Loading PSKEY_HOSTIO_MAP_SCO_PCM ... done
Loading PSKEY_HOSTIO_MAP_SCO_CODEC ... done
Loading PSKEY_CODEC_PIO ... done
Loading PSKEY_ANA_FTRIM ... done
~ #
~ # hciattach -s 921600 /dev/ttyS1 bcsp 921600
BCSP initialization timed out
Which baud rate do you set in your .psr file? You should use the same
speed in hciattach command, otherwise chip will be initialized to one
speed, and hciattach will try to connect using another one.
Post by skyflame
I try to use following cmd to see whether the cmd is write in to the chip,
~ # bccmd -t bcsp -d /dev/ttyS1 psget -s 0x0 0x1be
UART Baud rate: 0x0000 (0)
~ #
~ # bccmd -t bcsp -d /dev/ttyS1 psset -s 0x0 0x1be 0x0ebf
~ #
~ # bccmd -t bcsp -d /dev/ttyS1 psget -s 0x0 0x1be
UART Baud rate: 0x0000 (0)
seems chip just reset it self between two bccmd with bcsp protocol, and lost
everything write to it.
Yes, I had the same behaviour, and only if I use -r with first bccmd
things worked. Reading the fault code returned FAULT_HOSTIO_INVALID_ACK
(the chip received a BCSP ACK for a message it has not sent) - based on
this I conclude that repeating bccmd messes the chips state machine
during BCHS protocol initialization.

Regards,
Sanja




-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://sourceforge.net/services/buy/index.php
skyflame
2008-06-17 08:18:18 UTC
Permalink
Hi

I want to run up an hid daemon to connect hid device.

I notice that there are several bin as :

hidd
hid2hci
bluetoothd-service-input

I try to figure out what is their difference by man, however , the man
has only very short description. And also , I did not find many documents on
how to write the related config files for each bluez daemons.

So
1. Is there any good documents on describe the setting of different
bluez daemons ? Or is there any good sample on setting up the daemons from
scratch on embedded board ?
2. I can see on pc and on some system, it run bluetoothd-service-input
but no hidd found. Is that hidd is out of date and replaced ?
3. Is the same situation with bluetoothd-service-audio and etc ?
4. Is that possible to use bluez to simulate a hid device ? say
providing mouse function instead of acting as a server to use bt mouse ?

Thanks.

Raymond


-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://sourceforge.net/services/buy/index.php
Sanja Kolundzija
2008-06-17 08:25:09 UTC
Permalink
Hi Raymond,

great that it works! These CSR ROM devices can be really frustrating.
Post by skyflame
( However, It is really strange here, without setting this value, why
hciattach can connect the chip for the first time, while do a
warmreset , it
Post by skyflame
won't ? Is csr's chip do a self uart baudrate adjustment to match the host
for the first time ? )
Yes, you are right, they perform auto-baud procedure at the beginning.
They don't have any value set, but guess from the incoming message what
is the baud rate. That's why if you look with the scope at signals, you
see that chip doesn't reply to the first message from the processor, but
needs typically few messages to guess the baud rate.

Regards,
Sanja

-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://sourceforge.net/services/buy/index.php
skyflame
2008-06-17 01:38:17 UTC
Permalink
Hi Henry
Raymond,
1. Is your board designed by your company or purchased
from a vendor?
Designed by ourself, And I have run csr's bchs stack up and can play music,
So I think the bluetooth hardware is ok.
2. How do you know you use a correct psr file for
initialization?
I write the psr file according to the pskey I set in the csr's bchs stack,
They should work unless, I don't know : Bluez need more pskey setting to run
up the chip ?
I prefer to believe that the might setting process might have some wrong in
there.


-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://sourceforge.net/services/buy/index.php
skyflame
2008-06-18 00:45:33 UTC
Permalink
Henry
Why do not you guys use PStool provided by CSR to
generate psr file? It will reduce lots of hassle
experienced for initialization.
I only have bluesuit v1.22 on hand, do you got v2.0?
Also , I do not have casira board on hand 8 )
---henry
-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://sourceforge.net/services/buy/index.php
skyflame
2008-06-18 03:28:59 UTC
Permalink
Hi
I am try to build the audio related bin in bluez-utilits.
And I am use ./configure --enable-all , I found even if i build and
install all the package it depends on, the audio dir still do not get build.

Then I check the configure script, and found that only if you
using --enable-audio , then the audio with get built.

Is that designed to do so ?

Raymond


-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://sourceforge.net/services/buy/index.php

Loading...