mynewt-mcumgr icon indicating copy to clipboard operation
mynewt-mcumgr copied to clipboard

Error: can't scan: Unknown HCI Command

Open paulgavrikov opened this issue 3 years ago • 6 comments

I am trying to follow the tutorial on mcuboot@Zephyr but can't establish a connection from mcuboot (fails at scanning for the slave). I am on Ubuntu 18.04 and tried with my internal radio and a nrf52 dongle with zepyhr usb-hci sample.

paul@ubuntu:~/go/bin$ hciconfig
hci1:	Type: Primary  Bus: USB
	BD Address: 00:00:00:00:00:00  ACL MTU: 27:7  SCO MTU: 0:0
	UP RUNNING 
	RX bytes:996 acl:0 sco:0 events:86 errors:0
	TX bytes:542 acl:0 sco:0 commands:86 errors:0

hci0:	Type: Primary  Bus: USB
	BD Address: 04:D3:B0:1D:72:29  ACL MTU: 8192:128  SCO MTU: 64:128
	UP RUNNING 
	RX bytes:8518 acl:0 sco:0 events:379 errors:0
	TX bytes:6979 acl:0 sco:0 commands:470 errors:0

paul@ubuntu:~/go/bin$ sudo ./mcumgr --conntype ble --connstring ctlr_name=hci0,peer_name='Zephyr' echo hello
Error: can't scan: Unknown HCI Command
paul@ubuntu:~/go/bin$ sudo ./mcumgr --conntype ble --connstring ctlr_name=hci1,peer_name='Zephyr' echo hello
Error: can't scan: Unknown HCI Command

paulgavrikov avatar Aug 31 '20 12:08 paulgavrikov

I have the same problem. I've tried using both a USB Bluetooth dongle as well as the built in bluetooth on my laptop.

There might be some more info in the following Noridc thread, but I'm not really sure how to make sense of it. https://devzone.nordicsemi.com/f/nordic-q-a/73310/incompatibility-between-mcumgr-cli-and-hci_usb-when-running-with-bt_ll_softdevice-enabled

MattCampbellST avatar Dec 25 '21 23:12 MattCampbellST

could you provide btmon trace ?

sjanc avatar Dec 27 '21 12:12 sjanc

Sure, here is the btmon trace. I ran this on my internal BT device (note: this is passed through VMware). I don't have the external dongle handy right now to run on that. Trace file is attached.

This is the command I ran:

mcampbell@ubuntu ~/g/bin [1]> hciconfig -a
hci0:	Type: Primary  Bus: USB
	BD Address: AC:74:B1:85:B6:EF  ACL MTU: 8192:128  SCO MTU: 64:128
	UP RUNNING 
	RX bytes:12810 acl:0 sco:0 events:585 errors:0
	TX bytes:9398 acl:0 sco:0 commands:715 errors:0
	Features: 0xff 0xff 0x8f 0xfe 0x83 0xe1 0x08 0x80
	Packet type: DM1 DM3 DM5 DH1 DH3 DH5 HV1 HV2 HV3 
	Link policy: RSWITCH HOLD SNIFF PARK 
	Link mode: SLAVE ACCEPT 
	Name: 'ubuntu'
	Class: 0x6c0000
	Service Classes: Rendering, Capturing, Audio, Telephony
	Device Class: Miscellaneous, 
	HCI Version: 2.1 (0x4)  Revision: 0x100
	LMP Version: 2.1 (0x4)  Subversion: 0x100
	Manufacturer: not assigned (6502)

mcampbell@ubuntu ~/g/bin> sudo ./mcumgr --conntype ble --connstring ctlr_name=hci0,peer_name='Zephyr' echo asdf
Error: can't scan: Unknown HCI Command
mcampbell@ubuntu ~/g/bin [1]> 

mcumgr.trace.zip

MattCampbellST avatar Dec 27 '21 13:12 MattCampbellST

This is BR/EDR only controller and hence it is not supporting LE HCI commands. You should use something that supports at least Bluetooth 4.0

sjanc avatar Dec 27 '21 15:12 sjanc

That makes sense, HCI0 is the virtual pass through device that VMware uses to share BT devices with the VM guest and must only support BT classic.

I have a USB BT dongle that I was trying to use that for sure does support BT 4.0, but that wasn't working either. I tried running btmon on that and to my surprise, even though I had set mcumgr to use hci1, all the btmon output was for hci0. After disabling the VMWare device, things worked as expected. Looks like this might be a different issue where mcumgr isn't fully honoring the ctrl_name option for ble.

mcampbell@ubuntu ~ [1]> hciconfig -a
hci1:	Type: Primary  Bus: USB
	BD Address: 5C:F3:70:8C:94:B0  ACL MTU: 1021:8  SCO MTU: 64:1
	UP RUNNING 
	RX bytes:1548 acl:0 sco:0 events:61 errors:0
	TX bytes:3208 acl:0 sco:0 commands:62 errors:0
	Features: 0xbf 0xfe 0xcf 0xfe 0xdb 0xff 0x7b 0x87
	Packet type: DM1 DM3 DM5 DH1 DH3 DH5 HV1 HV2 HV3 
	Link policy: RSWITCH SNIFF 
	Link mode: SLAVE ACCEPT 
	Name: 'ubuntu #2'
	Class: 0x6c0000
	Service Classes: Rendering, Capturing, Audio, Telephony
	Device Class: Miscellaneous, 
	HCI Version: 4.0 (0x6)  Revision: 0x1000
	LMP Version: 4.0 (0x6)  Subversion: 0x220e
	Manufacturer: Broadcom Corporation (15)

hci0:	Type: Primary  Bus: USB
	BD Address: AC:74:B1:85:B6:EF  ACL MTU: 8192:128  SCO MTU: 64:128
	UP RUNNING 
	RX bytes:2277 acl:0 sco:0 events:91 errors:0
	TX bytes:1961 acl:0 sco:0 commands:104 errors:0
	Features: 0xff 0xff 0x8f 0xfe 0x83 0xe1 0x08 0x80
	Packet type: DM1 DM3 DM5 DH1 DH3 DH5 HV1 HV2 HV3 
	Link policy: RSWITCH HOLD SNIFF PARK 
	Link mode: SLAVE ACCEPT 
	Name: 'ubuntu #1'
	Class: 0x6c0000
	Service Classes: Rendering, Capturing, Audio, Telephony
	Device Class: Miscellaneous, 
	HCI Version: 2.1 (0x4)  Revision: 0x100
	LMP Version: 2.1 (0x4)  Subversion: 0x100
	Manufacturer: not assigned (6502)

mcampbell@ubuntu ~/g/bin> sudo ./mcumgr --conntype ble --connstring ctlr_name=hci1,peer_name='Zephyr' echo asdf
Error: can't scan: Unknown HCI Command

mcumgr.trace.zip

To prove that the USB BT dongle does work, II removed the VMWare BT device leaving only the USB BT 4.0 device and things then worked. This sounds like a different problem than this issue is getting at. Let me know if I should open up a new ticket for this.

MattCampbellST avatar Dec 27 '21 17:12 MattCampbellST

After digging deeper I found the -i HCI index option which wasn't referenced in any of the examples. It's pretty confusing to me why I need to both specify the ctlr_name and the -i option. There might be some way to simplify this in the code, or maybe just a documentation update. If you have any thoughts on the ladder I'd be happy to open a PR if you have some good direction on that. Thanks for the help getting me running with this also!

MattCampbellST avatar Dec 31 '21 16:12 MattCampbellST