2018-05-15 08:52:15

by Sean Wang

[permalink] [raw]
Subject: [PATCH v2 0/7] add support for Bluetooth on MT7622 SoC

From: Sean Wang <[email protected]>

v2 and changes since v1
- Dropped patches already being applied
- Rewirte the whole driver using btuart [1], and add slight extension
of btuart to fit into btmtkuart driver. Beware that [1] is also pulled
into one part of the series for avoiding any breakage when the patchset
is being compiled.

[1] btuart
https://www.spinics.net/lists/linux-bluetooth/msg74918.html

v1:

Hi,

This patchset introduces built-in Bluetooth support on MT7622 SoC.
And, it should be simple to make an extension to support other
MediaTek SoCs with adjusting a few of changes on the initialization
sequence of the device.

Before the main driver is being introduced, a few of things about
power-domain management should be re-worked for serdev core and MediaTek
SCPSYS to allow the Bluetooth to properly power up.

Patch 2: add a generic way attaching power domain to serdev
Patch 3 and 4: add cleanups with reuse APIs from Linux core
Patch 5: fix a limitation about power enablement Bluetooth depends on
Patch 1, 6 and 7: the major part of adding Bluetooth support to MT7622

Sean

Marcel Holtmann (1):
Bluetooth: Add new serdev based driver for UART attached controllers

Sean Wang (6):
dt-bindings: net: bluetooth: Add mediatek-bluetooth
serdev: add dev_pm_domain_attach|detach()
Bluetooth: Add new quirk for non-persistent setup settings
Bluetooth: Extend btuart driver for join more vendor devices
Bluetooth: mediatek: Add protocol support for MediaTek serial devices
MAINTAINERS: add an entry for MediaTek Bluetooth driver

.../devicetree/bindings/net/mediatek-bluetooth.txt | 35 ++
MAINTAINERS | 8 +
drivers/bluetooth/Kconfig | 23 +
drivers/bluetooth/Makefile | 3 +
drivers/bluetooth/btmtkuart.c | 383 +++++++++++++++
drivers/bluetooth/btmtkuart.h | 119 +++++
drivers/bluetooth/btuart.c | 527 +++++++++++++++++++++
drivers/bluetooth/btuart.h | 30 ++
drivers/tty/serdev/core.c | 14 +-
include/net/bluetooth/hci.h | 9 +
net/bluetooth/hci_core.c | 3 +-
11 files changed, 1152 insertions(+), 2 deletions(-)
create mode 100644 Documentation/devicetree/bindings/net/mediatek-bluetooth.txt
create mode 100644 drivers/bluetooth/btmtkuart.c
create mode 100644 drivers/bluetooth/btmtkuart.h
create mode 100644 drivers/bluetooth/btuart.c
create mode 100644 drivers/bluetooth/btuart.h

--
2.7.4


2018-05-30 06:26:42

by Marcel Holtmann

[permalink] [raw]
Subject: Re: [PATCH v2 4/7] Bluetooth: Add new quirk for non-persistent setup settings

Hi Sean,

>>>>>>
>>>>>> [ ... ]
>
> [ ... ]
>
>>> I post it as plain text as below
>>>
>>>
>>> Bluetooth monitor ver 5.37
>>> = Note: Linux version 4.16.0-rc1+ (aarch64) 0.641494
>>> = Note: Bluetooth subsystem version 2.22 0.641502
>>> = New Index: 00:00:46:76:22:01 (BR/EDR,UART,hci0) [hci0] 0.641505
>>> * Unknown packet (code 14 len 30) 0.641509
>>> 01 00 00 00 02 00 01 0e 00 01 00 00 00 10 62 6c ..............bl
>>> 75 65 74 6f 6f 74 68 64 00 00 00 00 00 00 uetoothd......
>>> * Unknown packet (code 14 len 30) 0.641592
>>> 02 00 00 00 02 00 01 0e 00 01 00 00 00 10 62 74 ..............bt
>>> 6d 6f 6e 00 00 00 00 00 00 00 00 00 00 00 mon...........
>>> * Unknown packet (code 16 len 7) [hci0] 6.536771
>>> 01 00 00 00 05 00 01 .......
>>> = Open Index: 00:00:46:76:22:01 [hci0] 6.717019
>>> = Index Info: 00:00:46:76:22:01 (MediaTek, Inc.) [hci0] 6.717030
>>
>> can you try with the latest BlueZ 5.49 or git version. Seems it actually stumbles over the extra packet here. Fun fact is that I can not get a backtrace to pin-point the issue in btmon and why it crashes.
>>
>
> I had less experience updating user land BlueZ, but I can try it as possible and see whether Unknown packets still are present at newest version BlueZ. Hopefully I don't misunderstand your point here.

please use the latest btmon and check if it can read your trace.

>>>> HCI Event: Unknown (0xe4) plen 5 [hci0] 6.741093
>>> 02 01 01 00 00 .....
>>>> HCI Event: Unknown (0xe4) plen 5 [hci0] 6.742088
>>> 02 01 01 00 00 .....
>>>> HCI Event: Unknown (0xe4) plen 5 [hci0] 6.743102
>>> 02 01 01 00 00 .....
>>>> HCI Event: Unknown (0xe4) plen 5 [hci0] 6.744105
>>> 02 01 01 00 00 .....
>>>> HCI Event: Unknown (0xe4) plen 5 [hci0] 6.745109
>>> 02 01 01 00 00 .....
>>>> HCI Event: Unknown (0xe4) plen 5 [hci0] 6.746104
>>> 02 01 01 00 00 .....
>>>> HCI Event: Unknown (0xe4) plen 5 [hci0] 6.747097
>>> 02 01 01 00 00 .....
>>>> HCI Event: Unknown (0xe4) plen 5 [hci0] 6.748090
>>> 02 01 01 00 00 .....
>>>> HCI Event: Unknown (0xe4) plen 5 [hci0] 6.749078
>>> 02 01 01 00 00 .....
>>>> HCI Event: Unknown (0xe4) plen 5 [hci0] 6.750070
>>> 02 01 01 00 00 .....
>>>> HCI Event: Unknown (0xe4) plen 5 [hci0] 6.751061
>>> 02 01 01 00 00 .....
>>>> HCI Event: Unknown (0xe4) plen 5 [hci0] 6.752054
>>> 02 01 01 00 00 .....
>>>> HCI Event: Unknown (0xe4) plen 5 [hci0] 6.753046
>>> 02 01 01 00 00 .....
>>>> HCI Event: Unknown (0xe4) plen 5 [hci0] 6.754038
>>> 02 01 01 00 00 .....
>>>> HCI Event: Unknown (0xe4) plen 5 [hci0] 6.755031
>>> 02 01 01 00 00 .....
>>>> HCI Event: Unknown (0xe4) plen 5 [hci0] 6.756025
>>> 02 01 01 00 00 .....
>>>> HCI Event: Unknown (0xe4) plen 5 [hci0] 6.757013
>>> 02 01 01 00 00 .....
>>>> HCI Event: Unknown (0xe4) plen 5 [hci0] 6.758006
>>> 02 01 01 00 00 .....
>>>> HCI Event: Unknown (0xe4) plen 5 [hci0] 6.758999
>>> 02 01 01 00 00 .....
>>>> HCI Event: Unknown (0xe4) plen 5 [hci0] 6.759991
>>> 02 01 01 00 00 .....
>>>> HCI Event: Unknown (0xe4) plen 5 [hci0] 6.760983
>>> 02 01 01 00 00 .....
>>>> HCI Event: Unknown (0xe4) plen 5 [hci0] 6.761975
>>> 02 01 01 00 00 .....
>>>> HCI Event: Unknown (0xe4) plen 5 [hci0] 6.762963
>>> 02 01 01 00 00 .....
>>>> HCI Event: Unknown (0xe4) plen 5 [hci0] 6.763956
>>> 02 01 01 00 00 .....
>>>> HCI Event: Unknown (0xe4) plen 5 [hci0] 6.764948
>>> 02 01 01 00 00 .....
>>>> HCI Event: Unknown (0xe4) plen 5 [hci0] 6.765941
>>> 02 01 01 00 00 .....
>>>> HCI Event: Unknown (0xe4) plen 5 [hci0] 6.766933
>>> 02 01 01 00 00 .....
>>>> HCI Event: Unknown (0xe4) plen 5 [hci0] 6.767926
>>> 02 01 01 00 00 .....
>>>> HCI Event: Unknown (0xe4) plen 5 [hci0] 6.768919
>>> 02 01 01 00 00 .....
>>>> HCI Event: Unknown (0xe4) plen 5 [hci0] 6.769914
>>> 02 01 01 00 00 .....
>>>> HCI Event: Unknown (0xe4) plen 5 [hci0] 6.770909
>>> 02 01 01 00 00 .....
>>>> HCI Event: Unknown (0xe4) plen 5 [hci0] 6.771908
>>> 02 01 01 00 00 .....
>>>> HCI Event: Unknown (0xe4) plen 5 [hci0] 6.772904
>>> 02 01 01 00 00 .....
>>>> HCI Event: Unknown (0xe4) plen 5 [hci0] 6.773898
>>> 02 01 01 00 00 .....
>>>> HCI Event: Unknown (0xe4) plen 5 [hci0] 6.774892
>>> 02 01 01 00 00 .....
>>>> HCI Event: Unknown (0xe4) plen 5 [hci0] 6.775890
>>> 02 01 01 00 00 .....
>>>> HCI Event: Unknown (0xe4) plen 5 [hci0] 6.776882
>>> 02 01 01 00 00 .....
>>>> HCI Event: Unknown (0xe4) plen 5 [hci0] 6.777877
>>> 02 01 01 00 00 .....
>>>> HCI Event: Unknown (0xe4) plen 5 [hci0] 6.778871
>>> 02 01 01 00 00 .....
>>>> HCI Event: Unknown (0xe4) plen 5 [hci0] 6.779869
>>> 02 01 01 00 00 .....
>>>> HCI Event: Unknown (0xe4) plen 5 [hci0] 6.780864
>>> 02 01 01 00 00 .....
>>>> HCI Event: Unknown (0xe4) plen 5 [hci0] 6.781858
>>> 02 01 01 00 00 .....
>>>> HCI Event: Unknown (0xe4) plen 5 [hci0] 6.782852
>>> 02 01 01 00 00 .....
>>>> HCI Event: Unknown (0xe4) plen 5 [hci0] 6.783850
>>> 02 01 01 00 00 .....
>>>> HCI Event: Unknown (0xe4) plen 5 [hci0] 6.784845
>>> 02 01 01 00 00 .....
>>>> HCI Event: Unknown (0xe4) plen 5 [hci0] 6.785839
>>> 02 01 01 00 00 .....
>>>> HCI Event: Unknown (0xe4) plen 5 [hci0] 6.786833
>>> 02 01 01 00 00 .....
>>>> HCI Event: Unknown (0xe4) plen 5 [hci0] 6.787831
>>> 02 01 01 00 00 .....
>>>> HCI Event: Unknown (0xe4) plen 5 [hci0] 6.788826
>>> 02 01 01 00 00 .....
>>>> HCI Event: Unknown (0xe4) plen 5 [hci0] 6.789820
>>> 02 01 01 00 00 .....
>>>> HCI Event: Unknown (0xe4) plen 5 [hci0] 6.790814
>>> 02 01 01 00 00 .....
>>>> HCI Event: Unknown (0xe4) plen 5 [hci0] 6.791813
>>> 02 01 01 00 00 .....
>>>> HCI Event: Unknown (0xe4) plen 5 [hci0] 6.792809
>>> 02 01 01 00 00 .....
>>>> HCI Event: Unknown (0xe4) plen 5 [hci0] 6.793803
>>> 02 01 01 00 00 .....
>>>> HCI Event: Unknown (0xe4) plen 5 [hci0] 6.794798
>>> 02 01 01 00 00 .....
>>>> HCI Event: Unknown (0xe4) plen 5 [hci0] 6.795797
>>> 02 01 01 00 00 .....
>>>> HCI Event: Unknown (0xe4) plen 5 [hci0] 6.796791
>>> 02 01 01 00 00 .....
>>>> HCI Event: Unknown (0xe4) plen 5 [hci0] 6.797786
>>> 02 01 01 00 00 .....
>>>> HCI Event: Unknown (0xe4) plen 5 [hci0] 6.798779
>>> 02 01 01 00 00 .....
>>>> HCI Event: Unknown (0xe4) plen 5 [hci0] 6.799778
>>> 02 01 01 00 00 .....
>>>> HCI Event: Unknown (0xe4) plen 5 [hci0] 6.800774
>>> 02 01 01 00 00 .....
>>>> HCI Event: Unknown (0xe4) plen 5 [hci0] 6.801769
>>> 02 01 01 00 00 .....
>>>> HCI Event: Unknown (0xe4) plen 5 [hci0] 6.802763
>>> 02 01 01 00 00 .....
>>>> HCI Event: Unknown (0xe4) plen 5 [hci0] 6.803761
>>> 02 01 01 00 00 .....
>>>> HCI Event: Unknown (0xe4) plen 5 [hci0] 6.804755
>>> 02 01 01 00 00 .....
>>>> HCI Event: Unknown (0xe4) plen 5 [hci0] 6.805749
>>> 02 01 01 00 00 .....
>>>> HCI Event: Unknown (0xe4) plen 5 [hci0] 6.806743
>>> 02 01 01 00 00 .....
>>>> HCI Event: Unknown (0xe4) plen 5 [hci0] 6.807741
>>> 02 01 01 00 00 .....
>>>> HCI Event: Unknown (0xe4) plen 5 [hci0] 6.808737
>>> 02 01 01 00 00 .....
>>>> HCI Event: Unknown (0xe4) plen 5 [hci0] 6.809731
>>> 02 01 01 00 00 .....
>>>> HCI Event: Unknown (0xe4) plen 5 [hci0] 6.810725
>>> 02 01 01 00 00 .....
>>>> HCI Event: Unknown (0xe4) plen 5 [hci0] 6.811725
>>> 02 01 01 00 00 .....
>>>> HCI Event: Unknown (0xe4) plen 5 [hci0] 6.812719
>>> 02 01 01 00 00 .....
>>>> HCI Event: Unknown (0xe4) plen 5 [hci0] 6.813714
>>> 02 01 01 00 00 .....
>>>> HCI Event: Unknown (0xe4) plen 5 [hci0] 6.814708
>>> 02 01 01 00 00 .....
>>>> HCI Event: Unknown (0xe4) plen 5 [hci0] 6.815705
>>> 02 01 01 00 00 .....
>>>> HCI Event: Unknown (0xe4) plen 5 [hci0] 6.816378
>>> 02 01 01 00 00 .....
>>
>> Why do I see only HCI events here? Is this event conveying any useful information. It is kinda complicated that this is 0xe4 event code which is actually reserved for future use by the Bluetooth SIG. Are there any accompanying HCI commands for this and they just not make it into btmon?
>>
>
> I have made all vendor HCI commands go through BlueZ core in v2 patch.
>
> And for these HCI events, they are all corresponding to vendor ACL data, applied only to firmware setup packets, but they're not being sent via BlueZ core, so they are not being logged in btmon.
>
> As for its event, where heading 0xe4 refers to a vendor event and is used on notification of that either vendor ACL data or vendor HCI command have been done.

I would prefer if everything goes via the Bluetooth core since then we have it all properly scheduled. Sending things down the ACL data path however if kinda funky. Does your hardware accept sending command both via ACL data and as HCI command? If so, then I would prefer sending them as HCI commands since the speed improvement you think you are getting is neglectable on Linux (I have been down that path). This seems to be a pure optimization when Windows is driving the device.

And the vendor event 0xe4 is really only received during firmware download? It is not ever received during normal operation?

>
>>
>>
>>> < HCI Command: Vendor (0x3f|0x006f) plen 5 [hci0] 6.816413
>>> 01 07 01 00 04 .....
>>>> HCI Event: Unknown (0xe4) plen 5 [hci0] 6.816536
>>> 02 07 01 00 00 .....
>>> < HCI Command: Vendor (0x3f|0x006f) plen 6 [hci0] 8.845071
>>> 01 06 02 00 00 01 ......
>>>> HCI Event: Unknown (0xe4) plen 5 [hci0] 8.923456
>>> 02 06 01 00 00 .....
>>
>> Here it looks like you have 0x006f opcode with first octet 0x01 for command and then vendor event 0xe4 with first octet 0x02 for event. I assume the second octet is then the vendor command code for these.
>>
>
> Yes, you're right.
>
>>> < HCI Command: Reset (0x03|0x0003) plen 0 [hci0] 10.861118
>>>> HCI Event: Command Complete (0x0e) plen 4 [hci0] 10.865763
>>> Reset (0x03|0x0003) ncmd 1
>>> Status: Success (0x00)
>>> < HCI Command: Read Local Supported Fe.. (0x04|0x0003) plen 0 [hci0] 10.865805
>>>> HCI Event: Command Complete (0x0e) plen 12 [hci0] 10.865965
>>> Read Local Supported Features (0x04|0x0003) ncmd 1
>>> Status: Success (0x00)
>>> Features: 0xbf 0x3e 0x8d 0xfe 0xdb 0xff 0x7b 0x87
>>> 3 slot packets
>>> 5 slot packets
>>> Encryption
>>> Slot offset
>>> Timing accuracy
>>> Role switch
>>> Sniff mode
>>> Power control requests
>>> Channel quality driven data rate (CQDDR)
>>> SCO link
>>> HV2 packets
>>> HV3 packets
>>> CVSD synchronous data
>>> Power control
>>> Transparent synchronous data
>>> Broadcast Encryption
>>> Enhanced Data Rate ACL 2 Mbps mode
>>> Enhanced Data Rate ACL 3 Mbps mode
>>> Enhanced inquiry scan
>>> Interlaced inquiry scan
>>> Interlaced page scan
>>> RSSI with inquiry results
>>> Extended SCO link (EV3 packets)
>>> EV4 packets
>>> EV5 packets
>>> AFH capable slave
>>> AFH classification slave
>>> LE Supported (Controller)
>>> 3-slot Enhanced Data Rate ACL packets
>>> 5-slot Enhanced Data Rate ACL packets
>>> Sniff subrating
>>> Pause encryption
>>> AFH capable master
>>> AFH classification master
>>> Enhanced Data Rate eSCO 2 Mbps mode
>>> Enhanced Data Rate eSCO 3 Mbps mode
>>> 3-slot Enhanced Data Rate eSCO packets
>>> Extended Inquiry Response
>>> Simultaneous LE and BR/EDR (Controller)
>>> Secure Simple Pairing
>>> Encapsulated PDU
>>> Erroneous Data Reporting
>>> Non-flushable Packet Boundary Flag
>>> Link Supervision Timeout Changed Event
>>> Inquiry TX Power Level
>>> Enhanced Power Control
>>> Extended features
>>> < HCI Command: Read Local Version Info.. (0x04|0x0001) plen 0 [hci0] 10.865987
>>>> HCI Event: Vendor (0xff) plen 9 [hci0] 10.866259
>>> 29 19 09 17 20 48 07 11 00 )... H…
>>
>> Is this meant to happen here?
>>
>
> If event received is not expected as the specification defines, I think it's probably incorrect.
>
> But it requires more discussion with firmware people to make it clearer.

Please check and let them decode what this event means.

>
>>>> HCI Event: Command Complete (0x0e) plen 12 [hci0] 10.866372
>>> Read Local Version Information (0x04|0x0001) ncmd 1
>>> Status: Success (0x00)
>>> HCI version: Bluetooth 4.2 (0x08) - Revision 4359 (0x1107)
>>> LMP version: Bluetooth 4.2 (0x08) - Subversion 2329 (0x0919)
>>> Manufacturer: MediaTek, Inc. (70)
>>> < HCI Command: Read BD ADDR (0x04|0x0009) plen 0 [hci0] 10.866391
>>>> HCI Event: Command Complete (0x0e) plen 10 [hci0] 10.866539
>>> Read BD ADDR (0x04|0x0009) ncmd 1
>>> Status: Success (0x00)
>>> Address: 00:00:46:76:22:01 (OLIVETTI NORTH AMERICA)
>>> < HCI Command: Read Buffer Size (0x04|0x0005) plen 0 [hci0] 10.866609
>>>> HCI Event: Command Complete (0x0e) plen 11 [hci0] 10.866754
>>> Read Buffer Size (0x04|0x0005) ncmd 1
>>> Status: Success (0x00)
>>> ACL MTU: 1021 ACL max packet: 8
>>> SCO MTU: 184 SCO max packet: 1
>>> < HCI Command: Read Class of Device (0x03|0x0023) plen 0 [hci0] 10.866775
>>>> HCI Event: Command Complete (0x0e) plen 7 [hci0] 10.866920
>>> Read Class of Device (0x03|0x0023) ncmd 1
>>> Status: Success (0x00)
>>> Class: 0x001f00
>>> Major class: Uncategorized, specific device code not specified
>>> Minor class: 0x00
>>> < HCI Command: Read Local Name (0x03|0x0014) plen 0 [hci0] 10.866939
>>>> HCI Event: Command Complete (0x0e) plen 252 [hci0] 10.867256
>>> Read Local Name (0x03|0x0014) ncmd 1
>>> Status: Success (0x00)
>>> Name: MTK MT7622 #1
>>> < HCI Command: Read Voice Setting (0x03|0x0025) plen 0 [hci0] 10.867308
>>>> HCI Event: Command Complete (0x0e) plen 6 [hci0] 10.867447
>>> Read Voice Setting (0x03|0x0025) ncmd 1
>>> Status: Success (0x00)
>>> Setting: 0x0060
>>> Input Coding: Linear
>>> Input Data Format: 2's complement
>>> Input Sample Size: 16-bit
>>> # of bits padding at MSB: 0
>>> Air Coding Format: CVSD
>>> < HCI Command: Read Number of Supporte.. (0x03|0x0038) plen 0 [hci0] 10.867474
>>>> HCI Event: Command Complete (0x0e) plen 5 [hci0] 10.867611
>>> Read Number of Supported IAC (0x03|0x0038) ncmd 1
>>> Status: Success (0x00)
>>> Number of IAC: 4
>>> < HCI Command: Read Current IAC LAP (0x03|0x0039) plen 0 [hci0] 10.867678
>>>> HCI Event: Command Complete (0x0e) plen 8 [hci0] 10.867865
>>> Read Current IAC LAP (0x03|0x0039) ncmd 1
>>> Status: Success (0x00)
>>> Number of IAC: 1
>>> Access code: 0x9e8b33 (General Inquiry)
>>> < HCI Command: Set Event Filter (0x03|0x0005) plen 1 [hci0] 10.867890
>>> Type: Clear All Filters (0x00)
>>>> HCI Event: Command Complete (0x0e) plen 4 [hci0] 10.868033
>>> Set Event Filter (0x03|0x0005) ncmd 1
>>> Status: Success (0x00)
>>> < HCI Command: Write Connection Accept.. (0x03|0x0016) plen 2 [hci0] 10.868054
>>> Timeout: 20000.000 msec (0x7d00)
>>>> HCI Event: Command Complete (0x0e) plen 4 [hci0] 10.868235
>>> Write Connection Accept Timeout (0x03|0x0016) ncmd 1
>>> Status: Success (0x00)
>>> < HCI Command: LE Read Buffer Size (0x08|0x0002) plen 0 [hci0] 10.868262
>>>> HCI Event: Command Complete (0x0e) plen 7 [hci0] 10.868392
>>> LE Read Buffer Size (0x08|0x0002) ncmd 1
>>> Status: Success (0x00)
>>> Data packet length: 251
>>> Num data packets: 8
>>> < HCI Command: LE Read Local Supported.. (0x08|0x0003) plen 0 [hci0] 10.868413
>>>> HCI Event: Command Complete (0x0e) plen 12 [hci0] 10.868587
>>> LE Read Local Supported Features (0x08|0x0003) ncmd 1
>>> Status: Success (0x00)
>>> Features: 0xfd 0x00 0x00 0x00 0x00 0x00 0x00 0x00
>>> LE Encryption
>>> Extended Reject Indication
>>> Slave-initiated Features Exchange
>>> LE Ping
>>> LE Data Packet Length Extension
>>> LL Privacy
>>> Extended Scanner Filter Policies
>>> < HCI Command: LE Read Supported States (0x08|0x001c) plen 0 [hci0] 10.868646
>>>> HCI Event: Command Complete (0x0e) plen 12 [hci0] 10.868787
>>> LE Read Supported States (0x08|0x001c) ncmd 1
>>> Status: Success (0x00)
>>> States: 0x000000001fffffff
>>> Non-connectable Advertising State
>>> Scannable Advertising State
>>> Connectable Advertising State
>>> High Duty Cycle Directed Advertising State
>>> Passive Scanning State
>>> Active Scanning State
>>> Initiating State
>>> and Connection State (Master Role)
>>> Connection State (Slave Role)
>>> Non-connectable Advertising State
>>> and Passive Scanning State
>>> Scannable Advertising State
>>> and Passive Scanning State
>>> Connectable Advertising State
>>> and Passive Scanning State
>>> High Duty Cycle Directed Advertising State
>>> and Passive Scanning State
>>> Non-connectable Advertising State
>>> and Active Scanning State
>>> Scannable Advertising State
>>> and Active Scanning State
>>> Connectable Advertising State
>>> and Active Scanning State
>>> High Duty Cycle Directed Advertising State
>>> and Active Scanning State
>>> Non-connectable Advertising State
>>> and Initiating State
>>> Scannable Advertising State
>>> and Initiating State
>>> Non-connectable Advertising State
>>> and Connection State (Master Role)
>>> Scannable Advertising State
>>> and Connection State (Master Role)
>>> Non-connectable Advertising State
>>> and Connection State (Slave Role)
>>> Scannable Advertising State
>>> and Connection State (Slave Role)
>>> Passive Scanning State
>>> and Initiating State
>>> Active Scanning State
>>> and Initiating State
>>> Passive Scanning State
>>> and Connection State (Master Role)
>>> Active Scanning State
>>> and Connection State (Master Role)
>>> Passive Scanning State
>>> and Connection State (Slave Role)
>>> Active Scanning State
>>> and Connection State (Slave Role)
>>> Initiating State
>>> and Connection State (Master Role)
>>> and Master Role & Master Role
>>> < HCI Command: Read Local Supported Co.. (0x04|0x0002) plen 0 [hci0] 10.868807
>>>> HCI Event: Command Complete (0x0e) plen 68 [hci0] 10.868985
>>> Read Local Supported Commands (0x04|0x0002) ncmd 1
>>> Status: Success (0x00)
>>> Commands: 176 entries
>>> Inquiry (Octet 0 - Bit 0)
>>> Inquiry Cancel (Octet 0 - Bit 1)
>>> Periodic Inquiry Mode (Octet 0 - Bit 2)
>>> Exit Periodic Inquiry Mode (Octet 0 - Bit 3)
>>> Create Connection (Octet 0 - Bit 4)
>>> Disconnect (Octet 0 - Bit 5)
>>> Add SCO Connection (Octet 0 - Bit 6)
>>> Create Connection Cancel (Octet 0 - Bit 7)
>>> Accept Connection Request (Octet 1 - Bit 0)
>>> Reject Connection Request (Octet 1 - Bit 1)
>>> Link Key Request Reply (Octet 1 - Bit 2)
>>> Link Key Request Negative Reply (Octet 1 - Bit 3)
>>> PIN Code Request Reply (Octet 1 - Bit 4)
>>> PIN Code Request Negative Reply (Octet 1 - Bit 5)
>>> Change Connection Packet Type (Octet 1 - Bit 6)
>>> Authentication Requested (Octet 1 - Bit 7)
>>> Set Connection Encryption (Octet 2 - Bit 0)
>>> Change Connection Link Key (Octet 2 - Bit 1)
>>> Master Link Key (Octet 2 - Bit 2)
>>> Remote Name Request (Octet 2 - Bit 3)
>>> Remote Name Request Cancel (Octet 2 - Bit 4)
>>> Read Remote Supported Features (Octet 2 - Bit 5)
>>> Read Remote Extended Features (Octet 2 - Bit 6)
>>> Read Remote Version Information (Octet 2 - Bit 7)
>>> Read Clock Offset (Octet 3 - Bit 0)
>>> Read LMP Handle (Octet 3 - Bit 1)
>>> Sniff Mode (Octet 4 - Bit 2)
>>> Exit Sniff Mode (Octet 4 - Bit 3)
>>> QoS Setup (Octet 4 - Bit 6)
>>> Role Discovery (Octet 4 - Bit 7)
>>> Switch Role (Octet 5 - Bit 0)
>>> Read Link Policy Settings (Octet 5 - Bit 1)
>>> Write Link Policy Settings (Octet 5 - Bit 2)
>>> Read Default Link Policy Settings (Octet 5 - Bit 3)
>>> Write Default Link Policy Settings (Octet 5 - Bit 4)
>>> Flow Specification (Octet 5 - Bit 5)
>>> Set Event Mask (Octet 5 - Bit 6)
>>> Reset (Octet 5 - Bit 7)
>>> Set Event Filter (Octet 6 - Bit 0)
>>> Flush (Octet 6 - Bit 1)
>>> Read PIN Type (Octet 6 - Bit 2)
>>> Write PIN Type (Octet 6 - Bit 3)
>>> Create New Unit Key (Octet 6 - Bit 4)
>>> Read Stored Link Key (Octet 6 - Bit 5)
>>> Write Stored Link Key (Octet 6 - Bit 6)
>>> Delete Stored Link Key (Octet 6 - Bit 7)
>>> Write Local Name (Octet 7 - Bit 0)
>>> Read Local Name (Octet 7 - Bit 1)
>>> Read Connection Accept Timeout (Octet 7 - Bit 2)
>>> Write Connection Accept Timeout (Octet 7 - Bit 3)
>>> Read Page Timeout (Octet 7 - Bit 4)
>>> Write Page Timeout (Octet 7 - Bit 5)
>>> Read Scan Enable (Octet 7 - Bit 6)
>>> Write Scan Enable (Octet 7 - Bit 7)
>>> Read Page Scan Activity (Octet 8 - Bit 0)
>>> Write Page Scan Activity (Octet 8 - Bit 1)
>>> Read Inquiry Scan Activity (Octet 8 - Bit 2)
>>> Write Inquiry Scan Activity (Octet 8 - Bit 3)
>>> Read Authentication Enable (Octet 8 - Bit 4)
>>> Write Authentication Enable (Octet 8 - Bit 5)
>>> Read Encryption Mode (Octet 8 - Bit 6)
>>> Write Encryption Mode (Octet 8 - Bit 7)
>>> Read Class of Device (Octet 9 - Bit 0)
>>> Write Class of Device (Octet 9 - Bit 1)
>>> Read Voice Setting (Octet 9 - Bit 2)
>>> Write Voice Setting (Octet 9 - Bit 3)
>>> Read Automatic Flush Timeout (Octet 9 - Bit 4)
>>> Write Automatic Flush Timeout (Octet 9 - Bit 5)
>>> Read Num Broadcast Retransmissions (Octet 9 - Bit 6)
>>> Write Num Broadcast Retransmissions (Octet 9 - Bit 7)
>>> Read Transmit Power Level (Octet 10 - Bit 2)
>>> Read Sync Flow Control Enable (Octet 10 - Bit 3)
>>> Write Sync Flow Control Enable (Octet 10 - Bit 4)
>>> Set Controller To Host Flow Control (Octet 10 - Bit 5)
>>> Host Buffer Size (Octet 10 - Bit 6)
>>> Host Number of Completed Packets (Octet 10 - Bit 7)
>>> Read Link Supervision Timeout (Octet 11 - Bit 0)
>>> Write Link Supervision Timeout (Octet 11 - Bit 1)
>>> Read Number of Supported IAC (Octet 11 - Bit 2)
>>> Read Current IAC LAP (Octet 11 - Bit 3)
>>> Write Current IAC LAP (Octet 11 - Bit 4)
>>> Read Page Scan Mode (Octet 11 - Bit 7)
>>> Write Page Scan Mode (Octet 12 - Bit 0)
>>> Set AFH Host Channel Classification (Octet 12 - Bit 1)
>>> Read Inquiry Scan Type (Octet 12 - Bit 4)
>>> Write Inquiry Scan Type (Octet 12 - Bit 5)
>>> Read Inquiry Mode (Octet 12 - Bit 6)
>>> Write Inquiry Mode (Octet 12 - Bit 7)
>>> Read Page Scan Type (Octet 13 - Bit 0)
>>> Write Page Scan Type (Octet 13 - Bit 1)
>>> Read AFH Channel Assessment Mode (Octet 13 - Bit 2)
>>> Write AFH Channel Assessment Mode (Octet 13 - Bit 3)
>>> Read Local Version Information (Octet 14 - Bit 3)
>>> Read Local Supported Features (Octet 14 - Bit 5)
>>> Read Local Extended Features (Octet 14 - Bit 6)
>>> Read Buffer Size (Octet 14 - Bit 7)
>>> Read Country Code (Octet 15 - Bit 0)
>>> Read BD ADDR (Octet 15 - Bit 1)
>>> Read Failed Contact Counter (Octet 15 - Bit 2)
>>> Reset Failed Contact Counter (Octet 15 - Bit 3)
>>> Read Link Quality (Octet 15 - Bit 4)
>>> Read RSSI (Octet 15 - Bit 5)
>>> Read AFH Channel Map (Octet 15 - Bit 6)
>>> Read Clock (Octet 15 - Bit 7)
>>> Read Loopback Mode (Octet 16 - Bit 0)
>>> Write Loopback Mode (Octet 16 - Bit 1)
>>> Enable Device Under Test Mode (Octet 16 - Bit 2)
>>> Setup Synchronous Connection (Octet 16 - Bit 3)
>>> Accept Synchronous Connection Request (Octet 16 - Bit 4)
>>> Reject Synchronous Connection Request (Octet 16 - Bit 5)
>>> Read Extended Inquiry Response (Octet 17 - Bit 0)
>>> Write Extended Inquiry Response (Octet 17 - Bit 1)
>>> Refresh Encryption Key (Octet 17 - Bit 2)
>>> Sniff Subrating (Octet 17 - Bit 4)
>>> Read Simple Pairing Mode (Octet 17 - Bit 5)
>>> Write Simple Pairing Mode (Octet 17 - Bit 6)
>>> Read Local OOB Data (Octet 17 - Bit 7)
>>> Read Inquiry Response TX Power Level (Octet 18 - Bit 0)
>>> Write Inquiry Transmit Power Level (Octet 18 - Bit 1)
>>> Read Default Erroneous Data Reporting (Octet 18 - Bit 2)
>>> Write Default Erroneous Data Reporting (Octet 18 - Bit 3)
>>> IO Capability Request Reply (Octet 18 - Bit 7)
>>> User Confirmation Request Reply (Octet 19 - Bit 0)
>>> User Confirmation Request Neg Reply (Octet 19 - Bit 1)
>>> User Passkey Request Reply (Octet 19 - Bit 2)
>>> User Passkey Request Negative Reply (Octet 19 - Bit 3)
>>> Remote OOB Data Request Reply (Octet 19 - Bit 4)
>>> Write Simple Pairing Debug Mode (Octet 19 - Bit 5)
>>> Enhanced Flush (Octet 19 - Bit 6)
>>> Remote OOB Data Request Neg Reply (Octet 19 - Bit 7)
>>> Send Keypress Notification (Octet 20 - Bit 2)
>>> IO Capability Request Negative Reply (Octet 20 - Bit 3)
>>> Read Encryption Key Size (Octet 20 - Bit 4)
>>> Set Event Mask Page 2 (Octet 22 - Bit 2)
>>> Read Enhanced Transmit Power Level (Octet 24 - Bit 0)
>>> Enhanced Setup Synchronous Connection (Octet 29 - Bit 3)
>>> Enhanced Accept Synchronous Connection Request (Octet 29 - Bit 4)
>>> Read Local Supported Codecs (Octet 29 - Bit 5)
>>> Set Triggered Clock Capture (Octet 30 - Bit 5)
>>> Truncated Page (Octet 30 - Bit 6)
>>> Truncated Page Cancel (Octet 30 - Bit 7)
>>> Set Connectionless Slave Broadcast (Octet 31 - Bit 0)
>>> Start Synchronization Train (Octet 31 - Bit 2)
>>> Set Reserved LT_ADDR (Octet 31 - Bit 4)
>>> Delete Reserved LT_ADDR (Octet 31 - Bit 5)
>>> Set Connectionless Slave Broadcast Data (Octet 31 - Bit 6)
>>> Read Synchronization Train Parameters (Octet 31 - Bit 7)
>>> Write Synchronization Train Parameters (Octet 32 - Bit 0)
>>> Remote OOB Extended Data Request Reply (Octet 32 - Bit 1)
>>> Read Authenticated Payload Timeout (Octet 32 - Bit 4)
>>> Write Authenticated Payload Timeout (Octet 32 - Bit 5)
>>> Read Local OOB Extended Data (Octet 32 - Bit 6)
>>> Write Secure Connections Test Mode (Octet 32 - Bit 7)
>>> Read Extended Page Timeout (Octet 33 - Bit 0)
>>> Write Extended Page Timeout (Octet 33 - Bit 1)
>>> Read Extended Inquiry Length (Octet 33 - Bit 2)
>>> Write Extended Inquiry Length (Octet 33 - Bit 3)
>>> LE Set Data Length (Octet 33 - Bit 6)
>>> LE Read Suggested Default Data Length (Octet 33 - Bit 7)
>>> LE Write Suggested Default Data Length (Octet 34 - Bit 0)
>>> LE Read Local P-256 Public Key (Octet 34 - Bit 1)
>>> LE Generate DHKey (Octet 34 - Bit 2)
>>> LE Add Device To Resolving List (Octet 34 - Bit 3)
>>> LE Remove Device From Resolving List (Octet 34 - Bit 4)
>>> LE Clear Resolving List (Octet 34 - Bit 5)
>>> LE Read Resolving List Size (Octet 34 - Bit 6)
>>> LE Read Peer Resolvable Address (Octet 34 - Bit 7)
>>> LE Read Local Resolvable Address (Octet 35 - Bit 0)
>>> LE Set Address Resolution Enable (Octet 35 - Bit 1)
>>> LE Set Resolvable Private Address Timeout (Octet 35 - Bit 2)
>>> LE Read Maximum Data Length (Octet 35 - Bit 3)
>>> Octet 35 - Bit 4
>>> Octet 35 - Bit 5
>>> Octet 35 - Bit 6
>>> Octet 35 - Bit 7
>>> Octet 36 - Bit 0
>>
>> So you support the PHY commands, but do not indicate support LE 2M or LE Coded? Also these are Bluetooth 5.0 commands.
>>
>
> To be honest. When I ported the device into Bluez core, a unexpected event for LE read local feature would cause a fail at Bluez core, so I made a hack on Bluez core
>
> to allow that I can keeping bring up the device without be blocked by the issue most probably from firmware.
>
> Below code snippet is the only thing I added to avoid a fail at Bluez core to bring up the device.
>
> @@ -927,6 +927,8 @@ static void hci_cc_le_read_local_features(struct hci_dev *hdev,
> return;
>
> memcpy(hdev->le_features, rp->features, 8);
> + hdev->le_features[0] = 0;
> + hdev->le_features[1] = 0;
> }

