This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

WL1271L & Linux 3.10 : unable to set Bluetooth encryption using hciconfig

Hello,

I am using a Murata module based on WL1271L running Linux 3.10.

For my application, Bluetooth must be encrypted, so I try to enable encyption  with no success

# hciconfig hci0 version
hci0:   Type: BR/EDR  Bus: UART
        BD Address: 88:33:14:03:F4:E3  ACL MTU: 1021:4  SCO MTU: 180:4
        HCI Version: 4.0 (0x6)  Revision: 0x0
        LMP Version: 4.0 (0x6)  Subversion: 0x1f55
        Manufacturer: Texas Instruments Inc. (13)

# hciconfig hci0 features
hci0:   Type: BR/EDR  Bus: UART
        BD Address: 88:33:14:03:F4:E3  ACL MTU: 1021:4  SCO MTU: 180:4
        Features page 0: 0xff 0xfe 0x2d 0xfe 0xdb 0xff 0x7b 0x87
                <3-slot packets> <5-slot packets> <encryption> <slot offset>
                <timing accuracy> <role switch> <hold mode> <sniff mode>
                <RSSI> <channel quality> <SCO link> <HV2 packets>
                <HV3 packets> <u-law log> <A-law log> <CVSD> <power control>
                <transparent SCO> <EDR ACL 2 Mbps> <EDR ACL 3 Mbps>
                <enhanced iscan> <interlaced iscan> <interlaced pscan>
                <inquiry with RSSI> <extended SCO> <EV4 packets> <EV5 packets>
                <AFH cap. slave> <AFH class. slave> <LE support>
                <3-slot EDR ACL> <5-slot EDR ACL> <sniff subrating>
                <pause encryption> <AFH cap. master> <AFH class. master>
                <EDR eSCO 2 Mbps> <EDR eSCO 3 Mbps> <3-slot EDR eSCO>
                <extended inquiry> <LE and BR/EDR> <simple pairing>
                <encapsulated PDU> <err. data report> <non-flush flag> <LSTO>
                <inquiry TX power> <EPC> <extended features>
        Features page 1: 0x07 0x00 0x00 0x00 0x00 0x00 0x00 0x00
# hciconfig hci0

hci0:   Type: BR/EDR  Bus: UART
        BD Address: 88:33:14:03:F4:E3  ACL MTU: 1021:4  SCO MTU: 180:4
        UP RUNNING PSCAN
        RX bytes:1197 acl:0 sco:0 events:61 errors:0
        TX bytes:1595 acl:0 sco:0 commands:61 errors:0
# hciconfig hci0 encrypt
Can't set encrypt on hci0: Invalid request code (56)
# hciconfig hci0
hci0:   Type: BR/EDR  Bus: UART
        BD Address: 88:33:14:03:F4:E3  ACL MTU: 1021:4  SCO MTU: 180:4
        UP RUNNING PSCAN AUTH
        RX bytes:1211 acl:0 sco:0 events:63 errors:0
        TX bytes:1605 acl:0 sco:0 commands:63 errors:0

 

AUTH has been automatically enabled as it should be but it seems that WL1271L refuse HCI_OP_WRITE_ENCRYPT_MODE commands.

I have enabled DEBUG in hci_core.c and hci_event.c and I hace the following log in dmesg:

// Succesfull HCI_OP_WRITE_AUTH_ENABLE command

[  263.560000] hci0 start
[  263.560000] hci0 1
[  263.560000] hci0 opcode 0x0c20 plen 1
[  263.560000] skb len 4
[  263.560000] length 1
[  263.560000] hci0 cmd_cnt 1 cmd queued 1
[  263.560000] hci0 type 1 len 4
[  263.560000] hci0
[  263.560000] hci0 Event packet
[  263.560000] hci0 status 0x00
[  263.560000] hci0 opcode 0x0c20
[  263.560000] opcode 0x0c20 status 0x00
[  263.560000] hci0 opcode 0x0c20
[  263.560000] hci0 result 0x00
[  263.560000] hci0 end: err 0

// Fail HCI_OP_WRITE_ENCRYPT_MODE command


