Difference between revisions of "How to setup Marvell bluetooth"

From IGEP - ISEE Wiki

Jump to: navigation, search
m
 
(17 intermediate revisions by 4 users not shown)
Line 3: Line 3:
 
=== Overview of How-To  ===
 
=== Overview of How-To  ===
  
This How-To is meant to be a starting point for people to learn how to setup the bluetooth on IGEP v2 devices as quickly and easily as possible.
+
This How-To is meant to be a starting point for people to learn how to setup the bluetooth on IGEP Technology devices as quickly and easily as possible.
  
 
=== Feedback and Contributing ===
 
=== Feedback and Contributing ===
 
At any point, if you see a mistake you can contribute to this How-To.
 
At any point, if you see a mistake you can contribute to this How-To.
  
=== Setup basics ===
+
== Setup basics ==
  
The IGEP v2 has built-in a Class 2 Bluetooth 2.0 + EDR device.
+
=== Bluetooth Classes (information) ===
 +
 
 +
Some IGEP Technology boards has built-in a Class 2 Bluetooth 2.0 + EDR device.
  
 
{| border=1 class="simple"
 
{| border=1 class="simple"
Line 30: Line 32:
 
|}
 
|}
  
 +
=== Setup bluetooth internal parameters ===
  
 
By default the WIFI-BT module is not configured for single antenna, so you need to configure this, set registers settings as follows:
 
By default the WIFI-BT module is not configured for single antenna, so you need to configure this, set registers settings as follows:
Line 52: Line 55:
 
You need to be root to do this - sudo won't do!
 
You need to be root to do this - sudo won't do!
 
<pre>
 
<pre>
# mount -t debugfs none /sys/kernel/debug
+
mount -t debugfs none /sys/kernel/debug
  
# cd /sys/kernel/debug/lbs_wireless/eth1/registers/  
+
echo "0xa58c 0x40865" > /sys/kernel/debug/lbs_wireless/wlan0/registers/wrmac
 +
echo "0xa5a0 0xd24d" > /sys/kernel/debug/lbs_wireless/wlan0/registers/wrmac
 +
echo "0xa5f0 0xa027181c" > /sys/kernel/debug/lbs_wireless/wlan0/registers/wrmac
 +
</pre>
  
# echo "0xa58c 0x40865" > wrmac
+
=== Validate serial comunication to CSR bluetooth xip ===
# echo "0xa5a0 0xd24d" > wrmac
+
Configure ttyO1
# echo "0xa5f0 0xa027181c" > wrmac
+
 
 +
<pre>
 +
stty -F /dev/ttyO1 ispeed 115200 ospeed 115200 cs8 -cstopb clocal -crtscts -parodd
 
</pre>
 
</pre>
Next, you will need to load some bluetooth modules
+
 
 +
To read CSR chip version
 
<pre>
 
<pre>
# modprobe bluetooth
+
bccmd -t bcsp -d /dev/ttyO1 chiprev
# modprobe hci_uart
+
Chip revision: 0x0030 (BC4-ROM)
# modprobe l2cap
 
# modprobe rfcomm
 
# dmesg
 
Bluetooth: Core ver 2.13
 
NET: Registered protocol family 31
 
Bluetooth: HCI device and connection manager initialized
 
Bluetooth: HCI socket layer initialized
 
Bluetooth: L2CAP ver 2.11
 
Bluetooth: L2CAP socket layer initialized
 
Bluetooth: BNEP (Ethernet Emulation) ver 1.3
 
Bluetooth: BNEP filters: protocol multicast
 
Bluetooth: RFCOMM socket layer initialized
 
Bluetooth: RFCOMM TTY layer initialized
 
Bluetooth: RFCOMM ver 1.10
 
 
</pre>
 
</pre>
With your preferred editor create a bluez.psr file like this
+
 
 +
 
 +
=== Load PSKEY parameters ===
 +
With your preferred editor create a 'bluez.psr' file like this:
 
<pre>
 
<pre>
 
// PSKEY Parameters for Bluetooth RF
 
// PSKEY Parameters for Bluetooth RF
Line 98: Line 96:
 
And send the file using the bccmd tool.
 
And send the file using the bccmd tool.
 
<pre>
 
<pre>
# bccmd -t bcsp -d /dev/ttyS1 psload -r bluez.psr
+
bccmd -t bcsp -d /dev/ttyO1 psload -r bluez.psr
  
 
Loading PSKEY_LC_ENHANCED_POWER_TABLE ... done
 