Send me the trace where you didn’t clear the feature bits and I check what is going on. I doubt that we have a bug, but maybe some of the commands are optional and we should add an appropriate check. Or you guys need to fix your firmware. A new btmon should decode all bits properly.

Regards

Marcel

2018-05-24 15:30:05

by Sean Wang

[permalink] [raw]
Subject: Re: [PATCH v2 4/7] Bluetooth: Add new quirk for non-persistent setup settings

On Thu, 2018-05-24 at 09:47 +0200, Marcel Holtmann wrote:
> Hi Sean,
>
> >>>>
> >>>> [ ... ]

[ ... ]

> > I post it as plain text as below
> >
> >
> > Bluetooth monitor ver 5.37
> > = Note: Linux version 4.16.0-rc1+ (aarch64) 0.641494
> > = Note: Bluetooth subsystem version 2.22 0.641502
> > = New Index: 00:00:46:76:22:01 (BR/EDR,UART,hci0) [hci0] 0.641505
> > * Unknown packet (code 14 len 30) 0.641509
> > 01 00 00 00 02 00 01 0e 00 01 00 00 00 10 62 6c ..............bl
> > 75 65 74 6f 6f 74 68 64 00 00 00 00 00 00 uetoothd......
> > * Unknown packet (code 14 len 30) 0.641592
> > 02 00 00 00 02 00 01 0e 00 01 00 00 00 10 62 74 ..............bt
> > 6d 6f 6e 00 00 00 00 00 00 00 00 00 00 00 mon...........
> > * Unknown packet (code 16 len 7) [hci0] 6.536771
> > 01 00 00 00 05 00 01 .......
> > = Open Index: 00:00:46:76:22:01 [hci0] 6.717019
> > = Index Info: 00:00:46:76:22:01 (MediaTek, Inc.) [hci0] 6.717030
>
> can you try with the latest BlueZ 5.49 or git version. Seems it actually stumbles over the extra packet here. Fun fact is that I can not get a backtrace to pin-point the issue in btmon and why it crashes.
>

I had less experience updating user land BlueZ, but I can try it as possible and see whether Unknown packets still are present at newest version BlueZ. Hopefully I don't misunderstand your point here.


> >> HCI Event: Unknown (0xe4) plen 5 [hci0] 6.741093
> > 02 01 01 00 00 .....
> >> HCI Event: Unknown (0xe4) plen 5 [hci0] 6.742088
> > 02 01 01 00 00 .....
> >> HCI Event: Unknown (0xe4) plen 5 [hci0] 6.743102
> > 02 01 01 00 00 .....
> >> HCI Event: Unknown (0xe4) plen 5 [hci0] 6.744105
> > 02 01 01 00 00 .....
> >> HCI Event: Unknown (0xe4) plen 5 [hci0] 6.745109
> > 02 01 01 00 00 .....
> >> HCI Event: Unknown (0xe4) plen 5 [hci0] 6.746104
> > 02 01 01 00 00 .....
> >> HCI Event: Unknown (0xe4) plen 5 [hci0] 6.747097
> > 02 01 01 00 00 .....
> >> HCI Event: Unknown (0xe4) plen 5 [hci0] 6.748090
> > 02 01 01 00 00 .....
> >> HCI Event: Unknown (0xe4) plen 5 [hci0] 6.749078
> > 02 01 01 00 00 .....
> >> HCI Event: Unknown (0xe4) plen 5 [hci0] 6.750070
> > 02 01 01 00 00 .....
> >> HCI Event: Unknown (0xe4) plen 5 [hci0] 6.751061
> > 02 01 01 00 00 .....
> >> HCI Event: Unknown (0xe4) plen 5 [hci0] 6.752054
> > 02 01 01 00 00 .....
> >> HCI Event: Unknown (0xe4) plen 5 [hci0] 6.753046
> > 02 01 01 00 00 .....
> >> HCI Event: Unknown (0xe4) plen 5 [hci0] 6.754038
> > 02 01 01 00 00 .....
> >> HCI Event: Unknown (0xe4) plen 5 [hci0] 6.755031
> > 02 01 01 00 00 .....
> >> HCI Event: Unknown (0xe4) plen 5 [hci0] 6.756025
> > 02 01 01 00 00 .....
> >> HCI Event: Unknown (0xe4) plen 5 [hci0] 6.757013
> > 02 01 01 00 00 .....
> >> HCI Event: Unknown (0xe4) plen 5 [hci0] 6.758006
> > 02 01 01 00 00 .....
> >> HCI Event: Unknown (0xe4) plen 5 [hci0] 6.758999
> > 02 01 01 00 00 .....
> >> HCI Event: Unknown (0xe4) plen 5 [hci0] 6.759991
> > 02 01 01 00 00 .....
> >> HCI Event: Unknown (0xe4) plen 5 [hci0] 6.760983
> > 02 01 01 00 00 .....
> >> HCI Event: Unknown (0xe4) plen 5 [hci0] 6.761975
> > 02 01 01 00 00 .....
> >> HCI Event: Unknown (0xe4) plen 5 [hci0] 6.762963
> > 02 01 01 00 00 .....
> >> HCI Event: Unknown (0xe4) plen 5 [hci0] 6.763956
> > 02 01 01 00 00 .....
> >> HCI Event: Unknown (0xe4) plen 5 [hci0] 6.764948
> > 02 01 01 00 00 .....
> >> HCI Event: Unknown (0xe4) plen 5 [hci0] 6.765941
> > 02 01 01 00 00 .....
> >> HCI Event: Unknown (0xe4) plen 5 [hci0] 6.766933
> > 02 01 01 00 00 .....
> >> HCI Event: Unknown (0xe4) plen 5 [hci0] 6.767926
> > 02 01 01 00 00 .....
> >> HCI Event: Unknown (0xe4) plen 5 [hci0] 6.768919
> > 02 01 01 00 00 .....
> >> HCI Event: Unknown (0xe4) plen 5 [hci0] 6.769914
> > 02 01 01 00 00 .....
> >> HCI Event: Unknown (0xe4) plen 5 [hci0] 6.770909
> > 02 01 01 00 00 .....
> >> HCI Event: Unknown (0xe4) plen 5 [hci0] 6.771908
> > 02 01 01 00 00 .....
> >> HCI Event: Unknown (0xe4) plen 5 [hci0] 6.772904
> > 02 01 01 00 00 .....
> >> HCI Event: Unknown (0xe4) plen 5 [hci0] 6.773898
> > 02 01 01 00 00 .....
> >> HCI Event: Unknown (0xe4) plen 5 [hci0] 6.774892
> > 02 01 01 00 00 .....
> >> HCI Event: Unknown (0xe4) plen 5 [hci0] 6.775890
> > 02 01 01 00 00 .....
> >> HCI Event: Unknown (0xe4) plen 5 [hci0] 6.776882
> > 02 01 01 00 00 .....
> >> HCI Event: Unknown (0xe4) plen 5 [hci0] 6.777877
> > 02 01 01 00 00 .....
> >> HCI Event: Unknown (0xe4) plen 5 [hci0] 6.778871
> > 02 01 01 00 00 .....
> >> HCI Event: Unknown (0xe4) plen 5 [hci0] 6.779869
> > 02 01 01 00 00 .....
> >> HCI Event: Unknown (0xe4) plen 5 [hci0] 6.780864
> > 02 01 01 00 00 .....
> >> HCI Event: Unknown (0xe4) plen 5 [hci0] 6.781858
> > 02 01 01 00 00 .....
> >> HCI Event: Unknown (0xe4) plen 5 [hci0] 6.782852
> > 02 01 01 00 00 .....
> >> HCI Event: Unknown (0xe4) plen 5 [hci0] 6.783850
> > 02 01 01 00 00 .....
> >> HCI Event: Unknown (0xe4) plen 5 [hci0] 6.784845
> > 02 01 01 00 00 .....
> >> HCI Event: Unknown (0xe4) plen 5 [hci0] 6.785839
> > 02 01 01 00 00 .....
> >> HCI Event: Unknown (0xe4) plen 5 [hci0] 6.786833
> > 02 01 01 00 00 .....
> >> HCI Event: Unknown (0xe4) plen 5 [hci0] 6.787831
> > 02 01 01 00 00 .....
> >> HCI Event: Unknown (0xe4) plen 5 [hci0] 6.788826
> > 02 01 01 00 00 .....
> >> HCI Event: Unknown (0xe4) plen 5 [hci0] 6.789820
> > 02 01 01 00 00 .....
> >> HCI Event: Unknown (0xe4) plen 5 [hci0] 6.790814
> > 02 01 01 00 00 .....
> >> HCI Event: Unknown (0xe4) plen 5 [hci0] 6.791813
> > 02 01 01 00 00 .....
> >> HCI Event: Unknown (0xe4) plen 5 [hci0] 6.792809
> > 02 01 01 00 00 .....
> >> HCI Event: Unknown (0xe4) plen 5 [hci0] 6.793803
> > 02 01 01 00 00 .....
> >> HCI Event: Unknown (0xe4) plen 5 [hci0] 6.794798
> > 02 01 01 00 00 .....
> >> HCI Event: Unknown (0xe4) plen 5 [hci0] 6.795797
> > 02 01 01 00 00 .....
> >> HCI Event: Unknown (0xe4) plen 5 [hci0] 6.796791
> > 02 01 01 00 00 .....
> >> HCI Event: Unknown (0xe4) plen 5 [hci0] 6.797786
> > 02 01 01 00 00 .....
> >> HCI Event: Unknown (0xe4) plen 5 [hci0] 6.798779
> > 02 01 01 00 00 .....
> >> HCI Event: Unknown (0xe4) plen 5 [hci0] 6.799778
> > 02 01 01 00 00 .....
> >> HCI Event: Unknown (0xe4) plen 5 [hci0] 6.800774
> > 02 01 01 00 00 .....
> >> HCI Event: Unknown (0xe4) plen 5 [hci0] 6.801769
> > 02 01 01 00 00 .....
> >> HCI Event: Unknown (0xe4) plen 5 [hci0] 6.802763
> > 02 01 01 00 00 .....
> >> HCI Event: Unknown (0xe4) plen 5 [hci0] 6.803761
> > 02 01 01 00 00 .....
> >> HCI Event: Unknown (0xe4) plen 5 [hci0] 6.804755
> > 02 01 01 00 00 .....
> >> HCI Event: Unknown (0xe4) plen 5 [hci0] 6.805749
> > 02 01 01 00 00 .....
> >> HCI Event: Unknown (0xe4) plen 5 [hci0] 6.806743
> > 02 01 01 00 00 .....
> >> HCI Event: Unknown (0xe4) plen 5 [hci0] 6.807741
> > 02 01 01 00 00 .....
> >> HCI Event: Unknown (0xe4) plen 5 [hci0] 6.808737
> > 02 01 01 00 00 .....
> >> HCI Event: Unknown (0xe4) plen 5 [hci0] 6.809731
> > 02 01 01 00 00 .....
> >> HCI Event: Unknown (0xe4) plen 5 [hci0] 6.810725
> > 02 01 01 00 00 .....
> >> HCI Event: Unknown (0xe4) plen 5 [hci0] 6.811725
> > 02 01 01 00 00 .....
> >> HCI Event: Unknown (0xe4) plen 5 [hci0] 6.812719
> > 02 01 01 00 00 .....
> >> HCI Event: Unknown (0xe4) plen 5 [hci0] 6.813714
> > 02 01 01 00 00 .....
> >> HCI Event: Unknown (0xe4) plen 5 [hci0] 6.814708
> > 02 01 01 00 00 .....
> >> HCI Event: Unknown (0xe4) plen 5 [hci0] 6.815705
> > 02 01 01 00 00 .....
> >> HCI Event: Unknown (0xe4) plen 5 [hci0] 6.816378
> > 02 01 01 00 00 .....
>
> Why do I see only HCI events here? Is this event conveying any useful information. It is kinda complicated that this is 0xe4 event code which is actually reserved for future use by the Bluetooth SIG. Are there any accompanying HCI commands for this and they just not make it into btmon?
>

I have made all vendor HCI commands go through BlueZ core in v2 patch.

And for these HCI events, they are all corresponding to vendor ACL data, applied only to firmware setup packets, but they're not being sent via BlueZ core, so they are not being logged in btmon.

As for its event, where heading 0xe4 refers to a vendor event and is used on notification of that either vendor ACL data or vendor HCI command have been done.

>
>
> > < HCI Command: Vendor (0x3f|0x006f) plen 5 [hci0] 6.816413
> > 01 07 01 00 04 .....
> >> HCI Event: Unknown (0xe4) plen 5 [hci0] 6.816536
> > 02 07 01 00 00 .....
> > < HCI Command: Vendor (0x3f|0x006f) plen 6 [hci0] 8.845071
> > 01 06 02 00 00 01 ......
> >> HCI Event: Unknown (0xe4) plen 5 [hci0] 8.923456
> > 02 06 01 00 00 .....
>
> Here it looks like you have 0x006f opcode with first octet 0x01 for command and then vendor event 0xe4 with first octet 0x02 for event. I assume the second octet is then the vendor command code for these.
>

Yes, you're right.

> > < HCI Command: Reset (0x03|0x0003) plen 0 [hci0] 10.861118
> >> HCI Event: Command Complete (0x0e) plen 4 [hci0] 10.865763
> > Reset (0x03|0x0003) ncmd 1
> > Status: Success (0x00)
> > < HCI Command: Read Local Supported Fe.. (0x04|0x0003) plen 0 [hci0] 10.865805
> >> HCI Event: Command Complete (0x0e) plen 12 [hci0] 10.865965
> > Read Local Supported Features (0x04|0x0003) ncmd 1
> > Status: Success (0x00)
> > Features: 0xbf 0x3e 0x8d 0xfe 0xdb 0xff 0x7b 0x87
> > 3 slot packets
> > 5 slot packets
> > Encryption
> > Slot offset
> > Timing accuracy
> > Role switch
> > Sniff mode
> > Power control requests
> > Channel quality driven data rate (CQDDR)
> > SCO link
> > HV2 packets
> > HV3 packets
> > CVSD synchronous data
> > Power control
> > Transparent synchronous data
> > Broadcast Encryption
> > Enhanced Data Rate ACL 2 Mbps mode
> > Enhanced Data Rate ACL 3 Mbps mode
> > Enhanced inquiry scan
> > Interlaced inquiry scan
> > Interlaced page scan
> > RSSI with inquiry results
> > Extended SCO link (EV3 packets)
> > EV4 packets
> > EV5 packets
> > AFH capable slave
> > AFH classification slave
> > LE Supported (Controller)
> > 3-slot Enhanced Data Rate ACL packets
> > 5-slot Enhanced Data Rate ACL packets
> > Sniff subrating
> > Pause encryption
> > AFH capable master
> > AFH classification master
> > Enhanced Data Rate eSCO 2 Mbps mode
> > Enhanced Data Rate eSCO 3 Mbps mode
> > 3-slot Enhanced Data Rate eSCO packets
> > Extended Inquiry Response
> > Simultaneous LE and BR/EDR (Controller)
> > Secure Simple Pairing
> > Encapsulated PDU
> > Erroneous Data Reporting
> > Non-flushable Packet Boundary Flag
> > Link Supervision Timeout Changed Event
> > Inquiry TX Power Level
> > Enhanced Power Control
> > Extended features
> > < HCI Command: Read Local Version Info.. (0x04|0x0001) plen 0 [hci0] 10.865987
> >> HCI Event: Vendor (0xff) plen 9 [hci0] 10.866259
> > 29 19 09 17 20 48 07 11 00 )... H…
>
> Is this meant to happen here?
>

If event received is not expected as the specification defines, I think it's probably incorrect.

But it requires more discussion with firmware people to make it clearer.

