[Linux][Bluez][Bluetooth] Failed to re-connect after forgetting while using NoInputNoOutput with bluetooth agent - linux-kernel

System is running below:
Bluez_version: 5.65
Linux Kernel version: 5.15.77-3
In this case let's call the system that's having the issue is called DUT
Steps to reproduce(Scenario):
Set the bluetooth agent capability NoInputNoOutput for the
default-agent on the DUT using bluetoothctl
Take a phone turn on bluetooth and search for the DUT Now wait for the DUT to show up in the phone BT menu, click on the DUT so that pairing is initiated Now
the phone is connected to the DUT without issues and no passcode is displayed as NoInputNoOutput is selected on the DUT in step 1
Now forget the DUT from the phone Now turn of BT on the phone, turn it back on
Now wait for the DUT to show up in the phone BT menu Now try
to pair again
The connection fails --> Issue is observed
The hcidump when the connection fails is as below:
> ACL data: handle 11 flags 0x02 dlen 12
L2CAP(s): Disconn req: dcid 0x0040 scid 0x0408
< ACL data: handle 11 flags 0x00 dlen 12
L2CAP(s): Disconn rsp: dcid 0x0040 scid 0x0408
> HCI Event: Link Supervision Timeout Change (0x38) plen 4
handle 11 timeout 32000
> HCI Event: IO Capability Response (0x32) plen 9
bdaddr 14:F2:87:BA:90:94 capability 0x01 oob 0x00 auth 0x04
Capability: DisplayYesNo (OOB data not present)
Authentication: General Bonding (No MITM Protection)
> HCI Event: IO Capability Request (0x31) plen 6
bdaddr 14:F2:87:BA:90:94
< HCI Command: IO Capability Request Reply (0x01|0x002b) plen 9
bdaddr 14:F2:87:BA:90:94 capability 0x03 oob 0x00 auth 0x04
Capability: NoInputNoOutput (OOB data not present)
Authentication: General Bonding (No MITM Protection)
> HCI Event: Command Complete (0x0e) plen 10
IO Capability Request Reply (0x01|0x002b) ncmd 1
status 0x00 bdaddr 14:F2:87:BA:90:94
> HCI Event: Number of Completed Packets (0x13) plen 5
handle 11 packets 1
> HCI Event: User Confirmation Request (0x33) plen 10
bdaddr 14:F2:87:BA:90:94 passkey 713305
< HCI Command: User Confirmation Request Negative Reply (0x01|0x002d) plen 6
bdaddr 14:F2:87:BA:90:94
> HCI Event: Command Complete (0x0e) plen 10
User Confirmation Request Negative Reply (0x01|0x002d) ncmd 1
status 0x00 bdaddr 14:F2:87:BA:90:94
> HCI Event: Simple Pairing Complete (0x36) plen 7
status 0x05 bdaddr 14:F2:87:BA:90:94
Error: Authentication Failure
Note: I tried the above scenario both with an iphone and an android phone same issue is observed

The solution is to use JustWorksRepairing = always in the etc/bluetooth/main.conf, this looks like a regression in the latest kernel after 4.19 and we need the JustWorksRepairing to make this to work.
FYI, More discussion can be found here:
Related Patch discussions:
'[PATCH 0/1] Bluetooth: Fix Just-Works re-pairing' - MARC
'[PATCH 1/1] Bluetooth: Fix Just-Works re-pairing' - MARC

Related

PCIe aer/dpc interrupt issue

I tried on Latitude 3500 Ubuntu kernel 5.13.1. Its pci switch 1d:0.0 is rp supporting aer/dpc, and connected to Eth port at 1:0.0 that support aer.
With aer_inject I can run all examples, generate aer interrupt from Eth port. I modified dpc.c to enable rp dpc and monitored dpc irq/handler, no dpc irq can be raised. Then I added code on aer_inject to replace the irq_inject_interrupt() with dpc s/w trigger which works. My questions are:
1.Why there is no dpc_inject? any possibility to do a dpc_inject?
2.irq_inject_interrupt() works for aer because its status reg is r/w, not work for dpc because its status reg is RO?
3.Per spec certain aer errors shall raise dpc interrupt, it doesn't work. would the the reason be I used aer_inject no real h/w error happens?

How can I force a USB device driver to call a specific HCI controller driver?