Loading PSKEY_LC_ENHANCED_POWER_TABLE ... done
Line 108: Line 106:
 
</pre>
 
</pre>
  
 +
----
 +
 +
== Setup HCI device ==
 +
 +
=== Load Linux kernel modules ===
 +
 +
Next, you will need to load some bluetooth modules. Prompt:
 +
<pre>
 +
modprobe bluetooth
 +
modprobe hci_uart
 +
modprobe hidp
 +
modprobe l2cap
 +
modprobe rfcomm
 +
</pre>
 +
 +
You shoud get these logs ( using [[IGEP_firmware_Yocto|IGEP Firmware Yocto 1.2.2-3]]  ):
 +
<pre>
 +
root@igep00x0:~# modprobe bluetooth
 +
[ 1183.967773] Bluetooth: Core ver 2.15
 +
[ 1183.971588] NET: Registered protocol family 31
 +
[ 1183.976226] Bluetooth: HCI device and connection manager initialized
 +
[ 1183.982849] Bluetooth: HCI socket layer initialized
 +
root@igep00x0:~# modprobe hci_uart
 +
[ 1184.013031] Bluetooth: HCI UART driver ver 2.2
 +
[ 1184.017669] Bluetooth: HCI H4 protocol initialized
 +
[ 1184.022674] Bluetooth: HCI BCSP protocol initialized
 +
[ 1184.027832] Bluetooth: HCILL protocol initialized
 +
root@igep00x0:~# modprobe hidp
 +
[ 1184.067993] Bluetooth: L2CAP ver 2.15
 +
[ 1184.071807] Bluetooth: L2CAP socket layer initialized
 +
[ 1184.087188] Bluetooth: HIDP (Human Interface Emulation) ver 1.2
 +
root@igep00x0:~# modprobe l2cap
 +
root@igep00x0:~# modprobe rfcomm
 +
[ 1184.147399] Bluetooth: RFCOMM TTY layer initialized
 +
[ 1184.152526] Bluetooth: RFCOMM socket layer initialized
 +
[ 1184.157867] Bluetooth: RFCOMM ver 1.11
 +
</pre>
 +
 +
=== Create HCI device ===
 
Finally you can attach to device an scan for other bluetooth devices.
 
Finally you can attach to device an scan for other bluetooth devices.
  
 
<pre>
 
<pre>
# hciattach -s 115200 /dev/ttyS1 bcsp 115200 noflow
+
hciattach -s 115200 /dev/ttyO1 bcsp 115200 noflow
# hciconfig hci0 up
+
hciconfig hci0 up
# hciconfig hci0 piscan
+
hciconfig hci0 piscan
# hciconfig -a hci0
+
hciconfig -a hci0
 
hci0: Type: UART
 
hci0: Type: UART
 
BD Address: 00:02:5B:00:A5:A5 ACL MTU: 310:10 SCO MTU: 64:8
 
BD Address: 00:02:5B:00:A5:A5 ACL MTU: 310:10 SCO MTU: 64:8
Line 130: Line 167:
 
HCI Ver: 2.0 (0x3) HCI Rev: 0xc5c LMP Ver: 2.0 (0x3) LMP Subver: 0xc5c
 
HCI Ver: 2.0 (0x3) HCI Rev: 0xc5c LMP Ver: 2.0 (0x3) LMP Subver: 0xc5c
 
Manufacturer: Cambridge Silicon Radio (10)
 
Manufacturer: Cambridge Silicon Radio (10)
# hcitool -i hci0 scan
+
</pre>
 +
 
 +
=== Scan for HCI bluetooth peer devices ===
 +
<pre>
 +
hcitool -i hci0 scan
 
Scanning ...
 
Scanning ...
 
         00:1E:A4:FC:EC:2E      Phone
 
         00:1E:A4:FC:EC:2E      Phone
 
</pre>
 
</pre>
  
For best performance you need to disable WIFI, you can do this
+
=== Ping bluetooth peer device ===
 +
<pre>
 +
root@igep00x0:/etc/bluetooth# l2ping -c 4  00:1E:A4:FC:EC:2E
 +
Ping: 00:1E:A4:FC:EC:2E from 00:02:5B:00:A5:A5 (data size 44) ...
 +
44 bytes from 00:1E:A4:FC:EC:2E id 0 time 38.79ms
 +
44 bytes from 00:1E:A4:FC:EC:2E id 1 time 38.60ms
 +