> >> HCI Event: Command Complete (0x0e) plen 12 [hci0] 10.866372
> > Read Local Version Information (0x04|0x0001) ncmd 1
> > Status: Success (0x00)
> > HCI version: Bluetooth 4.2 (0x08) - Revision 4359 (0x1107)
> > LMP version: Bluetooth 4.2 (0x08) - Subversion 2329 (0x0919)
> > Manufacturer: MediaTek, Inc. (70)
> > < HCI Command: Read BD ADDR (0x04|0x0009) plen 0 [hci0] 10.866391
> >> HCI Event: Command Complete (0x0e) plen 10 [hci0] 10.866539
> > Read BD ADDR (0x04|0x0009) ncmd 1
> > Status: Success (0x00)
> > Address: 00:00:46:76:22:01 (OLIVETTI NORTH AMERICA)
> > < HCI Command: Read Buffer Size (0x04|0x0005) plen 0 [hci0] 10.866609
> >> HCI Event: Command Complete (0x0e) plen 11 [hci0] 10.866754
> > Read Buffer Size (0x04|0x0005) ncmd 1
> > Status: Success (0x00)
> > ACL MTU: 1021 ACL max packet: 8
> > SCO MTU: 184 SCO max packet: 1
> > < HCI Command: Read Class of Device (0x03|0x0023) plen 0 [hci0] 10.866775
> >> HCI Event: Command Complete (0x0e) plen 7 [hci0] 10.866920
> > Read Class of Device (0x03|0x0023) ncmd 1
> > Status: Success (0x00)
> > Class: 0x001f00
> > Major class: Uncategorized, specific device code not specified
> > Minor class: 0x00
> > < HCI Command: Read Local Name (0x03|0x0014) plen 0 [hci0] 10.866939
> >> HCI Event: Command Complete (0x0e) plen 252 [hci0] 10.867256
> > Read Local Name (0x03|0x0014) ncmd 1
> > Status: Success (0x00)
> > Name: MTK MT7622 #1
> > < HCI Command: Read Voice Setting (0x03|0x0025) plen 0 [hci0] 10.867308
> >> HCI Event: Command Complete (0x0e) plen 6 [hci0] 10.867447
> > Read Voice Setting (0x03|0x0025) ncmd 1
> > Status: Success (0x00)
> > Setting: 0x0060
> > Input Coding: Linear
> > Input Data Format: 2's complement
> > Input Sample Size: 16-bit
> > # of bits padding at MSB: 0
> > Air Coding Format: CVSD
> > < HCI Command: Read Number of Supporte.. (0x03|0x0038) plen 0 [hci0] 10.867474
> >> HCI Event: Command Complete (0x0e) plen 5 [hci0] 10.867611
> > Read Number of Supported IAC (0x03|0x0038) ncmd 1
> > Status: Success (0x00)
> > Number of IAC: 4
> > < HCI Command: Read Current IAC LAP (0x03|0x0039) plen 0 [hci0] 10.867678
> >> HCI Event: Command Complete (0x0e) plen 8 [hci0] 10.867865
> > Read Current IAC LAP (0x03|0x0039) ncmd 1
> > Status: Success (0x00)
> > Number of IAC: 1
> > Access code: 0x9e8b33 (General Inquiry)
> > < HCI Command: Set Event Filter (0x03|0x0005) plen 1 [hci0] 10.867890
> > Type: Clear All Filters (0x00)
> >> HCI Event: Command Complete (0x0e) plen 4 [hci0] 10.868033
> > Set Event Filter (0x03|0x0005) ncmd 1
> > Status: Success (0x00)
> > < HCI Command: Write Connection Accept.. (0x03|0x0016) plen 2 [hci0] 10.868054
> > Timeout: 20000.000 msec (0x7d00)
> >> HCI Event: Command Complete (0x0e) plen 4 [hci0] 10.868235
> > Write Connection Accept Timeout (0x03|0x0016) ncmd 1
> > Status: Success (0x00)
> > < HCI Command: LE Read Buffer Size (0x08|0x0002) plen 0 [hci0] 10.868262
> >> HCI Event: Command Complete (0x0e) plen 7 [hci0] 10.868392
> > LE Read Buffer Size (0x08|0x0002) ncmd 1
> > Status: Success (0x00)
> > Data packet length: 251
> > Num data packets: 8
> > < HCI Command: LE Read Local Supported.. (0x08|0x0003) plen 0 [hci0] 10.868413
> >> HCI Event: Command Complete (0x0e) plen 12 [hci0] 10.868587
> > LE Read Local Supported Features (0x08|0x0003) ncmd 1
> > Status: Success (0x00)
> > Features: 0xfd 0x00 0x00 0x00 0x00 0x00 0x00 0x00
> > LE Encryption
> > Extended Reject Indication
> > Slave-initiated Features Exchange
> > LE Ping
> > LE Data Packet Length Extension
> > LL Privacy
> > Extended Scanner Filter Policies
> > < HCI Command: LE Read Supported States (0x08|0x001c) plen 0 [hci0] 10.868646
> >> HCI Event: Command Complete (0x0e) plen 12 [hci0] 10.868787
> > LE Read Supported States (0x08|0x001c) ncmd 1
> > Status: Success (0x00)
> > States: 0x000000001fffffff
> > Non-connectable Advertising State
> > Scannable Advertising State
> > Connectable Advertising State
> > High Duty Cycle Directed Advertising State
> > Passive Scanning State
> > Active Scanning State
> > Initiating State
> > and Connection State (Master Role)
> > Connection State (Slave Role)
> > Non-connectable Advertising State
> > and Passive Scanning State
> > Scannable Advertising State
> > and Passive Scanning State
> > Connectable Advertising State
> > and Passive Scanning State
> > High Duty Cycle Directed Advertising State
> > and Passive Scanning State
> > Non-connectable Advertising State
> > and Active Scanning State
> > Scannable Advertising State
> > and Active Scanning State
> > Connectable Advertising State
> > and Active Scanning State
> > High Duty Cycle Directed Advertising State
> > and Active Scanning State
> > Non-connectable Advertising State
> > and Initiating State
> > Scannable Advertising State
> > and Initiating State
> > Non-connectable Advertising State
> > and Connection State (Master Role)
> > Scannable Advertising State
> > and Connection State (Master Role)
> > Non-connectable Advertising State
> > and Connection State (Slave Role)
> > Scannable Advertising State
> > and Connection State (Slave Role)
> > Passive Scanning State
> > and Initiating State
> > Active Scanning State
> > and Initiating State
> > Passive Scanning State
> > and Connection State (Master Role)
> > Active Scanning State
> > and Connection State (Master Role)
> > Passive Scanning State
> > and Connection State (Slave Role)
> > Active Scanning State
> > and Connection State (Slave Role)
> > Initiating State
> > and Connection State (Master Role)
> > and Master Role & Master Role
> > < HCI Command: Read Local Supported Co.. (0x04|0x0002) plen 0 [hci0] 10.868807
> >> HCI Event: Command Complete (0x0e) plen 68 [hci0] 10.868985
> > Read Local Supported Commands (0x04|0x0002) ncmd 1
> > Status: Success (0x00)
> > Commands: 176 entries
> > Inquiry (Octet 0 - Bit 0)
> > Inquiry Cancel (Octet 0 - Bit 1)
> > Periodic Inquiry Mode (Octet 0 - Bit 2)
> > Exit Periodic Inquiry Mode (Octet 0 - Bit 3)
> > Create Connection (Octet 0 - Bit 4)
> > Disconnect (Octet 0 - Bit 5)
> > Add SCO Connection (Octet 0 - Bit 6)
> > Create Connection Cancel (Octet 0 - Bit 7)
> > Accept Connection Request (Octet 1 - Bit 0)
> > Reject Connection Request (Octet 1 - Bit 1)
> > Link Key Request Reply (Octet 1 - Bit 2)
> > Link Key Request Negative Reply (Octet 1 - Bit 3)
> > PIN Code Request Reply (Octet 1 - Bit 4)
> > PIN Code Request Negative Reply (Octet 1 - Bit 5)
> > Change Connection Packet Type (Octet 1 - Bit 6)
> > Authentication Requested (Octet 1 - Bit 7)
> > Set Connection Encryption (Octet 2 - Bit 0)
> > Change Connection Link Key (Octet 2 - Bit 1)
> > Master Link Key (Octet 2 - Bit 2)
> > Remote Name Request (Octet 2 - Bit 3)
> > Remote Name Request Cancel (Octet 2 - Bit 4)
> > Read Remote Supported Features (Octet 2 - Bit 5)
> > Read Remote Extended Features (Octet 2 - Bit 6)
> > Read Remote Version Information (Octet 2 - Bit 7)
> > Read Clock Offset (Octet 3 - Bit 0)
> > Read LMP Handle (Octet 3 - Bit 1)
> > Sniff Mode (Octet 4 - Bit 2)
> > Exit Sniff Mode (Octet 4 - Bit 3)
> > QoS Setup (Octet 4 - Bit 6)
> > Role Discovery (Octet 4 - Bit 7)
> > Switch Role (Octet 5 - Bit 0)
> > Read Link Policy Settings (Octet 5 - Bit 1)
> > Write Link Policy Settings (Octet 5 - Bit 2)
> > Read Default Link Policy Settings (Octet 5 - Bit 3)
> > Write Default Link Policy Settings (Octet 5 - Bit 4)
> > Flow Specification (Octet 5 - Bit 5)
> > Set Event Mask (Octet 5 - Bit 6)
> > Reset (Octet 5 - Bit 7)
> > Set Event Filter (Octet 6 - Bit 0)
> > Flush (Octet 6 - Bit 1)
> > Read PIN Type (Octet 6 - Bit 2)
> > Write PIN Type (Octet 6 - Bit 3)
> > Create New Unit Key (Octet 6 - Bit 4)
> > Read Stored Link Key (Octet 6 - Bit 5)
> > Write Stored Link Key (Octet 6 - Bit 6)
> > Delete Stored Link Key (Octet 6 - Bit 7)
> > Write Local Name (Octet 7 - Bit 0)
> > Read Local Name (Octet 7 - Bit 1)
> > Read Connection Accept Timeout (Octet 7 - Bit 2)
> > Write Connection Accept Timeout (Octet 7 - Bit 3)
> > Read Page Timeout (Octet 7 - Bit 4)
> > Write Page Timeout (Octet 7 - Bit 5)
> > Read Scan Enable (Octet 7 - Bit 6)
> > Write Scan Enable (Octet 7 - Bit 7)
> > Read Page Scan Activity (Octet 8 - Bit 0)
> > Write Page Scan Activity (Octet 8 - Bit 1)
> > Read Inquiry Scan Activity (Octet 8 - Bit 2)
> > Write Inquiry Scan Activity (Octet 8 - Bit 3)
> > Read Authentication Enable (Octet 8 - Bit 4)
> > Write Authentication Enable (Octet 8 - Bit 5)
> > Read Encryption Mode (Octet 8 - Bit 6)
> > Write Encryption Mode (Octet 8 - Bit 7)
> > Read Class of Device (Octet 9 - Bit 0)
> > Write Class of Device (Octet 9 - Bit 1)
> > Read Voice Setting (Octet 9 - Bit 2)
> > Write Voice Setting (Octet 9 - Bit 3)
> > Read Automatic Flush Timeout (Octet 9 - Bit 4)
> > Write Automatic Flush Timeout (Octet 9 - Bit 5)
> > Read Num Broadcast Retransmissions (Octet 9 - Bit 6)
> > Write Num Broadcast Retransmissions (Octet 9 - Bit 7)
> > Read Transmit Power Level (Octet 10 - Bit 2)
> > Read Sync Flow Control Enable (Octet 10 - Bit 3)
> > Write Sync Flow Control Enable (Octet 10 - Bit 4)
> > Set Controller To Host Flow Control (Octet 10 - Bit 5)
> > Host Buffer Size (Octet 10 - Bit 6)
> > Host Number of Completed Packets (Octet 10 - Bit 7)
> > Read Link Supervision Timeout (Octet 11 - Bit 0)
> > Write Link Supervision Timeout (Octet 11 - Bit 1)
> > Read Number of Supported IAC (Octet 11 - Bit 2)
> > Read Current IAC LAP (Octet 11 - Bit 3)
> > Write Current IAC LAP (Octet 11 - Bit 4)
> > Read Page Scan Mode (Octet 11 - Bit 7)
> > Write Page Scan Mode (Octet 12 - Bit 0)
> > Set AFH Host Channel Classification (Octet 12 - Bit 1)
> > Read Inquiry Scan Type (Octet 12 - Bit 4)
> > Write Inquiry Scan Type (Octet 12 - Bit 5)
> > Read Inquiry Mode (Octet 12 - Bit 6)
> > Write Inquiry Mode (Octet 12 - Bit 7)
> > Read Page Scan Type (Octet 13 - Bit 0)
> > Write Page Scan Type (Octet 13 - Bit 1)
> > Read AFH Channel Assessment Mode (Octet 13 - Bit 2)
> > Write AFH Channel Assessment Mode (Octet 13 - Bit 3)
> > Read Local Version Information (Octet 14 - Bit 3)
> > Read Local Supported Features (Octet 14 - Bit 5)
> > Read Local Extended Features (Octet 14 - Bit 6)
> > Read Buffer Size (Octet 14 - Bit 7)
> > Read Country Code (Octet 15 - Bit 0)
> > Read BD ADDR (Octet 15 - Bit 1)
> > Read Failed Contact Counter (Octet 15 - Bit 2)
> > Reset Failed Contact Counter (Octet 15 - Bit 3)
> > Read Link Quality (Octet 15 - Bit 4)
> > Read RSSI (Octet 15 - Bit 5)
> > Read AFH Channel Map (Octet 15 - Bit 6)
> > Read Clock (Octet 15 - Bit 7)
> > Read Loopback Mode (Octet 16 - Bit 0)
> > Write Loopback Mode (Octet 16 - Bit 1)
> > Enable Device Under Test Mode (Octet 16 - Bit 2)
> > Setup Synchronous Connection (Octet 16 - Bit 3)
> > Accept Synchronous Connection Request (Octet 16 - Bit 4)
> > Reject Synchronous Connection Request (Octet 16 - Bit 5)
> > Read Extended Inquiry Response (Octet 17 - Bit 0)
> > Write Extended Inquiry Response (Octet 17 - Bit 1)
> > Refresh Encryption Key (Octet 17 - Bit 2)
> > Sniff Subrating (Octet 17 - Bit 4)
> > Read Simple Pairing Mode (Octet 17 - Bit 5)
> > Write Simple Pairing Mode (Octet 17 - Bit 6)
> > Read Local OOB Data (Octet 17 - Bit 7)
> > Read Inquiry Response TX Power Level (Octet 18 - Bit 0)
> > Write Inquiry Transmit Power Level (Octet 18 - Bit 1)
> > Read Default Erroneous Data Reporting (Octet 18 - Bit 2)
> > Write Default Erroneous Data Reporting (Octet 18 - Bit 3)
> > IO Capability Request Reply (Octet 18 - Bit 7)
> > User Confirmation Request Reply (Octet 19 - Bit 0)
> > User Confirmation Request Neg Reply (Octet 19 - Bit 1)
> > User Passkey Request Reply (Octet 19 - Bit 2)
> > User Passkey Request Negative Reply (Octet 19 - Bit 3)
> > Remote OOB Data Request Reply (Octet 19 - Bit 4)
> > Write Simple Pairing Debug Mode (Octet 19 - Bit 5)
> > Enhanced Flush (Octet 19 - Bit 6)
> > Remote OOB Data Request Neg Reply (Octet 19 - Bit 7)
> > Send Keypress Notification (Octet 20 - Bit 2)
> > IO Capability Request Negative Reply (Octet 20 - Bit 3)
> > Read Encryption Key Size (Octet 20 - Bit 4)
> > Set Event Mask Page 2 (Octet 22 - Bit 2)
> > Read Enhanced Transmit Power Level (Octet 24 - Bit 0)
> > Enhanced Setup Synchronous Connection (Octet 29 - Bit 3)
> > Enhanced Accept Synchronous Connection Request (Octet 29 - Bit 4)
> > Read Local Supported Codecs (Octet 29 - Bit 5)
> > Set Triggered Clock Capture (Octet 30 - Bit 5)
> > Truncated Page (Octet 30 - Bit 6)
> > Truncated Page Cancel (Octet 30 - Bit 7)
> > Set Connectionless Slave Broadcast (Octet 31 - Bit 0)
> > Start Synchronization Train (Octet 31 - Bit 2)
> > Set Reserved LT_ADDR (Octet 31 - Bit 4)
> > Delete Reserved LT_ADDR (Octet 31 - Bit 5)
> > Set Connectionless Slave Broadcast Data (Octet 31 - Bit 6)
> > Read Synchronization Train Parameters (Octet 31 - Bit 7)
> > Write Synchronization Train Parameters (Octet 32 - Bit 0)
> > Remote OOB Extended Data Request Reply (Octet 32 - Bit 1)
> > Read Authenticated Payload Timeout (Octet 32 - Bit 4)
> > Write Authenticated Payload Timeout (Octet 32 - Bit 5)
> > Read Local OOB Extended Data (Octet 32 - Bit 6)
> > Write Secure Connections Test Mode (Octet 32 - Bit 7)
> > Read Extended Page Timeout (Octet 33 - Bit 0)
> > Write Extended Page Timeout (Octet 33 - Bit 1)
> > Read Extended Inquiry Length (Octet 33 - Bit 2)
> > Write Extended Inquiry Length (Octet 33 - Bit 3)
> > LE Set Data Length (Octet 33 - Bit 6)
> > LE Read Suggested Default Data Length (Octet 33 - Bit 7)
> > LE Write Suggested Default Data Length (Octet 34 - Bit 0)
> > LE Read Local P-256 Public Key (Octet 34 - Bit 1)
> > LE Generate DHKey (Octet 34 - Bit 2)
> > LE Add Device To Resolving List (Octet 34 - Bit 3)
> > LE Remove Device From Resolving List (Octet 34 - Bit 4)
> > LE Clear Resolving List (Octet 34 - Bit 5)
> > LE Read Resolving List Size (Octet 34 - Bit 6)
> > LE Read Peer Resolvable Address (Octet 34 - Bit 7)
> > LE Read Local Resolvable Address (Octet 35 - Bit 0)
> > LE Set Address Resolution Enable (Octet 35 - Bit 1)
> > LE Set Resolvable Private Address Timeout (Octet 35 - Bit 2)
> > LE Read Maximum Data Length (Octet 35 - Bit 3)
> > Octet 35 - Bit 4
> > Octet 35 - Bit 5
> > Octet 35 - Bit 6
> > Octet 35 - Bit 7
> > Octet 36 - Bit 0
>
> So you support the PHY commands, but do not indicate support LE 2M or LE Coded? Also these are Bluetooth 5.0 commands.
>

To be honest. When I ported the device into Bluez core, a unexpected event for LE read local feature would cause a fail at Bluez core, so I made a hack on Bluez core

to allow that I can keeping bring up the device without be blocked by the issue most probably from firmware.

Below code snippet is the only thing I added to avoid a fail at Bluez core to bring up the device.

@@ -927,6 +927,8 @@ static void hci_cc_le_read_local_features(struct hci_dev *hdev,
return;

memcpy(hdev->le_features, rp->features, 8);
+ hdev->le_features[0] = 0;
+ hdev->le_features[1] = 0;
}


> > < HCI Command: Write Simple Pairing Mode (0x03|0x0056) plen 1 [hci0] 10.869023
> > Mode: Enabled (0x01)
> >> HCI Event: Command Complete (0x0e) plen 4 [hci0] 10.869185
> > Write Simple Pairing Mode (0x03|0x0056) ncmd 1
> > Status: Success (0x00)
> > < HCI Command: Write Inquiry Mode (0x03|0x0045) plen 1 [hci0] 10.869239
> > Mode: Inquiry Result with RSSI or Extended Inquiry Result (0x02)
> >> HCI Event: Command Complete (0x0e) plen 4 [hci0] 10.869371
> > Write Inquiry Mode (0x03|0x0045) ncmd 1
> > Status: Success (0x00)
> > < HCI Command: Read Inquiry Response T.. (0x03|0x0058) plen 0 [hci0] 10.869396
> >> HCI Event: Command Complete (0x0e) plen 5 [hci0] 10.869552
> > Read Inquiry Response TX Power Level (0x03|0x0058) ncmd 1
> > Status: Success (0x00)
> > TX power: -1 dBm
> > < HCI Command: Read Local Extended Fea.. (0x04|0x0004) plen 1 [hci0] 10.869572
> > Page: 1
> >> HCI Event: Command Complete (0x0e) plen 14 [hci0] 10.869729
> > Read Local Extended Features (0x04|0x0004) ncmd 1
> > Status: Success (0x00)
> > Page: 1/2
> > Features: 0x01 0x00 0x00 0x00 0x00 0x00 0x00 0x00
> > Secure Simple Pairing (Host Support)
> > < HCI Command: Set Event Mask (0x03|0x0001) plen 8 [hci0] 10.869783
> > Mask: 0x3dbff807fffbffff
> > Inquiry Complete
> > Inquiry Result
> > Connection Complete
> > Connection Request
> > Disconnection Complete
> > Authentication Complete
> > Remote Name Request Complete
> > Encryption Change
> > Change Connection Link Key Complete
> > Master Link Key Complete
> > Read Remote Supported Features Complete
> > Read Remote Version Information Complete
> > QoS Setup Complete
> > Command Complete
> > Command Status
> > Hardware Error
> > Flush Occurred
> > Role Change
> > Mode Change
> > Return Link Keys
> > PIN Code Request
> > Link Key Request
> > Link Key Notification
> > Loopback Command
> > Data Buffer Overflow
> > Max Slots Change
> > Read Clock Offset Complete
> > Connection Packet Type Changed
> > QoS Violation
> > Page Scan Mode Change
> > Page Scan Repetition Mode Change
> > Flow Specification Complete
> > Inquiry Result with RSSI
> > Read Remote Extended Features Complete
> > Synchronous Connection Complete
> > Synchronous Connection Changed
> > Sniff Subrating
> > Extended Inquiry Result
> > Encryption Key Refresh Complete
> > IO Capability Request
> > IO Capability Request Reply
> > User Confirmation Request
> > User Passkey Request
> > Remote OOB Data Request
> > Simple Pairing Complete
> > Link Supervision Timeout Changed
> > Enhanced Flush Complete
> > User Passkey Notification
> > Keypress Notification
> > Remote Host Supported Features Notification
> > LE Meta
> >> HCI Event: Command Complete (0x0e) plen 4 [hci0] 10.869921
> > Set Event Mask (0x03|0x0001) ncmd 1
> > Status: Success (0x00)
> > < HCI Command: Read Stored Link Key (0x03|0x000d) plen 7 [hci0] 10.869947
> > Address: 00:00:00:00:00:00 (OUI 00-00-00)
> > Read all: 0x01
> >> HCI Event: Command Complete (0x0e) plen 8 [hci0] 10.870129
> > Read Stored Link Key (0x03|0x000d) ncmd 1
> > Status: Success (0x00)
> > Max num keys: 4
> > Num keys: 0
> > < HCI Command: Write Default Link Poli.. (0x02|0x000f) plen 2 [hci0] 10.870148
> > Link policy: 0x0005
> > Enable Role Switch
> > Enable Sniff Mode
> >> HCI Event: Command Complete (0x0e) plen 4 [hci0] 10.870310
> > Write Default Link Policy Settings (0x02|0x000f) ncmd 1
> > Status: Success (0x00)
> > < HCI Command: Read Page Scan Activity (0x03|0x001b) plen 0 [hci0] 10.870331
> >> HCI Event: Command Complete (0x0e) plen 8 [hci0] 10.870485
> > Read Page Scan Activity (0x03|0x001b) ncmd 1
> > Status: Success (0x00)
> > Interval: 1280.000 msec (0x0800)
> > Window: 11.250 msec (0x0012)
> > < HCI Command: Read Page Scan Type (0x03|0x0046) plen 0 [hci0] 10.870504
> >> HCI Event: Command Complete (0x0e) plen 5 [hci0] 10.870652
> > Read Page Scan Type (0x03|0x0046) ncmd 1
> > Status: Success (0x00)
> > Type: Standard Scan (0x00)
> > < HCI Command: LE Set Event Mask (0x08|0x0001) plen 8 [hci0] 10.870671
> > Mask: 0x0000000000000980
> > LE Read Local P-256 Public Key Complete
> > LE Generate DHKey Complete
> > Unknown mask (0x0000000000000800)
> >> HCI Event: Command Complete (0x0e) plen 4 [hci0] 10.870839
> > LE Set Event Mask (0x08|0x0001) ncmd 1
> > Status: Success (0x00)
> > < HCI Command: Write LE Host Supported (0x03|0x006d) plen 2 [hci0] 10.870859
> > Supported: 0x01
> > Simultaneous: 0x00
> >> HCI Event: Command Complete (0x0e) plen 4 [hci0] 10.871028
> > Write LE Host Supported (0x03|0x006d) ncmd 1
> > Status: Success (0x00)
> > < HCI Command: Read Local Extended Fea.. (0x04|0x0004) plen 1 [hci0] 10.871059
> > Page: 2
> >> HCI Event: Command Complete (0x0e) plen 14 [hci0] 10.871201
> > Read Local Extended Features (0x04|0x0004) ncmd 1
> > Status: Success (0x00)
> > Page: 2/2
> > Features: 0x25 0x0b 0x00 0x00 0x00 0x00 0x00 0x00
> > Connectionless Slave Broadcast - Master
> > Synchronization Train
> > Generalized interlaced scan
> > Secure Connections (Controller Support)
> > Ping
> > Train nudging
> > < HCI Command: Delete Stored Link Key (0x03|0x0012) plen 7 [hci0] 10.871240
> > Address: 00:00:00:00:00:00 (OUI 00-00-00)
> > Delete all: 0x01
> >> HCI Event: Command Complete (0x0e) plen 6 [hci0] 10.871384
> > Delete Stored Link Key (0x03|0x0012) ncmd 1
> > Status: Success (0x00)
> > Num keys: 0
> > < HCI Command: Set Event Mask Page 2 (0x03|0x0063) plen 8 [hci0] 10.871403
> > Mask: 0x0000000000b0c000
> > Triggered Clock Capture
> > Synchronization Train Complete
> > Slave Page Response Timeout
> > Connectionless Slave Broadcast Channel Map Change
> > Authenticated Payload Timeout Expired
> >> HCI Event: Command Complete (0x0e) plen 4 [hci0] 10.871566
> > Set Event Mask Page 2 (0x03|0x0063) ncmd 1
> > Status: Success (0x00)
> > < HCI Command: Read Local Supported Co.. (0x04|0x000b) plen 0 [hci0] 10.871599
> >> HCI Event: Command Complete (0x0e) plen 8 [hci0] 10.871750
> > Read Local Supported Codecs (0x04|0x000b) ncmd 1
> > Status: Success (0x00)
> > Number of supported codecs: 2
> > Codec: CVSD (0x02)
> > Codec: Transparent (0x03)
> > Number of vendor codecs: 0
> > < HCI Command: Read Synchronization Tr.. (0x03|0x0077) plen 0 [hci0] 10.871769
> >> HCI Event: Command Complete (0x0e) plen 11 [hci0] 10.871928
> > Read Synchronization Train Parameters (0x03|0x0077) ncmd 1
> > Status: Success (0x00)
> > Interval: 0.000 msec (0x0000)
> > Timeout: 0.000 msec (0x00000000)
> > Service data: 0x00
> > < HCI Command: Write Secure Connection.. (0x03|0x007a) plen 1 [hci0] 10.871947
> > Support: Enabled (0x01)
> >> HCI Event: Command Complete (0x0e) plen 4 [hci0] 10.872098
> > Write Secure Connections Host Support (0x03|0x007a) ncmd 1
> > Status: Success (0x00)
> > < HCI Command: Unknown (0x08|0x0031) plen 3 [hci0] 10.872156
> > 03 00 00 ...
> >> HCI Event: Command Complete (0x0e) plen 4 [hci0] 10.872322
> > Unknown (0x08|0x0031) ncmd 1
> > Status: Success (0x00)
> > = Index Info: 00:00:46:76:22:01 (MediaTek, Inc.) [hci0] 10.872361
>
> This extra index info worries me a little bit. I need to check if that is suppose to happen.
> > < HCI Command: LE Set Scan Response D.. (0x08|0x0009) plen 32 [hci0] 10.872431
> > Length: 10
> > Name (complete): builder
> >> HCI Event: Command Complete (0x0e) plen 4 [hci0] 10.872606
> > LE Set Scan Response Data (0x08|0x0009) ncmd 1
> > Status: Success (0x00)
> > < HCI Command: Write Scan Enable (0x03|0x001a) plen 1 [hci0] 10.872627
> > Scan enable: Page Scan (0x02)
> >> HCI Event: Command Complete (0x0e) plen 4 [hci0] 10.872819
> > Write Scan Enable (0x03|0x001a) ncmd 1
> > Status: Success (0x00)
> > < HCI Command: Write Class of Device (0x03|0x0024) plen 3 [hci0] 10.872841
> > Class: 0x000000
> > Major class: Miscellaneous
> > Minor class: 0x00
> >> HCI Event: Command Complete (0x0e) plen 4 [hci0] 10.873036
> > Write Class of Device (0x03|0x0024) ncmd 1
> > Status: Success (0x00)
> > * Unknown packet (code 17 len 9) [hci0] 10.873069
> > 02 00 00 00 07 00 00 00 00 .........
> > * Unknown packet (code 17 len 9) [hci0] 10.873069
> > 01 00 00 00 07 00 00 00 00 .........
> > < HCI Command: Write Local Name (0x03|0x0013) plen 248 [hci0] 10.873096
> > Name: builder
> >> HCI Event: Command Complete (0x0e) plen 4 [hci0] 10.873446
> > Write Local Name (0x03|0x0013) ncmd 1
> > Status: Success (0x00)
> > < HCI Command: Write Extended Inquir.. (0x03|0x0052) plen 241 [hci0] 10.873470
> > FEC: Not required (0x00)
> > Name (complete): builder
> > TX power: -1 dBm
> > Device ID: USB Implementer's Forum assigned (0x0002)
> > Vendor: Linux Foundation (0x1d6b)
> > Product: 0x0246
> > Version: 5.2.11 (0x052b)
> > 16-bit Service UUIDs (complete): 4 entries
> > Generic Access Profile (0x1800)
> > Generic Attribute Profile (0x1801)
> > A/V Remote Control (0x110e)
> > A/V Remote Control Target (0x110c)
> >> HCI Event: Command Complete (0x0e) plen 4 [hci0] 10.873857
> > Write Extended Inquiry Response (0x03|0x0052) ncmd 1
> > Status: Success (0x00)
> > * Unknown packet (code 17 len 13) [hci0] 10.873903
> > 01 00 00 00 01 00 05 00 00 d1 0a 00 00 .............
> > * Unknown packet (code 17 len 10) [hci0] 10.873913
> > 02 00 00 00 06 00 d1 0a 00 00 ..........
> > * Unknown packet (code 16 len 7) [hci0] 17.803939
> > 01 00 00 00 05 00 00 .......
> > < HCI Command: Write Scan Enable (0x03|0x001a) plen 1 [hci0] 17.803983
> > Scan enable: No Scans (0x00)
> >> HCI Event: Command Complete (0x0e) plen 4 [hci0] 17.804233
> > Write Scan Enable (0x03|0x001a) ncmd 1
> > Status: Success (0x00)
> > < HCI Command: Vendor (0x3f|0x006f) plen 6 [hci0] 17.804282
> > 01 06 02 00 00 00 ......
> >> HCI Event: Unknown (0xe4) plen 5 [hci0] 17.804636
> > 02 06 01 00 00 .....
> > * Unknown packet (code 17 len 13) [hci0] 17.811580
> > 01 00 00 00 01 00 05 00 00 d0 0a 00 00 .............
> > * Unknown packet (code 17 len 10) [hci0] 17.811596
> > 02 00 00 00 06 00 d0 0a 00 00 ..........
> > = Close Index: 00:00:46:76:22:01 [hci0] 17.811625
>
> Regards
>
> Marcel
>

2018-05-24 07:47:57

by Marcel Holtmann

[permalink] [raw]
Subject: Re: [PATCH v2 4/7] Bluetooth: Add new quirk for non-persistent setup settings

Hi Sean,

