Difference between revisions of "How to setup Marvell bluetooth"
From IGEP - ISEE Wiki
(→Switch-off wifi to get better bluetooth performance) |
m |
||
Line 71: | Line 71: | ||
To read CSR chip version | To read CSR chip version | ||
<pre> | <pre> | ||
− | + | bccmd -t bcsp -d /dev/ttyO1 chiprev | |
Chip revision: 0x0030 (BC4-ROM) | Chip revision: 0x0030 (BC4-ROM) | ||
</pre> | </pre> | ||
Line 96: | 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/ttyO1 psload -r bluez.psr | |
Loading PSKEY_LC_ENHANCED_POWER_TABLE ... done | Loading PSKEY_LC_ENHANCED_POWER_TABLE ... done | ||
Line 148: | Line 148: | ||
<pre> | <pre> | ||
− | + | hciattach -s 115200 /dev/ttyO1 bcsp 115200 noflow | |
− | + | hciconfig hci0 up | |
− | + | hciconfig hci0 piscan | |
− | + | 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 171: | Line 171: | ||
=== Scan for HCI bluetooth peer devices === | === Scan for HCI bluetooth peer devices === | ||
<pre> | <pre> | ||
− | + | hcitool -i hci0 scan | |
Scanning ... | Scanning ... | ||
00:1E:A4:FC:EC:2E Phone | 00:1E:A4:FC:EC:2E Phone | ||
Line 194: | Line 194: | ||
Disable wlan0 interface | Disable wlan0 interface | ||
<pre> | <pre> | ||
− | + | ifconfig wlan0 down | |
</pre> | </pre> | ||
Line 200: | Line 200: | ||
* For IGEPv2 RevC ('''IGEP0020-RC''') and IGEP COM MODULE ('''IGEP0030-RE''') series | * For IGEPv2 RevC ('''IGEP0020-RC''') and IGEP COM MODULE ('''IGEP0030-RE''') series | ||
<pre> | <pre> | ||
− | + | echo 0 > /sys/class/gpio/gpio138/value | |
</pre> | </pre> | ||
* For older IGEPv2 RevB ('''IGEP0020-RB''') series | * For older IGEPv2 RevB ('''IGEP0020-RB''') series | ||
<pre> | <pre> | ||
− | + | echo 0 > /sys/class/gpio/gpio94/value | |
</pre> | </pre> | ||
Latest revision as of 18:40, 1 October 2015
Contents
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!