[  263.560000] hci0 start
[  263.560000] hci0 1
[  263.560000] hci0 opcode 0x0c22 plen 1
[  263.560000] skb len 4
[  263.560000] length 1
[  263.560000] hci0 cmd_cnt 1 cmd queued 1
[  263.560000] hci0 type 1 len 4
[  263.560000] hci0
[  263.570000] hci0 Event packet
[  263.570000] hci0 status 0x01
[  263.570000] hci0 opcode 0x0c22
[  263.570000] opcode 0x0c22 status 0x01
[  263.570000] hci0 opcode 0x0c22
[  263.570000] hci0 result 0x01
[  263.570000] hci0 end: err -56

Anyone has an idea?

Regards

Baptiste Moraine

  • Hi,

    Have you tried "hciconfig -a hci0 encrypt enable" or

    "hciconfig hci0 up" and "hcitool cmd 0x03 0x0022 0x00"?

  • Hi,

    Thanks for your answer.


    I tried the different commands :

    # start-stop-daemon -S --exec /usr/sbin/hciattach -- /dev/ttyS2 texas 115200
    Found a Texas Instruments' chip!
    Firmware file : /lib/firmware/TIInit_7.6.15.bts
    Loaded BTS script version 1
    texas: changing baud rate to 115200, flow control to 1
    [   66.230000] Bluetooth: HCI UART driver ver 2.2
    [   66.230000] Bluetooth: HCILL protocol initialized
    Device setup complete
    # hciconfig hci0 up
    # hciconfig -a hci0 encrypt enable
    Can't set encrypt on hci0: Invalid request code (56)
    # hcitool cmd 0x03 0x0022 0x00
    < HCI Command: ogf 0x03, ocf 0x0022, plen 1
      00
    > HCI Event: 0x0e plen 4
      01 22 0C 01

    I tried to read current encryption status with :

    # hcitool cmd 0x03 0x0021
    < HCI Command: ogf 0x03, ocf 0x0021, plen 0
    > HCI Event: 0x0e plen 4
      01 21 0C 01

    Does it help?


    Baptiste Moraine

  • Hi,

    I do have the same issue ..Any update on this ?. How to enable the encryption ? Is it enabled in firmware ?

    Pls find the logs below

    root@am335x-evm:/mytest# hciconfig hci0 encrypt
    < HCI Command: Write Authentication Enable (0x03|0x0020) plen 1
    enable 1
    > HCI Event: Command Complete (0x0e) plen 4
    Write Authentication Enable (0x03|0x0020) ncmd 1
    status 0x00
    < HCI Command: Write Encryption Mode (0x03|0x0022) plen 1
    mode 1
    > HCI Event: Command Complete (0x0e) plen 4
    Write Encryption Mode (0x03|0x0022) ncmd 1
    status 0x01
    Error: Unknown HCI Command
    Can't set encrypt on hci0: Invalid request code (56)
    root@am335x-evm:/mytest#
    root@am335x-evm:/mytest# hciconfig -a hci0 encrypt enable
    < HCI Command: Write Encryption Mode (0x03|0x0022) plen 1
    mode 1
    > HCI Event: Command Complete (0x0e) plen 4
    Write Encryption Mode (0x03|0x0022) ncmd 1
    status 0x01
    Error: Unknown HCI Command
    Can't set encrypt on hci0: Invalid request code (56)
    root@am335x-evm:/mytest#
    root@am335x-evm:/mytest# hcitool cmd 0x03 0x0022 0x00
    < HCI Command: ogf 0x03, ocf 0x0022, plen 1
    00
    < HCI Command: Write Encryption Mode (0x03|0x0022) plen 1
    mode 0
    > HCI Event: Command Complete (0x0e) plen 4
    Write Encryption Mode (0x03|0x0022) ncmd 1
    status 0x01
    Error: Unknown HCI Command
    > HCI Event: 0x0e plen 4
    01 22 0C 01

  • Hi,

    The bluetooth Specification says this command is Deprecated. Please check the section "Appendix A: Deprecated Commands, Events and Configuration Parameters" from the specification.

    Instead I think you can use Set Connection Encryption Command for a specific Connection Handle of a ACL connection. Please see the specification for more details.