Hci hardware error 0x21 when 2 bluetooth devices connected

Board: verdin-am62
OS: currently testing on 6.8 (unreleased) as I had to compile in some ftrace kernel configs, but issue is likely to be on 6.7
kernel: 6.1.8-6.8.0-devel+git.3122b7a08183

Currently can not provide steps to reproduce, but to give an overview,
Our docker container python application creates a BLE peripheral device, exposing 2 services with some characteristics.
When 1 central device connects, everything works as expected.
When 2nd central device connects, fairly soon we hit the

Bluetooth: hci0: hardware error 0x21

After which device may work for a while longer, or hci device may go down and become unrecoverable unless a reboot is performed.

It seems that this happens when our verdin hci device receives a bad data packet which triggers the hci hardware error event. What I was hoping to inquire is the meaning of “0x21”, I can’t seem to find what is this error associated with. Does anyone know by chance?

Thanks,
Stanislav

Hi, I’m the Toradex AI Assistant. I’m in early beta, and I would appreciate your feedback.
The Toradex Support team will follow up with you shortly!

Did you like my answer?

:+1: :-1:


Hello,

The HCI hardware error 0x21 you’re encountering on the Verdin AM62 with a Linux kernel version 6.1.8-6.8.0-devel+git.3122b7a08183 indicates a hardware-related issue specific to the Bluetooth controller. The error code “0x21” typically corresponds to a vendor-specific error, which means its interpretation can vary depending on the Bluetooth hardware and firmware used by the device. In general, HCI (Host Controller Interface) hardware errors are reported by the Bluetooth chip to the host (in your case, the Verdin AM62 module) when the chip encounters an unrecoverable error.

Given the scenario where the error occurs when a second Bluetooth central device connects, it suggests that the issue might be related to the handling of multiple connections or the data traffic generated by these connections. This could be due to a limitation or bug in the Bluetooth firmware, or possibly an issue with how the Bluetooth stack on your system is configured to handle multiple connections.

To troubleshoot this issue, consider the following steps:

  1. Firmware Update: Check if there is a firmware update available for the Bluetooth module on your Verdin AM62. An update might contain fixes for issues related to handling multiple connections.

  2. Kernel Logs: Examine the kernel logs (dmesg) for any additional messages that precede the hardware error. This might provide more context on what the system is doing when the error occurs.

  3. Bluetooth Stack Configuration: Review the configuration of the Bluetooth stack, particularly settings related to connection management and data throughput. Adjusting these settings might help in accommodating multiple connections more effectively.

  4. Test with Different Kernel Versions: Since you mentioned the issue is likely present on kernel version 6.7 and you’re currently testing on an unreleased 6.8 version, it might be beneficial to test with different kernel versions, if possible. A regression or change in the Bluetooth subsystem between versions could be a contributing factor.

  5. Isolate the Issue: Try to reproduce the issue outside of the Docker container environment, if feasible. This can help determine whether the issue is related to the containerized environment or the system as a whole.

  6. Bluetooth Debugging Tools: Utilize Bluetooth debugging tools and utilities to gather more information about the Bluetooth communication and errors. Tools like btmon can capture the HCI packets and might provide insights into what leads up to the error.

If the issue persists and you’re unable to find a resolution through these

Please, also check if these links can help you solve your problem:

Workspace - Settings | Toradex Developer Center.

Hello @stasgil,

I will try to reproduce the problem.
When there are further updates I will send them here.

Best Regards,
Bruno

Hello @stasgil,

Unfortunately I was not able to get a BLE setup to work in order to reproduce the issue.

Could you send more information about your setup?

Best Regards,
Bruno

Hi Bruno,
Many thanks for trying, frankly i did not expect it as i didn’t provide any good way to reproduce it, was just trying to find any information on the error code.
I apologise for the late response, things were busy, but I think I have found the root cause and it is not related to the verdin OS. I think the issue was that we were sending several chunks of data (all at max default MTU of 517 bytes) to the bluetoothd over dbus in a quick succession. This worked when a single central device was connected to our peripheral, however when second device connected and subscribed to the same characteristic, i believe it resulted in a race condition within the bluetooth stack / hw, which eventually crashed, likely at the moment when 1 of the central devices was trying to read the value attribute of the characteristic at the moment, when the data of this attribute was updated internally by the bluez stack. Making sure we don’t exceed the MTU size for any data we send seemed to have solved the issue.

Regards,
Stanislav

Hello @stasgil,

Thanks for sharing your workaround for this issue.

Best Regards,
Bruno