44 bytes from 00:1E:A4:FC:EC:2E id 2 time 38.66ms
 +
44 bytes from 00:1E:A4:FC:EC:2E id 3 time 538.79ms
 +
4 sent, 4 received, 0% loss
 +
</pre>
 +
 
 +
== Others ==
 +
 
 +
=== Switch-off wifi to get better bluetooth performance ===
 +
For best performance you need to disable WIFI, you can do this:<br>
 +
<br>
 +
Disable wlan0 interface
 +
<pre>
 +
ifconfig wlan0 down
 +
</pre>
 +
 
 +
Switch-off "power down" line of wifi
 +
* For IGEPv2 RevC ('''IGEP0020-RC''') and IGEP COM MODULE ('''IGEP0030-RE''') series
 
<pre>
 
<pre>
# echo 0 > /sys/class/gpio/gpio94/value
+
echo 0 > /sys/class/gpio/gpio138/value
 
</pre>
 
</pre>
  
 +
* For older IGEPv2 RevB ('''IGEP0020-RB''') series
 +
<pre>
 +
echo 0 > /sys/class/gpio/gpio94/value
 +
</pre>
  
To read CSR chip version
+
=== Ensure uart2 gpio/mux configuration ===
 +
In IGEPv2 you should configure uart2_XXX pins like:
 
<pre>
 
<pre>
root@igep0020:~# bccmd -t bcsp -d /dev/ttyS1 chiprev
+
root@igep00x0:~# mount -t debugfs none /sys/kernel/debug
Chip revision: 0x0030 (BC4-ROM)
+
 
 +
root@igep00x0:~# cat /sys/kernel/debug/omap_mux/uart2_*
 +
name: uart2_cts.uart2_cts (0x48002174/0x144 = 0x0118), b ab26, t NA
 +
mode: OMAP_PIN_INPUT_PULLUP | OMAP_MUX_MODE0
 +
signals: uart2_cts | mcbsp3_dx | gpt9_pwm_evt | NA | gpio_144 | NA | NA | safe_mode
 +
 
 +
name: uart2_rts.uart2_rts (0x48002176/0x146 = 0x0000), b ab25, t NA
 +
mode: OMAP_PIN_OUTPUT | OMAP_MUX_MODE0
 +
signals: uart2_rts | mcbsp3_dr | gpt10_pwm_evt | NA | gpio_145 | NA | NA | safe_mode
 +
 
 +
name: uart2_rx.uart2_rx (0x4800217a/0x14a = 0x0100), b ad25, t NA
 +
mode: OMAP_PIN_INPUT | OMAP_MUX_MODE0
 +
signals: uart2_rx | mcbsp3_fsx | gpt8_pwm_evt | NA | gpio_147 | NA | NA | safe_mode
 +
 
 +
name: uart2_tx.uart2_tx (0x48002178/0x148 = 0x0000), b aa25, t NA
 +
mode: OMAP_PIN_OUTPUT | OMAP_MUX_MODE0
 +
signals: uart2_tx | mcbsp3_clkx | gpt11_pwm_evt | NA | gpio_146 | NA | NA | safe_mode
 
</pre>
 
</pre>
  
--- That's all folks ---
+
== External References ==
 +