>>>>
>>>> [ ... ]
>>>>
>>>>>> - if (hci_dev_test_flag(hdev, HCI_SETUP)) {
>>>>>> + if (hci_dev_test_flag(hdev, HCI_SETUP) ||
>>>>>> + test_bit(HCI_QUIRK_NON_PERSISTENT_SETUP, &hdev->quirks)) {
>>>>>> hci_sock_dev_event(hdev, HCI_DEV_SETUP);
>>>>>
>>>>> I am not 100% sure that we want to send the HCI_DEV_SETUP event also multiple times. That is a userspace change that I would need to think about. We need to check create_monitor_event() and see what the btmon trace for this looks like. Can you send me a btmon -w trace.log when this change is active.
>>>>>
>>>>> Regards
>>>>>
>>>>> Marcel
>>>>>
>>>>
>>>> Sure, I'll send you the trace.log with the change is active.
>>>>
>>>> Sean
>>>>
>>>
>>>
>>> Attached trace.log was captured when I inputted commands power on and
>>> then off in bluetoothctl.
>>
>> the trace.log is somehow mangled. Something is not fully correct. Can you read it with btmon -r trace.log?
>>
>> Regards
>>
>> Marcel
>>
>
> Yes, I can read it with btmon -r trace.log.
>
> I post it as plain text as below
>
>
> Bluetooth monitor ver 5.37
> = Note: Linux version 4.16.0-rc1+ (aarch64) 0.641494
> = Note: Bluetooth subsystem version 2.22 0.641502
> = New Index: 00:00:46:76:22:01 (BR/EDR,UART,hci0) [hci0] 0.641505
> * Unknown packet (code 14 len 30) 0.641509
> 01 00 00 00 02 00 01 0e 00 01 00 00 00 10 62 6c ..............bl
> 75 65 74 6f 6f 74 68 64 00 00 00 00 00 00 uetoothd......
> * Unknown packet (code 14 len 30) 0.641592
> 02 00 00 00 02 00 01 0e 00 01 00 00 00 10 62 74 ..............bt
> 6d 6f 6e 00 00 00 00 00 00 00 00 00 00 00 mon...........
> * Unknown packet (code 16 len 7) [hci0] 6.536771
> 01 00 00 00 05 00 01 .......
> = Open Index: 00:00:46:76:22:01 [hci0] 6.717019
> = Index Info: 00:00:46:76:22:01 (MediaTek, Inc.) [hci0] 6.717030

can you try with the latest BlueZ 5.49 or git version. Seems it actually stumbles over the extra packet here. Fun fact is that I can not get a backtrace to pin-point the issue in btmon and why it crashes.

>> HCI Event: Unknown (0xe4) plen 5 [hci0] 6.741093
> 02 01 01 00 00 .....
>> HCI Event: Unknown (0xe4) plen 5 [hci0] 6.742088
> 02 01 01 00 00 .....
>> HCI Event: Unknown (0xe4) plen 5 [hci0] 6.743102
> 02 01 01 00 00 .....
>> HCI Event: Unknown (0xe4) plen 5 [hci0] 6.744105
> 02 01 01 00 00 .....
>> HCI Event: Unknown (0xe4) plen 5 [hci0] 6.745109
> 02 01 01 00 00 .....
>> HCI Event: Unknown (0xe4) plen 5 [hci0] 6.746104
> 02 01 01 00 00 .....
>> HCI Event: Unknown (0xe4) plen 5 [hci0] 6.747097
> 02 01 01 00 00 .....
>> HCI Event: Unknown (0xe4) plen 5 [hci0] 6.748090
> 02 01 01 00 00 .....
>> HCI Event: Unknown (0xe4) plen 5 [hci0] 6.749078
> 02 01 01 00 00 .....
>> HCI Event: Unknown (0xe4) plen 5 [hci0] 6.750070
> 02 01 01 00 00 .....
>> HCI Event: Unknown (0xe4) plen 5 [hci0] 6.751061
> 02 01 01 00 00 .....
>> HCI Event: Unknown (0xe4) plen 5 [hci0] 6.752054
> 02 01 01 00 00 .....
>> HCI Event: Unknown (0xe4) plen 5 [hci0] 6.753046
> 02 01 01 00 00 .....
>> HCI Event: Unknown (0xe4) plen 5 [hci0] 6.754038
> 02 01 01 00 00 .....
>> HCI Event: Unknown (0xe4) plen 5 [hci0] 6.755031
> 02 01 01 00 00 .....
>> HCI Event: Unknown (0xe4) plen 5 [hci0] 6.756025
> 02 01 01 00 00 .....
>> HCI Event: Unknown (0xe4) plen 5 [hci0] 6.757013
> 02 01 01 00 00 .....
>> HCI Event: Unknown (0xe4) plen 5 [hci0] 6.758006
> 02 01 01 00 00 .....
>> HCI Event: Unknown (0xe4) plen 5 [hci0] 6.758999
> 02 01 01 00 00 .....
>> HCI Event: Unknown (0xe4) plen 5 [hci0] 6.759991
> 02 01 01 00 00 .....
>> HCI Event: Unknown (0xe4) plen 5 [hci0] 6.760983
> 02 01 01 00 00 .....
>> HCI Event: Unknown (0xe4) plen 5 [hci0] 6.761975
> 02 01 01 00 00 .....
>> HCI Event: Unknown (0xe4) plen 5 [hci0] 6.762963
> 02 01 01 00 00 .....
>> HCI Event: Unknown (0xe4) plen 5 [hci0] 6.763956
> 02 01 01 00 00 .....
>> HCI Event: Unknown (0xe4) plen 5 [hci0] 6.764948
> 02 01 01 00 00 .....
>> HCI Event: Unknown (0xe4) plen 5 [hci0] 6.765941
> 02 01 01 00 00 .....
>> HCI Event: Unknown (0xe4) plen 5 [hci0] 6.766933
> 02 01 01 00 00 .....
>> HCI Event: Unknown (0xe4) plen 5 [hci0] 6.767926
> 02 01 01 00 00 .....
>> HCI Event: Unknown (0xe4) plen 5 [hci0] 6.768919
> 02 01 01 00 00 .....
>> HCI Event: Unknown (0xe4) plen 5 [hci0] 6.769914
> 02 01 01 00 00 .....
>> HCI Event: Unknown (0xe4) plen 5 [hci0] 6.770909
> 02 01 01 00 00 .....
>> HCI Event: Unknown (0xe4) plen 5 [hci0] 6.771908
> 02 01 01 00 00 .....
>> HCI Event: Unknown (0xe4) plen 5 [hci0] 6.772904
> 02 01 01 00 00 .....
>> HCI Event: Unknown (0xe4) plen 5 [hci0] 6.773898
> 02 01 01 00 00 .....
>> HCI Event: Unknown (0xe4) plen 5 [hci0] 6.774892
> 02 01 01 00 00 .....
>> HCI Event: Unknown (0xe4) plen 5 [hci0] 6.775890
> 02 01 01 00 00 .....
>> HCI Event: Unknown (0xe4) plen 5 [hci0] 6.776882
> 02 01 01 00 00 .....
>> HCI Event: Unknown (0xe4) plen 5 [hci0] 6.777877
> 02 01 01 00 00 .....
>> HCI Event: Unknown (0xe4) plen 5 [hci0] 6.778871
> 02 01 01 00 00 .....
>> HCI Event: Unknown (0xe4) plen 5 [hci0] 6.779869
> 02 01 01 00 00 .....
>> HCI Event: Unknown (0xe4) plen 5 [hci0] 6.780864
> 02 01 01 00 00 .....
>> HCI Event: Unknown (0xe4) plen 5 [hci0] 6.781858
> 02 01 01 00 00 .....
>> HCI Event: Unknown (0xe4) plen 5 [hci0] 6.782852
> 02 01 01 00 00 .....
>> HCI Event: Unknown (0xe4) plen 5 [hci0] 6.783850
> 02 01 01 00 00 .....
>> HCI Event: Unknown (0xe4) plen 5 [hci0] 6.784845
> 02 01 01 00 00 .....
>> HCI Event: Unknown (0xe4) plen 5 [hci0] 6.785839
> 02 01 01 00 00 .....
>> HCI Event: Unknown (0xe4) plen 5 [hci0] 6.786833
> 02 01 01 00 00 .....
>> HCI Event: Unknown (0xe4) plen 5 [hci0] 6.787831
> 02 01 01 00 00 .....
>> HCI Event: Unknown (0xe4) plen 5 [hci0] 6.788826
> 02 01 01 00 00 .....
>> HCI Event: Unknown (0xe4) plen 5 [hci0] 6.789820
> 02 01 01 00 00 .....
>> HCI Event: Unknown (0xe4) plen 5 [hci0] 6.790814
> 02 01 01 00 00 .....
>> HCI Event: Unknown (0xe4) plen 5 [hci0] 6.791813
> 02 01 01 00 00 .....
>> HCI Event: Unknown (0xe4) plen 5 [hci0] 6.792809
> 02 01 01 00 00 .....
>> HCI Event: Unknown (0xe4) plen 5 [hci0] 6.793803
> 02 01 01 00 00 .....
>> HCI Event: Unknown (0xe4) plen 5 [hci0] 6.794798
> 02 01 01 00 00 .....
>> HCI Event: Unknown (0xe4) plen 5 [hci0] 6.795797
> 02 01 01 00 00 .....
>> HCI Event: Unknown (0xe4) plen 5 [hci0] 6.796791
> 02 01 01 00 00 .....
>> HCI Event: Unknown (0xe4) plen 5 [hci0] 6.797786
> 02 01 01 00 00 .....
>> HCI Event: Unknown (0xe4) plen 5 [hci0] 6.798779
> 02 01 01 00 00 .....
>> HCI Event: Unknown (0xe4) plen 5 [hci0] 6.799778
> 02 01 01 00 00 .....
>> HCI Event: Unknown (0xe4) plen 5 [hci0] 6.800774
> 02 01 01 00 00 .....
>> HCI Event: Unknown (0xe4) plen 5 [hci0] 6.801769
> 02 01 01 00 00 .....
>> HCI Event: Unknown (0xe4) plen 5 [hci0] 6.802763
> 02 01 01 00 00 .....
>> HCI Event: Unknown (0xe4) plen 5 [hci0] 6.803761
> 02 01 01 00 00 .....
>> HCI Event: Unknown (0xe4) plen 5 [hci0] 6.804755
> 02 01 01 00 00 .....
>> HCI Event: Unknown (0xe4) plen 5 [hci0] 6.805749
> 02 01 01 00 00 .....
>> HCI Event: Unknown (0xe4) plen 5 [hci0] 6.806743
> 02 01 01 00 00 .....
>> HCI Event: Unknown (0xe4) plen 5 [hci0] 6.807741
> 02 01 01 00 00 .....
>> HCI Event: Unknown (0xe4) plen 5 [hci0] 6.808737
> 02 01 01 00 00 .....
>> HCI Event: Unknown (0xe4) plen 5 [hci0] 6.809731
> 02 01 01 00 00 .....
>> HCI Event: Unknown (0xe4) plen 5 [hci0] 6.810725
> 02 01 01 00 00 .....
>> HCI Event: Unknown (0xe4) plen 5 [hci0] 6.811725
> 02 01 01 00 00 .....
>> HCI Event: Unknown (0xe4) plen 5 [hci0] 6.812719
> 02 01 01 00 00 .....
>> HCI Event: Unknown (0xe4) plen 5 [hci0] 6.813714
> 02 01 01 00 00 .....
>> HCI Event: Unknown (0xe4) plen 5 [hci0] 6.814708
> 02 01 01 00 00 .....
>> HCI Event: Unknown (0xe4) plen 5 [hci0] 6.815705
> 02 01 01 00 00 .....
>> HCI Event: Unknown (0xe4) plen 5 [hci0] 6.816378
> 02 01 01 00 00 .....

Why do I see only HCI events here? Is this event conveying any useful information. It is kinda complicated that this is 0xe4 event code which is actually reserved for future use by the Bluetooth SIG. Are there any accompanying HCI commands for this and they just not make it into btmon?

> < HCI Command: Vendor (0x3f|0x006f) plen 5 [hci0] 6.816413
> 01 07 01 00 04 .....
>> HCI Event: Unknown (0xe4) plen 5 [hci0] 6.816536
> 02 07 01 00 00 .....
> < HCI Command: Vendor (0x3f|0x006f) plen 6 [hci0] 8.845071
> 01 06 02 00 00 01 ......
>> HCI Event: Unknown (0xe4) plen 5 [hci0] 8.923456
> 02 06 01 00 00 .....

Here it looks like you have 0x006f opcode with first octet 0x01 for command and then vendor event 0xe4 with first octet 0x02 for event. I assume the second octet is then the vendor command code for these.

> < HCI Command: Reset (0x03|0x0003) plen 0 [hci0] 10.861118
>> HCI Event: Command Complete (0x0e) plen 4 [hci0] 10.865763
> Reset (0x03|0x0003) ncmd 1
> Status: Success (0x00)
> < HCI Command: Read Local Supported Fe.. (0x04|0x0003) plen 0 [hci0] 10.865805
>> HCI Event: Command Complete (0x0e) plen 12 [hci0] 10.865965
> Read Local Supported Features (0x04|0x0003) ncmd 1
> Status: Success (0x00)
> Features: 0xbf 0x3e 0x8d 0xfe 0xdb 0xff 0x7b 0x87
> 3 slot packets
> 5 slot packets
> Encryption
> Slot offset
> Timing accuracy
> Role switch
> Sniff mode
> Power control requests
> Channel quality driven data rate (CQDDR)
> SCO link
> HV2 packets
> HV3 packets
> CVSD synchronous data
> Power control
> Transparent synchronous data
> Broadcast Encryption
> Enhanced Data Rate ACL 2 Mbps mode
> Enhanced Data Rate ACL 3 Mbps mode
> Enhanced inquiry scan
> Interlaced inquiry scan
> Interlaced page scan
> RSSI with inquiry results
> Extended SCO link (EV3 packets)
> EV4 packets
> EV5 packets
> AFH capable slave
> AFH classification slave
> LE Supported (Controller)
> 3-slot Enhanced Data Rate ACL packets
> 5-slot Enhanced Data Rate ACL packets
> Sniff subrating
> Pause encryption
> AFH capable master
> AFH classification master
> Enhanced Data Rate eSCO 2 Mbps mode
> Enhanced Data Rate eSCO 3 Mbps mode
> 3-slot Enhanced Data Rate eSCO packets
> Extended Inquiry Response
> Simultaneous LE and BR/EDR (Controller)
> Secure Simple Pairing
> Encapsulated PDU
> Erroneous Data Reporting
> Non-flushable Packet Boundary Flag
> Link Supervision Timeout Changed Event
> Inquiry TX Power Level
> Enhanced Power Control
> Extended features
> < HCI Command: Read Local Version Info.. (0x04|0x0001) plen 0 [hci0] 10.865987
>> HCI Event: Vendor (0xff) plen 9 [hci0] 10.866259
> 29 19 09 17 20 48 07 11 00 )... H…

Is this meant to happen here?

>> HCI Event: Command Complete (0x0e) plen 12 [hci0] 10.866372
> Read Local Version Information (0x04|0x0001) ncmd 1
> Status: Success (0x00)
> HCI version: Bluetooth 4.2 (0x08) - Revision 4359 (0x1107)
> LMP version: Bluetooth 4.2 (0x08) - Subversion 2329 (0x0919)
> Manufacturer: MediaTek, Inc. (70)
> < HCI Command: Read BD ADDR (0x04|0x0009) plen 0 [hci0] 10.866391
>> HCI Event: Command Complete (0x0e) plen 10 [hci0] 10.866539
> Read BD ADDR (0x04|0x0009) ncmd 1
> Status: Success (0x00)
> Address: 00:00:46:76:22:01 (OLIVETTI NORTH AMERICA)
> < HCI Command: Read Buffer Size (0x04|0x0005) plen 0 [hci0] 10.866609
>> HCI Event: Command Complete (0x0e) plen 11 [hci0] 10.866754
> Read Buffer Size (0x04|0x0005) ncmd 1
> Status: Success (0x00)
> ACL MTU: 1021 ACL max packet: 8
> SCO MTU: 184 SCO max packet: 1
> < HCI Command: Read Class of Device (0x03|0x0023) plen 0 [hci0] 10.866775
>> HCI Event: Command Complete (0x0e) plen 7 [hci0] 10.866920
> Read Class of Device (0x03|0x0023) ncmd 1
> Status: Success (0x00)
> Class: 0x001f00
> Major class: Uncategorized, specific device code not specified
> Minor class: 0x00
> < HCI Command: Read Local Name (0x03|0x0014) plen 0 [hci0] 10.866939
>> HCI Event: Command Complete (0x0e) plen 252 [hci0] 10.867256
> Read Local Name (0x03|0x0014) ncmd 1
> Status: Success (0x00)
> Name: MTK MT7622 #1
> < HCI Command: Read Voice Setting (0x03|0x0025) plen 0 [hci0] 10.867308
>> HCI Event: Command Complete (0x0e) plen 6 [hci0] 10.867447
> Read Voice Setting (0x03|0x0025) ncmd 1
> Status: Success (0x00)
> Setting: 0x0060
> Input Coding: Linear
> Input Data Format: 2's complement
> Input Sample Size: 16-bit
> # of bits padding at MSB: 0
> Air Coding Format: CVSD
> < HCI Command: Read Number of Supporte.. (0x03|0x0038) plen 0 [hci0] 10.867474
>> HCI Event: Command Complete (0x0e) plen 5 [hci0] 10.867611
> Read Number of Supported IAC (0x03|0x0038) ncmd 1
> Status: Success (0x00)
> Number of IAC: 4
> < HCI Command: Read Current IAC LAP (0x03|0x0039) plen 0 [hci0] 10.867678
>> HCI Event: Command Complete (0x0e) plen 8 [hci0] 10.867865
> Read Current IAC LAP (0x03|0x0039) ncmd 1
> Status: Success (0x00)
> Number of IAC: 1
> Access code: 0x9e8b33 (General Inquiry)
> < HCI Command: Set Event Filter (0x03|0x0005) plen 1 [hci0] 10.867890
> Type: Clear All Filters (0x00)
>> HCI Event: Command Complete (0x0e) plen 4 [hci0] 10.868033
> Set Event Filter (0x03|0x0005) ncmd 1
> Status: Success (0x00)
> < HCI Command: Write Connection Accept.. (0x03|0x0016) plen 2 [hci0] 10.868054
> Timeout: 20000.000 msec (0x7d00)
>> HCI Event: Command Complete (0x0e) plen 4 [hci0] 10.868235
> Write Connection Accept Timeout (0x03|0x0016) ncmd 1
> Status: Success (0x00)
> < HCI Command: LE Read Buffer Size (0x08|0x0002) plen 0 [hci0] 10.868262
>> HCI Event: Command Complete (0x0e) plen 7 [hci0] 10.868392
> LE Read Buffer Size (0x08|0x0002) ncmd 1
> Status: Success (0x00)
> Data packet length: 251
> Num data packets: 8
> < HCI Command: LE Read Local Supported.. (0x08|0x0003) plen 0 [hci0] 10.868413
>> HCI Event: Command Complete (0x0e) plen 12 [hci0] 10.868587
> LE Read Local Supported Features (0x08|0x0003) ncmd 1
> Status: Success (0x00)
> Features: 0xfd 0x00 0x00 0x00 0x00 0x00 0x00 0x00
> LE Encryption
> Extended Reject Indication
> Slave-initiated Features Exchange
> LE Ping
> LE Data Packet Length Extension
> LL Privacy
> Extended Scanner Filter Policies
> < HCI Command: LE Read Supported States (0x08|0x001c) plen 0 [hci0] 10.868646
>> HCI Event: Command Complete (0x0e) plen 12 [hci0] 10.868787
> LE Read Supported States (0x08|0x001c) ncmd 1
> Status: Success (0x00)
> States: 0x000000001fffffff
> Non-connectable Advertising State
> Scannable Advertising State
> Connectable Advertising State
> High Duty Cycle Directed Advertising State
> Passive Scanning State
> Active Scanning State
> Initiating State
> and Connection State (Master Role)
> Connection State (Slave Role)
> Non-connectable Advertising State
> and Passive Scanning State
> Scannable Advertising State
> and Passive Scanning State
> Connectable Advertising State
> and Passive Scanning State
> High Duty Cycle Directed Advertising State
> and Passive Scanning State
> Non-connectable Advertising State
> and Active Scanning State
> Scannable Advertising State
> and Active Scanning State
> Connectable Advertising State
> and Active Scanning State
> High Duty Cycle Directed Advertising State
> and Active Scanning State
> Non-connectable Advertising State
> and Initiating State
> Scannable Advertising State
> and Initiating State
> Non-connectable Advertising State
> and Connection State (Master Role)
> Scannable Advertising State
> and Connection State (Master Role)
> Non-connectable Advertising State
> and Connection State (Slave Role)
> Scannable Advertising State
> and Connection State (Slave Role)
> Passive Scanning State
> and Initiating State
> Active Scanning State
> and Initiating State
> Passive Scanning State
> and Connection State (Master Role)
> Active Scanning State
> and Connection State (Master Role)
> Passive Scanning State
> and Connection State (Slave Role)
> Active Scanning State
> and Connection State (Slave Role)
> Initiating State
> and Connection State (Master Role)
> and Master Role & Master Role
> < HCI Command: Read Local Supported Co.. (0x04|0x0002) plen 0 [hci0] 10.868807
>> HCI Event: Command Complete (0x0e) plen 68 [hci0] 10.868985
> Read Local Supported Commands (0x04|0x0002) ncmd 1
> Status: Success (0x00)
> Commands: 176 entries
> Inquiry (Octet 0 - Bit 0)
> Inquiry Cancel (Octet 0 - Bit 1)
> Periodic Inquiry Mode (Octet 0 - Bit 2)
> Exit Periodic Inquiry Mode (Octet 0 - Bit 3)
> Create Connection (Octet 0 - Bit 4)
> Disconnect (Octet 0 - Bit 5)
> Add SCO Connection (Octet 0 - Bit 6)
> Create Connection Cancel (Octet 0 - Bit 7)
> Accept Connection Request (Octet 1 - Bit 0)
> Reject Connection Request (Octet 1 - Bit 1)
> Link Key Request Reply (Octet 1 - Bit 2)
> Link Key Request Negative Reply (Octet 1 - Bit 3)
> PIN Code Request Reply (Octet 1 - Bit 4)
> PIN Code Request Negative Reply (Octet 1 - Bit 5)
> Change Connection Packet Type (Octet 1 - Bit 6)
> Authentication Requested (Octet 1 - Bit 7)
> Set Connection Encryption (Octet 2 - Bit 0)
> Change Connection Link Key (Octet 2 - Bit 1)
> Master Link Key (Octet 2 - Bit 2)
> Remote Name Request (Octet 2 - Bit 3)
> Remote Name Request Cancel (Octet 2 - Bit 4)
> Read Remote Supported Features (Octet 2 - Bit 5)
> Read Remote Extended Features (Octet 2 - Bit 6)
> Read Remote Version Information (Octet 2 - Bit 7)
> Read Clock Offset (Octet 3 - Bit 0)
> Read LMP Handle (Octet 3 - Bit 1)
> Sniff Mode (Octet 4 - Bit 2)
> Exit Sniff Mode (Octet 4 - Bit 3)
> QoS Setup (Octet 4 - Bit 6)
> Role Discovery (Octet 4 - Bit 7)
> Switch Role (Octet 5 - Bit 0)
> Read Link Policy Settings (Octet 5 - Bit 1)
> Write Link Policy Settings (Octet 5 - Bit 2)
> Read Default Link Policy Settings (Octet 5 - Bit 3)
> Write Default Link Policy Settings (Octet 5 - Bit 4)
> Flow Specification (Octet 5 - Bit 5)
> Set Event Mask (Octet 5 - Bit 6)
> Reset (Octet 5 - Bit 7)
> Set Event Filter (Octet 6 - Bit 0)
> Flush (Octet 6 - Bit 1)
> Read PIN Type (Octet 6 - Bit 2)
> Write PIN Type (Octet 6 - Bit 3)
> Create New Unit Key (Octet 6 - Bit 4)
> Read Stored Link Key (Octet 6 - Bit 5)
> Write Stored Link Key (Octet 6 - Bit 6)
> Delete Stored Link Key (Octet 6 - Bit 7)
> Write Local Name (Octet 7 - Bit 0)
> Read Local Name (Octet 7 - Bit 1)
> Read Connection Accept Timeout (Octet 7 - Bit 2)
> Write Connection Accept Timeout (Octet 7 - Bit 3)
> Read Page Timeout (Octet 7 - Bit 4)
> Write Page Timeout (Octet 7 - Bit 5)
> Read Scan Enable (Octet 7 - Bit 6)
> Write Scan Enable (Octet 7 - Bit 7)
> Read Page Scan Activity (Octet 8 - Bit 0)
> Write Page Scan Activity (Octet 8 - Bit 1)
> Read Inquiry Scan Activity (Octet 8 - Bit 2)
> Write Inquiry Scan Activity (Octet 8 - Bit 3)
> Read Authentication Enable (Octet 8 - Bit 4)
> Write Authentication Enable (Octet 8 - Bit 5)
> Read Encryption Mode (Octet 8 - Bit 6)
> Write Encryption Mode (Octet 8 - Bit 7)
> Read Class of Device (Octet 9 - Bit 0)
> Write Class of Device (Octet 9 - Bit 1)
> Read Voice Setting (Octet 9 - Bit 2)
> Write Voice Setting (Octet 9 - Bit 3)
> Read Automatic Flush Timeout (Octet 9 - Bit 4)
> Write Automatic Flush Timeout (Octet 9 - Bit 5)
> Read Num Broadcast Retransmissions (Octet 9 - Bit 6)
> Write Num Broadcast Retransmissions (Octet 9 - Bit 7)
> Read Transmit Power Level (Octet 10 - Bit 2)
> Read Sync Flow Control Enable (Octet 10 - Bit 3)
> Write Sync Flow Control Enable (Octet 10 - Bit 4)
> Set Controller To Host Flow Control (Octet 10 - Bit 5)
> Host Buffer Size (Octet 10 - Bit 6)
> Host Number of Completed Packets (Octet 10 - Bit 7)
> Read Link Supervision Timeout (Octet 11 - Bit 0)
> Write Link Supervision Timeout (Octet 11 - Bit 1)
> Read Number of Supported IAC (Octet 11 - Bit 2)
> Read Current IAC LAP (Octet 11 - Bit 3)
> Write Current IAC LAP (Octet 11 - Bit 4)
> Read Page Scan Mode (Octet 11 - Bit 7)
> Write Page Scan Mode (Octet 12 - Bit 0)
> Set AFH Host Channel Classification (Octet 12 - Bit 1)
> Read Inquiry Scan Type (Octet 12 - Bit 4)
> Write Inquiry Scan Type (Octet 12 - Bit 5)
> Read Inquiry Mode (Octet 12 - Bit 6)
> Write Inquiry Mode (Octet 12 - Bit 7)
> Read Page Scan Type (Octet 13 - Bit 0)
> Write Page Scan Type (Octet 13 - Bit 1)
> Read AFH Channel Assessment Mode (Octet 13 - Bit 2)
> Write AFH Channel Assessment Mode (Octet 13 - Bit 3)
> Read Local Version Information (Octet 14 - Bit 3)
> Read Local Supported Features (Octet 14 - Bit 5)
> Read Local Extended Features (Octet 14 - Bit 6)
> Read Buffer Size (Octet 14 - Bit 7)
> Read Country Code (Octet 15 - Bit 0)
> Read BD ADDR (Octet 15 - Bit 1)
> Read Failed Contact Counter (Octet 15 - Bit 2)
> Reset Failed Contact Counter (Octet 15 - Bit 3)
> Read Link Quality (Octet 15 - Bit 4)
> Read RSSI (Octet 15 - Bit 5)
> Read AFH Channel Map (Octet 15 - Bit 6)
> Read Clock (Octet 15 - Bit 7)
> Read Loopback Mode (Octet 16 - Bit 0)
> Write Loopback Mode (Octet 16 - Bit 1)
> Enable Device Under Test Mode (Octet 16 - Bit 2)
> Setup Synchronous Connection (Octet 16 - Bit 3)
> Accept Synchronous Connection Request (Octet 16 - Bit 4)
> Reject Synchronous Connection Request (Octet 16 - Bit 5)
> Read Extended Inquiry Response (Octet 17 - Bit 0)
> Write Extended Inquiry Response (Octet 17 - Bit 1)
> Refresh Encryption Key (Octet 17 - Bit 2)
> Sniff Subrating (Octet 17 - Bit 4)
> Read Simple Pairing Mode (Octet 17 - Bit 5)
> Write Simple Pairing Mode (Octet 17 - Bit 6)
> Read Local OOB Data (Octet 17 - Bit 7)
> Read Inquiry Response TX Power Level (Octet 18 - Bit 0)
> Write Inquiry Transmit Power Level (Octet 18 - Bit 1)
> Read Default Erroneous Data Reporting (Octet 18 - Bit 2)
> Write Default Erroneous Data Reporting (Octet 18 - Bit 3)
> IO Capability Request Reply (Octet 18 - Bit 7)
> User Confirmation Request Reply (Octet 19 - Bit 0)
> User Confirmation Request Neg Reply (Octet 19 - Bit 1)
> User Passkey Request Reply (Octet 19 - Bit 2)
> User Passkey Request Negative Reply (Octet 19 - Bit 3)
> Remote OOB Data Request Reply (Octet 19 - Bit 4)
> Write Simple Pairing Debug Mode (Octet 19 - Bit 5)
> Enhanced Flush (Octet 19 - Bit 6)
> Remote OOB Data Request Neg Reply (Octet 19 - Bit 7)
> Send Keypress Notification (Octet 20 - Bit 2)
> IO Capability Request Negative Reply (Octet 20 - Bit 3)
> Read Encryption Key Size (Octet 20 - Bit 4)
> Set Event Mask Page 2 (Octet 22 - Bit 2)
> Read Enhanced Transmit Power Level (Octet 24 - Bit 0)
> Enhanced Setup Synchronous Connection (Octet 29 - Bit 3)
> Enhanced Accept Synchronous Connection Request (Octet 29 - Bit 4)
> Read Local Supported Codecs (Octet 29 - Bit 5)
> Set Triggered Clock Capture (Octet 30 - Bit 5)
> Truncated Page (Octet 30 - Bit 6)
> Truncated Page Cancel (Octet 30 - Bit 7)
> Set Connectionless Slave Broadcast (Octet 31 - Bit 0)
> Start Synchronization Train (Octet 31 - Bit 2)
> Set Reserved LT_ADDR (Octet 31 - Bit 4)
> Delete Reserved LT_ADDR (Octet 31 - Bit 5)
> Set Connectionless Slave Broadcast Data (Octet 31 - Bit 6)
> Read Synchronization Train Parameters (Octet 31 - Bit 7)
> Write Synchronization Train Parameters (Octet 32 - Bit 0)
> Remote OOB Extended Data Request Reply (Octet 32 - Bit 1)
> Read Authenticated Payload Timeout (Octet 32 - Bit 4)
> Write Authenticated Payload Timeout (Octet 32 - Bit 5)
> Read Local OOB Extended Data (Octet 32 - Bit 6)
> Write Secure Connections Test Mode (Octet 32 - Bit 7)
> Read Extended Page Timeout (Octet 33 - Bit 0)
> Write Extended Page Timeout (Octet 33 - Bit 1)
> Read Extended Inquiry Length (Octet 33 - Bit 2)
> Write Extended Inquiry Length (Octet 33 - Bit 3)
> LE Set Data Length (Octet 33 - Bit 6)
> LE Read Suggested Default Data Length (Octet 33 - Bit 7)
> LE Write Suggested Default Data Length (Octet 34 - Bit 0)
> LE Read Local P-256 Public Key (Octet 34 - Bit 1)
> LE Generate DHKey (Octet 34 - Bit 2)
> LE Add Device To Resolving List (Octet 34 - Bit 3)
> LE Remove Device From Resolving List (Octet 34 - Bit 4)
> LE Clear Resolving List (Octet 34 - Bit 5)
> LE Read Resolving List Size (Octet 34 - Bit 6)
> LE Read Peer Resolvable Address (Octet 34 - Bit 7)
> LE Read Local Resolvable Address (Octet 35 - Bit 0)
> LE Set Address Resolution Enable (Octet 35 - Bit 1)
> LE Set Resolvable Private Address Timeout (Octet 35 - Bit 2)
> LE Read Maximum Data Length (Octet 35 - Bit 3)
> Octet 35 - Bit 4
> Octet 35 - Bit 5
> Octet 35 - Bit 6
> Octet 35 - Bit 7
> Octet 36 - Bit 0

So you support the PHY commands, but do not indicate support LE 2M or LE Coded? Also these are Bluetooth 5.0 commands.

> < HCI Command: Write Simple Pairing Mode (0x03|0x0056) plen 1 [hci0] 10.869023
> Mode: Enabled (0x01)
>> HCI Event: Command Complete (0x0e) plen 4 [hci0] 10.869185
> Write Simple Pairing Mode (0x03|0x0056) ncmd 1
> Status: Success (0x00)
> < HCI Command: Write Inquiry Mode (0x03|0x0045) plen 1 [hci0] 10.869239
> Mode: Inquiry Result with RSSI or Extended Inquiry Result (0x02)
>> HCI Event: Command Complete (0x0e) plen 4 [hci0] 10.869371
> Write Inquiry Mode (0x03|0x0045) ncmd 1
> Status: Success (0x00)
> < HCI Command: Read Inquiry Response T.. (0x03|0x0058) plen 0 [hci0] 10.869396
>> HCI Event: Command Complete (0x0e) plen 5 [hci0] 10.869552
> Read Inquiry Response TX Power Level (0x03|0x0058) ncmd 1
> Status: Success (0x00)
> TX power: -1 dBm
> < HCI Command: Read Local Extended Fea.. (0x04|0x0004) plen 1 [hci0] 10.869572
> Page: 1
>> HCI Event: Command Complete (0x0e) plen 14 [hci0] 10.869729
> Read Local Extended Features (0x04|0x0004) ncmd 1
> Status: Success (0x00)
> Page: 1/2
> Features: 0x01 0x00 0x00 0x00 0x00 0x00 0x00 0x00
> Secure Simple Pairing (Host Support)
> < HCI Command: Set Event Mask (0x03|0x0001) plen 8 [hci0] 10.869783
> Mask: 0x3dbff807fffbffff
> Inquiry Complete
> Inquiry Result
> Connection Complete
> Connection Request
> Disconnection Complete
> Authentication Complete
> Remote Name Request Complete
> Encryption Change
> Change Connection Link Key Complete
> Master Link Key Complete
> Read Remote Supported Features Complete
> Read Remote Version Information Complete
> QoS Setup Complete
> Command Complete
> Command Status
> Hardware Error
> Flush Occurred
> Role Change
> Mode Change
> Return Link Keys
> PIN Code Request
> Link Key Request
> Link Key Notification
> Loopback Command
> Data Buffer Overflow
> Max Slots Change
> Read Clock Offset Complete
> Connection Packet Type Changed
> QoS Violation
> Page Scan Mode Change
> Page Scan Repetition Mode Change
> Flow Specification Complete
> Inquiry Result with RSSI
> Read Remote Extended Features Complete
> Synchronous Connection Complete
> Synchronous Connection Changed
> Sniff Subrating
> Extended Inquiry Result
> Encryption Key Refresh Complete
> IO Capability Request
> IO Capability Request Reply
> User Confirmation Request
> User Passkey Request
> Remote OOB Data Request
> Simple Pairing Complete
> Link Supervision Timeout Changed
> Enhanced Flush Complete
> User Passkey Notification
> Keypress Notification
> Remote Host Supported Features Notification
> LE Meta
>> HCI Event: Command Complete (0x0e) plen 4 [hci0] 10.869921
> Set Event Mask (0x03|0x0001) ncmd 1
> Status: Success (0x00)
> < HCI Command: Read Stored Link Key (0x03|0x000d) plen 7 [hci0] 10.869947
> Address: 00:00:00:00:00:00 (OUI 00-00-00)
> Read all: 0x01
>> HCI Event: Command Complete (0x0e) plen 8 [hci0] 10.870129
> Read Stored Link Key (0x03|0x000d) ncmd 1
> Status: Success (0x00)
> Max num keys: 4
> Num keys: 0
> < HCI Command: Write Default Link Poli.. (0x02|0x000f) plen 2 [hci0] 10.870148
> Link policy: 0x0005
> Enable Role Switch
> Enable Sniff Mode
>> HCI Event: Command Complete (0x0e) plen 4 [hci0] 10.870310
> Write Default Link Policy Settings (0x02|0x000f) ncmd 1
> Status: Success (0x00)
> < HCI Command: Read Page Scan Activity (0x03|0x001b) plen 0 [hci0] 10.870331
>> HCI Event: Command Complete (0x0e) plen 8 [hci0] 10.870485
> Read Page Scan Activity (0x03|0x001b) ncmd 1
> Status: Success (0x00)
> Interval: 1280.000 msec (0x0800)
> Window: 11.250 msec (0x0012)
> < HCI Command: Read Page Scan Type (0x03|0x0046) plen 0 [hci0] 10.870504
>> HCI Event: Command Complete (0x0e) plen 5 [hci0] 10.870652
> Read Page Scan Type (0x03|0x0046) ncmd 1
> Status: Success (0x00)
> Type: Standard Scan (0x00)
> < HCI Command: LE Set Event Mask (0x08|0x0001) plen 8 [hci0] 10.870671
> Mask: 0x0000000000000980
> LE Read Local P-256 Public Key Complete
> LE Generate DHKey Complete
> Unknown mask (0x0000000000000800)
>> HCI Event: Command Complete (0x0e) plen 4 [hci0] 10.870839
> LE Set Event Mask (0x08|0x0001) ncmd 1
> Status: Success (0x00)
> < HCI Command: Write LE Host Supported (0x03|0x006d) plen 2 [hci0] 10.870859
> Supported: 0x01
> Simultaneous: 0x00
>> HCI Event: Command Complete (0x0e) plen 4 [hci0] 10.871028
> Write LE Host Supported (0x03|0x006d) ncmd 1
> Status: Success (0x00)
> < HCI Command: Read Local Extended Fea.. (0x04|0x0004) plen 1 [hci0] 10.871059
> Page: 2
>> HCI Event: Command Complete (0x0e) plen 14 [hci0] 10.871201
> Read Local Extended Features (0x04|0x0004) ncmd 1
> Status: Success (0x00)
> Page: 2/2
> Features: 0x25 0x0b 0x00 0x00 0x00 0x00 0x00 0x00
> Connectionless Slave Broadcast - Master
> Synchronization Train
> Generalized interlaced scan
> Secure Connections (Controller Support)
> Ping
> Train nudging
> < HCI Command: Delete Stored Link Key (0x03|0x0012) plen 7 [hci0] 10.871240
> Address: 00:00:00:00:00:00 (OUI 00-00-00)
> Delete all: 0x01
>> HCI Event: Command Complete (0x0e) plen 6 [hci0] 10.871384
> Delete Stored Link Key (0x03|0x0012) ncmd 1
> Status: Success (0x00)
> Num keys: 0
> < HCI Command: Set Event Mask Page 2 (0x03|0x0063) plen 8 [hci0] 10.871403
> Mask: 0x0000000000b0c000
> Triggered Clock Capture
> Synchronization Train Complete
> Slave Page Response Timeout
> Connectionless Slave Broadcast Channel Map Change
> Authenticated Payload Timeout Expired
>> HCI Event: Command Complete (0x0e) plen 4 [hci0] 10.871566
> Set Event Mask Page 2 (0x03|0x0063) ncmd 1
> Status: Success (0x00)
> < HCI Command: Read Local Supported Co.. (0x04|0x000b) plen 0 [hci0] 10.871599
>> HCI Event: Command Complete (0x0e) plen 8 [hci0] 10.871750
> Read Local Supported Codecs (0x04|0x000b) ncmd 1
> Status: Success (0x00)
> Number of supported codecs: 2
> Codec: CVSD (0x02)
> Codec: Transparent (0x03)
> Number of vendor codecs: 0
> < HCI Command: Read Synchronization Tr.. (0x03|0x0077) plen 0 [hci0] 10.871769
>> HCI Event: Command Complete (0x0e) plen 11 [hci0] 10.871928
> Read Synchronization Train Parameters (0x03|0x0077) ncmd 1
> Status: Success (0x00)
> Interval: 0.000 msec (0x0000)
> Timeout: 0.000 msec (0x00000000)
> Service data: 0x00
> < HCI Command: Write Secure Connection.. (0x03|0x007a) plen 1 [hci0] 10.871947
> Support: Enabled (0x01)
>> HCI Event: Command Complete (0x0e) plen 4 [hci0] 10.872098
> Write Secure Connections Host Support (0x03|0x007a) ncmd 1
> Status: Success (0x00)
> < HCI Command: Unknown (0x08|0x0031) plen 3 [hci0] 10.872156
> 03 00 00 ...
>> HCI Event: Command Complete (0x0e) plen 4 [hci0] 10.872322
> Unknown (0x08|0x0031) ncmd 1
> Status: Success (0x00)
> = Index Info: 00:00:46:76:22:01 (MediaTek, Inc.) [hci0] 10.872361

This extra index info worries me a little bit. I need to check if that is suppose to happen.

> < HCI Command: LE Set Scan Response D.. (0x08|0x0009) plen 32 [hci0] 10.872431
> Length: 10
> Name (complete): builder
>> HCI Event: Command Complete (0x0e) plen 4 [hci0] 10.872606
> LE Set Scan Response Data (0x08|0x0009) ncmd 1
> Status: Success (0x00)
> < HCI Command: Write Scan Enable (0x03|0x001a) plen 1 [hci0] 10.872627
> Scan enable: Page Scan (0x02)
>> HCI Event: Command Complete (0x0e) plen 4 [hci0] 10.872819
> Write Scan Enable (0x03|0x001a) ncmd 1
> Status: Success (0x00)
> < HCI Command: Write Class of Device (0x03|0x0024) plen 3 [hci0] 10.872841
> Class: 0x000000
> Major class: Miscellaneous
> Minor class: 0x00
>> HCI Event: Command Complete (0x0e) plen 4 [hci0] 10.873036
> Write Class of Device (0x03|0x0024) ncmd 1
> Status: Success (0x00)
> * Unknown packet (code 17 len 9) [hci0] 10.873069
> 02 00 00 00 07 00 00 00 00 .........
> * Unknown packet (code 17 len 9) [hci0] 10.873069
> 01 00 00 00 07 00 00 00 00 .........
> < HCI Command: Write Local Name (0x03|0x0013) plen 248 [hci0] 10.873096
> Name: builder
>> HCI Event: Command Complete (0x0e) plen 4 [hci0] 10.873446
> Write Local Name (0x03|0x0013) ncmd 1
> Status: Success (0x00)
> < HCI Command: Write Extended Inquir.. (0x03|0x0052) plen 241 [hci0] 10.873470
> FEC: Not required (0x00)
> Name (complete): builder
> TX power: -1 dBm
> Device ID: USB Implementer's Forum assigned (0x0002)
> Vendor: Linux Foundation (0x1d6b)
> Product: 0x0246
> Version: 5.2.11 (0x052b)
> 16-bit Service UUIDs (complete): 4 entries
> Generic Access Profile (0x1800)
> Generic Attribute Profile (0x1801)
> A/V Remote Control (0x110e)
> A/V Remote Control Target (0x110c)
>> HCI Event: Command Complete (0x0e) plen 4 [hci0] 10.873857
> Write Extended Inquiry Response (0x03|0x0052) ncmd 1
> Status: Success (0x00)
> * Unknown packet (code 17 len 13) [hci0] 10.873903
> 01 00 00 00 01 00 05 00 00 d1 0a 00 00 .............
> * Unknown packet (code 17 len 10) [hci0] 10.873913
> 02 00 00 00 06 00 d1 0a 00 00 ..........
> * Unknown packet (code 16 len 7) [hci0] 17.803939
> 01 00 00 00 05 00 00 .......
> < HCI Command: Write Scan Enable (0x03|0x001a) plen 1 [hci0] 17.803983
> Scan enable: No Scans (0x00)
>> HCI Event: Command Complete (0x0e) plen 4 [hci0] 17.804233
> Write Scan Enable (0x03|0x001a) ncmd 1
> Status: Success (0x00)
> < HCI Command: Vendor (0x3f|0x006f) plen 6 [hci0] 17.804282
> 01 06 02 00 00 00 ......
>> HCI Event: Unknown (0xe4) plen 5 [hci0] 17.804636
> 02 06 01 00 00 .....
> * Unknown packet (code 17 len 13) [hci0] 17.811580
> 01 00 00 00 01 00 05 00 00 d0 0a 00 00 .............
> * Unknown packet (code 17 len 10) [hci0] 17.811596
> 02 00 00 00 06 00 d0 0a 00 00 ..........
> = Close Index: 00:00:46:76:22:01 [hci0] 17.811625

Regards

Marcel


2018-05-23 14:09:04

by Sean Wang

[permalink] [raw]
Subject: Re: [PATCH v2 4/7] Bluetooth: Add new quirk for non-persistent setup settings

On Wed, 2018-05-23 at 14:31 +0200, Marcel Holtmann wrote:
> Hi Sean,
>
> >>
> >> [ ... ]
> >>
> >>>> - if (hci_dev_test_flag(hdev, HCI_SETUP)) {
> >>>> + if (hci_dev_test_flag(hdev, HCI_SETUP) ||
> >>>> + test_bit(HCI_QUIRK_NON_PERSISTENT_SETUP, &hdev->quirks)) {
> >>>> hci_sock_dev_event(hdev, HCI_DEV_SETUP);
> >>>
> >>> I am not 100% sure that we want to send the HCI_DEV_SETUP event also multiple times. That is a userspace change that I would need to think about. We need to check create_monitor_event() and see what the btmon trace for this looks like. Can you send me a btmon -w trace.log when this change is active.
> >>>
> >>> Regards
> >>>
> >>> Marcel
> >>>
> >>
> >> Sure, I'll send you the trace.log with the change is active.
> >>
> >> Sean
> >>
> >
> >
> > Attached trace.log was captured when I inputted commands power on and
> > then off in bluetoothctl.
>
> the trace.log is somehow mangled. Something is not fully correct. Can you read it with btmon -r trace.log?
>
> Regards
>
> Marcel
>

Yes, I can read it with btmon -r trace.log.

I post it as plain text as below


Bluetooth monitor ver 5.37
= Note: Linux version 4.16.0-rc1+ (aarch64) 0.641494
= Note: Bluetooth subsystem version 2.22 0.641502
= New Index: 00:00:46:76:22:01 (BR/EDR,UART,hci0) [hci0] 0.641505
* Unknown packet (code 14 len 30) 0.641509
01 00 00 00 02 00 01 0e 00 01 00 00 00 10 62 6c ..............bl
75 65 74 6f 6f 74 68 64 00 00 00 00 00 00 uetoothd......
* Unknown packet (code 14 len 30) 0.641592
02 00 00 00 02 00 01 0e 00 01 00 00 00 10 62 74 ..............bt
6d 6f 6e 00 00 00 00 00 00 00 00 00 00 00 mon...........
* Unknown packet (code 16 len 7) [hci0] 6.536771
01 00 00 00 05 00 01 .......
= Open Index: 00:00:46:76:22:01 [hci0] 6.717019
= Index Info: 00:00:46:76:22:01 (MediaTek, Inc.) [hci0] 6.717030
> HCI Event: Unknown (0xe4) plen 5 [hci0] 6.741093
02 01 01 00 00 .....
> HCI Event: Unknown (0xe4) plen 5 [hci0] 6.742088
02 01 01 00 00 .....
> HCI Event: Unknown (0xe4) plen 5 [hci0] 6.743102
02 01 01 00 00 .....
> HCI Event: Unknown (0xe4) plen 5 [hci0] 6.744105
02 01 01 00 00 .....
> HCI Event: Unknown (0xe4) plen 5 [hci0] 6.745109
02 01 01 00 00 .....
> HCI Event: Unknown (0xe4) plen 5 [hci0] 6.746104
02 01 01 00 00 .....
> HCI Event: Unknown (0xe4) plen 5 [hci0] 6.747097
02 01 01 00 00 .....
> HCI Event: Unknown (0xe4) plen 5 [hci0] 6.748090
02 01 01 00 00 .....
> HCI Event: Unknown (0xe4) plen 5 [hci0] 6.749078
02 01 01 00 00 .....
> HCI Event: Unknown (0xe4) plen 5 [hci0] 6.750070
02 01 01 00 00 .....
> HCI Event: Unknown (0xe4) plen 5 [hci0] 6.751061
02 01 01 00 00 .....
> HCI Event: Unknown (0xe4) plen 5 [hci0] 6.752054
02 01 01 00 00 .....
> HCI Event: Unknown (0xe4) plen 5 [hci0] 6.753046
02 01 01 00 00 .....
> HCI Event: Unknown (0xe4) plen 5 [hci0] 6.754038
02 01 01 00 00 .....
> HCI Event: Unknown (0xe4) plen 5 [hci0] 6.755031
02 01 01 00 00 .....
> HCI Event: Unknown (0xe4) plen 5 [hci0] 6.756025
02 01 01 00 00 .....
> HCI Event: Unknown (0xe4) plen 5 [hci0] 6.757013
02 01 01 00 00 .....
> HCI Event: Unknown (0xe4) plen 5 [hci0] 6.758006
02 01 01 00 00 .....
> HCI Event: Unknown (0xe4) plen 5 [hci0] 6.758999
02 01 01 00 00 .....
> HCI Event: Unknown (0xe4) plen 5 [hci0] 6.759991
02 01 01 00 00 .....
> HCI Event: Unknown (0xe4) plen 5 [hci0] 6.760983
02 01 01 00 00 .....
> HCI Event: Unknown (0xe4) plen 5 [hci0] 6.761975
02 01 01 00 00 .....
> HCI Event: Unknown (0xe4) plen 5 [hci0] 6.762963
02 01 01 00 00 .....
> HCI Event: Unknown (0xe4) plen 5 [hci0] 6.763956
02 01 01 00 00 .....
> HCI Event: Unknown (0xe4) plen 5 [hci0] 6.764948
02 01 01 00 00 .....
> HCI Event: Unknown (0xe4) plen 5 [hci0] 6.765941
02 01 01 00 00 .....
> HCI Event: Unknown (0xe4) plen 5 [hci0] 6.766933
02 01 01 00 00 .....
> HCI Event: Unknown (0xe4) plen 5 [hci0] 6.767926
02 01 01 00 00 .....
> HCI Event: Unknown (0xe4) plen 5 [hci0] 6.768919
02 01 01 00 00 .....
> HCI Event: Unknown (0xe4) plen 5 [hci0] 6.769914
02 01 01 00 00 .....
> HCI Event: Unknown (0xe4) plen 5 [hci0] 6.770909
02 01 01 00 00 .....
> HCI Event: Unknown (0xe4) plen 5 [hci0] 6.771908
02 01 01 00 00 .....
> HCI Event: Unknown (0xe4) plen 5 [hci0] 6.772904
02 01 01 00 00 .....
> HCI Event: Unknown (0xe4) plen 5 [hci0] 6.773898
02 01 01 00 00 .....
> HCI Event: Unknown (0xe4) plen 5 [hci0] 6.774892
02 01 01 00 00 .....
> HCI Event: Unknown (0xe4) plen 5 [hci0] 6.775890
02 01 01 00 00 .....
> HCI Event: Unknown (0xe4) plen 5 [hci0] 6.776882
02 01 01 00 00 .....
> HCI Event: Unknown (0xe4) plen 5 [hci0] 6.777877
02 01 01 00 00 .....
> HCI Event: Unknown (0xe4) plen 5 [hci0] 6.778871
02 01 01 00 00 .....
> HCI Event: Unknown (0xe4) plen 5 [hci0] 6.779869
02 01 01 00 00 .....
> HCI Event: Unknown (0xe4) plen 5 [hci0] 6.780864
02 01 01 00 00 .....
> HCI Event: Unknown (0xe4) plen 5 [hci0] 6.781858
02 01 01 00 00 .....
> HCI Event: Unknown (0xe4) plen 5 [hci0] 6.782852
02 01 01 00 00 .....
> HCI Event: Unknown (0xe4) plen 5 [hci0] 6.783850
02 01 01 00 00 .....
> HCI Event: Unknown (0xe4) plen 5 [hci0] 6.784845
02 01 01 00 00 .....
> HCI Event: Unknown (0xe4) plen 5 [hci0] 6.785839
02 01 01 00 00 .....
> HCI Event: Unknown (0xe4) plen 5 [hci0] 6.786833
02 01 01 00 00 .....
> HCI Event: Unknown (0xe4) plen 5 [hci0] 6.787831
02 01 01 00 00 .....
> HCI Event: Unknown (0xe4) plen 5 [hci0] 6.788826
02 01 01 00 00 .....
> HCI Event: Unknown (0xe4) plen 5 [hci0] 6.789820
02 01 01 00 00 .....
> HCI Event: Unknown (0xe4) plen 5 [hci0] 6.790814
02 01 01 00 00 .....
> HCI Event: Unknown (0xe4) plen 5 [hci0] 6.791813
02 01 01 00 00 .....
> HCI Event: Unknown (0xe4) plen 5 [hci0] 6.792809
02 01 01 00 00 .....
> HCI Event: Unknown (0xe4) plen 5 [hci0] 6.793803
02 01 01 00 00 .....
> HCI Event: Unknown (0xe4) plen 5 [hci0] 6.794798
02 01 01 00 00 .....
> HCI Event: Unknown (0xe4) plen 5 [hci0] 6.795797
02 01 01 00 00 .....
> HCI Event: Unknown (0xe4) plen 5 [hci0] 6.796791
02 01 01 00 00 .....
> HCI Event: Unknown (0xe4) plen 5 [hci0] 6.797786
02 01 01 00 00 .....
> HCI Event: Unknown (0xe4) plen 5 [hci0] 6.798779
02 01 01 00 00 .....
> HCI Event: Unknown (0xe4) plen 5 [hci0] 6.799778
02 01 01 00 00 .....
> HCI Event: Unknown (0xe4) plen 5 [hci0] 6.800774
02 01 01 00 00 .....
> HCI Event: Unknown (0xe4) plen 5 [hci0] 6.801769
02 01 01 00 00 .....
> HCI Event: Unknown (0xe4) plen 5 [hci0] 6.802763
02 01 01 00 00 .....
> HCI Event: Unknown (0xe4) plen 5 [hci0] 6.803761
02 01 01 00 00 .....
> HCI Event: Unknown (0xe4) plen 5 [hci0] 6.804755
02 01 01 00 00 .....
> HCI Event: Unknown (0xe4) plen 5 [hci0] 6.805749
02 01 01 00 00 .....
> HCI Event: Unknown (0xe4) plen 5 [hci0] 6.806743
02 01 01 00 00 .....
> HCI Event: Unknown (0xe4) plen 5 [hci0] 6.807741
02 01 01 00 00 .....
> HCI Event: Unknown (0xe4) plen 5 [hci0] 6.808737
02 01 01 00 00 .....
> HCI Event: Unknown (0xe4) plen 5 [hci0] 6.809731
02 01 01 00 00 .....
> HCI Event: Unknown (0xe4) plen 5 [hci0] 6.810725
02 01 01 00 00 .....
> HCI Event: Unknown (0xe4) plen 5 [hci0] 6.811725
02 01 01 00 00 .....
> HCI Event: Unknown (0xe4) plen 5 [hci0] 6.812719
02 01 01 00 00 .....
> HCI Event: Unknown (0xe4) plen 5 [hci0] 6.813714
02 01 01 00 00 .....
> HCI Event: Unknown (0xe4) plen 5 [hci0] 6.814708
02 01 01 00 00 .....
> HCI Event: Unknown (0xe4) plen 5 [hci0] 6.815705
02 01 01 00 00 .....
> HCI Event: Unknown (0xe4) plen 5 [hci0] 6.816378
02 01 01 00 00 .....
< HCI Command: Vendor (0x3f|0x006f) plen 5 [hci0] 6.816413
01 07 01 00 04 .....
> HCI Event: Unknown (0xe4) plen 5 [hci0] 6.816536
02 07 01 00 00 .....
< HCI Command: Vendor (0x3f|0x006f) plen 6 [hci0] 8.845071
01 06 02 00 00 01 ......
> HCI Event: Unknown (0xe4) plen 5 [hci0] 8.923456
02 06 01 00 00 .....
< HCI Command: Reset (0x03|0x0003) plen 0 [hci0] 10.861118
> HCI Event: Command Complete (0x0e) plen 4 [hci0] 10.865763
Reset (0x03|0x0003) ncmd 1
Status: Success (0x00)
< HCI Command: Read Local Supported Fe.. (0x04|0x0003) plen 0 [hci0] 10.865805
> HCI Event: Command Complete (0x0e) plen 12 [hci0] 10.865965
Read Local Supported Features (0x04|0x0003) ncmd 1
Status: Success (0x00)
Features: 0xbf 0x3e 0x8d 0xfe 0xdb 0xff 0x7b 0x87
3 slot packets
5 slot packets
Encryption
Slot offset
Timing accuracy
Role switch
Sniff mode
Power control requests
Channel quality driven data rate (CQDDR)
SCO link
HV2 packets
HV3 packets
CVSD synchronous data
Power control
Transparent synchronous data
Broadcast Encryption
Enhanced Data Rate ACL 2 Mbps mode
Enhanced Data Rate ACL 3 Mbps mode
Enhanced inquiry scan
Interlaced inquiry scan
Interlaced page scan
RSSI with inquiry results
Extended SCO link (EV3 packets)
EV4 packets
EV5 packets
AFH capable slave
AFH classification slave
LE Supported (Controller)
3-slot Enhanced Data Rate ACL packets
5-slot Enhanced Data Rate ACL packets
Sniff subrating
Pause encryption
AFH capable master
AFH classification master
Enhanced Data Rate eSCO 2 Mbps mode
Enhanced Data Rate eSCO 3 Mbps mode
3-slot Enhanced Data Rate eSCO packets
Extended Inquiry Response
Simultaneous LE and BR/EDR (Controller)
Secure Simple Pairing
Encapsulated PDU
Erroneous Data Reporting
Non-flushable Packet Boundary Flag
Link Supervision Timeout Changed Event
Inquiry TX Power Level
Enhanced Power Control
Extended features
< HCI Command: Read Local Version Info.. (0x04|0x0001) plen 0 [hci0] 10.865987
> HCI Event: Vendor (0xff) plen 9 [hci0] 10.866259
29 19 09 17 20 48 07 11 00 )... H...
> HCI Event: Command Complete (0x0e) plen 12 [hci0] 10.866372
Read Local Version Information (0x04|0x0001) ncmd 1
Status: Success (0x00)
HCI version: Bluetooth 4.2 (0x08) - Revision 4359 (0x1107)
LMP version: Bluetooth 4.2 (0x08) - Subversion 2329 (0x0919)
Manufacturer: MediaTek, Inc. (70)
< HCI Command: Read BD ADDR (0x04|0x0009) plen 0 [hci0] 10.866391
> HCI Event: Command Complete (0x0e) plen 10 [hci0] 10.866539
Read BD ADDR (0x04|0x0009) ncmd 1
Status: Success (0x00)
Address: 00:00:46:76:22:01 (OLIVETTI NORTH AMERICA)
< HCI Command: Read Buffer Size (0x04|0x0005) plen 0 [hci0] 10.866609
> HCI Event: Command Complete (0x0e) plen 11 [hci0] 10.866754
Read Buffer Size (0x04|0x0005) ncmd 1
Status: Success (0x00)
ACL MTU: 1021 ACL max packet: 8
SCO MTU: 184 SCO max packet: 1
< HCI Command: Read Class of Device (0x03|0x0023) plen 0 [hci0] 10.866775
> HCI Event: Command Complete (0x0e) plen 7 [hci0] 10.866920
Read Class of Device (0x03|0x0023) ncmd 1
Status: Success (0x00)
Class: 0x001f00
Major class: Uncategorized, specific device code not specified
Minor class: 0x00
< HCI Command: Read Local Name (0x03|0x0014) plen 0 [hci0] 10.866939
> HCI Event: Command Complete (0x0e) plen 252 [hci0] 10.867256
Read Local Name (0x03|0x0014) ncmd 1
Status: Success (0x00)
Name: MTK MT7622 #1
< HCI Command: Read Voice Setting (0x03|0x0025) plen 0 [hci0] 10.867308
> HCI Event: Command Complete (0x0e) plen 6 [hci0] 10.867447
Read Voice Setting (0x03|0x0025) ncmd 1
Status: Success (0x00)
Setting: 0x0060
Input Coding: Linear
Input Data Format: 2's complement
Input Sample Size: 16-bit
# of bits padding at MSB: 0
Air Coding Format: CVSD
< HCI Command: Read Number of Supporte.. (0x03|0x0038) plen 0 [hci0] 10.867474
> HCI Event: Command Complete (0x0e) plen 5 [hci0] 10.867611
Read Number of Supported IAC (0x03|0x0038) ncmd 1
Status: Success (0x00)
Number of IAC: 4
< HCI Command: Read Current IAC LAP (0x03|0x0039) plen 0 [hci0] 10.867678
> HCI Event: Command Complete (0x0e) plen 8 [hci0] 10.867865
Read Current IAC LAP (0x03|0x0039) ncmd 1
Status: Success (0x00)
Number of IAC: 1
Access code: 0x9e8b33 (General Inquiry)
< HCI Command: Set Event Filter (0x03|0x0005) plen 1 [hci0] 10.867890
Type: Clear All Filters (0x00)
> HCI Event: Command Complete (0x0e) plen 4 [hci0] 10.868033
Set Event Filter (0x03|0x0005) ncmd 1
Status: Success (0x00)
< HCI Command: Write Connection Accept.. (0x03|0x0016) plen 2 [hci0] 10.868054
Timeout: 20000.000 msec (0x7d00)
> HCI Event: Command Complete (0x0e) plen 4 [hci0] 10.868235
Write Connection Accept Timeout (0x03|0x0016) ncmd 1
Status: Success (0x00)
< HCI Command: LE Read Buffer Size (0x08|0x0002) plen 0 [hci0] 10.868262
> HCI Event: Command Complete (0x0e) plen 7 [hci0] 10.868392
LE Read Buffer Size (0x08|0x0002) ncmd 1
Status: Success (0x00)
Data packet length: 251
Num data packets: 8
< HCI Command: LE Read Local Supported.. (0x08|0x0003) plen 0 [hci0] 10.868413
> HCI Event: Command Complete (0x0e) plen 12 [hci0] 10.868587
LE Read Local Supported Features (0x08|0x0003) ncmd 1
Status: Success (0x00)
Features: 0xfd 0x00 0x00 0x00 0x00 0x00 0x00 0x00
LE Encryption
Extended Reject Indication
Slave-initiated Features Exchange
LE Ping
LE Data Packet Length Extension
LL Privacy
Extended Scanner Filter Policies
< HCI Command: LE Read Supported States (0x08|0x001c) plen 0 [hci0] 10.868646
> HCI Event: Command Complete (0x0e) plen 12 [hci0] 10.868787
LE Read Supported States (0x08|0x001c) ncmd 1
Status: Success (0x00)
States: 0x000000001fffffff
Non-connectable Advertising State
Scannable Advertising State
Connectable Advertising State
High Duty Cycle Directed Advertising State
Passive Scanning State
Active Scanning State
Initiating State
and Connection State (Master Role)
Connection State (Slave Role)
Non-connectable Advertising State
and Passive Scanning State
Scannable Advertising State
and Passive Scanning State
Connectable Advertising State
and Passive Scanning State
High Duty Cycle Directed Advertising State
and Passive Scanning State
Non-connectable Advertising State
and Active Scanning State
Scannable Advertising State
and Active Scanning State
Connectable Advertising State
and Active Scanning State
High Duty Cycle Directed Advertising State
and Active Scanning State
Non-connectable Advertising State
and Initiating State
Scannable Advertising State
and Initiating State
Non-connectable Advertising State
and Connection State (Master Role)
Scannable Advertising State
and Connection State (Master Role)
Non-connectable Advertising State
and Connection State (Slave Role)
Scannable Advertising State
and Connection State (Slave Role)
Passive Scanning State
and Initiating State
Active Scanning State
and Initiating State
Passive Scanning State
and Connection State (Master Role)
Active Scanning State
and Connection State (Master Role)
Passive Scanning State
and Connection State (Slave Role)
Active Scanning State
and Connection State (Slave Role)
Initiating State
and Connection State (Master Role)
and Master Role & Master Role
< HCI Command: Read Local Supported Co.. (0x04|0x0002) plen 0 [hci0] 10.868807
> HCI Event: Command Complete (0x0e) plen 68 [hci0] 10.868985
Read Local Supported Commands (0x04|0x0002) ncmd 1
Status: Success (0x00)
Commands: 176 entries
Inquiry (Octet 0 - Bit 0)
Inquiry Cancel (Octet 0 - Bit 1)
Periodic Inquiry Mode (Octet 0 - Bit 2)
Exit Periodic Inquiry Mode (Octet 0 - Bit 3)
Create Connection (Octet 0 - Bit 4)
Disconnect (Octet 0 - Bit 5)
Add SCO Connection (Octet 0 - Bit 6)
Create Connection Cancel (Octet 0 - Bit 7)
Accept Connection Request (Octet 1 - Bit 0)
Reject Connection Request (Octet 1 - Bit 1)
Link Key Request Reply (Octet 1 - Bit 2)
Link Key Request Negative Reply (Octet 1 - Bit 3)
PIN Code Request Reply (Octet 1 - Bit 4)
PIN Code Request Negative Reply (Octet 1 - Bit 5)
Change Connection Packet Type (Octet 1 - Bit 6)
Authentication Requested (Octet 1 - Bit 7)
Set Connection Encryption (Octet 2 - Bit 0)
Change Connection Link Key (Octet 2 - Bit 1)
Master Link Key (Octet 2 - Bit 2)
Remote Name Request (Octet 2 - Bit 3)
Remote Name Request Cancel (Octet 2 - Bit 4)
Read Remote Supported Features (Octet 2 - Bit 5)
Read Remote Extended Features (Octet 2 - Bit 6)
Read Remote Version Information (Octet 2 - Bit 7)
Read Clock Offset (Octet 3 - Bit 0)
Read LMP Handle (Octet 3 - Bit 1)
Sniff Mode (Octet 4 - Bit 2)
Exit Sniff Mode (Octet 4 - Bit 3)
QoS Setup (Octet 4 - Bit 6)
Role Discovery (Octet 4 - Bit 7)
Switch Role (Octet 5 - Bit 0)
Read Link Policy Settings (Octet 5 - Bit 1)
Write Link Policy Settings (Octet 5 - Bit 2)
Read Default Link Policy Settings (Octet 5 - Bit 3)
Write Default Link Policy Settings (Octet 5 - Bit 4)
Flow Specification (Octet 5 - Bit 5)
Set Event Mask (Octet 5 - Bit 6)
Reset (Octet 5 - Bit 7)
Set Event Filter (Octet 6 - Bit 0)
Flush (Octet 6 - Bit 1)
Read PIN Type (Octet 6 - Bit 2)
Write PIN Type (Octet 6 - Bit 3)
Create New Unit Key (Octet 6 - Bit 4)
Read Stored Link Key (Octet 6 - Bit 5)
Write Stored Link Key (Octet 6 - Bit 6)
Delete Stored Link Key (Octet 6 - Bit 7)
Write Local Name (Octet 7 - Bit 0)
Read Local Name (Octet 7 - Bit 1)
Read Connection Accept Timeout (Octet 7 - Bit 2)
Write Connection Accept Timeout (Octet 7 - Bit 3)
Read Page Timeout (Octet 7 - Bit 4)
Write Page Timeout (Octet 7 - Bit 5)
Read Scan Enable (Octet 7 - Bit 6)
Write Scan Enable (Octet 7 - Bit 7)
Read Page Scan Activity (Octet 8 - Bit 0)
Write Page Scan Activity (Octet 8 - Bit 1)
Read Inquiry Scan Activity (Octet 8 - Bit 2)
Write Inquiry Scan Activity (Octet 8 - Bit 3)
Read Authentication Enable (Octet 8 - Bit 4)
Write Authentication Enable (Octet 8 - Bit 5)
Read Encryption Mode (Octet 8 - Bit 6)
Write Encryption Mode (Octet 8 - Bit 7)
Read Class of Device (Octet 9 - Bit 0)
Write Class of Device (Octet 9 - Bit 1)
Read Voice Setting (Octet 9 - Bit 2)
Write Voice Setting (Octet 9 - Bit 3)
Read Automatic Flush Timeout (Octet 9 - Bit 4)
Write Automatic Flush Timeout (Octet 9 - Bit 5)
Read Num Broadcast Retransmissions (Octet 9 - Bit 6)
Write Num Broadcast Retransmissions (Octet 9 - Bit 7)
Read Transmit Power Level (Octet 10 - Bit 2)
Read Sync Flow Control Enable (Octet 10 - Bit 3)
Write Sync Flow Control Enable (Octet 10 - Bit 4)
Set Controller To Host Flow Control (Octet 10 - Bit 5)
Host Buffer Size (Octet 10 - Bit 6)
Host Number of Completed Packets (Octet 10 - Bit 7)
Read Link Supervision Timeout (Octet 11 - Bit 0)
Write Link Supervision Timeout (Octet 11 - Bit 1)
Read Number of Supported IAC (Octet 11 - Bit 2)
Read Current IAC LAP (Octet 11 - Bit 3)
Write Current IAC LAP (Octet 11 - Bit 4)
Read Page Scan Mode (Octet 11 - Bit 7)
Write Page Scan Mode (Octet 12 - Bit 0)
Set AFH Host Channel Classification (Octet 12 - Bit 1)
Read Inquiry Scan Type (Octet 12 - Bit 4)
Write Inquiry Scan Type (Octet 12 - Bit 5)
Read Inquiry Mode (Octet 12 - Bit 6)
Write Inquiry Mode (Octet 12 - Bit 7)
Read Page Scan Type (Octet 13 - Bit 0)
Write Page Scan Type (Octet 13 - Bit 1)
Read AFH Channel Assessment Mode (Octet 13 - Bit 2)
Write AFH Channel Assessment Mode (Octet 13 - Bit 3)
Read Local Version Information (Octet 14 - Bit 3)
Read Local Supported Features (Octet 14 - Bit 5)
Read Local Extended Features (Octet 14 - Bit 6)
Read Buffer Size (Octet 14 - Bit 7)
Read Country Code (Octet 15 - Bit 0)
Read BD ADDR (Octet 15 - Bit 1)
Read Failed Contact Counter (Octet 15 - Bit 2)
Reset Failed Contact Counter (Octet 15 - Bit 3)
Read Link Quality (Octet 15 - Bit 4)
Read RSSI (Octet 15 - Bit 5)
Read AFH Channel Map (Octet 15 - Bit 6)
Read Clock (Octet 15 - Bit 7)
Read Loopback Mode (Octet 16 - Bit 0)
Write Loopback Mode (Octet 16 - Bit 1)
Enable Device Under Test Mode (Octet 16 - Bit 2)
Setup Synchronous Connection (Octet 16 - Bit 3)
Accept Synchronous Connection Request (Octet 16 - Bit 4)
Reject Synchronous Connection Request (Octet 16 - Bit 5)
Read Extended Inquiry Response (Octet 17 - Bit 0)
Write Extended Inquiry Response (Octet 17 - Bit 1)
Refresh Encryption Key (Octet 17 - Bit 2)
Sniff Subrating (Octet 17 - Bit 4)
Read Simple Pairing Mode (Octet 17 - Bit 5)
Write Simple Pairing Mode (Octet 17 - Bit 6)
Read Local OOB Data (Octet 17 - Bit 7)
Read Inquiry Response TX Power Level (Octet 18 - Bit 0)
Write Inquiry Transmit Power Level (Octet 18 - Bit 1)
Read Default Erroneous Data Reporting (Octet 18 - Bit 2)
Write Default Erroneous Data Reporting (Octet 18 - Bit 3)
IO Capability Request Reply (Octet 18 - Bit 7)
User Confirmation Request Reply (Octet 19 - Bit 0)
User Confirmation Request Neg Reply (Octet 19 - Bit 1)
User Passkey Request Reply (Octet 19 - Bit 2)
User Passkey Request Negative Reply (Octet 19 - Bit 3)
Remote OOB Data Request Reply (Octet 19 - Bit 4)
Write Simple Pairing Debug Mode (Octet 19 - Bit 5)
Enhanced Flush (Octet 19 - Bit 6)
Remote OOB Data Request Neg Reply (Octet 19 - Bit 7)
Send Keypress Notification (Octet 20 - Bit 2)
IO Capability Request Negative Reply (Octet 20 - Bit 3)
Read Encryption Key Size (Octet 20 - Bit 4)
Set Event Mask Page 2 (Octet 22 - Bit 2)
Read Enhanced Transmit Power Level (Octet 24 - Bit 0)
Enhanced Setup Synchronous Connection (Octet 29 - Bit 3)
Enhanced Accept Synchronous Connection Request (Octet 29 - Bit 4)
Read Local Supported Codecs (Octet 29 - Bit 5)
Set Triggered Clock Capture (Octet 30 - Bit 5)
Truncated Page (Octet 30 - Bit 6)
Truncated Page Cancel (Octet 30 - Bit 7)
Set Connectionless Slave Broadcast (Octet 31 - Bit 0)
Start Synchronization Train (Octet 31 - Bit 2)
Set Reserved LT_ADDR (Octet 31 - Bit 4)
Delete Reserved LT_ADDR (Octet 31 - Bit 5)
Set Connectionless Slave Broadcast Data (Octet 31 - Bit 6)
Read Synchronization Train Parameters (Octet 31 - Bit 7)
Write Synchronization Train Parameters (Octet 32 - Bit 0)
Remote OOB Extended Data Request Reply (Octet 32 - Bit 1)
Read Authenticated Payload Timeout (Octet 32 - Bit 4)
Write Authenticated Payload Timeout (Octet 32 - Bit 5)
Read Local OOB Extended Data (Octet 32 - Bit 6)
Write Secure Connections Test Mode (Octet 32 - Bit 7)
Read Extended Page Timeout (Octet 33 - Bit 0)
Write Extended Page Timeout (Octet 33 - Bit 1)
Read Extended Inquiry Length (Octet 33 - Bit 2)
Write Extended Inquiry Length (Octet 33 - Bit 3)
LE Set Data Length (Octet 33 - Bit 6)
LE Read Suggested Default Data Length (Octet 33 - Bit 7)
LE Write Suggested Default Data Length (Octet 34 - Bit 0)
LE Read Local P-256 Public Key (Octet 34 - Bit 1)
LE Generate DHKey (Octet 34 - Bit 2)
LE Add Device To Resolving List (Octet 34 - Bit 3)
LE Remove Device From Resolving List (Octet 34 - Bit 4)
LE Clear Resolving List (Octet 34 - Bit 5)
LE Read Resolving List Size (Octet 34 - Bit 6)
LE Read Peer Resolvable Address (Octet 34 - Bit 7)
LE Read Local Resolvable Address (Octet 35 - Bit 0)
LE Set Address Resolution Enable (Octet 35 - Bit 1)
LE Set Resolvable Private Address Timeout (Octet 35 - Bit 2)
LE Read Maximum Data Length (Octet 35 - Bit 3)
Octet 35 - Bit 4
Octet 35 - Bit 5
Octet 35 - Bit 6
Octet 35 - Bit 7
Octet 36 - Bit 0
< HCI Command: Write Simple Pairing Mode (0x03|0x0056) plen 1 [hci0] 10.869023
Mode: Enabled (0x01)
> HCI Event: Command Complete (0x0e) plen 4 [hci0] 10.869185
Write Simple Pairing Mode (0x03|0x0056) ncmd 1
Status: Success (0x00)
< HCI Command: Write Inquiry Mode (0x03|0x0045) plen 1 [hci0] 10.869239
Mode: Inquiry Result with RSSI or Extended Inquiry Result (0x02)
> HCI Event: Command Complete (0x0e) plen 4 [hci0] 10.869371
Write Inquiry Mode (0x03|0x0045) ncmd 1
Status: Success (0x00)
< HCI Command: Read Inquiry Response T.. (0x03|0x0058) plen 0 [hci0] 10.869396
> HCI Event: Command Complete (0x0e) plen 5 [hci0] 10.869552
Read Inquiry Response TX Power Level (0x03|0x0058) ncmd 1
Status: Success (0x00)
TX power: -1 dBm
< HCI Command: Read Local Extended Fea.. (0x04|0x0004) plen 1 [hci0] 10.869572
Page: 1
> HCI Event: Command Complete (0x0e) plen 14 [hci0] 10.869729
Read Local Extended Features (0x04|0x0004) ncmd 1
Status: Success (0x00)
Page: 1/2
Features: 0x01 0x00 0x00 0x00 0x00 0x00 0x00 0x00
Secure Simple Pairing (Host Support)
< HCI Command: Set Event Mask (0x03|0x0001) plen 8 [hci0] 10.869783
Mask: 0x3dbff807fffbffff
Inquiry Complete
Inquiry Result
Connection Complete
Connection Request
Disconnection Complete
Authentication Complete
Remote Name Request Complete
Encryption Change
Change Connection Link Key Complete
Master Link Key Complete
Read Remote Supported Features Complete
Read Remote Version Information Complete
QoS Setup Complete
Command Complete
Command Status
Hardware Error
Flush Occurred
Role Change
Mode Change
Return Link Keys
PIN Code Request
Link Key Request
Link Key Notification
Loopback Command
Data Buffer Overflow
Max Slots Change
Read Clock Offset Complete
Connection Packet Type Changed
QoS Violation
Page Scan Mode Change
Page Scan Repetition Mode Change
Flow Specification Complete
Inquiry Result with RSSI
Read Remote Extended Features Complete
Synchronous Connection Complete
Synchronous Connection Changed
Sniff Subrating
Extended Inquiry Result
Encryption Key Refresh Complete
IO Capability Request
IO Capability Request Reply
User Confirmation Request
User Passkey Request
Remote OOB Data Request
Simple Pairing Complete
Link Supervision Timeout Changed
Enhanced Flush Complete
User Passkey Notification
Keypress Notification
Remote Host Supported Features Notification
LE Meta
> HCI Event: Command Complete (0x0e) plen 4 [hci0] 10.869921
Set Event Mask (0x03|0x0001) ncmd 1
Status: Success (0x00)
< HCI Command: Read Stored Link Key (0x03|0x000d) plen 7 [hci0] 10.869947
Address: 00:00:00:00:00:00 (OUI 00-00-00)
Read all: 0x01
> HCI Event: Command Complete (0x0e) plen 8 [hci0] 10.870129
Read Stored Link Key (0x03|0x000d) ncmd 1
Status: Success (0x00)
Max num keys: 4
Num keys: 0
< HCI Command: Write Default Link Poli.. (0x02|0x000f) plen 2 [hci0] 10.870148
Link policy: 0x0005
Enable Role Switch
Enable Sniff Mode
> HCI Event: Command Complete (0x0e) plen 4 [hci0] 10.870310
Write Default Link Policy Settings (0x02|0x000f) ncmd 1
Status: Success (0x00)
< HCI Command: Read Page Scan Activity (0x03|0x001b) plen 0 [hci0] 10.870331
> HCI Event: Command Complete (0x0e) plen 8 [hci0] 10.870485
Read Page Scan Activity (0x03|0x001b) ncmd 1
Status: Success (0x00)
Interval: 1280.000 msec (0x0800)
Window: 11.250 msec (0x0012)
< HCI Command: Read Page Scan Type (0x03|0x0046) plen 0 [hci0] 10.870504
> HCI Event: Command Complete (0x0e) plen 5 [hci0] 10.870652
Read Page Scan Type (0x03|0x0046) ncmd 1
Status: Success (0x00)
Type: Standard Scan (0x00)
< HCI Command: LE Set Event Mask (0x08|0x0001) plen 8 [hci0] 10.870671
Mask: 0x0000000000000980
LE Read Local P-256 Public Key Complete
LE Generate DHKey Complete
Unknown mask (0x0000000000000800)
> HCI Event: Command Complete (0x0e) plen 4 [hci0] 10.870839
LE Set Event Mask (0x08|0x0001) ncmd 1
Status: Success (0x00)
< HCI Command: Write LE Host Supported (0x03|0x006d) plen 2 [hci0] 10.870859
Supported: 0x01
Simultaneous: 0x00
> HCI Event: Command Complete (0x0e) plen 4 [hci0] 10.871028
Write LE Host Supported (0x03|0x006d) ncmd 1
Status: Success (0x00)
< HCI Command: Read Local Extended Fea.. (0x04|0x0004) plen 1 [hci0] 10.871059
Page: 2
> HCI Event: Command Complete (0x0e) plen 14 [hci0] 10.871201
Read Local Extended Features (0x04|0x0004) ncmd 1
Status: Success (0x00)
Page: 2/2
Features: 0x25 0x0b 0x00 0x00 0x00 0x00 0x00 0x00
Connectionless Slave Broadcast - Master
Synchronization Train
Generalized interlaced scan
Secure Connections (Controller Support)
Ping
Train nudging
< HCI Command: Delete Stored Link Key (0x03|0x0012) plen 7 [hci0] 10.871240
Address: 00:00:00:00:00:00 (OUI 00-00-00)
Delete all: 0x01
> HCI Event: Command Complete (0x0e) plen 6 [hci0] 10.871384
Delete Stored Link Key (0x03|0x0012) ncmd 1
Status: Success (0x00)
Num keys: 0
< HCI Command: Set Event Mask Page 2 (0x03|0x0063) plen 8 [hci0] 10.871403
Mask: 0x0000000000b0c000
Triggered Clock Capture
Synchronization Train Complete
Slave Page Response Timeout
Connectionless Slave Broadcast Channel Map Change
Authenticated Payload Timeout Expired
> HCI Event: Command Complete (0x0e) plen 4 [hci0] 10.871566
Set Event Mask Page 2 (0x03|0x0063) ncmd 1
Status: Success (0x00)
< HCI Command: Read Local Supported Co.. (0x04|0x000b) plen 0 [hci0] 10.871599
> HCI Event: Command Complete (0x0e) plen 8 [hci0] 10.871750
Read Local Supported Codecs (0x04|0x000b) ncmd 1
Status: Success (0x00)
Number of supported codecs: 2
Codec: CVSD (0x02)
Codec: Transparent (0x03)
Number of vendor codecs: 0
< HCI Command: Read Synchronization Tr.. (0x03|0x0077) plen 0 [hci0] 10.871769
> HCI Event: Command Complete (0x0e) plen 11 [hci0] 10.871928
Read Synchronization Train Parameters (0x03|0x0077) ncmd 1
Status: Success (0x00)
Interval: 0.000 msec (0x0000)
Timeout: 0.000 msec (0x00000000)
Service data: 0x00
< HCI Command: Write Secure Connection.. (0x03|0x007a) plen 1 [hci0] 10.871947
Support: Enabled (0x01)
> HCI Event: Command Complete (0x0e) plen 4 [hci0] 10.872098
Write Secure Connections Host Support (0x03|0x007a) ncmd 1
Status: Success (0x00)
< HCI Command: Unknown (0x08|0x0031) plen 3 [hci0] 10.872156
03 00 00 ...
> HCI Event: Command Complete (0x0e) plen 4 [hci0] 10.872322
Unknown (0x08|0x0031) ncmd 1
Status: Success (0x00)
= Index Info: 00:00:46:76:22:01 (MediaTek, Inc.) [hci0] 10.872361
< HCI Command: LE Set Scan Response D.. (0x08|0x0009) plen 32 [hci0] 10.872431
Length: 10
Name (complete): builder
> HCI Event: Command Complete (0x0e) plen 4 [hci0] 10.872606
LE Set Scan Response Data (0x08|0x0009) ncmd 1
Status: Success (0x00)
< HCI Command: Write Scan Enable (0x03|0x001a) plen 1 [hci0] 10.872627
Scan enable: Page Scan (0x02)
> HCI Event: Command Complete (0x0e) plen 4 [hci0] 10.872819
Write Scan Enable (0x03|0x001a) ncmd 1
Status: Success (0x00)
< HCI Command: Write Class of Device (0x03|0x0024) plen 3 [hci0] 10.872841
Class: 0x000000
Major class: Miscellaneous
Minor class: 0x00
> HCI Event: Command Complete (0x0e) plen 4 [hci0] 10.873036
Write Class of Device (0x03|0x0024) ncmd 1
Status: Success (0x00)
* Unknown packet (code 17 len 9) [hci0] 10.873069
02 00 00 00 07 00 00 00 00 .........
* Unknown packet (code 17 len 9) [hci0] 10.873069
01 00 00 00 07 00 00 00 00 .........
< HCI Command: Write Local Name (0x03|0x0013) plen 248 [hci0] 10.873096
Name: builder
> HCI Event: Command Complete (0x0e) plen 4 [hci0] 10.873446
Write Local Name (0x03|0x0013) ncmd 1
Status: Success (0x00)
< HCI Command: Write Extended Inquir.. (0x03|0x0052) plen 241 [hci0] 10.873470
FEC: Not required (0x00)
Name (complete): builder
TX power: -1 dBm
Device ID: USB Implementer's Forum assigned (0x0002)
Vendor: Linux Foundation (0x1d6b)
Product: 0x0246
Version: 5.2.11 (0x052b)
16-bit Service UUIDs (complete): 4 entries
Generic Access Profile (0x1800)
Generic Attribute Profile (0x1801)
A/V Remote Control (0x110e)
A/V Remote Control Target (0x110c)
> HCI Event: Command Complete (0x0e) plen 4 [hci0] 10.873857
Write Extended Inquiry Response (0x03|0x0052) ncmd 1
Status: Success (0x00)
* Unknown packet (code 17 len 13) [hci0] 10.873903
01 00 00 00 01 00 05 00 00 d1 0a 00 00 .............
* Unknown packet (code 17 len 10) [hci0] 10.873913
02 00 00 00 06 00 d1 0a 00 00 ..........
* Unknown packet (code 16 len 7) [hci0] 17.803939
01 00 00 00 05 00 00 .......
< HCI Command: Write Scan Enable (0x03|0x001a) plen 1 [hci0] 17.803983
Scan enable: No Scans (0x00)
> HCI Event: Command Complete (0x0e) plen 4 [hci0] 17.804233
Write Scan Enable (0x03|0x001a) ncmd 1
Status: Success (0x00)
< HCI Command: Vendor (0x3f|0x006f) plen 6 [hci0] 17.804282
01 06 02 00 00 00 ......
> HCI Event: Unknown (0xe4) plen 5 [hci0] 17.804636
02 06 01 00 00 .....
* Unknown packet (code 17 len 13) [hci0] 17.811580
01 00 00 00 01 00 05 00 00 d0 0a 00 00 .............
* Unknown packet (code 17 len 10) [hci0] 17.811596
02 00 00 00 06 00 d0 0a 00 00 ..........
= Close Index: 00:00:46:76:22:01 [hci0] 17.811625

2018-05-23 12:31:30

by Marcel Holtmann

[permalink] [raw]
Subject: Re: [PATCH v2 4/7] Bluetooth: Add new quirk for non-persistent setup settings

Hi Sean,

>>
>> [ ... ]
>>
>>>> - if (hci_dev_test_flag(hdev, HCI_SETUP)) {
>>>> + if (hci_dev_test_flag(hdev, HCI_SETUP) ||
>>>> + test_bit(HCI_QUIRK_NON_PERSISTENT_SETUP, &hdev->quirks)) {
>>>> hci_sock_dev_event(hdev, HCI_DEV_SETUP);
>>>
>>> I am not 100% sure that we want to send the HCI_DEV_SETUP event also multiple times. That is a userspace change that I would need to think about. We need to check create_monitor_event() and see what the btmon trace for this looks like. Can you send me a btmon -w trace.log when this change is active.
>>>
>>> Regards
>>>
>>> Marcel
>>>
>>
>> Sure, I'll send you the trace.log with the change is active.
>>
>> Sean
>>
>
>
> Attached trace.log was captured when I inputted commands power on and
> then off in bluetoothctl.

the trace.log is somehow mangled. Something is not fully correct. Can you read it with btmon -r trace.log?

Regards

Marcel


2018-05-23 06:37:03

by Sean Wang

[permalink] [raw]
Subject: Re: [SPAM]Re: [PATCH v2 4/7] Bluetooth: Add new quirk for non-persistent setup settings

On Tue, 2018-05-22 at 16:05 +0800, Sean Wang wrote:
> On Tue, 2018-05-22 at 09:21 +0200, Marcel Holtmann wrote:
> > Hi Sean,
> >
>
> [ ... ]
>
> > > - if (hci_dev_test_flag(hdev, HCI_SETUP)) {
> > > + if (hci_dev_test_flag(hdev, HCI_SETUP) ||
> > > + test_bit(HCI_QUIRK_NON_PERSISTENT_SETUP, &hdev->quirks)) {
> > > hci_sock_dev_event(hdev, HCI_DEV_SETUP);
> >
> > I am not 100% sure that we want to send the HCI_DEV_SETUP event also multiple times. That is a userspace change that I would need to think about. We need to check create_monitor_event() and see what the btmon trace for this looks like. Can you send me a btmon -w trace.log when this change is active.
> >
> > Regards
> >
> > Marcel
> >
>
> Sure, I'll send you the trace.log with the change is active.
>
> Sean
>

Hi, Marcel

Attached trace.log was captured when I inputted commands power on and
then off in bluetoothctl.

Sean

>
> _______________________________________________
> Linux-mediatek mailing list
> [email protected]
> http://lists.infradead.org/mailman/listinfo/linux-mediatek


Attachments:
trace.log (6.42 kB)

2018-05-22 08:05:23

by Sean Wang

[permalink] [raw]
Subject: Re: [PATCH v2 4/7] Bluetooth: Add new quirk for non-persistent setup settings

On Tue, 2018-05-22 at 09:21 +0200, Marcel Holtmann wrote:
> Hi Sean,
>

[ ... ]

> > - if (hci_dev_test_flag(hdev, HCI_SETUP)) {
> > + if (hci_dev_test_flag(hdev, HCI_SETUP) ||
> > + test_bit(HCI_QUIRK_NON_PERSISTENT_SETUP, &hdev->quirks)) {
> > hci_sock_dev_event(hdev, HCI_DEV_SETUP);
>
> I am not 100% sure that we want to send the HCI_DEV_SETUP event also multiple times. That is a userspace change that I would need to think about. We need to check create_monitor_event() and see what the btmon trace for this looks like. Can you send me a btmon -w trace.log when this change is active.
>
> Regards
>
> Marcel
>

Sure, I'll send you the trace.log with the change is active.

Sean

2018-05-22 07:21:23

by Marcel Holtmann

[permalink] [raw]
Subject: Re: [PATCH v2 4/7] Bluetooth: Add new quirk for non-persistent setup settings

Hi Sean,

> Add a new quirk HCI_QUIRK_NON_PERSISTENT_SETUP allowing that a quirk that
> runs setup() after every open() and not just after the first open().
>
> Signed-off-by: Sean Wang <[email protected]>
> ---
> include/net/bluetooth/hci.h | 9 +++++++++
> net/bluetooth/hci_core.c | 3 ++-
> 2 files changed, 11 insertions(+), 1 deletion(-)
>
> diff --git a/include/net/bluetooth/hci.h b/include/net/bluetooth/hci.h
> index 1668211..b37d973 100644
> --- a/include/net/bluetooth/hci.h
> +++ b/include/net/bluetooth/hci.h
> @@ -183,6 +183,15 @@ enum {
> * during the hdev->setup vendor callback.
> */
> HCI_QUIRK_NON_PERSISTENT_DIAG,
> +
> + /* When this quirk is set, setup() would be run after every
> + * open() and not just after the first open().
> + *
> + * This quirk can be set before hci_register_dev is called or
> + * during the hdev->setup vendor callback.
> + *
> + */
> + HCI_QUIRK_NON_PERSISTENT_SETUP,
> };
>
> /* HCI device flags */
> diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c
> index 40d260f..7de712e2 100644
> --- a/net/bluetooth/hci_core.c
> +++ b/net/bluetooth/hci_core.c
> @@ -1377,7 +1377,8 @@ static int hci_dev_do_open(struct hci_dev *hdev)
> atomic_set(&hdev->cmd_cnt, 1);
> set_bit(HCI_INIT, &hdev->flags);
>
> - if (hci_dev_test_flag(hdev, HCI_SETUP)) {
> + if (hci_dev_test_flag(hdev, HCI_SETUP) ||
> + test_bit(HCI_QUIRK_NON_PERSISTENT_SETUP, &hdev->quirks)) {
> hci_sock_dev_event(hdev, HCI_DEV_SETUP);

I am not 100% sure that we want to send the HCI_DEV_SETUP event also multiple times. That is a userspace change that I would need to think about. We need to check create_monitor_event() and see what the btmon trace for this looks like. Can you send me a btmon -w trace.log when this change is active.

Regards

Marcel


2018-05-15 08:52:18

by Sean Wang

[permalink] [raw]
Subject: [PATCH v2 3/7] Bluetooth: Add new serdev based driver for UART attached controllers

From: Marcel Holtmann <[email protected]>

This is a from scratch written driver to run H:4 on serdev based system
with a Bluetooth controller attached via an UART. It is currently tested
on RPi3 and it has Broadcom integration. It is DT only and is missing
GPIO and runtime power management integration. Also Apple or ACPI
support is currently not added.

To integrate with controllers from Intel and Qualcomm, similar handling
like with btusb.c has to be done. A simple abstraction for that has been
provided to make it similar to hci_uart.

The goal is to run individual drivers on serdev capable systems so that
we can retire hci_uart on these system and continue with a lot simpler
and easier to maintain driver. It seems that hci_uart has too many race
conditions due to handling TTY and line disciplines. And fixes for that
are not really related to serdev based drivers. In a serdev only world
it makes sense to remove any of the complex code.

Signed-off-by: Marcel Holtmann <[email protected]>
---
drivers/bluetooth/Kconfig | 11 +
drivers/bluetooth/Makefile | 1 +
drivers/bluetooth/btuart.c | 506 +++++++++++++++++++++++++++++++++++++++++++++
3 files changed, 518 insertions(+)
create mode 100644 drivers/bluetooth/btuart.c

diff --git a/drivers/bluetooth/Kconfig b/drivers/bluetooth/Kconfig
index 010f5f5..6d69ac2 100644
--- a/drivers/bluetooth/Kconfig
+++ b/drivers/bluetooth/Kconfig
@@ -74,6 +74,17 @@ config BT_HCIBTSDIO
Say Y here to compile support for Bluetooth SDIO devices into the
kernel or say M to compile it as module (btsdio).

+config BT_HCIBTUART
+ tristate "HCI UART driver"
+ depends on SERIAL_DEV_BUS
+ help
+ Bluetooth HCI UART driver.
+ This driver is required if you want to use Bluetooth device with
+ UART interface.
+
+ Say Y here to compile support for Bluetooth UART devices into the
+ kernel or say M to compile it as module (btuart).
+
config BT_HCIUART
tristate "HCI UART driver"
depends on SERIAL_DEV_BUS || !SERIAL_DEV_BUS
diff --git a/drivers/bluetooth/Makefile b/drivers/bluetooth/Makefile
index ec16c55..60a19cb 100644
--- a/drivers/bluetooth/Makefile
+++ b/drivers/bluetooth/Makefile
@@ -14,6 +14,7 @@ obj-$(CONFIG_BT_HCIBLUECARD) += bluecard_cs.o

obj-$(CONFIG_BT_HCIBTUSB) += btusb.o
obj-$(CONFIG_BT_HCIBTSDIO) += btsdio.o
+obj-$(CONFIG_BT_HCIBTUART) += btuart.o

obj-$(CONFIG_BT_INTEL) += btintel.o
obj-$(CONFIG_BT_ATH3K) += ath3k.o
diff --git a/drivers/bluetooth/btuart.c b/drivers/bluetooth/btuart.c
new file mode 100644
index 0000000..03e980f
--- /dev/null
+++ b/drivers/bluetooth/btuart.c
@@ -0,0 +1,506 @@
+/*
+ *
+ * Generic Bluetooth HCI UART driver
+ *
+ * Copyright (C) 2015-2018 Intel Corporation
+ *
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ */
+
+#include <linux/kernel.h>
+#include <linux/module.h>
+#include <linux/skbuff.h>
+#include <linux/serdev.h>
+#include <linux/of.h>
+#include <linux/firmware.h>
+#include <asm/unaligned.h>
+
+#include <net/bluetooth/bluetooth.h>
+#include <net/bluetooth/hci_core.h>
+
+#include "h4_recv.h"
+#include "btbcm.h"
+
+#define VERSION "1.0"
+
+struct btuart_vnd {
+ const struct h4_recv_pkt *recv_pkts;
+ int recv_pkts_cnt;
+ unsigned int manufacturer;
+ int (*open)(struct hci_dev *hdev);
+ int (*close)(struct hci_dev *hdev);
+ int (*setup)(struct hci_dev *hdev);
+};
+
+struct btuart_dev {
+ struct hci_dev *hdev;
+ struct serdev_device *serdev;
+
+ struct work_struct tx_work;
+ unsigned long tx_state;
+ struct sk_buff_head txq;
+
+ struct sk_buff *rx_skb;
+
+ const struct btuart_vnd *vnd;
+};
+
+#define BTUART_TX_STATE_ACTIVE 1
+#define BTUART_TX_STATE_WAKEUP 2
+
+static void btuart_tx_work(struct work_struct *work)
+{
+ struct btuart_dev *bdev = container_of(work, struct btuart_dev,
+ tx_work);
+ struct serdev_device *serdev = bdev->serdev;
+ struct hci_dev *hdev = bdev->hdev;
+
+ while (1) {
+ clear_bit(BTUART_TX_STATE_WAKEUP, &bdev->tx_state);
+
+ while (1) {
+ struct sk_buff *skb = skb_dequeue(&bdev->txq);
+ int len;
+
+ if (!skb)
+ break;
+
+ len = serdev_device_write_buf(serdev, skb->data,
+ skb->len);
+ hdev->stat.byte_tx += len;
+
+ skb_pull(skb, len);
+ if (skb->len > 0) {
+ skb_queue_head(&bdev->txq, skb);
+ break;
+ }
+
+ switch (hci_skb_pkt_type(skb)) {
+ case HCI_COMMAND_PKT:
+ hdev->stat.cmd_tx++;
+ break;
+ case HCI_ACLDATA_PKT:
+ hdev->stat.acl_tx++;
+ break;
+ case HCI_SCODATA_PKT:
+ hdev->stat.sco_tx++;
+ break;
+ }
+
+ kfree_skb(skb);
+ }
+
+ if (!test_bit(BTUART_TX_STATE_WAKEUP, &bdev->tx_state))
+ break;
+ }
+
+ clear_bit(BTUART_TX_STATE_ACTIVE, &bdev->tx_state);
+}
+
+static int btuart_tx_wakeup(struct btuart_dev *bdev)
+{
+ if (test_and_set_bit(BTUART_TX_STATE_ACTIVE, &bdev->tx_state)) {
+ set_bit(BTUART_TX_STATE_WAKEUP, &bdev->tx_state);
+ return 0;
+ }
+
+ schedule_work(&bdev->tx_work);
+ return 0;
+}
+
+static int btuart_open(struct hci_dev *hdev)
+{
+ struct btuart_dev *bdev = hci_get_drvdata(hdev);
+ int err;
+
+ err = serdev_device_open(bdev->serdev);
+ if (err) {
+ bt_dev_err(hdev, "Unable to open UART device %s",
+ dev_name(&bdev->serdev->dev));
+ return err;
+ }
+
+ if (bdev->vnd->open) {
+ err = bdev->vnd->open(hdev);
+ if (err) {
+ serdev_device_close(bdev->serdev);
+ return err;
+ }
+ }
+
+ return 0;
+}
+
+static int btuart_close(struct hci_dev *hdev)
+{
+ struct btuart_dev *bdev = hci_get_drvdata(hdev);
+ int err;
+
+ if (bdev->vnd->close) {
+ err = bdev->vnd->close(hdev);
+ if (err)
+ return err;
+ }
+
+ serdev_device_close(bdev->serdev);
+
+ return 0;
+}
+
+static int btuart_flush(struct hci_dev *hdev)
+{
+ struct btuart_dev *bdev = hci_get_drvdata(hdev);
+
+ /* Flush any pending characters */
+ serdev_device_write_flush(bdev->serdev);
+ skb_queue_purge(&bdev->txq);
+
+ cancel_work_sync(&bdev->tx_work);
+
+ kfree_skb(bdev->rx_skb);
+ bdev->rx_skb = NULL;
+
+ return 0;
+}
+
+static int btuart_setup(struct hci_dev *hdev)
+{
+ struct btuart_dev *bdev = hci_get_drvdata(hdev);
+
+ if (bdev->vnd->setup)
+ return bdev->vnd->setup(hdev);
+
+ return 0;
+}
+
+static int btuart_send_frame(struct hci_dev *hdev, struct sk_buff *skb)
+{
+ struct btuart_dev *bdev = hci_get_drvdata(hdev);
+
+ /* Prepend skb with frame type */
+ memcpy(skb_push(skb, 1), &hci_skb_pkt_type(skb), 1);
+ skb_queue_tail(&bdev->txq, skb);
+
+ btuart_tx_wakeup(bdev);
+ return 0;
+}
+
+static int btuart_receive_buf(struct serdev_device *serdev, const u8 *data,
+ size_t count)
+{
+ struct btuart_dev *bdev = serdev_device_get_drvdata(serdev);
+ const struct btuart_vnd *vnd = bdev->vnd;
+
+ bdev->rx_skb = h4_recv_buf(bdev->hdev, bdev->rx_skb, data, count,
+ vnd->recv_pkts, vnd->recv_pkts_cnt);
+ if (IS_ERR(bdev->rx_skb)) {
+ int err = PTR_ERR(bdev->rx_skb);
+ bt_dev_err(bdev->hdev, "Frame reassembly failed (%d)", err);
+ bdev->rx_skb = NULL;
+ return err;
+ }
+
+ bdev->hdev->stat.byte_rx += count;
+
+ return count;
+}
+
+static void btuart_write_wakeup(struct serdev_device *serdev)
+{
+ struct btuart_dev *bdev = serdev_device_get_drvdata(serdev);
+
+ btuart_tx_wakeup(bdev);
+}
+
+static const struct serdev_device_ops btuart_client_ops = {
+ .receive_buf = btuart_receive_buf,
+ .write_wakeup = btuart_write_wakeup,
+};
+
+#define BCM_NULL_PKT 0x00
+#define BCM_NULL_SIZE 0
+
+#define BCM_LM_DIAG_PKT 0x07
+#define BCM_LM_DIAG_SIZE 63
+
+#define BCM_RECV_LM_DIAG \
+ .type = BCM_LM_DIAG_PKT, \
+ .hlen = BCM_LM_DIAG_SIZE, \
+ .loff = 0, \
+ .lsize = 0, \
+ .maxlen = BCM_LM_DIAG_SIZE
+
+#define BCM_RECV_NULL \
+ .type = BCM_NULL_PKT, \
+ .hlen = BCM_NULL_SIZE, \
+ .loff = 0, \
+ .lsize = 0, \
+ .maxlen = BCM_NULL_SIZE
+
+static int bcm_set_diag(struct hci_dev *hdev, bool enable)
+{
+ struct btuart_dev *bdev = hci_get_drvdata(hdev);
+ struct sk_buff *skb;
+
+ if (!test_bit(HCI_RUNNING, &hdev->flags))
+ return -ENETDOWN;
+
+ skb = bt_skb_alloc(3, GFP_KERNEL);
+ if (!skb)
+ return -ENOMEM;
+
+ skb_put_u8(skb, BCM_LM_DIAG_PKT);
+ skb_put_u8(skb, 0xf0);
+ skb_put_u8(skb, enable);
+
+ skb_queue_tail(&bdev->txq, skb);
+ btuart_tx_wakeup(bdev);
+
+ return 0;
+}
+
+static int bcm_set_baudrate(struct btuart_dev *bdev, unsigned int speed)
+{
+ struct hci_dev *hdev = bdev->hdev;
+ struct sk_buff *skb;
+ struct bcm_update_uart_baud_rate param;
+
+ if (speed > 3000000) {
+ struct bcm_write_uart_clock_setting clock;
+
+ clock.type = BCM_UART_CLOCK_48MHZ;
+
+ bt_dev_dbg(hdev, "Set Controller clock (%d)", clock.type);
+
+ /* This Broadcom specific command changes the UART's controller
+ * clock for baud rate > 3000000.
+ */
+ skb = __hci_cmd_sync(hdev, 0xfc45, 1, &clock, HCI_INIT_TIMEOUT);
+ if (IS_ERR(skb)) {
+ int err = PTR_ERR(skb);
+ bt_dev_err(hdev, "Failed to write clock (%d)", err);
+ return err;
+ }
+
+ kfree_skb(skb);
+ }
+
+ bt_dev_dbg(hdev, "Set Controller UART speed to %d bit/s", speed);
+
+ param.zero = cpu_to_le16(0);
+ param.baud_rate = cpu_to_le32(speed);
+
+ /* This Broadcom specific command changes the UART's controller baud
+ * rate.
+ */
+ skb = __hci_cmd_sync(hdev, 0xfc18, sizeof(param), &param,
+ HCI_INIT_TIMEOUT);
+ if (IS_ERR(skb)) {
+ int err = PTR_ERR(skb);
+ bt_dev_err(hdev, "Failed to write update baudrate (%d)", err);
+ return err;
+ }
+
+ kfree_skb(skb);
+
+ return 0;
+}
+
+static int bcm_setup(struct hci_dev *hdev)
+{
+ struct btuart_dev *bdev = hci_get_drvdata(hdev);
+ char fw_name[64];
+ const struct firmware *fw;
+ unsigned int speed;
+ int err;
+
+ hdev->set_diag = bcm_set_diag;
+ hdev->set_bdaddr = btbcm_set_bdaddr;
+
+ /* Init speed if any */
+ speed = 115200;
+
+ if (speed)
+ serdev_device_set_baudrate(bdev->serdev, speed);
+
+ /* Operational speed if any */
+ speed = 115200;
+
+ if (speed) {
+ err = bcm_set_baudrate(bdev, speed);
+ if (err)
+ bt_dev_err(hdev, "Failed to set baudrate");
+ else
+ serdev_device_set_baudrate(bdev->serdev, speed);
+ }
+
+ err = btbcm_initialize(hdev, fw_name, sizeof(fw_name));
+ if (err)
+ return err;
+
+ err = request_firmware(&fw, fw_name, &hdev->dev);
+ if (err < 0) {
+ bt_dev_warn(hdev, "Patch %s not found", fw_name);
+ return 0;
+ }
+
+ err = btbcm_patchram(bdev->hdev, fw);
+ if (err) {
+ bt_dev_err(hdev, "Patching failed (%d)", err);
+ goto finalize;
+ }
+
+ /* Init speed if any */
+ speed = 115200;
+
+ if (speed)
+ serdev_device_set_baudrate(bdev->serdev, speed);
+
+ /* Operational speed if any */
+ speed = 115200;
+
+ if (speed) {
+ err = bcm_set_baudrate(bdev, speed);
+ if (!err)
+ serdev_device_set_baudrate(bdev->serdev, speed);
+ }
+
+finalize:
+ release_firmware(fw);
+
+ err = btbcm_finalize(hdev);
+ if (err)
+ return err;
+
+ return err;
+}
+
+static const struct h4_recv_pkt bcm_recv_pkts[] = {
+ { H4_RECV_ACL, .recv = hci_recv_frame },
+ { H4_RECV_SCO, .recv = hci_recv_frame },
+ { H4_RECV_EVENT, .recv = hci_recv_frame },
+ { BCM_RECV_LM_DIAG, .recv = hci_recv_diag },
+ { BCM_RECV_NULL, .recv = hci_recv_diag },
+};
+
+static const struct btuart_vnd bcm_vnd = {
+ .recv_pkts = bcm_recv_pkts,
+ .recv_pkts_cnt = ARRAY_SIZE(bcm_recv_pkts),
+ .manufacturer = 15,
+ .setup = bcm_setup,
+};
+
+static const struct h4_recv_pkt default_recv_pkts[] = {
+ { H4_RECV_ACL, .recv = hci_recv_frame },
+ { H4_RECV_SCO, .recv = hci_recv_frame },
+ { H4_RECV_EVENT, .recv = hci_recv_frame },
+};
+
+static const struct btuart_vnd default_vnd = {
+ .recv_pkts = default_recv_pkts,
+ .recv_pkts_cnt = ARRAY_SIZE(default_recv_pkts),
+};
+
+static int btuart_probe(struct serdev_device *serdev)
+{
+ struct btuart_dev *bdev;
+ struct hci_dev *hdev;
+
+ bdev = devm_kzalloc(&serdev->dev, sizeof(*bdev), GFP_KERNEL);
+ if (!bdev)
+ return -ENOMEM;
+
+ /* Request the vendor specific data and callbacks */
+ bdev->vnd = device_get_match_data(&serdev->dev);
+ if (!bdev->vnd)
+ bdev->vnd = &default_vnd;
+
+ bdev->serdev = serdev;
+ serdev_device_set_drvdata(serdev, bdev);
+
+ serdev_device_set_client_ops(serdev, &btuart_client_ops);
+
+ INIT_WORK(&bdev->tx_work, btuart_tx_work);
+ skb_queue_head_init(&bdev->txq);
+
+ /* Initialize and register HCI device */
+ hdev = hci_alloc_dev();
+ if (!hdev) {
+ dev_err(&serdev->dev, "Can't allocate HCI device\n");
+ return -ENOMEM;
+ }
+
+ bdev->hdev = hdev;
+
+ hdev->bus = HCI_UART;
+ hci_set_drvdata(hdev, bdev);
+
+ /* Only when vendor specific setup callback is provided, consider
+ * the manufacturer information valid. This avoids filling in the
+ * value for Ericsson when nothing is specified.
+ */
+ if (bdev->vnd->setup)
+ hdev->manufacturer = bdev->vnd->manufacturer;
+
+ hdev->open = btuart_open;
+ hdev->close = btuart_close;
+ hdev->flush = btuart_flush;
+ hdev->setup = btuart_setup;
+ hdev->send = btuart_send_frame;
+ SET_HCIDEV_DEV(hdev, &serdev->dev);
+
+ if (hci_register_dev(hdev) < 0) {
+ dev_err(&serdev->dev, "Can't register HCI device\n");
+ hci_free_dev(hdev);
+ return -ENODEV;
+ }
+
+ return 0;
+}
+
+static void btuart_remove(struct serdev_device *serdev)
+{
+ struct btuart_dev *bdev = serdev_device_get_drvdata(serdev);
+ struct hci_dev *hdev = bdev->hdev;
+
+ hci_unregister_dev(hdev);
+ hci_free_dev(hdev);
+}
+
+#ifdef CONFIG_OF
+static const struct of_device_id btuart_of_match_table[] = {
+ { .compatible = "brcm,bcm43438-bt", .data = &bcm_vnd },
+ { }
+};
+MODULE_DEVICE_TABLE(of, btuart_of_match_table);
+#endif
+
+static struct serdev_device_driver btuart_driver = {
+ .probe = btuart_probe,
+ .remove = btuart_remove,
+ .driver = {
+ .name = "btuart",
+ .of_match_table = of_match_ptr(btuart_of_match_table),
+ },
+};
+
+module_serdev_device_driver(btuart_driver);
+
+MODULE_AUTHOR("Marcel Holtmann <[email protected]>");
+MODULE_DESCRIPTION("Generic Bluetooth UART driver ver " VERSION);
+MODULE_VERSION(VERSION);
+MODULE_LICENSE("GPL");
--
2.7.4

2018-05-15 08:52:16

by Sean Wang

[permalink] [raw]
Subject: [PATCH v2 1/7] dt-bindings: net: bluetooth: Add mediatek-bluetooth

From: Sean Wang <[email protected]>

Add binding document for a SoC built-in device using MediaTek protocol.
Which could be found on MT7622 SoC or other similar MediaTek SoCs.

Signed-off-by: Sean Wang <[email protected]>
Reviewed-by: Rob Herring <[email protected]>
---
.../devicetree/bindings/net/mediatek-bluetooth.txt | 35 ++++++++++++++++++++++
1 file changed, 35 insertions(+)
create mode 100644 Documentation/devicetree/bindings/net/mediatek-bluetooth.txt

diff --git a/Documentation/devicetree/bindings/net/mediatek-bluetooth.txt b/Documentation/devicetree/bindings/net/mediatek-bluetooth.txt
new file mode 100644
index 0000000..1335429
--- /dev/null
+++ b/Documentation/devicetree/bindings/net/mediatek-bluetooth.txt
@@ -0,0 +1,35 @@
+MediaTek SoC built-in Bluetooth Devices
+==================================
+
+This device is a serial attached device to BTIF device and thus it must be a
+child node of the serial node with BTIF. The dt-bindings details for BTIF
+device can be known via Documentation/devicetree/bindings/serial/8250.txt.
+
+Required properties:
+
+- compatible: Must be one of
+ "mediatek,mt7622-bluetooth"": for MT7622 SoC
+- clocks: Should be the clock specifiers corresponding to the entry in
+ clock-names property.
+- clock-names: Should contain "ref" entries.
+- power-domains: Phandle to the power domain that the device is part of
+
+Example:
+
+ btif: serial@1100c000 {
+ compatible = "mediatek,mt7622-btif",
+ "mediatek,mtk-btif";
+ reg = <0 0x1100c000 0 0x1000>;
+ interrupts = <GIC_SPI 90 IRQ_TYPE_LEVEL_LOW>;
+ clocks = <&pericfg CLK_PERI_BTIF_PD>;
+ clock-names = "main";
+ reg-shift = <2>;
+ reg-io-width = <4>;
+
+ bluetooth {
+ compatible = "mediatek,mt7622-bluetooth";
+ power-domains = <&scpsys MT7622_POWER_DOMAIN_WB>;
+ clocks = <&clk25m>;
+ clock-names = "ref";
+ };
+ };
--
2.7.4

2018-05-15 08:52:19

by Sean Wang

[permalink] [raw]
Subject: [PATCH v2 4/7] Bluetooth: Add new quirk for non-persistent setup settings

From: Sean Wang <[email protected]>

Add a new quirk HCI_QUIRK_NON_PERSISTENT_SETUP allowing that a quirk that
runs setup() after every open() and not just after the first open().

Signed-off-by: Sean Wang <[email protected]>
---
include/net/bluetooth/hci.h | 9 +++++++++
net/bluetooth/hci_core.c | 3 ++-
2 files changed, 11 insertions(+), 1 deletion(-)

diff --git a/include/net/bluetooth/hci.h b/include/net/bluetooth/hci.h
index 1668211..b37d973 100644
--- a/include/net/bluetooth/hci.h
+++ b/include/net/bluetooth/hci.h
@@ -183,6 +183,15 @@ enum {
* during the hdev->setup vendor callback.
*/
HCI_QUIRK_NON_PERSISTENT_DIAG,
+
+ /* When this quirk is set, setup() would be run after every
+ * open() and not just after the first open().
+ *
+ * This quirk can be set before hci_register_dev is called or
+ * during the hdev->setup vendor callback.
+ *
+ */
+ HCI_QUIRK_NON_PERSISTENT_SETUP,
};

/* HCI device flags */
diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c
index 40d260f..7de712e2 100644
--- a/net/bluetooth/hci_core.c
+++ b/net/bluetooth/hci_core.c
@@ -1377,7 +1377,8 @@ static int hci_dev_do_open(struct hci_dev *hdev)
atomic_set(&hdev->cmd_cnt, 1);
set_bit(HCI_INIT, &hdev->flags);

- if (hci_dev_test_flag(hdev, HCI_SETUP)) {
+ if (hci_dev_test_flag(hdev, HCI_SETUP) ||
+ test_bit(HCI_QUIRK_NON_PERSISTENT_SETUP, &hdev->quirks)) {
hci_sock_dev_event(hdev, HCI_DEV_SETUP);

if (hdev->setup)
--
2.7.4

2018-05-15 08:52:22

by Sean Wang

[permalink] [raw]
Subject: [PATCH v2 7/7] MAINTAINERS: add an entry for MediaTek Bluetooth driver

From: Sean Wang <[email protected]>

Add an entry for the MediaTek Bluetooth driver.

Signed-off-by: Sean Wang <[email protected]>
---
MAINTAINERS | 8 ++++++++
1 file changed, 8 insertions(+)

diff --git a/MAINTAINERS b/MAINTAINERS
index 0a1410d..3e9fa7c2 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -8874,6 +8874,14 @@ F: include/uapi/linux/meye.h
F: include/uapi/linux/ivtv*
F: include/uapi/linux/uvcvideo.h

+MEDIATEK BLUETOOTH DRIVER
+M: Sean Wang <[email protected]>
+L: [email protected]
+L: [email protected] (moderated for non-subscribers)
+S: Maintained
+F: Documentation/devicetree/bindings/net/mediatek-bluetooth.txt
+F: drivers/bluetooth/btmtkuart.c
+
MEDIATEK CIR DRIVER
M: Sean Wang <[email protected]>
S: Maintained
--
2.7.4

2018-05-15 08:52:17

by Sean Wang

[permalink] [raw]
Subject: [PATCH v2 2/7] serdev: add dev_pm_domain_attach|detach()

From: Sean Wang <[email protected]>

In order to open up the required power gate before any operation can be
effectively performed over the serial bus between CPU and serdev, it's
clearly essential to add common attach functions for PM domains to serdev
at the probe phase.

Similarly, the relevant dettach function for the PM domains should be
properly and reversely added at the remove phase.

Signed-off-by: Sean Wang <[email protected]>
Cc: Rob Herring <[email protected]>
Cc: Ulf Hansson <[email protected]>
Cc: Greg Kroah-Hartman <[email protected]>
Cc: Jiri Slaby <[email protected]>
Cc: [email protected]
---
drivers/tty/serdev/core.c | 14 +++++++++++++-
1 file changed, 13 insertions(+), 1 deletion(-)

diff --git a/drivers/tty/serdev/core.c b/drivers/tty/serdev/core.c
index df93b72..c93d8ee 100644
--- a/drivers/tty/serdev/core.c
+++ b/drivers/tty/serdev/core.c
@@ -13,6 +13,7 @@
#include <linux/module.h>
#include <linux/of.h>
#include <linux/of_device.h>
+#include <linux/pm_domain.h>
#include <linux/serdev.h>
#include <linux/slab.h>

@@ -330,8 +331,16 @@ EXPORT_SYMBOL_GPL(serdev_device_set_tiocm);
static int serdev_drv_probe(struct device *dev)
{
const struct serdev_device_driver *sdrv = to_serdev_device_driver(dev->driver);
+ int ret;
+
+ ret = dev_pm_domain_attach(dev, true);
+ if (ret != -EPROBE_DEFER) {
+ ret = sdrv->probe(to_serdev_device(dev));
+ if (ret)
+ dev_pm_domain_detach(dev, true);
+ }

- return sdrv->probe(to_serdev_device(dev));
+ return ret;
}

static int serdev_drv_remove(struct device *dev)
@@ -339,6 +348,9 @@ static int serdev_drv_remove(struct device *dev)
const struct serdev_device_driver *sdrv = to_serdev_device_driver(dev->driver);
if (sdrv->remove)
sdrv->remove(to_serdev_device(dev));
+
+ dev_pm_domain_detach(dev, true);
+
return 0;
}

--
2.7.4

2018-05-15 08:52:21

by Sean Wang

[permalink] [raw]
Subject: [PATCH v2 6/7] Bluetooth: mediatek: Add protocol support for MediaTek serial devices

From: Sean Wang <[email protected]>

This adds a driver to run on the top of btuart driver for the MediaTek
serial protocol based on running H:4, which can enable the built-in
Bluetooth device inside MT7622 SoC.

Signed-off-by: Sean Wang <[email protected]>
---
drivers/bluetooth/Kconfig | 12 ++
drivers/bluetooth/Makefile | 2 +
drivers/bluetooth/btmtkuart.c | 383 ++++++++++++++++++++++++++++++++++++++++++
drivers/bluetooth/btmtkuart.h | 119 +++++++++++++
drivers/bluetooth/btuart.c | 18 ++
5 files changed, 534 insertions(+)
create mode 100644 drivers/bluetooth/btmtkuart.c
create mode 100644 drivers/bluetooth/btmtkuart.h

diff --git a/drivers/bluetooth/Kconfig b/drivers/bluetooth/Kconfig
index 6d69ac2..13aff1ed 100644
--- a/drivers/bluetooth/Kconfig
+++ b/drivers/bluetooth/Kconfig
@@ -85,6 +85,18 @@ config BT_HCIBTUART
Say Y here to compile support for Bluetooth UART devices into the
kernel or say M to compile it as module (btuart).

+config BT_HCIBTUART_MTK
+ tristate "MediaTek HCI UART driver"
+ depends on BT_HCIBTUART
+ default y
+ help
+ MediaTek Bluetooth HCI UART driver.
+ This driver is required if you want to use MediaTek Bluetooth
+ with serial interface.
+
+ Say Y here to compile support for MediaTek Bluetooth UART devices
+ into the kernel or say M to compile it as module (btmtkuart).
+
config BT_HCIUART
tristate "HCI UART driver"
depends on SERIAL_DEV_BUS || !SERIAL_DEV_BUS
diff --git a/drivers/bluetooth/Makefile b/drivers/bluetooth/Makefile
index 60a19cb..c9a8926 100644
--- a/drivers/bluetooth/Makefile
+++ b/drivers/bluetooth/Makefile
@@ -26,6 +26,8 @@ obj-$(CONFIG_BT_BCM) += btbcm.o
obj-$(CONFIG_BT_RTL) += btrtl.o
obj-$(CONFIG_BT_QCA) += btqca.o

+obj-$(CONFIG_BT_HCIBTUART_MTK) += btmtkuart.o
+
obj-$(CONFIG_BT_HCIUART_NOKIA) += hci_nokia.o

obj-$(CONFIG_BT_HCIRSI) += btrsi.o
diff --git a/drivers/bluetooth/btmtkuart.c b/drivers/bluetooth/btmtkuart.c
new file mode 100644
index 0000000..0e43a4ae
--- /dev/null
+++ b/drivers/bluetooth/btmtkuart.c
@@ -0,0 +1,383 @@
+// SPDX-License-Identifier: GPL-2.0
+// Copyright (c) 2018 MediaTek Inc.
+
+/*
+ * Bluetooth support for MediaTek serial devices
+ *
+ * Author: Sean Wang <[email protected]>
+ *
+ */
+
+#include <asm/unaligned.h>
+#include <linux/clk.h>
+#include <linux/firmware.h>
+#include <linux/module.h>
+#include <linux/pm_runtime.h>
+#include <linux/serdev.h>
+#include <net/bluetooth/bluetooth.h>
+#include <net/bluetooth/hci_core.h>
+
+#include "h4_recv.h"
+#include "btuart.h"
+#include "btmtkuart.h"
+
+static void mtk_stp_reset(struct mtk_stp_splitter *sp)
+{
+ sp->cursor = 2;
+ sp->dlen = 0;
+}
+
+static const unsigned char *
+mtk_stp_split(struct btuart_dev *bdev, struct mtk_stp_splitter *sp,
+ const unsigned char *data, int count, int *sz_h4)
+{
+ struct mtk_stp_hdr *shdr;
+
+ /* The cursor is reset when all the data of STP is consumed out. */
+ if (!sp->dlen && sp->cursor >= 6)
+ sp->cursor = 0;
+
+ /* Filling pad until all STP info is obtained. */
+ while (sp->cursor < 6 && count > 0) {
+ sp->pad[sp->cursor] = *data;
+ sp->cursor++;
+ data++;
+ count--;
+ }
+
+ /* Retrieve STP info and have a sanity check. */
+ if (!sp->dlen && sp->cursor >= 6) {
+ shdr = (struct mtk_stp_hdr *)&sp->pad[2];
+ sp->dlen = shdr->dlen1 << 8 | shdr->dlen2;
+
+ /* Resync STP when unexpected data is being read. */
+ if (shdr->prefix != 0x80 || sp->dlen > 2048) {
+ bt_dev_err(bdev->hdev, "stp format unexpect (%d, %d)",
+ shdr->prefix, sp->dlen);
+ mtk_stp_reset(sp);
+ }
+ }
+
+ /* Directly quit when there's no data found for H4 can process. */
+ if (count <= 0)
+ return NULL;
+
+ /* Tranlate to how much the size of data H4 can handle so far. */
+ *sz_h4 = min_t(int, count, sp->dlen);
+ /* Update the remaining size of STP packet. */
+ sp->dlen -= *sz_h4;
+
+ /* Data points to STP payload which can be handled by H4. */
+ return data;
+}
+
+static int mtk_stp_send(struct btuart_dev *bdev, struct sk_buff *skb)
+{
+ struct mtk_stp_hdr *shdr;
+ struct sk_buff *new_skb;
+ int dlen;
+
+ memcpy(skb_push(skb, 1), &hci_skb_pkt_type(skb), 1);
+ dlen = skb->len;
+
+ /* Make sure of STP header at least has 4-bytes free space to fill. */
+ if (unlikely(skb_headroom(skb) < MTK_STP_HDR_SIZE)) {
+ new_skb = skb_realloc_headroom(skb, MTK_STP_HDR_SIZE);
+ kfree_skb(skb);
+ skb = new_skb;
+ }
+
+ /* Build for STP packet format. */
+ shdr = skb_push(skb, MTK_STP_HDR_SIZE);
+ mtk_make_stp_hdr(shdr, 0, dlen);
+ skb_put_zero(skb, MTK_STP_TLR_SIZE);
+
+ skb_queue_tail(&bdev->txq, skb);
+
+ return 0;
+}
+
+static int mtk_hci_wmt_sync(struct btuart_dev *bdev, u8 opcode, u8 flag,
+ u16 plen, const void *param)
+{
+ struct mtk_hci_wmt_cmd wc;
+ struct mtk_wmt_hdr *hdr;
+ struct sk_buff *skb;
+
+ hdr = (struct mtk_wmt_hdr *)&wc;
+ mtk_make_wmt_hdr(hdr, opcode, plen, flag);
+ memcpy(wc.data, param, plen);
+
+ skb = __hci_cmd_sync_ev(bdev->hdev, 0xfc6f, sizeof(*hdr) + plen, &wc,
+ 0xe4, HCI_INIT_TIMEOUT);
+
+ if (IS_ERR(skb)) {
+ int err = PTR_ERR(skb);
+
+ bt_dev_err(bdev->hdev, "Failed to send wmt cmd (%d)\n", err);
+ return err;
+ }
+
+ kfree_skb(skb);
+
+ return 0;
+}
+
+static int mtk_acl_wmt_sync(struct btuart_dev *bdev, u8 opcode, u8 flag,
+ u16 plen, const void *param)
+{
+ struct mtk_bt_dev *soc = bdev->data;
+ struct hci_acl_hdr *ahdr;
+ struct mtk_wmt_hdr *whdr;
+ struct sk_buff *skb;
+ int ret = 0;
+
+ init_completion(&soc->wmt_cmd);
+
+ skb = bt_skb_alloc(plen + MTK_WMT_CMD_SIZE, GFP_KERNEL);
+ if (!skb)
+ return -ENOMEM;
+
+ /* The SoC-specific ACL data is going with an opcode 0xfc6f. */
+ ahdr = skb_put(skb, HCI_ACL_HDR_SIZE);
+ ahdr->handle = cpu_to_le16(0xfc6f);
+ ahdr->dlen = cpu_to_le16(plen + MTK_WMT_HDR_SIZE);
+ hci_skb_pkt_type(skb) = HCI_ACLDATA_PKT;
+
+ /* Then add a WMT header and its actual payload. */
+ whdr = skb_put(skb, MTK_WMT_HDR_SIZE);
+ mtk_make_wmt_hdr(whdr, opcode, plen, flag);
+ skb_put_data(skb, param, plen);
+
+ mtk_stp_send(bdev, skb);
+
+ if (test_and_set_bit(BTUART_TX_STATE_ACTIVE, &bdev->tx_state))
+ set_bit(BTUART_TX_STATE_WAKEUP, &bdev->tx_state);
+ else
+ schedule_work(&bdev->tx_work);
+
+ /* Wait for its event back. */
+ ret = wait_for_completion_interruptible_timeout(&soc->wmt_cmd,
+ HZ);
+ return ret > 0 ? 0 : ret < 0 ? ret : -ETIMEDOUT;
+}
+
+static int mtk_setup_fw(struct btuart_dev *bdev)
+{
+ const struct firmware *fw;
+ struct device *dev;
+ const char *fwname;
+ const u8 *fw_ptr;
+ size_t fw_size;
+ int err, dlen;
+ u8 flag;
+
+ dev = &bdev->serdev->dev;
+ fwname = FIRMWARE_MT7622;
+
+ err = request_firmware(&fw, fwname, dev);
+ if (err < 0) {
+ bt_dev_err(bdev->hdev, "Failed to load firmware file (%d)",
+ err);
+ return err;
+ }
+
+ fw_ptr = fw->data;
+ fw_size = fw->size;
+
+ /* The size of a patch header at least has 30 bytes. */
+ if (fw_size < 30)
+ return -EINVAL;
+
+ while (fw_size > 0) {
+ dlen = min_t(int, 1000, fw_size);
+
+ /* Tell deivice the position in sequence. */
+ flag = (fw_size - dlen <= 0) ? 3 :
+ (fw_size < fw->size) ? 2 : 1;
+
+ err = mtk_acl_wmt_sync(bdev, MTK_WMT_PATCH_DWNLD, flag, dlen,
+ fw_ptr);
+ if (err < 0)
+ break;
+
+ fw_size -= dlen;
+ fw_ptr += dlen;
+ }
+
+ release_firmware(fw);
+
+ return err;
+}
+
+void *mtk_btuart_init(struct device *dev)
+{
+ struct mtk_bt_dev *soc;
+
+ soc = devm_kzalloc(dev, sizeof(*soc), GFP_KERNEL);
+ if (!soc)
+ return ERR_PTR(-ENOMEM);
+
+ soc->sp = devm_kzalloc(dev, sizeof(*soc->sp), GFP_KERNEL);
+ if (!soc->sp)
+ return ERR_PTR(-ENOMEM);
+
+ soc->clk = devm_clk_get(dev, "ref");
+ if (IS_ERR(soc->clk))
+ return ERR_CAST(soc->clk);
+
+ return soc;
+}
+EXPORT_SYMBOL_GPL(mtk_btuart_init);
+
+int mtk_btuart_send(struct hci_dev *hdev, struct sk_buff *skb)
+{
+ struct btuart_dev *bdev = hci_get_drvdata(hdev);
+
+ return mtk_stp_send(bdev, skb);
+}
+EXPORT_SYMBOL_GPL(mtk_btuart_send);
+
+int mtk_btuart_hci_frame(struct hci_dev *hdev, struct sk_buff *skb)
+{
+ struct hci_event_hdr *hdr = (void *)skb->data;
+ struct btuart_dev *bdev = hci_get_drvdata(hdev);
+ struct mtk_bt_dev *soc = bdev->data;
+
+ /* Complete the SoC-specific data being sent. */
+ if (hdr->evt == 0xe4)
+ complete(&soc->wmt_cmd);
+
+ /* Each HCI event would go through the core. */
+ return hci_recv_frame(hdev, skb);
+}
+EXPORT_SYMBOL_GPL(mtk_btuart_hci_frame);
+
+int mtk_btuart_recv(struct hci_dev *hdev, const u8 *data, size_t count)
+{
+ struct btuart_dev *bdev = hci_get_drvdata(hdev);
+ const unsigned char *p_left = data, *p_h4;
+ const struct btuart_vnd *vnd = bdev->vnd;
+ struct mtk_bt_dev *soc = bdev->data;
+ int sz_left = count, sz_h4, adv;
+ struct device *dev;
+ int err;
+
+ dev = &bdev->serdev->dev;
+
+ while (sz_left > 0) {
+ /* The serial data received from MT7622 BT controller is
+ * at all time padded around with the STP header and tailer.
+ *
+ * A full STP packet is looking like
+ * -----------------------------------
+ * | STP header | H:4 | STP tailer |
+ * -----------------------------------
+ * but it don't guarantee to contain a full H:4 packet which
+ * means that it's possible for multiple STP packets forms a
+ * full H:4 packet and whose length recorded in STP header can
+ * shows up the most length the H:4 engine can handle in one
+ * time.
+ */
+
+ p_h4 = mtk_stp_split(bdev, soc->sp, p_left, sz_left, &sz_h4);
+ if (!p_h4)
+ break;
+
+ adv = p_h4 - p_left;
+ sz_left -= adv;
+ p_left += adv;
+
+ bdev->rx_skb = h4_recv_buf(bdev->hdev, bdev->rx_skb, p_h4,
+ sz_h4, vnd->recv_pkts,
+ vnd->recv_pkts_cnt);
+ if (IS_ERR(bdev->rx_skb)) {
+ err = PTR_ERR(bdev->rx_skb);
+ bt_dev_err(bdev->hdev,
+ "Frame reassembly failed (%d)", err);
+ bdev->rx_skb = NULL;
+ return err;
+ }
+
+ sz_left -= sz_h4;
+ p_left += sz_h4;
+ }
+
+ return 0;
+}
+EXPORT_SYMBOL_GPL(mtk_btuart_recv);
+
+int mtk_btuart_setup(struct hci_dev *hdev)
+{
+ struct btuart_dev *bdev = hci_get_drvdata(hdev);
+ struct mtk_bt_dev *soc = bdev->data;
+ struct device *dev;
+ u8 param = 0x1;
+ int err = 0;
+
+ dev = &bdev->serdev->dev;
+
+ mtk_stp_reset(soc->sp);
+
+ /* Enable the power domain and clock the device requires. */
+ pm_runtime_enable(dev);
+ err = pm_runtime_get_sync(dev);
+ if (err < 0)
+ goto err_pm2;
+
+ err = clk_prepare_enable(soc->clk);
+ if (err < 0)
+ goto err_pm1;
+
+ /* Setup a firmware which the device definitely requires. */
+ err = mtk_setup_fw(bdev);
+ if (err < 0)
+ goto err_clk;
+
+ /* Activate funciton the firmware providing to. */
+ err = mtk_hci_wmt_sync(bdev, MTK_WMT_RST, 0x4, 0, 0);
+ if (err < 0)
+ goto err_clk;
+
+ /* Enable Bluetooth protocol. */
+ err = mtk_hci_wmt_sync(bdev, MTK_WMT_FUNC_CTRL, 0x0, sizeof(param),
+ &param);
+ if (err < 0)
+ goto err_clk;
+
+ set_bit(HCI_QUIRK_NON_PERSISTENT_SETUP, &hdev->quirks);
+
+ return 0;
+err_clk:
+ clk_disable_unprepare(soc->clk);
+err_pm1:
+ pm_runtime_put_sync(dev);
+err_pm2:
+ pm_runtime_disable(dev);
+
+ return err;
+}
+EXPORT_SYMBOL_GPL(mtk_btuart_setup);
+
+int mtk_btuart_shutdown(struct hci_dev *hdev)
+{
+ struct btuart_dev *bdev = hci_get_drvdata(hdev);
+ struct device *dev = &bdev->serdev->dev;
+ struct mtk_bt_dev *soc = bdev->data;
+ u8 param = 0x0;
+
+ /* Disable the device. */
+ mtk_hci_wmt_sync(bdev, MTK_WMT_FUNC_CTRL, 0x0, sizeof(param), &param);
+
+ /* Shutdown the clock and power domain the device requires. */
+ clk_disable_unprepare(soc->clk);
+ pm_runtime_put_sync(dev);
+ pm_runtime_disable(dev);
+
+ return 0;
+}
+EXPORT_SYMBOL_GPL(mtk_btuart_shutdown);
+
+MODULE_AUTHOR("Sean Wang <[email protected]>");
+MODULE_DESCRIPTION("Bluetooth Support for MediaTek Serial Devices");
+MODULE_LICENSE("GPL v2");
diff --git a/drivers/bluetooth/btmtkuart.h b/drivers/bluetooth/btmtkuart.h
new file mode 100644
index 0000000..ea6fc36
--- /dev/null
+++ b/drivers/bluetooth/btmtkuart.h
@@ -0,0 +1,119 @@
+// SPDX-License-Identifier: GPL-2.0
+// Copyright (c) 2018 MediaTek Inc.
+
+/*
+ * Bluetooth support for MediaTek serial devices
+ *
+ * Author: Sean Wang <[email protected]>
+ *
+ */
+
+#define FIRMWARE_MT7622 "mediatek/mt7622_patch_firmware.bin"
+
+#define MTK_STP_HDR_SIZE 4
+#define MTK_STP_TLR_SIZE 2
+#define MTK_WMT_HDR_SIZE 5
+#define MTK_WMT_CMD_SIZE (MTK_WMT_HDR_SIZE + MTK_STP_HDR_SIZE + \
+ MTK_STP_TLR_SIZE + HCI_ACL_HDR_SIZE)
+
+enum {
+ MTK_WMT_PATCH_DWNLD = 0x1,
+ MTK_WMT_FUNC_CTRL = 0x6,
+ MTK_WMT_RST = 0x7
+};
+
+struct mtk_stp_hdr {
+ __u8 prefix;
+ __u8 dlen1:4;
+ __u8 type:4;
+ __u8 dlen2:8;
+ __u8 cs;
+} __packed;
+
+struct mtk_wmt_hdr {
+ __u8 dir;
+ __u8 op;
+ __le16 dlen;
+ __u8 flag;
+} __packed;
+
+struct mtk_hci_wmt_cmd {
+ struct mtk_wmt_hdr hdr;
+ __u8 data[16];
+} __packed;
+
+struct mtk_stp_splitter {
+ u8 pad[6];
+ u8 cursor;
+ u16 dlen;
+};
+
+struct mtk_bt_dev {
+ struct clk *clk;
+ struct completion wmt_cmd;
+ struct mtk_stp_splitter *sp;
+};
+
+static inline void mtk_make_stp_hdr(struct mtk_stp_hdr *hdr, u8 type, u32 dlen)
+{
+ __u8 *p = (__u8 *)hdr;
+
+ hdr->prefix = 0x80;
+ hdr->dlen1 = (dlen & 0xf00) >> 8;
+ hdr->type = type;
+ hdr->dlen2 = dlen & 0xff;
+ hdr->cs = p[0] + p[1] + p[2];
+}
+
+static inline void mtk_make_wmt_hdr(struct mtk_wmt_hdr *hdr, u8 op, u16 plen,
+ u8 flag)
+{
+ hdr->dir = 1;
+ hdr->op = op;
+ hdr->dlen = cpu_to_le16(plen + 1);
+ hdr->flag = flag;
+}
+
+#if IS_ENABLED(CONFIG_BT_HCIBTUART_MTK)
+
+void *mtk_btuart_init(struct device *dev);
+int mtk_btuart_setup(struct hci_dev *hdev);
+int mtk_btuart_shutdown(struct hci_dev *hdev);
+int mtk_btuart_send(struct hci_dev *hdev, struct sk_buff *skb);
+int mtk_btuart_hci_frame(struct hci_dev *hdev, struct sk_buff *skb);
+int mtk_btuart_recv(struct hci_dev *hdev, const u8 *data, size_t count);
+
+#else
+
+static void *mtk_btuart_init(struct device *dev)
+{
+ return 0;
+}
+
+static inline int mtk_btuart_setup(struct hci_dev *hdev)
+{
+ return -EOPNOTSUPP;
+}
+
+static inline int mtk_btuart_shutdown(struct hci_dev *hdev)
+{
+ return -EOPNOTSUPP;
+}
+
+static inline int mtk_btuart_send(struct hci_dev *hdev, struct sk_buff *skb)
+{
+ return -EOPNOTSUPP;
+}
+
+static int mtk_btuart_hci_frame(struct hci_dev *hdev, struct sk_buff *skb)
+{
+ return -EOPNOTSUPP;
+}
+
+static inline int mtk_btuart_recv(struct hci_dev *hdev, const u8 *data,
+ size_t count)
+{
+ return -EOPNOTSUPP;
+}
+
+#endif
diff --git a/drivers/bluetooth/btuart.c b/drivers/bluetooth/btuart.c
index ab7f836..169bf1a 100644
--- a/drivers/bluetooth/btuart.c
+++ b/drivers/bluetooth/btuart.c
@@ -35,6 +35,7 @@
#include "h4_recv.h"
#include "btuart.h"
#include "btbcm.h"
+#include "btmtkuart.h"

#define VERSION "1.0"

@@ -396,6 +397,12 @@ static const struct h4_recv_pkt bcm_recv_pkts[] = {
{ BCM_RECV_NULL, .recv = hci_recv_diag },
};

+static const struct h4_recv_pkt mtk_recv_pkts[] = {
+ { H4_RECV_ACL, .recv = hci_recv_frame },
+ { H4_RECV_SCO, .recv = hci_recv_frame },
+ { H4_RECV_EVENT, .recv = mtk_btuart_hci_frame },
+};
+
static const struct btuart_vnd bcm_vnd = {
.recv_pkts = bcm_recv_pkts,
.recv_pkts_cnt = ARRAY_SIZE(bcm_recv_pkts),
@@ -403,6 +410,16 @@ static const struct btuart_vnd bcm_vnd = {
.setup = bcm_setup,
};

+static const struct btuart_vnd mtk_vnd = {
+ .recv_pkts = mtk_recv_pkts,
+ .recv_pkts_cnt = ARRAY_SIZE(mtk_recv_pkts),
+ .init = mtk_btuart_init,
+ .setup = mtk_btuart_setup,
+ .shutdown = mtk_btuart_shutdown,
+ .send = mtk_btuart_send,
+ .recv = mtk_btuart_recv,
+};
+
static const struct h4_recv_pkt default_recv_pkts[] = {
{ H4_RECV_ACL, .recv = hci_recv_frame },
{ H4_RECV_SCO, .recv = hci_recv_frame },
@@ -487,6 +504,7 @@ static void btuart_remove(struct serdev_device *serdev)
#ifdef CONFIG_OF
static const struct of_device_id btuart_of_match_table[] = {
{ .compatible = "brcm,bcm43438-bt", .data = &bcm_vnd },
+ { .compatible = "mediatek,mt7622-bluetooth", .data = &mtk_vnd },
{ }
};
MODULE_DEVICE_TABLE(of, btuart_of_match_table);
--
2.7.4

2018-05-15 08:52:20

by Sean Wang

[permalink] [raw]
Subject: [PATCH v2 5/7] Bluetooth: Extend btuart driver for join more vendor devices

From: Sean Wang <[email protected]>

Adding an independent btuart.h header allows these essential definitions
can be reused in vendor driver. Also, struct btuart_vnd is extended with
additional callbacks such as .init initializing vendor data, .shtudown,
.recv and .send supporting SoC specific framing for that btuart can
simply adapt to various Bluetooth uart-based devices.

Signed-off-by: Sean Wang <[email protected]>
---
drivers/bluetooth/btuart.c | 73 ++++++++++++++++++++++++----------------------
drivers/bluetooth/btuart.h | 30 +++++++++++++++++++
2 files changed, 68 insertions(+), 35 deletions(-)
create mode 100644 drivers/bluetooth/btuart.h

diff --git a/drivers/bluetooth/btuart.c b/drivers/bluetooth/btuart.c
index 03e980f..ab7f836 100644
--- a/drivers/bluetooth/btuart.c
+++ b/drivers/bluetooth/btuart.c
@@ -33,35 +33,11 @@
#include <net/bluetooth/hci_core.h>

#include "h4_recv.h"
+#include "btuart.h"
#include "btbcm.h"

#define VERSION "1.0"

-struct btuart_vnd {
- const struct h4_recv_pkt *recv_pkts;
- int recv_pkts_cnt;
- unsigned int manufacturer;
- int (*open)(struct hci_dev *hdev);
- int (*close)(struct hci_dev *hdev);
- int (*setup)(struct hci_dev *hdev);
-};
-
-struct btuart_dev {
- struct hci_dev *hdev;
- struct serdev_device *serdev;
-
- struct work_struct tx_work;
- unsigned long tx_state;
- struct sk_buff_head txq;
-
- struct sk_buff *rx_skb;
-
- const struct btuart_vnd *vnd;
-};
-
-#define BTUART_TX_STATE_ACTIVE 1
-#define BTUART_TX_STATE_WAKEUP 2
-
static void btuart_tx_work(struct work_struct *work)
{
struct btuart_dev *bdev = container_of(work, struct btuart_dev,
@@ -187,13 +163,27 @@ static int btuart_setup(struct hci_dev *hdev)
return 0;
}

+static int btuart_shutdown(struct hci_dev *hdev)
+{
+ struct btuart_dev *bdev = hci_get_drvdata(hdev);
+
+ if (bdev->vnd->shutdown)
+ return bdev->vnd->shutdown(hdev);
+
+ return 0;
+}
+
static int btuart_send_frame(struct hci_dev *hdev, struct sk_buff *skb)
{
struct btuart_dev *bdev = hci_get_drvdata(hdev);

- /* Prepend skb with frame type */
- memcpy(skb_push(skb, 1), &hci_skb_pkt_type(skb), 1);
- skb_queue_tail(&bdev->txq, skb);
+ if (bdev->vnd->send) {
+ bdev->vnd->send(hdev, skb);
+ } else {
+ /* Prepend skb with frame type */
+ memcpy(skb_push(skb, 1), &hci_skb_pkt_type(skb), 1);
+ skb_queue_tail(&bdev->txq, skb);
+ }

btuart_tx_wakeup(bdev);
return 0;
@@ -204,14 +194,23 @@ static int btuart_receive_buf(struct serdev_device *serdev, const u8 *data,
{
struct btuart_dev *bdev = serdev_device_get_drvdata(serdev);
const struct btuart_vnd *vnd = bdev->vnd;
+ int err;

- bdev->rx_skb = h4_recv_buf(bdev->hdev, bdev->rx_skb, data, count,
- vnd->recv_pkts, vnd->recv_pkts_cnt);
- if (IS_ERR(bdev->rx_skb)) {
- int err = PTR_ERR(bdev->rx_skb);
- bt_dev_err(bdev->hdev, "Frame reassembly failed (%d)", err);
- bdev->rx_skb = NULL;
- return err;
+ if (bdev->vnd->recv) {
+ err = bdev->vnd->recv(bdev->hdev, data, count);
+ if (err < 0)
+ return err;
+ } else {
+ bdev->rx_skb = h4_recv_buf(bdev->hdev, bdev->rx_skb,
+ data, count, vnd->recv_pkts,
+ vnd->recv_pkts_cnt);
+ if (IS_ERR(bdev->rx_skb)) {
+ err = PTR_ERR(bdev->rx_skb);
+ bt_dev_err(bdev->hdev,
+ "Frame reassembly failed (%d)", err);
+ bdev->rx_skb = NULL;
+ return err;
+ }
}

bdev->hdev->stat.byte_rx += count;
@@ -429,6 +428,9 @@ static int btuart_probe(struct serdev_device *serdev)
if (!bdev->vnd)
bdev->vnd = &default_vnd;

+ if (bdev->vnd->init)
+ bdev->data = bdev->vnd->init(&serdev->dev);
+
bdev->serdev = serdev;
serdev_device_set_drvdata(serdev, bdev);

@@ -460,6 +462,7 @@ static int btuart_probe(struct serdev_device *serdev)
hdev->close = btuart_close;
hdev->flush = btuart_flush;
hdev->setup = btuart_setup;
+ hdev->shutdown = btuart_shutdown;
hdev->send = btuart_send_frame;
SET_HCIDEV_DEV(hdev, &serdev->dev);

diff --git a/drivers/bluetooth/btuart.h b/drivers/bluetooth/btuart.h
new file mode 100644
index 0000000..6c1fe31
--- /dev/null
+++ b/drivers/bluetooth/btuart.h
@@ -0,0 +1,30 @@
+struct btuart_vnd {
+ const struct h4_recv_pkt *recv_pkts;
+ int recv_pkts_cnt;
+ unsigned int manufacturer;
+ void *(*init)(struct device *dev);
+
+ int (*open)(struct hci_dev *hdev);
+ int (*close)(struct hci_dev *hdev);
+ int (*setup)(struct hci_dev *hdev);
+ int (*shutdown)(struct hci_dev *hdev);
+ int (*send)(struct hci_dev *hdev, struct sk_buff *skb);
+ int (*recv)(struct hci_dev *hdev, const u8 *data, size_t count);
+};
+
+struct btuart_dev {
+ struct hci_dev *hdev;
+ struct serdev_device *serdev;
+
+ struct work_struct tx_work;
+ unsigned long tx_state;
+ struct sk_buff_head txq;
+
+ struct sk_buff *rx_skb;
+
+ const struct btuart_vnd *vnd;
+ void *data;
+};
+
+#define BTUART_TX_STATE_ACTIVE 1
+#define BTUART_TX_STATE_WAKEUP 2
--
2.7.4

2018-06-14 03:10:14

by Sean Wang

[permalink] [raw]
Subject: Re: [PATCH v2 4/7] Bluetooth: Add new quirk for non-persistent setup settings

On Tue, 2018-06-12 at 17:58 +0800, Sean Wang wrote:
> On Wed, 2018-05-30 at 08:26 +0200, Marcel Holtmann wrote:
> > Hi Sean,
> >
> > >>>>>>
>
> [ ... ]
>
> > >>> * Unknown packet (code 14 len 30) 0.641509
> > >>> 01 00 00 00 02 00 01 0e 00 01 00 00 00 10 62 6c ..............bl
> > >>> 75 65 74 6f 6f 74 68 64 00 00 00 00 00 00 uetoothd......
> > >>> * Unknown packet (code 14 len 30) 0.641592
> > >>> 02 00 00 00 02 00 01 0e 00 01 00 00 00 10 62 74 ..............bt
> > >>> 6d 6f 6e 00 00 00 00 00 00 00 00 00 00 00 mon...........
> > >>> * Unknown packet (code 16 len 7) [hci0] 6.536771
> > >>> 01 00 00 00 05 00 01 .......
> > >>> = Open Index: 00:00:46:76:22:01 [hci0] 6.717019
> > >>> = Index Info: 00:00:46:76:22:01 (MediaTek, Inc.) [hci0] 6.717030
> > >>
> > >> can you try with the latest BlueZ 5.49 or git version. Seems it actually stumbles over the extra packet here. Fun fact is that I can not get a backtrace to pin-point the issue in btmon and why it crashes.
> > >>
> > >
> > > I had less experience updating user land BlueZ, but I can try it as possible and see whether Unknown packets still are present at newest version BlueZ. Hopefully I don't misunderstand your point here.
> >
> > please use the latest btmon and check if it can read your trace.
> >
>
> sure, I'll have a try with the latest btmon.


I use the btmon version 5.50 and it can read the trace

>
> > >>>> HCI Event: Unknown (0xe4) plen 5 [hci0] 6.741093
> > >>> 02 01 01 00 00 .....
> > >>>> HCI Event: Unknown (0xe4) plen 5 [hci0] 6.742088
> > >>> 02 01 01 00 00 .....
> > >>>> HCI Event: Unknown (0xe4) plen 5 [hci0] 6.743102
> > >>> 02 01 01 00 00 .....
>
>
> [ ... ]
>
> > >>>> HCI Event: Unknown (0xe4) plen 5 [hci0] 6.814708
> > >>> 02 01 01 00 00 .....
> > >>>> HCI Event: Unknown (0xe4) plen 5 [hci0] 6.815705
> > >>> 02 01 01 00 00 .....
> > >>>> HCI Event: Unknown (0xe4) plen 5 [hci0] 6.816378
> > >>> 02 01 01 00 00 .....
> > >>
> > >> Why do I see only HCI events here? Is this event conveying any useful information. It is kinda complicated that this is 0xe4 event code which is actually reserved for future use by the Bluetooth SIG. Are there any accompanying HCI commands for this and they just not make it into btmon?
> > >>
> > >
> > > I have made all vendor HCI commands go through BlueZ core in v2 patch.
> > >
> > > And for these HCI events, they are all corresponding to vendor ACL data, applied only to firmware setup packets, but they're not being sent via BlueZ core, so they are not being logged in btmon.
> > >
> > > As for its event, where heading 0xe4 refers to a vendor event and is used on notification of that either vendor ACL data or vendor HCI command have been done.
> >
> > I would prefer if everything goes via the Bluetooth core since then we have it all properly scheduled. Sending things down the ACL data path however if kinda funky. Does your hardware accept sending command both via ACL data and as HCI command? If so, then I would prefer sending them as HCI commands since the speed improvement you think you are getting is neglectable on Linux (I have been down that path). This seems to be a pure optimization when Windows is driving the device.
> >
>
> firmware people said the device can support firmware download as HCI commands. According to my test, this way indeed works so I will improve the part in the next version.
>
>
> > And the vendor event 0xe4 is really only received during firmware download? It is not ever received during normal operation?
> >
>
> 0xe4 is only received during chip initialization.
>
> I also thought 0xe4 is a poor definition for vendor event and already have notified firmware people should pick 0xff as its vendor event id in the future.
>
> but for now, unfortunately, 0xe4 cannot be changed on the device, the only way is to add a workaround in RX path as below to allow btmon can recognize these bad events properly.
>
> int mtk_btuart_hci_frame(struct hci_dev *hdev, struct sk_buff *skb)
> {
> struct hci_event_hdr *hdr = (void *)skb->data;
>
> /* Fix up the vendor event id with HCI_VENDOR_PKT instead of
> * 0xe4 so that btmon can parse the kind of vendor event properly.
> */
> if (hdr->evt == 0xe4)
> hdr->evt = HCI_VENDOR_PKT;
>
> /* Each HCI event would go through the core. */
> return hci_recv_frame(hdev, skb);
> }
>
>
> > >
> > >>
> > >>
> > >>> < HCI Command: Vendor (0x3f|0x006f) plen 5 [hci0] 6.816413
> > >>> 01 07 01 00 04 .....
> > >>>> HCI Event: Unknown (0xe4) plen 5 [hci0] 6.816536
> > >>> 02 07 01 00 00 .....
>
> [ ... ]
>
> > >>> Encapsulated PDU
> > >>> Erroneous Data Reporting
> > >>> Non-flushable Packet Boundary Flag
> > >>> Link Supervision Timeout Changed Event
> > >>> Inquiry TX Power Level
> > >>> Enhanced Power Control
> > >>> Extended features
> > >>> < HCI Command: Read Local Version Info.. (0x04|0x0001) plen 0 [hci0] 10.865987
> > >>>> HCI Event: Vendor (0xff) plen 9 [hci0] 10.866259
> > >>> 29 19 09 17 20 48 07 11 00 )... H…
> > >>
> > >> Is this meant to happen here?
> > >>
> > >
> > > If event received is not expected as the specification defines, I think it's probably incorrect.
> > >
> > > But it requires more discussion with firmware people to make it clearer.
> >
> > Please check and let them decode what this event means.
> >
>
> it's just debugging purpose information listing built-time something
> like that and will be removed in the firmware.
>
> > >
> > >>>> HCI Event: Command Complete (0x0e) plen 12 [hci0] 10.866372
> > >>> Read Local Version Information (0x04|0x0001) ncmd 1
> > >>> Status: Success (0x00)
> > >>> HCI version: Bluetooth 4.2 (0x08) - Revision 4359 (0x1107)
> > >>> LMP version: Bluetooth 4.2 (0x08) - Subversion 2329 (0x0919)
> > >>> Manufacturer: MediaTek, Inc. (70)
> > >>> < HCI Command: Read BD ADDR (0x04|0x0009) plen 0 [hci0] 10.866391
> > >>>> HCI Event: Command Complete (0x0e) plen 10 [hci0] 10.866539
>
> [ ... ]
>
> > >>> LE Add Device To Resolving List (Octet 34 - Bit 3)
> > >>> LE Remove Device From Resolving List (Octet 34 - Bit 4)
> > >>> LE Clear Resolving List (Octet 34 - Bit 5)
> > >>> LE Read Resolving List Size (Octet 34 - Bit 6)
> > >>> LE Read Peer Resolvable Address (Octet 34 - Bit 7)
> > >>> LE Read Local Resolvable Address (Octet 35 - Bit 0)
> > >>> LE Set Address Resolution Enable (Octet 35 - Bit 1)
> > >>> LE Set Resolvable Private Address Timeout (Octet 35 - Bit 2)
> > >>> LE Read Maximum Data Length (Octet 35 - Bit 3)
> > >>> Octet 35 - Bit 4
> > >>> Octet 35 - Bit 5
> > >>> Octet 35 - Bit 6
> > >>> Octet 35 - Bit 7
> > >>> Octet 36 - Bit 0
> > >>
> > >> So you support the PHY commands, but do not indicate support LE 2M or LE Coded? Also these are Bluetooth 5.0 commands.
> > >>
> > >
> > > To be honest. When I ported the device into Bluez core, a unexpected event for LE read local feature would cause a fail at Bluez core, so I made a hack on Bluez core
> > >
> > > to allow that I can keeping bring up the device without be blocked by the issue most probably from firmware.
> > >
> > > Below code snippet is the only thing I added to avoid a fail at Bluez core to bring upbtsnoop the device.
> > >
> > > @@ -927,6 +927,8 @@ static void hci_cc_le_read_local_features(struct hci_dev *hdev,
> > > return;
> > >
> > > memcpy(hdev->le_features, rp->features, 8);
> > > + hdev->le_features[0] = 0;
> > > + hdev->le_features[1] = 0;
> > > }
> >
> > Send me the trace where you didn’t clear the feature bits and I check what is going on. I doubt that we have a bug, but maybe some of the commands are optional and we should add an appropriate check. Or you guys need to fix your firmware. A new btmon should decode all bits properly.
> >
>
> okay, I'll have a follow-up.where

.
It's a fault from the device and can be simply fixed up in the firmware.
The fault is the device reporting to host told it can support "LE Read
Maximum Data Length", but actually it can't. so it's just a fail at the
command.


The attached here is the fail log I captured with btmon 5.50 where I
already turned the patch setup in HCI command from ACL data and turned
event id 0xe4 to 0xff every vendor should use. And, finally, it can be
seen that btmon already can record and parse all traffic between host
and device well.

>
> > Regards
> >
> > Marcel
> >
>


Attachments:
trace3_fail_at_le_read_max_data.log (99.16 kB)

2018-06-12 09:58:36

by Sean Wang

[permalink] [raw]
Subject: Re: [PATCH v2 4/7] Bluetooth: Add new quirk for non-persistent setup settings

On Wed, 2018-05-30 at 08:26 +0200, Marcel Holtmann wrote:
> Hi Sean,
>
> >>>>>>

[ ... ]

> >>> * Unknown packet (code 14 len 30) 0.641509
> >>> 01 00 00 00 02 00 01 0e 00 01 00 00 00 10 62 6c ..............bl
> >>> 75 65 74 6f 6f 74 68 64 00 00 00 00 00 00 uetoothd......
> >>> * Unknown packet (code 14 len 30) 0.641592
> >>> 02 00 00 00 02 00 01 0e 00 01 00 00 00 10 62 74 ..............bt
> >>> 6d 6f 6e 00 00 00 00 00 00 00 00 00 00 00 mon...........
> >>> * Unknown packet (code 16 len 7) [hci0] 6.536771
> >>> 01 00 00 00 05 00 01 .......
> >>> = Open Index: 00:00:46:76:22:01 [hci0] 6.717019
> >>> = Index Info: 00:00:46:76:22:01 (MediaTek, Inc.) [hci0] 6.717030
> >>
> >> can you try with the latest BlueZ 5.49 or git version. Seems it actually stumbles over the extra packet here. Fun fact is that I can not get a backtrace to pin-point the issue in btmon and why it crashes.
> >>
> >
> > I had less experience updating user land BlueZ, but I can try it as possible and see whether Unknown packets still are present at newest version BlueZ. Hopefully I don't misunderstand your point here.
>
> please use the latest btmon and check if it can read your trace.
>

sure, I'll have a try with the latest btmon.

> >>>> HCI Event: Unknown (0xe4) plen 5 [hci0] 6.741093
> >>> 02 01 01 00 00 .....
> >>>> HCI Event: Unknown (0xe4) plen 5 [hci0] 6.742088
> >>> 02 01 01 00 00 .....
> >>>> HCI Event: Unknown (0xe4) plen 5 [hci0] 6.743102
> >>> 02 01 01 00 00 .....


[ ... ]

> >>>> HCI Event: Unknown (0xe4) plen 5 [hci0] 6.814708
> >>> 02 01 01 00 00 .....
> >>>> HCI Event: Unknown (0xe4) plen 5 [hci0] 6.815705
> >>> 02 01 01 00 00 .....
> >>>> HCI Event: Unknown (0xe4) plen 5 [hci0] 6.816378
> >>> 02 01 01 00 00 .....
> >>
> >> Why do I see only HCI events here? Is this event conveying any useful information. It is kinda complicated that this is 0xe4 event code which is actually reserved for future use by the Bluetooth SIG. Are there any accompanying HCI commands for this and they just not make it into btmon?
> >>
> >
> > I have made all vendor HCI commands go through BlueZ core in v2 patch.
> >
> > And for these HCI events, they are all corresponding to vendor ACL data, applied only to firmware setup packets, but they're not being sent via BlueZ core, so they are not being logged in btmon.
> >
> > As for its event, where heading 0xe4 refers to a vendor event and is used on notification of that either vendor ACL data or vendor HCI command have been done.
>
> I would prefer if everything goes via the Bluetooth core since then we have it all properly scheduled. Sending things down the ACL data path however if kinda funky. Does your hardware accept sending command both via ACL data and as HCI command? If so, then I would prefer sending them as HCI commands since the speed improvement you think you are getting is neglectable on Linux (I have been down that path). This seems to be a pure optimization when Windows is driving the device.
>

firmware people said the device can support firmware download as HCI commands. According to my test, this way indeed works so I will improve the part in the next version.


> And the vendor event 0xe4 is really only received during firmware download? It is not ever received during normal operation?
>

0xe4 is only received during chip initialization.

I also thought 0xe4 is a poor definition for vendor event and already have notified firmware people should pick 0xff as its vendor event id in the future.

but for now, unfortunately, 0xe4 cannot be changed on the device, the only way is to add a workaround in RX path as below to allow btmon can recognize these bad events properly.

int mtk_btuart_hci_frame(struct hci_dev *hdev, struct sk_buff *skb)
{
struct hci_event_hdr *hdr = (void *)skb->data;

/* Fix up the vendor event id with HCI_VENDOR_PKT instead of
* 0xe4 so that btmon can parse the kind of vendor event properly.
*/
if (hdr->evt == 0xe4)
hdr->evt = HCI_VENDOR_PKT;

/* Each HCI event would go through the core. */
return hci_recv_frame(hdev, skb);
}


> >
> >>
> >>
> >>> < HCI Command: Vendor (0x3f|0x006f) plen 5 [hci0] 6.816413
> >>> 01 07 01 00 04 .....
> >>>> HCI Event: Unknown (0xe4) plen 5 [hci0] 6.816536
> >>> 02 07 01 00 00 .....

[ ... ]

> >>> Encapsulated PDU
> >>> Erroneous Data Reporting
> >>> Non-flushable Packet Boundary Flag
> >>> Link Supervision Timeout Changed Event
> >>> Inquiry TX Power Level
> >>> Enhanced Power Control
> >>> Extended features
> >>> < HCI Command: Read Local Version Info.. (0x04|0x0001) plen 0 [hci0] 10.865987
> >>>> HCI Event: Vendor (0xff) plen 9 [hci0] 10.866259
> >>> 29 19 09 17 20 48 07 11 00 )... H…
> >>
> >> Is this meant to happen here?
> >>
> >
> > If event received is not expected as the specification defines, I think it's probably incorrect.
> >
> > But it requires more discussion with firmware people to make it clearer.
>
> Please check and let them decode what this event means.
>

it's just debugging purpose information listing built-time something
like that and will be removed in the firmware.

> >
> >>>> HCI Event: Command Complete (0x0e) plen 12 [hci0] 10.866372
> >>> Read Local Version Information (0x04|0x0001) ncmd 1
> >>> Status: Success (0x00)
> >>> HCI version: Bluetooth 4.2 (0x08) - Revision 4359 (0x1107)
> >>> LMP version: Bluetooth 4.2 (0x08) - Subversion 2329 (0x0919)
> >>> Manufacturer: MediaTek, Inc. (70)
> >>> < HCI Command: Read BD ADDR (0x04|0x0009) plen 0 [hci0] 10.866391
> >>>> HCI Event: Command Complete (0x0e) plen 10 [hci0] 10.866539

[ ... ]

> >>> LE Add Device To Resolving List (Octet 34 - Bit 3)
> >>> LE Remove Device From Resolving List (Octet 34 - Bit 4)
> >>> LE Clear Resolving List (Octet 34 - Bit 5)
> >>> LE Read Resolving List Size (Octet 34 - Bit 6)
> >>> LE Read Peer Resolvable Address (Octet 34 - Bit 7)
> >>> LE Read Local Resolvable Address (Octet 35 - Bit 0)
> >>> LE Set Address Resolution Enable (Octet 35 - Bit 1)
> >>> LE Set Resolvable Private Address Timeout (Octet 35 - Bit 2)
> >>> LE Read Maximum Data Length (Octet 35 - Bit 3)
> >>> Octet 35 - Bit 4
> >>> Octet 35 - Bit 5
> >>> Octet 35 - Bit 6
> >>> Octet 35 - Bit 7
> >>> Octet 36 - Bit 0
> >>
> >> So you support the PHY commands, but do not indicate support LE 2M or LE Coded? Also these are Bluetooth 5.0 commands.
> >>
> >
> > To be honest. When I ported the device into Bluez core, a unexpected event for LE read local feature would cause a fail at Bluez core, so I made a hack on Bluez core
> >
> > to allow that I can keeping bring up the device without be blocked by the issue most probably from firmware.
> >
> > Below code snippet is the only thing I added to avoid a fail at Bluez core to bring up the device.
> >
> > @@ -927,6 +927,8 @@ static void hci_cc_le_read_local_features(struct hci_dev *hdev,
> > return;
> >
> > memcpy(hdev->le_features, rp->features, 8);
> > + hdev->le_features[0] = 0;
> > + hdev->le_features[1] = 0;
> > }
>
> Send me the trace where you didn’t clear the feature bits and I check what is going on. I doubt that we have a bug, but maybe some of the commands are optional and we should add an appropriate check. Or you guys need to fix your firmware. A new btmon should decode all bits properly.
>

okay, I'll have a follow-up.

> Regards
>
> Marcel
>