I have looked into couple USB device driver code looks like they have to associates with PCI device(s) and when usb_submit_urb() is called in USB device driver, the urb structure has already been associated with specific HCI driver, then when usb_submit_urb() calls usb_hcd_submit_urb (), usb_hcd_submit_urb() will fetch hcd from the parameter urb then calls urb->enqueue() which maps to the specific HCI driver.
int usb_hcd_submit_urb (struct urb *urb, gfp_t mem_flags)
{
int status;
struct usb_hcd *hcd = bus_to_hcd(urb->dev->bus);
......
......
if (likely(status == 0)) {
status = hcd->driver->urb_enqueue(hcd, urb, mem_flags);
In my case I need to write a USB HCI driver that talks to a hardware which needs to be hidden from USB device driver, so I cannot change USB device driver to search for PCI ids for the hardware... In this case is there any way to force a specific device driver to associate with the USB HCI driver?
Update:
I have created two diagrams based on the discussion.
Diagram #1 shows the current USB model in kernel, I see from 'lspci' output that xHCI is the only host controller driver that is being used in my system.
Diagram #2 is a proposed design. While still allows NCM CDC device driver to work as a driver for current devices listed in its PCI tables, I would like to register my customized HCI with USB core for NCM CDC device driver. The customized HCI talks to customized hardware driver which hides the customized hardware info from user space (meaning there is no PCI probe).
My customized HCI needs to parse URB messages passed down from USB core and map them to corresponding APIs provided by customized hardware driver.
The problems I am having is that it looks like xHCI is by default used by all USB device drivers, I am not sure how can I tell USB core to use my customized HCI at all... even if I maybe able to hardcode USB core to force all traffics from NCM CDC USB device driver to customized HCI, because I won't be able to provide PCI productID/vendorID to NCM CDC device driver, how can I trigger NCM CDC device driver's probe() function to start at all?
Diagram #1 (Current kernel USB model):
----------------- ------------------ ------------------- -------------------
| NCM CDC | <----> | USB Core | <----> | xHCI | <----> | USB devices |
----------------- ------------------ ------------------- -------------------
Diagram #2 (proposed design):
----------------- ------------------ ----------------------------- -------------------------------- --------------------
| NCM CDC | <----> | USB Core | <-----> | Customized HCI | <----> | Customized Hardware driver | <----> | Customized HW |
----------------- ------------------ | ----------------------------- -------------------------------- --------------------
|
|
|
| ------------------- -------------------
|--->| xHCI | <----> | USB devices |
------------------- -------------------
If I understood properly your needs: you need to write a HCI driver which will be working outside of standard USB stack in Linux? So you don't want to register your HCI in Linux usb-core? If yes - just write HCI driver and don't register his API into usb-core. AFAIK which USB HCI driver (and HCI HW) is used only depends on the physical USB port you connected. So if you have system with more than one USB HCI then you can select HCI just by plugging USB device to given physical port. As I remember in USB 2.0 (ehci + companion controller) there was possibility to assign some USB port to either ehci or uhci/ohci (with some kind of mux) but now with xhci - I don't think it is possible. Mainly because xhci doesn't need any companion controller.

KITL connection issue: WIN EC7

I am using OpenBoard-AM335x from Phytec india and have installed WIN EC7.
My problem is, i can not create a KITL connection between platform builder and my device.
To create a KITL connection i have followed steps as below:
Device side setup:-
started device, opened EBOOT configuration at boot time
selected option '4' for Network settings in EBOOT main menu
set static-ip=192.168.0.182 subnet-mask=255.255.255.0 and router-ip=192.168.0.1(our router ip address, device is connected with LAN cable)
selected Boot from Internal EMAC from boot device menu
PC side setup:-
set ip of PC to 192.168.0.102, subnet-mask=255.255.255.0 and default gateway=192.168.0.1 (pc is connected with wi-fi router)
disabled firewall and anti-virus software
opened Target->Connectivity options in Visual studio 2008
Added device with target device name "AM335X" and Associated OS design with "Windows CE" in Add device menu
set Target device to "AM335X", Kernel Download to "Ethernet", Kernel Transport "Ethernet", Kernel Debugger to "KdStub" in Kernel Service Map menu
opened "settings" of Kernel Download
Now platform builder is waiting for active devices
Next, started device to boot with above described settings, the device starts to send messages "sent BOOTME to 255.255.255.255" to serial console. But, nothing detected by platform builder.
Device's serial log is as follows:
--------------------------------------------------------------------------------
Main Menu
--------------------------------------------------------------------------------
[1] Show Current Settings
[2] Select Boot Device
[3] Select KITL (Debug) Device
[4] Network Settings
[5] SDCard Settings
[6] Set Device ID
[7] Save Settings
[8] Flash Management
[9] Enable/Disable OAL Retail Messages
[a] Select Display Resolution
[b] Select OPP Mode
[0] Exit and Continue
Selection: 1
Main:
Boot device: Internal EMAC
Debug device: Internal EMAC
Retail Msgs: disabled
Device ID: 0
Display Res: 7in LCD_017 (800x480#60Hz)
Flashing NK.bin: disabled
OPP Mode: MPU[720Mhz # 1.26V]
SDCard:
Filename: "nk.bin"
Network:
KITL state: enabled
KITL type: active
KITL mode: interrupt
DHCP: disabled
IP address: 192.168.0.182
IP mask: 255.255.255.0
IP router: 192.168.0.1
Eth MAC Addr : 00:18:31:8d:c6:92 (Boot settings)
Eth MAC Addr 1: 00:18:31:8d:c6:93 (Boot settings)
VMINI: enabled
Note: USBFN RNDIS MAC Addr cannot be changed.
--------------------------------------------------------------------------------
Main Menu
--------------------------------------------------------------------------------
[1] Show Current Settings
[2] Select Boot Device
[3] Select KITL (Debug) Device
[4] Network Settings
[5] SDCard Settings
[6] Set Device ID
[7] Save Settings
[8] Flash Management
[9] Enable/Disable OAL Retail Messages
[a] Select Display Resolution
[b] Select OPP Mode
[0] Exit and Continue
Selection: 0
ShowSDLogo
Init HW: controller RST
SDCARD: requested speed 1000000, actual speed 1000000
SDCARD: requested speed 25000000, actual speed 19200000
BLSDCardReadLogo: cannot open Logo.bmp
+Cpsw3gInit(0x4a100000, 0x00000001, 0x8fefff6c) v0.3
Auto negotitation failed
Phy_init: Auto negotitation completed
Cpsw3gInit, wait link up on mac port:1.
Cpsw3gInit, LINK down on port:1.
INFO: Boot device uses MAC 00:18:31:8d:c6:92
INFO: *** Device Name AM335X-50834 ***
+EbootSendBootmeAndWaitForTftp
Sent BOOTME to 255.255.255.255
Sent BOOTME to 255.255.255.255
Sent BOOTME to 255.255.255.255
Sent BOOTME to 255.255.255.255
Sent BOOTME to 255.255.255.255
Sent BOOTME to 255.255.255.255
Sent BOOTME to 255.255.255.255
Sent BOOTME to 255.255.255.255
Sent BOOTME to 255.255.255.255
Any suggestions/comments ?
Thanks in advance.
Check that you don't have any firewall installed on your machine preventing platform builder from receiving packets from your device. If both machines are on the same IP subnet you should be able to receive broadcast packets. Usually if you have the Windows firewall enabled you will get a message reporting that platform builder is opening a port on your PC and if you don't allow the operation it will not be able to connect.

pn532 card emulation mode and pn532 virtual card mode

pn532 card emulation mode
I want to konw pn532 card emultion . I success running "iso 14443-4A emulation mode" but it have not block data like mifare card . How can i make block data ? what frame is run "mifare classic card mode" . And in virtual card mode in samconfiguration , how can i get sam ( secure access module)?.
I have arduino mega adk , and nfc shield v1.0 ( pn532) . In this situation , how can i connect "sam" to nfc shield (pn532 )? . please help me .
I believe that if configured properly the PN532 can perform card emulation with a smart card that is compatible with SWP/HCI protocol (single wire connection, ETSI TS 102 603, 102 622).
If you can get a sample test card that supports this protocol, and for which you know the keys, then you could do APDU (ISO 14443-4) card emulation.
You can use PN532 as a NFC tag 4 card which can contain a NDEF message (block data?). If you use Arduino, https://github.com/Seeed-Studio/PN532 is for you.

Creating a serial PPP connection between a Windows CE 6 device and Windows 7

I need to create a PPP connection over a serial port between an embedded device running Windows CE 6 and a PC running Windows 7.
I've configured a dial-up modem on Windows 7 according to this: https://stackoverflow.com/a/7085259/512910
I used a terminal app on the CE device to confirm that attempting a connection sends the string "CLIENT".
I've also created a direct connection interface on the CE device, and used a terminal app to confirm that attempting a connection also sends the string "CLIENT" to the Windows 7 machine.
Unfortunately, neither side actually responds, and I'm not sure what the problem is.
What am I missing here? Is there a way to make either side listen for an incoming connection?
-------------------------------- Edit 1/12/12 ----------------------------------
I needed to add an incoming connection on the Windows 7 side. However, the connection doesn't appear to work, and times out after 90 seconds.
Here is my modem log.
01-09-2012 19:06:29.542 - Recv: CLIENT
01-09-2012 19:06:29.542 - Interpreted response: Ring
01-09-2012 19:06:29.542 - TSP Completing Async Operation(0x00010227) Status 0x00000000
01-09-2012 19:06:29.542 - TSP(0000): LINEEVENT: LINEDEVSTATE_RINGING(0x1)
01-09-2012 19:06:29.542 - TSP(0000): Answering Call
01-09-2012 19:06:29.542 - Answering the call.
01-09-2012 19:06:29.557 - Send: CLIENTSERVER
01-09-2012 19:06:29.557 - Connection established at 115200bps.
01-09-2012 19:06:29.557 - Error-control off or unknown.
01-09-2012 19:06:29.557 - Data compression off or unknown.
01-09-2012 19:06:29.557 - TSP Completing Async Operation(0x0001029e) Status 0x00000000
01-09-2012 19:06:29.557 - TSP(0000): LINEEVENT: LINECALLSTATE_CONNECTED
01-09-2012 19:06:59.572 - Read: Total: 388, Per/Sec: 12, Written: Total: 12, Per/Sec: 0
01-09-2012 19:08:30.208 - TSP(0000): Dropping Call
01-09-2012 19:08:30.208 - Hanging up the modem.
01-09-2012 19:08:30.208 - Hardware hangup by lowering DTR.
01-09-2012 19:08:30.208 - 115200,8,N,1, ctsfl=1, rtsctl=2
01-09-2012 19:08:30.208 - Initializing modem.
01-09-2012 19:08:30.208 - Waiting for a call.
01-09-2012 19:08:30.208 - TSP(0000): LINEEVENT: LINECALLSTATE_DISCONNECTED(0x1)
01-09-2012 19:08:30.208 - TSP(0000): LINEEVENT: LINECALLSTATE_IDLE
01-09-2012 19:08:30.208 - TSP Completing Async Operation(0x0001027c) Status 0x00000000
01-09-2012 19:08:30.208 - TSP(0000): Dropping Call
01-09-2012 19:08:30.208 - TSP Completing Async Operation(0x000101e3) Status 0x00000000
01-09-2012 19:08:30.208 - TSP(0000): Closing Call
Here's a troubleshooting list I created back in 2002, but it should still be valid (#8 is likely not applicable, and some menus may have changed):
Make sure your cable is truly null modem. Your null modem cable must also be fully connected (CTS, RTS, DTR, DSR).
Click the ActiveSync icon on your PC and select Get Connected from the File menu. It should be actively scanning for your device when you run REPLLOG (the timing of getting both systems searching for each other is sometimes important).
Reset the CE device and follow the instructions from the beginning.
If REPLLOG doesn't connect within a few seconds of being run, tap the CANCEL button and retry.
If you get the "Verify COM Port Availability" dialog shortly after telling ActiveSync to Get Connected, you may not be connected to the right port of the CE device, or your cable may have a problem.
You can test the serial connection to your desktop PC by shutting down ActiveSync and running Hyperterminal at 19200,8N1. When you run REPLLOG, you should see "CLIENT" appear in the Hypterterminal window each of the four times the CE device tries to connect.
Verify that your device supports DTR or you have it shunted in the cable. PC ActiveSync application looks at DTR to determine if a device is connected.
A bug in some releases of CE reduce the number of chances you have to get connected. Consider loading a build created in June 2001 or later that adds DataSync components from Microsoft.
Make sure that ActiveSync has the communication protocol you are trying enabled. For example, if you are connecting with a null modem serail cable, make sure that ActiveSync has serial communications enabled. These settings are available through the ActiveSync interface under File | Connection Settings...

Resources