[http://www.bluez.org/ BlueZ (Official Linux Bluetooth protocol stack)]<br>
 +
[http://web.inter.nl.net/users/hanscees/bluezhowto.html#up BlueZ user howto - 6.0 Get your bluetooth device up!]<br>
  
 
= See also =
 
= See also =
Line 153: Line 239:
 
*[[How to setup Marvell 88w8686 SDIO wifi]]
 
*[[How to setup Marvell 88w8686 SDIO wifi]]
  
[[Category:How to forge|Bluetooth]]
+
[[Category:Bluetooth]]

Latest revision as of 18:40, 1 October 2015

How to setup Marvell bluetooth

Overview of How-To

This How-To is meant to be a starting point for people to learn how to setup the bluetooth on IGEP Technology devices as quickly and easily as possible.

Feedback and Contributing

At any point, if you see a mistake you can contribute to this How-To.

Setup basics

Bluetooth Classes (information)

Some IGEP Technology boards has built-in a Class 2 Bluetooth 2.0 + EDR device.

Class Maximum Permitted Power
mW (dBm)
Range
(approximate)
Class 1 100 mW (20 dBm) ~100 meters
Class 2 2.5 mW (4 dBm) ~10 meters
Class 3 1 mW (0 dBm) ~1 meter

Setup bluetooth internal parameters

By default the WIFI-BT module is not configured for single antenna, so you need to configure this, set registers settings as follows:

Register offset Register Name 8686 Bx
0x8000_A58C BT Switch Control 0x40865
0x8000_A5A0 3/4W BCA mode config 0xD24D
0x8000_A5F0 BCA WLAN modes 0xA027181C

You need to be root to do this - sudo won't do!

mount -t debugfs none /sys/kernel/debug

echo "0xa58c 0x40865" > /sys/kernel/debug/lbs_wireless/wlan0/registers/wrmac 
echo "0xa5a0 0xd24d" > /sys/kernel/debug/lbs_wireless/wlan0/registers/wrmac 
echo "0xa5f0 0xa027181c" > /sys/kernel/debug/lbs_wireless/wlan0/registers/wrmac

Validate serial comunication to CSR bluetooth xip

Configure ttyO1

stty -F /dev/ttyO1 ispeed 115200 ospeed 115200 cs8 -cstopb clocal -crtscts -parodd

To read CSR chip version

bccmd -t bcsp -d /dev/ttyO1 chiprev
Chip revision: 0x0030 (BC4-ROM)


Load PSKEY parameters

With your preferred editor create a 'bluez.psr' file like this:

// PSKEY Parameters for Bluetooth RF
// (1) 0x0031 (PSKEY_LC_ENHANCED_POWER_TABLE)
&0031 = 0900 0000 3f00 4700 ec00 0f00 0000 3f00 4a00 f000 1600 0000 3f00 4d00 f400 1e00 0000 \
3f00 5000 f800 2600 0000 3f00 5500 fc00 2e00 0000 3f00 5b00 0000 3800 0000 3f00 6900 0400
// (2) 0x01f6 (PSKEY_ANA_FTRIM)
&01f6 = 001d
// (3) 0x01fe (PSKEY_ANA_FREQ)
&01fe = 6590    // 26MHz reference clock
// (4) 0x01be (PSKEY_UART_BAUDRATE)
&01be = 0x1d8  // 115200
// (5) 0x0028 (PSKEY_LC_COMBO_DISABLE_PIO_MASK)
&0028 = 0200 0000 0000
// (6) 0x002a (PSKEY_LC_COMBO_DOT11_CHANNEL_PIO_BASE)
&002a = 0011

And send the file using the bccmd tool.

bccmd -t bcsp -d /dev/ttyO1 psload -r bluez.psr

Loading PSKEY_LC_ENHANCED_POWER_TABLE ... done
Loading PSKEY_ANA_FTRIM ... done
Loading PSKEY_ANA_FREQ ... done
Loading PSKEY_UART_BAUDRATE...done
Loading PSKEY_LC_COMBO_DISABLE_PIO_MASK ... done
Loading PSKEY_LC_COMBO_DOT11_CHANNEL_PIO_BASE ... done

Setup HCI device

Load Linux kernel modules

Next, you will need to load some bluetooth modules. Prompt:

modprobe bluetooth
modprobe hci_uart
modprobe hidp
modprobe l2cap
modprobe rfcomm

You shoud get these logs ( using IGEP Firmware Yocto 1.2.2-3 ):

root@igep00x0:~# modprobe bluetooth
[ 1183.967773] Bluetooth: Core ver 2.15
[ 1183.971588] NET: Registered protocol family 31
[ 1183.976226] Bluetooth: HCI device and connection manager initialized
[ 1183.982849] Bluetooth: HCI socket layer initialized
root@igep00x0:~# modprobe hci_uart
[ 1184.013031] Bluetooth: HCI UART driver ver 2.2
[ 1184.017669] Bluetooth: HCI H4 protocol initialized
[ 1184.022674] Bluetooth: HCI BCSP protocol initialized
[ 1184.027832] Bluetooth: HCILL protocol initialized
root@igep00x0:~# modprobe hidp
[ 1184.067993] Bluetooth: L2CAP ver 2.15
[ 1184.071807] Bluetooth: L2CAP socket layer initialized
[ 1184.087188] Bluetooth: HIDP (Human Interface Emulation) ver 1.2
root@igep00x0:~# modprobe l2cap
root@igep00x0:~# modprobe rfcomm
[ 1184.147399] Bluetooth: RFCOMM TTY layer initialized
[ 1184.152526] Bluetooth: RFCOMM socket layer initialized
[ 1184.157867] Bluetooth: RFCOMM ver 1.11

Create HCI device

Finally you can attach to device an scan for other bluetooth devices.

hciattach -s 115200 /dev/ttyO1 bcsp 115200 noflow
hciconfig hci0 up
hciconfig hci0 piscan
hciconfig -a hci0
hci0:	Type: UART
	BD Address: 00:02:5B:00:A5:A5 ACL MTU: 310:10 SCO MTU: 64:8
	UP RUNNING PSCAN ISCAN 
	RX bytes:1376 acl:0 sco:0 events:25 errors:0
	TX bytes:740 acl:0 sco:0 commands:24 errors:0
	Features: 0xff 0xff 0x8f 0xfe 0x9b 0xf9 0x00 0x80
	Packet type: DM1 DM3 DM5 DH1 DH3 DH5 HV1 HV2 HV3 
	Link policy: RSWITCH HOLD SNIFF PARK 
	Link mode: SLAVE ACCEPT 
	Name: 'igep0020b (0)'
	Class: 0x120112
	Service Classes: Networking, Object Transfer
	Device Class: Computer, Handheld
	HCI Ver: 2.0 (0x3) HCI Rev: 0xc5c LMP Ver: 2.0 (0x3) LMP Subver: 0xc5c
	Manufacturer: Cambridge Silicon Radio (10)

Scan for HCI bluetooth peer devices

hcitool -i hci0 scan
Scanning ...
        00:1E:A4:FC:EC:2E       Phone

Ping bluetooth peer device

root@igep00x0:/etc/bluetooth# l2ping -c 4  00:1E:A4:FC:EC:2E
Ping: 00:1E:A4:FC:EC:2E from 00:02:5B:00:A5:A5 (data size 44) ...
44 bytes from 00:1E:A4:FC:EC:2E id 0 time 38.79ms
44 bytes from 00:1E:A4:FC:EC:2E id 1 time 38.60ms
44 bytes from 00:1E:A4:FC:EC:2E id 2 time 38.66ms
44 bytes from 00:1E:A4:FC:EC:2E id 3 time 538.79ms
4 sent, 4 received, 0% loss

Others

Switch-off wifi to get better bluetooth performance

For best performance you need to disable WIFI, you can do this:

Disable wlan0 interface

ifconfig wlan0 down

Switch-off "power down" line of wifi

  • For IGEPv2 RevC (IGEP0020-RC) and IGEP COM MODULE (IGEP0030-RE) series
echo 0 > /sys/class/gpio/gpio138/value
  • For older IGEPv2 RevB (IGEP0020-RB) series
echo 0 > /sys/class/gpio/gpio94/value

Ensure uart2 gpio/mux configuration

In IGEPv2 you should configure uart2_XXX pins like:

root@igep00x0:~# mount -t debugfs none /sys/kernel/debug

root@igep00x0:~# cat /sys/kernel/debug/omap_mux/uart2_*
name: uart2_cts.uart2_cts (0x48002174/0x144 = 0x0118), b ab26, t NA
mode: OMAP_PIN_INPUT_PULLUP | OMAP_MUX_MODE0
signals: uart2_cts | mcbsp3_dx | gpt9_pwm_evt | NA | gpio_144 | NA | NA | safe_mode

name: uart2_rts.uart2_rts (0x48002176/0x146 = 0x0000), b ab25, t NA
mode: OMAP_PIN_OUTPUT | OMAP_MUX_MODE0
signals: uart2_rts | mcbsp3_dr | gpt10_pwm_evt | NA | gpio_145 | NA | NA | safe_mode

name: uart2_rx.uart2_rx (0x4800217a/0x14a = 0x0100), b ad25, t NA
mode: OMAP_PIN_INPUT | OMAP_MUX_MODE0
signals: uart2_rx | mcbsp3_fsx | gpt8_pwm_evt | NA | gpio_147 | NA | NA | safe_mode

name: uart2_tx.uart2_tx (0x48002178/0x148 = 0x0000), b aa25, t NA
mode: OMAP_PIN_OUTPUT | OMAP_MUX_MODE0
signals: uart2_tx | mcbsp3_clkx | gpt11_pwm_evt | NA | gpio_146 | NA | NA | safe_mode

External References

BlueZ (Official Linux Bluetooth protocol stack)
BlueZ user howto - 6.0 Get your bluetooth device up!

See also