Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bluetooth: HCI cmd response timeout #34659

Closed
caco3 opened this issue Apr 28, 2021 · 44 comments
Closed

Bluetooth: HCI cmd response timeout #34659

caco3 opened this issue Apr 28, 2021 · 44 comments
Assignees
Labels
area: Bluetooth Host area: Bluetooth area: USB Universal Serial Bus bug The issue is a bug, or the PR is fixing a bug priority: low Low impact/importance bug

Comments

@caco3
Copy link
Contributor

caco3 commented Apr 28, 2021

Describe the bug
We have an application based on a nrf52840. We see k_sem_take failed with err -11 assertion when we stress the device with a lot of notifications and read requests at the same time.

The system is used for a measurement device. We run an external ADC at 10 kSamples/s and read its data through SPI DMA transfers. After 30 samples (=> 333 Hz) we trigger an Interrupt Handler which copies the data into another buffer.
Then we we release a semaphore. A Kernel Thread is waiting for this semaphore so it can grab the data from the buffer and call bt_gatt_notify() with it. DLE is enabled and the data length set to 251.

Code snippets:

K_SEM_DEFINE(dataReadyToBeSend, 0, 1);
K_THREAD_DEFINE(DataStreaming, 10240, Thread_DataStreaming, NULL, NULL, NULL, 0, 0, 0);

#define TIMER_IRQ_PRIORITY  0

void init() {
    IRQ_DIRECT_CONNECT(TIMER2_IRQn, TIMER_IRQ_PRIORITY, TIMER2_IRQHandler, 0);
}

void TIMER2_IRQHandler(nrf_timer_event_t event_type, void *p_context) {
    [Copy data from DMA buffer to buffer...]
    k_sem_give(&dataReadyToBeSend);
}

static void Thread_DataStreaming(void) {
    [..]
    while (1) {
        semRet = k_sem_take(&dataReadyToBeSend, K_MSEC(1000));
        err = bt_gatt_notify(NULL, &myAttr, data, len);
    }
}

Log:

[..]
[00:00:04.257,873] <dbg> bt.connected: Update 2MBit PHY
[00:00:04.257,934] <inf> bt: Setting the Connection Parameters: Interval min: 7ms, Interval max: 4000ms, Latency: 0, timout: 5000ms...
[..]
[00:00:04.906,433] <dbg> bt.le_phy_updated: PHY updated!
[00:00:04.906,463] <dbg> bt.showConnectionInfo: Connection Information:
[00:00:04.906,463] <dbg> bt.showConnectionInfo:  - Role: Slave
[00:00:04.906,463] <dbg> bt.showConnectionInfo:  - Connection Type: LE
[00:00:04.906,494] <dbg> bt.showConnectionInfo:    PHY: TX: LE_PHY_2M, RX: LE_PHY_2M
[00:00:04.906,524] <dbg> bt.showDataLengthInfo:    Data Length: TX Max length: 251, TX Max time: 1064us, RX Max length: 251, RX Max time: 1064us
[..]
[00:00:56.955,780] <inf> bt_service:  13212 data notif. sent ( 627 kbit/s), Meas Data Buffer Level:  0.0% (   0 samples in buffer), TX RSSI: -56 dBm
[00:00:57.172,241] <inf> bt_service:  13284 data notif. sent ( 622 kbit/s), Meas Data Buffer Level:  0.0% (   0 samples in buffer), TX RSSI: -52 dBm
[00:00:57.389,099] <inf> bt_service:  13356 data notif. sent ( 625 kbit/s), Meas Data Buffer Level:  0.0% (   0 samples in buffer), TX RSSI: -59 dBm
[00:00:57.605,255] <inf> bt_service:  13428 data notif. sent ( 622 kbit/s), Meas Data Buffer Level:  0.0% (   0 samples in buffer), TX RSSI: -53 dBm
[00:00:57.821,899] <inf> bt_service:  13500 data notif. sent ( 625 kbit/s), Meas Data Buffer Level:  0.0% (   0 samples in buffer), TX RSSI: -54 dBm
[00:00:58.039,550] <inf> bt_service:  13573 data notif. sent ( 627 kbit/s), Meas Data Buffer Level:  0.0% (   0 samples in buffer), TX RSSI: -53 dBm
[00:00:58.255,859] <inf> bt_service:  13645 data notif. sent ( 625 kbit/s), Meas Data Buffer Level:  0.0% (   0 samples in buffer), TX RSSI: -57 dBm
[00:00:58.473,419] <inf> bt_service:  13718 data notif. sent ( 622 kbit/s), Meas Data Buffer Level:  0.0% (   0 samples in buffer), TX RSSI: -69 dBm
[00:00:58.690,795] <inf> bt_service:  13790 data notif. sent ( 627 kbit/s), Meas Data Buffer Level:  0.0% (   0 samples in buffer), TX RSSI: -53 dBm
[00:00:58.907,226] <inf> bt_service:  13862 data notif. sent ( 622 kbit/s), Meas Data Buffer Level:  0.0% (   0 samples in buffer), TX RSSI: -58 dBm
[00:00:59.124,572] <inf> bt_service:  13935 data notif. sent ( 630 kbit/s), Meas Data Buffer Level:  0.0% (   0 samples in buffer), TX RSSI: -63 dBm
[00:01:00.192,047] <wrn> ringbuffer: Buffer full, overwriting oldest sample! (w: 1441, r: 1470, in: 433440, out: 424470)
[00:01:00.192,047] <wrn> ringbuffer: Buffer full, overwriting oldest sample! (w: 1442, r: 1471, in: 433441, out: 424470)

ASSERTION FAIL [err == 0] @ WEST_TOPDIR/zephyr/subsys/bluetooth/host/hci_core.c:311
        k_sem_take failed with err -11
[00:01:09.351,501] <err> os: r0/a1:  0x00000003  r1/a2:  0x00000001  r2/a3:  0x40002000

*** Booting Zephyr OS build zephyr-v2.5.0-2746-g1cc73074d054  ***      // <= WATCHDOG RESET

What is the best way to trace this further down?

prj.conf (sanitized):

### General Kernel Configuration
CONFIG_LOG=y
CONFIG_UART_CONSOLE=y
CONFIG_ASSERT=y

## Logging (used in the defines)
CONFIG_LOG_STRDUP_BUF_COUNT=50
CONFIG_LOG_BUFFER_SIZE=65536
CONFIG_LOG_STRDUP_MAX_STRING=100

CONFIG_NEWLIB_LIBC=y              # Needed for logging only
CONFIG_NEWLIB_LIBC_FLOAT_PRINTF=y # Needed for logging only

## Optimization
CONFIG_SPEED_OPTIMIZATIONS=y
CONFIG_BT_CTLR_OPTIMIZE_FOR_SPEED=y

## Bluetooth Low Energy
# Increased stack due to settings API usage
CONFIG_SYSTEM_WORKQUEUE_STACK_SIZE=2048


# Bluetooth
CONFIG_BT=y
CONFIG_BT_DEBUG_LOG=y
CONFIG_BT_SMP=y
CONFIG_BT_SIGNING=y
CONFIG_BT_PERIPHERAL=y
CONFIG_BT_DIS=y
CONFIG_BT_ATT_PREPARE_COUNT=5
CONFIG_BT_BAS=y
CONFIG_BT_PRIVACY=y
CONFIG_BT_DEVICE_APPEARANCE=833
CONFIG_BT_DEVICE_NAME_DYNAMIC=y
CONFIG_BT_DEVICE_NAME_MAX=65

CONFIG_BT_KEYS_OVERWRITE_OLDEST=y # Overwrite oldest keys with new ones if key storage is full


# Below is setup to be able to update DIS at runtime
# There is still a warning "bt_hci_core: Unable to store name" of which I could not get rid off.
# See also https://github.com/zephyrproject-rtos/zephyr/issues/22478
CONFIG_BT_SETTINGS=y # Needed for settings_runtime_set()
CONFIG_SETTINGS=y # Needed for settings_runtime_set()
CONFIG_SETTINGS_RUNTIME=y # Needed for settings_runtime_set()
CONFIG_SETTINGS_NONE=y

CONFIG_BT_GATT_CACHING=n # To avoid error "bt_gatt: Failed to save Database Hash"

# BLE Throughput Maximization
# Adapted from https://github.com/nrfconnect/sdk-nrf/blob/master/samples/bluetooth/throughput/prj.conf
# Not all parameters might be needed/usefull!
CONFIG_HEAP_MEM_POOL_SIZE=2048
CONFIG_BT_RX_BUF_LEN=258
CONFIG_BT_GATT_CLIENT=y
CONFIG_BT_ATT_PREPARE_COUNT=2
CONFIG_BT_CONN_TX_MAX=255

CONFIG_BT_L2CAP_TX_BUF_COUNT=10
CONFIG_BT_L2CAP_TX_MTU=247
CONFIG_BT_L2CAP_RX_MTU=247
CONFIG_BT_L2CAP_DYNAMIC_CHANNEL=y

CONFIG_BT_CTLR_PHY_2M=y
CONFIG_BT_CTLR_TX_BUFFERS=10
CONFIG_BT_CTLR_TX_BUFFER_SIZE=251
CONFIG_BT_USER_PHY_UPDATE=y
CONFIG_BT_USER_DATA_LEN_UPDATE=y

CONFIG_BT_CTLR_DATA_LENGTH_MAX=251
CONFIG_BT_CTLR_ADVANCED_FEATURES=y
CONFIG_BT_CTLR_XTAL_THRESHOLD=500000

CONFIG_BT_PHY_UPDATE=y
CONFIG_BT_DATA_LEN_UPDATE=y

CONFIG_BT_CTLR_CONN_RSSI=y
CONFIG_BT_CTLR_TX_PWR_DYNAMIC_CONTROL=y

# This seems to fix the following assertion:
#     ASSERTION FAIL [!radio_is_ready()] @ WEST_TOPDIR/zephyr/subsys/bluetooth/controller/ll_sw/nordic/lll/lll_conn.c:317
# See https://github.com/zephyrproject-rtos/zephyr/issues/29994#issuecomment-739623736
CONFIG_ZERO_LATENCY_IRQS=y
CONFIG_BT_CTLR_ZLI=y

We also played with the following parameters but did not see an improvement:

CONFIG_BT_LLL_VENDOR_NORDIC=y
CONFIG_BT_CTLR_LLL_PRIO=0
CONFIG_BT_CTLR_ULL_HIGH_PRIO=0
CONFIG_BT_CTLR_ULL_LOW_PRIO=0

and changed TIMER_IRQ_PRIORITY to 3

Environment :

  • OS: Ubuntu 20.04,
  • Toolchain: zephyr-sdk-0.12.2
  • Zephyr Project (Tag 2.5.0) but also tested with 1cc7307

Reference to code:

BT_ASSERT_MSG(err == 0, "k_sem_take failed with err %d", err);

@caco3 caco3 changed the title ASSERTION FAIL [err == 0] @ WEST_TOPDIR/zephyr/subsys/bluetooth/host/hci_core.c:333, k_sem_take failed with err -11 ASSERTION FAIL [err == 0] @ [..]/hci_core.c:333, k_sem_take failed with err -11 Apr 28, 2021
@carlescufi carlescufi added area: Bluetooth area: Bluetooth Controller bug The issue is a bug, or the PR is fixing a bug labels Apr 28, 2021
@cvinayak
Copy link
Contributor

@caco3 Relates to #25917

@joerchan can #26057 be used as a fix/workaround for the deadlock?

@caco3
Copy link
Contributor Author

caco3 commented Apr 28, 2021

Thanks for the reference to this open patch. I ported it to 2.5.0 and gave it a try.
Patch is here, I just did it quickly but it compiled and BLE communication worked.

Sadly, I still experience the crashes, but it looks a bit different now:

[00:03:31.587,738] <inf> bt_service_helper:  63270 data notif. sent (   0 kbit/s), Meas Data Buffer Level: 99.7% (8970 samples in buffer), TX RSSI: -54 dBm
[00:03:31.804,016] <inf> bt_service_helper:  63270 data notif. sent (   0 kbit/s), Meas Data Buffer Level: 99.7% (8970 samples in buffer), TX RSSI: -51 dBm
[00:03:32.020,172] <inf> bt_service_helper:  63270 data notif. sent (   0 kbit/s), Meas Data Buffer Level: 99.7% (8970 samples in buffer), TX RSSI: -53 dBm
[00:03:32.236,389] <inf> bt_service_helper:  63270 data notif. sent (   0 kbit/s), Meas Data Buffer Level: 99.7% (8970 samples in buffer), TX RSSI: -53 dBm
[00:03:32.452,575] <inf> bt_service_helper:  63270 data notif. sent (   0 kbit/s), Meas Data Buffer Level: 99.7% (8970 samples in buffer), TX RSSI: -76 dBm
[00:03:32.668,701] <inf> bt_service_helper:  63270 data notif. sent (   0 kbit/s), Meas Data Buffer Level: 99.7% (8970 samples in buffer), TX RSSI: -65 dBm
[00:03:32.884,887] <inf> bt_service_helper:  63270 data notif. sent (   0 kbit/s), Meas Data Buffer Level: 99.7% (8970 samples in buffer), TX RSSI: -51 dBm
[00:03:33.112,030] <inf> bt_service_helper:  63270 data notif. sent (   0 kbit/s), Meas Data Buffer Level: 99.7% (8970 samples in buffer), TX RSSI: -55 dBm
[00:03:33.153,564] <err> os: ***** USAGE FAULT *****
ASSERTION FAIL [out_ctx->contro*** Booting Zephyr OS build zephyr-v2.5.0  ***
=> Watchdog reset

Another time it looked as following:

[00:01:48.125,000] <inf> bt_service_helper:  27321 data notif. sent (   0 kbit/s), Meas Data Buffer Level: 99.7% (8970 samples in buffer), TX RSSI: -52 dBm
[00:01:48.341,217] <inf> bt_service_helper:  27321 data notif. sent (   0 kbit/s), Meas Data Buffer Level: 99.7% (8970 samples in buffer), TX RSSI: -51 dBm
[00:01:48.557,525] <inf> bt_service_helper:  27321 data notif. sent (   0 kbit/s), Meas Data Buffer Level: 99.7% (8970 samples in buffer), TX RSSI: -51 dBm
[00:01:48.773,773] <inf> bt_service_helper:  27321 data notif. sent (   0 kbit/s), Meas Data Buffer Level: 99.7% (8970 samples in buffer), TX RSSI: -51 dBm
[00:01:48.989,929] <inf> bt_service_helper:  27321 data notif. sent (   0 kbit/s), Meas Data Buffer Level: 99.7% (8970 samples in buffer), TX RSSI: -72 dBm
[00:01:49.206,237] <inf> bt_service_helper:  27321 data notif. sent (   0 kbit/s), Meas Data Buffer Level: 99.7% (8970 samples in buffer), TX RSSI: -50 dBm
[00:01:49.422,393] <inf> bt_service_helper:  27321 data notif. sent (   0 kbit/s), Meas Data Buffer Level: 99.7% (8970 samples in buffer), TX RSSI: -53 dBm
[00:01:49.638,519] <inf> bt_service_helper:  27321 data notif. sent (   0 kbit/s), Meas Data Buffer Level: 99.7% (8970 samples in buffer), TX RSSI: -65 dBm
[00:01:49.795,806] <err> os: ***** USAGE FAULT *****
[00:01:49.795,837] <err> os:   Illegal use o*** Booting Zephyr OS build zephyr-v2.5.0  ***
=> CPU-Lockup Reset

@joerchan
Copy link
Contributor

joerchan can 26057 be used as a fix/workaround for the deadlock?

I think if this is the fix needed the symptom should be possible to see in a sniffer log, it should be locked with NACKS at the LL.

The USAGE fault could mean a stack overflow, or calling of an invalid function pointer.

@caco3
Copy link
Contributor Author

caco3 commented May 2, 2021

Thanks for the tip. I did a trace using an nRF52840-DK and Wireshark.
The trace is attached: Wireshark.pcapng.gz
How ever I do not see any error in it.
Below some screenshots for further explaining the happening.

The tests where performed with an unpatched zephyr 2.5.0 on the device as well as on the receiver (USB HCI Example).

Measure Mode: Data notifications (handle 0x28, 241 bytes of payload) at high rate

notification
This works reliable for hours!

Read other Characteristic (Handle 0x39) while in Measure Mode

The first and the 3th black lines are the read request, the 2nd black and the blue lines are the responses.
(For testing purpose we added a log back-end which we can poll entry by entry through this characteristic).
read characteristic while measure

Watchdog Reset after some minutes

Reading the log Characteristic (Handle 0x39) while in Measure Mode works for some minutes but the crashes with a Watchdog Reset (marked back, 60 seconds window):
WDR

Device Log

[00:02:19.312,286] <inf> bt_service_helper:  38521 data notif. sent ( 625 kbit/s), Meas Data Buffer Level:  0.0% (   0 samples in buffer), TX RSSI: -49 dBm
[00:02:19.528,533] <inf> bt_service_helper:  38593 data notif. sent ( 625 kbit/s), Meas Data Buffer Level:  0.0% (   0 samples in buffer), TX RSSI: -65 dBm
[00:02:19.745,971] <inf> bt_service_helper:  38666 data notif. sent ( 630 kbit/s), Meas Data Buffer Level:  0.0% (   0 samples in buffer), TX RSSI: -47 dBm
[00:02:19.964,141] <inf> bt_service_helper:  38739 data notif. sent ( 627 kbit/s), Meas Data Buffer Level:  0.0% (   0 samples in buffer), TX RSSI: -52 dBm
[00:02:20.194,580] <inf> bt_service_helper:  38815 data notif. sent ( 622 kbit/s), Meas Data Buffer Level:  0.0% (   0 samples in buffer), TX RSSI: -49 dBm
[00:02:20.411,682] <inf> bt_service_helper:  38888 data notif. sent ( 625 kbit/s), Meas Data Buffer Level:  0.0% (   0 samples in buffer), TX RSSI: -48 dBm
[00:02:20.627,929] <inf> bt_service_helper:  38960 data notif. sent ( 625 kbit/s), Meas Data Buffer Level:  0.0% (   0 samples in buffer), TX RSSI: -47 dBm
[00:02:20.846,069] <inf> bt_service_helper:  39033 data notif. sent ( 622 kbit/s), Meas Data Buffer Level:  0.0% (   0 samples in buffer), TX RSSI: -51 dBm
[00:02:21.063,720] <inf> bt_service_helper:  39105 data notif. sent ( 625 kbit/s), Meas Data Buffer Level:  0.0% (   0 samples in buffer), TX RSSI: -47 dBm
[00:02:21.279,815] <inf> bt_service_helper:  39177 data notif. sent ( 625 kbit/s), Meas Data Buffer Level:  0.0% (   0 samples in buffer), TX RSSI: -47 dBm
[00:02:21.497,283] <inf> bt_service_helper:  39250 data notif. sent ( 622 kbit/s), Meas Data Buffer Level:  0.0% (   0 samples in buffer), TX RSSI: -61 dBm
[00:02:21.714,752] <inf> bt_service_helper:  39322 data notif. sent ( 627 kbit/s), Meas Data Buffer Level:  0.0% (   0 samples in buffer), TX RSSI: -50 dBm
[00:02:21.933,135] <inf> bt_service_helper:  39395 data notif. sent ( 625 kbit/s), Meas Data Buffer Level:  0.0% (   0 samples in buffer), TX RSSI: -49 dBm
[00:02:22.151,397] <inf> bt_service_helper:  39468 data notif. sent ( 622 kbit/s), Meas Data Buffer Level:  0.0% (   0 samples in buffer), TX RSSI: -58 dBm
[00:02:22.369,323] <inf> bt_service_helper:  39540 data notif. sent ( 625 kbit/s), Meas Data Buffer Level:  0.0% (   0 samples in buffer), TX RSSI: -49 dBm
[00:02:22.431,549] <dbg> peripherals.peripherals_getBatteryPercentage: Battery Voltage: 4018 mV => 100%
[00:02:22.585,083] <inf> bt_service_helper:  39612 data notif. sent ( 627 kbit/s), Meas Data Buffer Level:  0.0% (   0 samples in buffer), TX RSSI: -47 dBm
[00:02:22.812,744] <inf> bt_service_helper:  39688 data notif. sent ( 625 kbit/s), Meas Data Buffer Level:  0.0% (   0 samples in buffer), TX RSSI: -48 dBm
[00:02:23.029,174] <inf> bt_service_helper:  39760 data notif. sent ( 622 kbit/s), Meas Data Buffer Level:  0.0% (   0 samples in buffer), TX RSSI: -48 dBm
[00:02:23.246,063] <inf> bt_service_helper:  39833 data notif. sent ( 625 kbit/s), Meas Data Buffer Level:  0.0% (   0 samples in buffer), TX RSSI: -50 dBm
[00:02:23.463,378] <inf> bt_service_helper:  39905 data notif. sent ( 627 kbit/s), Meas Data Buffer Level:  0.0% (   0 samples in buffer), TX RSSI: -49 dBm
[00:02:23.678,894] <inf> bt_service_helper:  39977 data notif. sent ( 627 kbit/s), Meas Data Buffer Level:  0.0% (   0 samples in buffer), TX RSSI: -57 dBm
[00:02:23.895,965] <inf> bt_service_helper:  40049 data notif. sent ( 622 kbit/s), Meas Data Buffer Level:  0.0% (   0 samples in buffer), TX RSSI: -62 dBm
[00:02:24.112,579] <inf> bt_service_helper:  40121 data notif. sent ( 622 kbit/s), Meas Data Buffer Level:  0.0% (   0 samples in buffer), TX RSSI: -47 dBm
[00:02:24.328,491] <inf> bt_service_helper:  40193 data notif. sent ( 625 kbit/s), Meas Data Buffer Level:  0.0% (   0 samples in buffer), TX RSSI: -48 dBm
[00:02:24.545,440] <inf> bt_service_helper:  40266 data notif. sent ( 630 kbit/s), Meas Data Buffer Level:  0.0% (   0 samples in buffer), TX RSSI: -50 dBm
[00:02:24.762,939] <inf> bt_service_helper:  40338 data notif. sent ( 622 kbit/s), Meas Data Buffer Level:  0.0% (   0 samples in buffer), TX RSSI: -49 dBm
[00:02:24.978,851] <inf> bt_service_helper:  40410 data notif. sent ( 625 kbit/s), Meas Data Buffer Level:  0.0% (   0 samples in buffer), TX RSSI: -61 dBm
[00:02:25.195,953] <inf> bt_service_helper:  40483 data notif. sent ( 622 kbit/s), Meas Data Buffer Level:  0.0% (   0 samples in buffer), TX RSSI: -49 dBm
[00:02:25.413,421] <inf> bt_service_helper:  40555 data notif. sent ( 627 kbit/s), Meas Data Buffer Level:  0.0% (   0 samples in buffer), TX RSSI: -53 dBm
[00:02:25.630,523] <inf> bt_service_helper:  40627 data notif. sent ( 622 kbit/s), Meas Data Buffer Level:  0.0% (   0 samples in buffer), TX RSSI: -48 dBm
[00:02:25.847,381] <inf> bt_service_helper:  40700 data notif. sent ( 630 kbit/s), Meas Data Buffer Level:  0.0% (   0 samples in buffer), TX RSSI: -49 dBm
[00:02:26.064,575] <inf> bt_service_helper:  40772 data notif. sent ( 622 kbit/s), Meas Data Buffer Level:  0.0% (   0 samples in buffer), TX RSSI: -49 dBm
[00:02:26.281,036] <inf> bt_service_helper:  40844 data notif. sent ( 625 kbit/s), Meas Data Buffer Level:  0.0% (   0 samples in buffer), TX RSSI: -49 dBm
[00:02:26.544,464] <inf> bt_service_helper:  40927 data notif. sent ( 630 kbit/s), Meas Data Buffer Level:  0.0% ( 120 samples in buffer), TX RSSI: -46 dBm
[00:02:26.763,122] <inf> bt_service_helper:  41005 data notif. sent ( 622 kbit/s), Meas Data Buffer Level:  0.0% (   0 samples in buffer), TX RSSI: -47 dBm
[00:02:26.980,285] <inf> bt_service_helper:  41077 data notif. sent ( 619 kbit/s), Meas Data Buffer Level:  0.0% (   0 samples in buffer), TX RSSI: -48 dBm
[00:02:27.198,486] <inf> bt_service_helper:  41150 data notif. sent ( 630 kbit/s), Meas Data Buffer Level:  0.0% (   0 samples in buffer), TX RSSI: -48 dBm
[00:02:27.416,442] <inf> bt_service_helper:  41223 data notif. sent ( 625 kbit/s), Meas Data Buffer Level:  0.0% (   0 samples in buffer), TX RSSI: -62 dBm
[00:02:27.633,178] <inf> bt_service_helper:  41295 data notif. sent ( 622 kbit/s), Meas Data Buffer Level:  0.0% (   0 samples in buffer), TX RSSI: -47 dBm
[00:02:27.850,280] <inf> bt_service_helper:  41367 data notif. sent ( 622 kbit/s), Meas Data Buffer Level:  0.0% (   0 samples in buffer), TX RSSI: -54 dBm
[00:02:28.067,749] <inf> bt_service_helper:  41440 data notif. sent ( 630 kbit/s), Meas Data Buffer Level:  0.0% (   0 samples in buffer), TX RSSI: -48 dBm
[00:02:28.284,088] <inf> bt_service_helper:  41512 data notif. sent ( 625 kbit/s), Meas Data Buffer Level:  0.0% (   0 samples in buffer), TX RSSI: -48 dBm
[00:02:28.500,885] <inf> bt_service_helper:  41584 data notif. sent ( 622 kbit/s), Meas Data Buffer Level:  0.0% (   0 samples in buffer), TX RSSI: -48 dBm
[00:02:29.626,739] <wrn> ringbuffer: Buffer full, overwriting oldest sample! (w: 2011, r: 2040, in: 1271010, out: 1262040)
[00:02:32.458,068] <dbg> peripherals.peripherals_getBatteryPercentage: Battery Voltage: 4018 mV => 100%
ASSERTION FAIL [err == 0] @ WEST_TOPDIR/zephyr/subsys/bluetooth/host/hci_core.c:333
        k_sem_take failed with err -11
[00:02:38.729,217] <err> os: r0/a1:  0x00000003  r1/a2:  0x00000000  r2/a3:  0x00000001
[00:02:38.729,*** Booting Zephyr OS build zephyr-v2.5.0  ***
I: Starting bootloader | Apr  9 2021 16:55:39 | Version: 0.8.1 | MCUboot: v1.7.0-80-g3fc59410 | Zephyrproject: v2.5.0
I: Primary image: magic=unset, swap_type=0x1, copy_done=0x3, image_ok=0x3
I: Secondary image: magic=unset, swap_type=0x1, copy_done=0x3, image_ok=0x3
I: Boot source: none
I: Swap type: none
I: Bootloader chainload address offset: 0x12000
I: Jumping to the first image slot
*** Booting Zephyr OS build zephyr-v2.5.0  ***
[..]
[00:00:00.004,272] <dbg> watchdog.initWatchdog: Configured the Watchdog to reset the device if it does not get feed withing 60 seconds
[00:00:00.004,302] <inf> misc: Reset Reason: Watchdog
[00:00:00.004,302] <err> main: ####################
[00:00:00.004,302] <err> main: ## WATCHDOG RESET ##
[00:00:00.004,302] <err> main: ####################

@carlescufi
Copy link
Member

@caco3 so to summarize:

  • You see the issue both in v2.5.0 and also current master
  • This patch did not help

Is this correct?

@carlescufi carlescufi added the priority: medium Medium impact/importance bug label May 5, 2021
@caco3
Copy link
Contributor Author

caco3 commented May 10, 2021

@carlescufi

I am not 100% sure if the patch did help. Fact is, running stock 2.5.0 or 1cc7307 leads to

ASSERTION FAIL [err == 0] @ WEST_TOPDIR/zephyr/subsys/bluetooth/host/hci_core.c:311
        k_sem_take failed with err -11
=> Watchdog Reset

Then I ported the mentioned patch to 2.5.0 and gave it another try. The system still crashes but the trace looks a bit different, so I am not sure if it is the same issue:

[00:01:49.795,806] <err> os: ***** USAGE FAULT *****
[00:01:49.795,837] <err> os:   Illegal use o*** Booting Zephyr OS build zephyr-v2.5.0  ***
=> CPU-Lockup Reset

Is there a way to get more output (printk) in case of such a crash?

Note 1:
I also can see such crashes when I do not stress the system with permanent read requests but instead just send notifications at a weak RSSI!

Note 2:
Unluckely I will be away for the next couple of weeks.
I will tell my co-workers to have a look on this issue.

@cvinayak
Copy link
Contributor

I also can see such crashes when I do not stress the system with permanent read requests but instead just send notifications at a weak RSSI!

@joerchan will tx thread timeout if num complete does not arrive for long time until supervision timeout?

@joerchan
Copy link
Contributor

No, TX thread waits for num completes indefinitely.

@carlescufi
Copy link
Member

@caco3 we will need more information in order to try and figure out the root cause. Ideally we'd need a small sample that reproduces this on an Nordic DK so we can then analyze the issue.

@carlescufi carlescufi changed the title ASSERTION FAIL [err == 0] @ [..]/hci_core.c:333, k_sem_take failed with err -11 Bluetooth: HCI cmd reponse timeout May 20, 2021
@carlescufi carlescufi changed the title Bluetooth: HCI cmd reponse timeout Bluetooth: HCI cmd response timeout May 20, 2021
@carlescufi carlescufi added the Waiting for response Waiting for author's response label May 27, 2021
@carlescufi
Copy link
Member

@caco3 when you come back please do comment on this issue, since Zephyr 2.6.0 is currently being stabilizied and ideally we'd like to include a fix for this.

@caco3
Copy link
Contributor Author

caco3 commented Jun 1, 2021

@carlescufi I will look into this after I get back to work. How ever this will only be at beginning of July, most likely to late for the 2.6.0 release, sry!

@carlescufi carlescufi added this to the v2.7.0 milestone Jun 3, 2021
@caco3
Copy link
Contributor Author

caco3 commented Jul 5, 2021

Just a little update:
I am now back @ work and migrated to 2.6.0. As expected the issue still is the same.

I will now try to build a minimal example to reproduce the issue.

@carlescufi
Copy link
Member

I will now try to build a minimal example to reproduce the issue.

Thanks @caco3. Please do let us know when you have the sample so we can analyze it.

@caco3
Copy link
Contributor Author

caco3 commented Jul 16, 2021

We are trying intensively to trace the issue down as deep that we can provide a minimal example.

I ported the mentioned patch to Zephyr 2.6.0 (see caco3@434370b) and applied it to the measuring device as well as the BLE receiver dongle (a nrf52840 dongle running the Zephyr HCI_USB example) connected to the host system. This brings quite some improvement; The measurement device now no longer crashes but only disconnects!

It will need further testing but I strongly believe that this patch helps against the crashing!

We still have stability issues but maybe they are no longer directly related to this issue.
In the setup as we use it, the host system is an ARM Cortex-A8 device on which we run a Yocto based Linux System. As mentioned earlier, we only have the stability issue when we stress the BLE connection additionally with extra GATT reads while we send notifications at a high rate from the measurement device to the host.
I tried to reproduce the issue on a more powerful host (x86 PC running Ubuntu 20.04) but haven't been able to get it crashing in the same way, althrough the software is almost identical (same dongle, same bluez, similair kernel). This leads me to the impression, that the sudden disconnects might be performance issue on receiver side. How ever we will need to investigate more for this.

@carlescufi
Copy link
Member

the host system is an ARM Cortex-A8

I feel we need to clarify the setup here, because we are confused.
If the Host is a Cortex-A8 running Linux, then what Bluetooth Host are you using? Because the patch you applied is for the Zephyr Bluetooth Host, but if the Host is Linux then I don't see how that can help.
Could you please describe your setup in detail, including all ICs present, the physical connections among them as well as the exact software stacks that you are using?

@caco3
Copy link
Contributor Author

caco3 commented Aug 4, 2021

Sorry for the confusion. I try to describe it better below:

Setup A:

 --------------------           --------------------           --------------------
| Measurement Device |   BLE   | BLE Receiver       |   USB   | Processing Host    |
| Running patched    |  <--->  | Running patched    |  <--->  | Yocto based Linux  |
| Zephyr 2.6 (nrf52) |         | Zephyr 2.6 (nrf52) |         | (Cortex-A8)        |
 --------------------           --------------------           --------------------

Setup B:
Same as Setup A, but we replaced the Processing Host by a x86 PC running Ubuntu 20.04


The Measurement Device sends data at around 625 kbit/s to the Processing Host using GATT Notify.
This works fine until the Processing Host (Cortex-A8) starts to do GATT reads excessively while still receiving the notifications!

Without the patch the Measurement Device crashes.
With the patch, it no longer crashes, but it simply stops transmitting any notification or read response.
We do not see any error message or disconnect, just no more communication.

Output of `btmon` (run on the Cortex-A8):
> ACL Data RX: Handle 0 flags 0x02 dlen 248                                                                                                                                                                                #1433 [hci0] 18.701375
      ATT: Handle Value Notification (0x1b) len 243
        Handle: 0x0028
          Data: b6499dddd0f4e9d8b6369dc3d0e8e9beb6199d9bd0d5e997b6059d83d0c9e97eb60f9d90d0d0e98db6009d7bd0c6e97ab5f09d67d0bce966b5df9d51d0b1e952b5cc9d37d0a5e938b5bc9d22d09ae923b5a49d03d08ce904b58c9ce3d07de8e5b5769cc5d06ee8c8b5609ca8d060e8abb5499c8ad051e88fb5349c6ed044e873b5219c53d036e859b50b9c35d028e83cb4f59c18d01ae820b4e19bfdd00ee807b4cd9be2d001e7edb4b49bc1cff1e7ccb49b9ba0cfe0e7acb4879b85cfd4e793b46a9b5fcfc2e76cb44e9b38cfafe747b4379b1dcfa1e72bb4069adccf81e6e9b3d69a9ccf62e6a9b3c59a84cf57e6948a
> ACL Data RX: Handle 0 flags 0x02 dlen 248                                                                                                                                                                                #1434 [hci0] 18.702721
      ATT: Handle Value Notification (0x1b) len 243
        Handle: 0x0028
          Data: b3b39a6bcf4be67bb39d9a4ecf3de65fb3849a2ccf2ce63eb36b9a0acf1ce61eb35999f2cf12e607b34699d8cf06e5eeb33299bfcef9e5d4b32f99bbcef7e5d2b33599c2cefbe5dcb31f99a5ceede5c0b317999bcee7e5b7b3079986cedee5a2b2ee9966cecfe583b2df9952cec4e56eb2cc9937ceb6e554b2b8991cceabe53cb2a49903ce9ee523b28e98e5ce8fe506b27a98c9ce83e4edb26898b0ce77e4d5b2529892ce69e4b8b238986fce59e496b2229853ce4ae47ab210983ace3ee462b1fb981fce31e447b1e69803ce23e42bb1cf97e5ce15e40eb1bb97c9ce08e3f4b1a697aecdfae3dab1919793cdede3c18b
> ACL Data RX: Handle 0 flags 0x02 dlen 248                                                                                                                                                                                #1435 [hci0] 18.716373
      ATT: Handle Value Notification (0x1b) len 243
        Handle: 0x0028
          Data: aabf8e79c98bdb0baa868e2dc966dac0aa518de6c944da7baa258daac928da41aa178d97c91eda30a9f98d6fc90cda0ba9d78d43c8f6d9dfa9b88d1ac8e3d9b8a99c8cf7c8d1d994a97e8ccfc8bed96da95d8ca2c8a8d940a9398c73c891d911a9168c44c87bd8e3a8fc8c20c86ad8c2a8e08bfac858d89ea8c68bd8c847d87ea8ae8bb7c838d85ea8928b90c825d839a8788b6ec814d817a85f8b4fc805d7f8a8448b2cc7f5d7d7a8298b06c7e3d7b2a80d8ae0c7d1d78ea7f58ac1c7c2d770a7d88a9bc7aed74aa7b78a70c799d71fa79e8a4fc789d6fea76b8a09c768d6baa74189d0c74cd682a72789adc73cd6608f
> ACL Data RX: Handle 0 flags 0x02 dlen 248                                                                                                                                                                                #1436 [hci0] 18.720519
      ATT: Handle Value Notification (0x1b) len 243
        Handle: 0x0028
          Data: a1d98298c3d2cf91a1c2827cc3c4cf74a1ac825ec3b6cf57a19d824bc3accf45a18c8236c3a2cf30a1728213c392cf10a15d81f8c385cef5a14981dcc378cedba13381bdc36acebfa11a819cc35ace9ea0fc8174c346ce76a0e38152c336ce55a0a78100c30ece06a08380d1c2f7cdd7a07480bdc2edcdc5a06280a4c2e1cdaea04f808ac2d6cd96a03b8070c2c9cd7da0238050c2b9cd5fa0108038c2adcd479ff9801bc29fcd2c9fe28000c290cd0e9fda8000c28ccd059fea8006c296cd1b9fd58000c288cd009fbb8000c277ccdf9f878000c255cc9c9f688000c241cc739f508000c232cc549f398000c223cc3692
< ACL Data TX: Handle 0 flags 0x00 dlen 7                                                                                                                                                                                  #1437 [hci0] 18.731080
      ATT: Read Request (0x0a) len 2
        Handle: 0x002b
@ MGMT Command: Get Connection Information (0x0031) plen 7                                                                                                                                                              {0x0003} [hci0] 19.058409
        LE Address: xx:xx:xx:4B:43:B4 (XXX)
< HCI Command: Read RSSI (0x05|0x0005) plen 2                                                                                                                                                                              #1438 [hci0] 19.058508
        Handle: 0
@ MGMT Command: Get Connection Information (0x0031) plen 7                                                                                                                                                              {0x0003} [hci0] 19.609856
        LE Address: xx:xx:xx:4B:43:B4 (XXX)
@ MGMT Event: Command Complete (0x0001) plen 13                                                                                                                                                                         {0x0003} [hci0] 19.609928
      Get Connection Information (0x0031) plen 10
        Status: Busy (0x0a)
        LE Address: xx:xx:xx:4B:43:B4 (XXX)
        RSSI: 0 dBm (0x00)
        TX power: 0 dbm (0x00)
        TX power (max): 0 dbm (0x00)
@ MGMT Command: Get Connection Information (0x0031) plen 7                                                                                                                                                              {0x0003} [hci0] 20.161220
        LE Address: xx:xx:xx:4B:43:B4 (XXX)
@ MGMT Event: Command Complete (0x0001) plen 13                                                                                                                                                                         {0x0003} [hci0] 20.161293
      Get Connection Information (0x0031) plen 10
        Status: Busy (0x0a)
        LE Address: xx:xx:xx:4B:43:B4 (XXX)
        RSSI: 0 dBm (0x00)
        TX power: 0 dbm (0x00)
        TX power (max): 0 dbm (0x00)
@ MGMT Command: Get Connection Information (0x0031) plen 7                                                                                                                                                              {0x0003} [hci0] 20.712558
        LE Address: xx:xx:xx:4B:43:B4 (XXX)
@ MGMT Event: Command Complete (0x0001) plen 13                                                                                                                                                                         {0x0003} [hci0] 20.712628
      Get Connection Information (0x0031) plen 10
        Status: Busy (0x0a)
        LE Address: xx:xx:xx:4B:43:B4 (XXX)
        RSSI: 0 dBm (0x00)
        TX power: 0 dbm (0x00)
        TX power (max): 0 dbm (0x00)
@ MGMT Command: Get Connection Information (0x0031) plen 7                                                                                                                                                              {0x0003} [hci0] 21.264040
        LE Address: xx:xx:xx:4B:43:B4 (XXX)

Now, when we replace the Cortex-A8 with a more powerful machine (Setup B), it seems to run stable for a while, but then the sensor crashes and causes a watchdog reset:

[00:08:15.020,996] <inf> bt_wrcd_service_helper:  67786 data notif. sent ( 625 kbit/s), Meas Data Buffer Level:  0.0% (   0 samples in buffer), TX RSSI: -37 dBm                                                                                                              
[00:08:20.021,148] <inf> bt_wrcd_service_helper:  69452 data notif. sent ( 624 kbit/s), Meas Data Buffer Level:  0.0% (   0 samples in buffer), TX RSSI: -36 dBm                                                                                                              
HP--- 9999 messages dropped ---
[00:08:22.560,729] <err> os: Halting system

*** Booting Zephyr OS build zephyr-v2.6.0-1-g1ab6d4d08072  ***
[..]                                                                                                                           
[00:00:00.005,676] <inf> misc: Reset Reason: Watchdog
Output of `btmon` (run on the x86 machine):
> ACL Data RX: Handle 0 flags 0x02 dlen 248                                                                                                                                                                              #79182 [hci0] 148.718983
      ATT: Handle Value Notification (0x1b) len 243
        Handle: 0x0028
          Data: 80008000800080008000800080008000800080008000800080008000800080008000800080008000800080008000800080008000800080008000800080008000800080008000800080008000800080008000800080008000800080008000800080008000800080008000800080008000800080008000800080008000800080008000800080008000800080008000800080008000800080008000800080008000800080008000800080008000800080008000800080008000800080008000800080008000800080008000800080008000800080008000800080008000800080008000800080008000800080008000800094
> ACL Data RX: Handle 0 flags 0x02 dlen 248                                                                                                                                                                              #79183 [hci0] 148.723221
      ATT: Handle Value Notification (0x1b) len 243
        Handle: 0x0028
          Data: 80008000800080008000800080008000800080008000800080008000800080008000800080008000800080008000800080008000800080008000800080008000800080008000800080008000800080008000800080008000800080008000800080008000800080008000800080008000800080008000800080008000800080008000800080008000800080008000800080008000800080008000800080008000800080008000800080008000800080008000800080008000800080008000800080008000800080008000800080008000800080008000800080008000800080008000800080008000800080008000800095
< ACL Data TX: Handle 0 flags 0x00 dlen 7                                                                                                                                                                                #79184 [hci0] 148.724183
      ATT: Read Request (0x0a) len 2
        Handle: 0x002b
> HCI Event: Number of Completed Packets (0x13) plen 5                                                                                                                                                                   #79185 [hci0] 148.731324
        Num handles: 1
        Handle: 0
        Count: 1
> ACL Data RX: Handle 0 flags 0x02 dlen 248                                                                                                                                                                              #79186 [hci0] 148.731801
      ATT: Handle Value Notification (0x1b) len 243
        Handle: 0x0028
          Data: 80008000800080008000800080008000800080008000800080008000800080008000800080008000800080008000800080008000800080008000800080008000800080008000800080008000800080008000800080008000800080008000800080008000800080008000800080008000800080008000800080008000800080008000800080008000800080008000800080008000800080008000800080008000800080008000800080008000800080008000800080008000800080008000800080008000800080008000800080008000800080008000800080008000800080008000800080008000800080008000800096
> ACL Data RX: Handle 0 flags 0x02 dlen 248                                                                                                                                                                              #79187 [hci0] 148.732339
      ATT: Handle Value Notification (0x1b) len 243
        Handle: 0x0028
          Data: 80008000800080008000800080008000800080008000800080008000800080008000800080008000800080008000800080008000800080008000800080008000800080008000800080008000800080008000800080008000800080008000800080008000800080008000800080008000800080008000800080008000800080008000800080008000800080008000800080008000800080008000800080008000800080008000800080008000800080008000800080008000800080008000800080008000800080008000800080008000800080008000800080008000800080008000800080008000800080008000800097
> HCI Event: Disconnect Complete (0x05) plen 4                                                                                                                                                                           #79188 [hci0] 148.835344
        Status: Success (0x00)
        Handle: 0
        Reason: Connection Timeout (0x08)
@ MGMT Event: Device Disconnected (0x000c) plen 8                                                                                                                                                                      {0x0003} [hci0] 148.835406
        LE Address: xx:xx:xx:4B:43:B4 (XXX)
        Reason: Connection timeout (0x01)
@ MGMT Event: Device Disconnected (0x000c) plen 8                                                                                                                                                                      {0x0001} [hci0] 148.835406
        LE Address: xx:xx:xx:4B:43:B4 (XXX)
        Reason: Connection timeout (0x01)
@ MGMT Command: Get Connection Information (0x0031) plen 7                                                                                                                                                             {0x0002} [hci0] 149.199034
        LE Address: xx:xx:xx:4B:43:B4 (XXX)
@ MGMT Event: Command Status (0x0002) plen 3                                                                                                                                                                           {0x0002} [hci0] 149.199051
      Get Connection Information (0x0031)
        Status: Permission Denied (0x14)

Connection Parameters (Measurement Device): Interval min: 7ms, Interval max: 7ms, Latency: 0, timout: 100ms
Connection Information (Measurement Device):

- Role: Slave
- Connection Type: LE
  PHY: TX: LE_PHY_2M, RX: LE_PHY_2M
  Data Length: TX Max length: 251, TX Max time: 1064us, RX Max length: 251, RX Max time: 1064us

@carlescufi
Copy link
Member

@caco3 Thanks for the clarification. This issue seems to always happen when your ring buffer fills up:

[00:02:29.626,739] <wrn> ringbuffer: Buffer full, overwriting oldest sample! (w: 2011, r: 2040, in: 1271010, out: 1262040)

I have a feeling that the fix you backported (#26057) is only masking the real issue, which seems to be related to your ring buffer being full and then somehow preventing the scheduler from running the controller thread. Can you confirm that the issue only happens when your ring buffer is full?

@caco3
Copy link
Contributor Author

caco3 commented Aug 25, 2021

@jfischer-no , @carlescufi FYI

Thanks to the great support of @cvinayak , we could trace it further down to a stalling in the USB subsystem.

It seems to hang at the ret = k_sem_take(&pdata.sem, K_MSEC(USB_TRANSFER_SYNC_TIMEOUT)); in usb_transfer_sync() in /zephyr/subsys/usb/usb_transfer.c

I added printk calls on various places, see the log below:

/zephyr/subsys/usb/class/bluetooth.c:
grafik

/zephyr/subsys/usb/usb_transfer.c:
grafik

HCI_USB Log:
grafik

I tested this with commit 8c31f31, run on a nrf52840 DK board.
Below a sanitized proj,conf of the HCI_USB project:

CONFIG_STDOUT_CONSOLE=y
CONFIG_GPIO=y
CONFIG_SERIAL=y
CONFIG_UART_INTERRUPT_DRIVEN=y

CONFIG_BT=y
CONFIG_BT_HCI_RAW=y

CONFIG_USB_DEVICE_STACK=y
CONFIG_USB_DEVICE_BLUETOOTH=y
CONFIG_USB_DEVICE_BLUETOOTH_VS_H4=n

# Workaround: Unable to allocate command buffer when using K_NO_WAIT since
# Host number of completed commands does not follow normal flow control.
CONFIG_BT_BUF_CMD_TX_COUNT=10
   
CONFIG_BT_CTLR_DEBUG_PINS=y

########################################
# System
########################################
# Some command handlers require a large stack.
CONFIG_SYSTEM_WORKQUEUE_STACK_SIZE=2048

########################################
# Bluetooth
########################################
CONFIG_BT=y
# - RAW HCI access
CONFIG_BT_HCI_RAW=y

# - Peripheral Role support
#CONFIG_BT_PERIPHERAL=n

# - Maximum supported HCI RX buffer length
CONFIG_BT_BUF_ACL_RX_SIZE=254
CONFIG_BT_BUF_EVT_RX_SIZE=255
CONFIG_BT_BUF_CMD_TX_SIZE=255

# Bluetooth -> Bluetooth Controller
# - Maximum supported ACL size for outgoing data
CONFIG_BT_BUF_ACL_TX_SIZE=251
CONFIG_BT_BUF_ACL_TX_COUNT=255

# - Maximum data length supported
CONFIG_BT_CTLR_DATA_LENGTH_MAX=251
# - Coded PHY
CONFIG_BT_CTLR_PHY_CODED=n
# - Tx Power
CONFIG_BT_CTLR_TX_PWR_PLUS_8=y

########################################
# USB device stack
########################################
#CONFIG_USB=y
CONFIG_USB_DEVICE_STACK=y

# USB HCI
CONFIG_USB_DEVICE_BLUETOOTH=y
CONFIG_USB_DEVICE_BLUETOOTH_VS_H4=y

@jfischer-no
Copy link
Collaborator

jfischer-no commented Aug 25, 2021

I am only able to provoke the issue when using the weak-powered Cortex-A8 Processing Host (thats where the receiver-dongle is connected to).
If I use a PC as Processing Host, it works stable.

Seems to depend on USB host controller.
Is there a possibility on 'Cortex-A8' to connect external USB host controller via PCI Express?
@cvinayak Could it be a HCI events / ACL Data out of order on some USB host controllers issue?

It seems to hang at the ret = k_sem_take(&pdata.sem, K_MSEC(USB_TRANSFER_SYNC_TIMEOUT)); in usb_transfer_sync() in /zephyr/subsys/usb/usb_transfer.c

I guess it timeouts in a loop, not sure why you do not see a 'p', this lines are changed by cd74614, before that is was just k_sem_take(&pdata.sem, K_FOREVER);.
However usb_transfer_sync() would block until endpoint buffer is transferred to the host (HCI_IN_EP). The obvious reason is that the host (host application) does not request an IN transfer, so the host controller does not issue IN tokens, and usb_transfer_sync() blocks. On the host side, does the Linux Kernel complain about something related?

I added printk calls on various places, see the log below:

printk (over UART?) is too slow (synchronous if not via logging) and "too much printk" is not suitable for tracing something in USB device support.

@jfischer-no
Copy link
Collaborator

CONFIG_USB_DEVICE_BLUETOOTH=y
CONFIG_USB_DEVICE_BLUETOOTH_VS_H4=y

you do not need CONFIG_USB_DEVICE_BLUETOOTH_VS_H4=y

@cvinayak
Copy link
Contributor

cvinayak commented Aug 25, 2021

Could it be a HCI events / ACL Data out of order on some USB host controllers issue?

@jfischer-no There are not much HCI events, only ACL Data is being received as fast as possible in the scenario.

Unrelated, pdata is auto variable in the usb_transfer_sync function, what will happen if the function returns after k_sem_take timeout and k_sem_give is called by usb_transfer? Wouldn't it be out-of-bound access?

@jfischer-no
Copy link
Collaborator

Unrelated, pdata is auto variable in the usb_transfer_sync function, what will happen if the function returns after k_sem_take timeout and k_sem_give is called by usb_transfer? Wouldn't it be out-of-bound access?

But usb_transfer_sync is not finished when k_sem_take timeouts, it tries again and again until it was successful or cancelled.

@caco3
Copy link
Contributor Author

caco3 commented Aug 27, 2021

Seems to depend on USB host controller.
Is there a possibility on 'Cortex-A8' to connect external USB host controller via PCI Express?

@jfischer-no Not on the hardware we use. Maybe on a different board, but that might also use a different USB-Controller.

printk (over UART?) is too slow (synchronous if not via logging) and "too much printk" is not suitable for tracing something in USB device support.

@jfischer-no I used the ACM-UART via SEGGER Programmer.
I will try to nail it further down by using testpins instead of UART.

@caco3
Copy link
Contributor Author

caco3 commented Aug 27, 2021

I recorded the usb_transfer_sync() once more with testpins.

  • CONFIG_BT_CTLR_DEBUG_PINS=y

  • In the images below D0..D7 relate to P1.01..P1.08.

  • The 3 top lines (yellow, green. blue) are as documented in Bluetooth: HCI cmd response timeout #34659 (comment)

  • On D3 I mapped k_sem_init(&pdata.sem, 0, 1); and ret = usb_transfer(ep, data, dlen, flags, usb_transfer_sync_cb, &pdata);

  • On D4 I mapped ret = k_sem_take(&pdata.sem, K_MSEC(USB_TRANSFER_SYNC_TIMEOUT));

  • On D5 I mapped trans = usb_ep_get_transfer(ep);

Screenshot 1:
grafik

Screenshot 2 (zoomed):
grafik

Screenshot 3 (zoomed):
grafik

In normal operation, k_sem_init(&pdata.sem, 0, 1);/ret = usb_transfer(ep, data, dlen, flags, usb_transfer_sync_cb, &pdata); and ret = k_sem_take(&pdata.sem, K_MSEC(USB_TRANSFER_SYNC_TIMEOUT)); return quickly. trans = usb_ep_get_transfer(ep); never gets reached => k_sem_take() always returns 0.

At the start of the stalling, ret = k_sem_take(&pdata.sem, K_MSEC(USB_TRANSFER_SYNC_TIMEOUT)); takes longer (3 ms).
How ever from then on, it always takes 100ms until ret = k_sem_take(&pdata.sem, K_MSEC(USB_TRANSFER_SYNC_TIMEOUT)); resp. trans = usb_ep_get_transfer(ep); get called again!

Because D3 no longer gets toggled, I interprete that it stays in the while loop, how ever I do not understand where it blocks.

Below the modified usb_transfer_sync():

int usb_transfer_sync(uint8_t ep, uint8_t *data, size_t dlen, unsigned int flags)
{
	struct usb_transfer_sync_priv pdata;
	int ret;

    DEBUG_PORT->OUTSET = DEBUG_PIN3;
	k_sem_init(&pdata.sem, 0, 1);
	ret = usb_transfer(ep, data, dlen, flags, usb_transfer_sync_cb, &pdata);
    DEBUG_PORT->OUTCLR = DEBUG_PIN3;
	if (ret) {
		return ret;
	}

	/* Semaphore will be released by the transfer completion callback
	 * which might not be called when transfer was cancelled
	 */
	while (1) {
		struct usb_transfer_data *trans;

        DEBUG_PORT->OUTSET = DEBUG_PIN4;      
		ret = k_sem_take(&pdata.sem, K_MSEC(USB_TRANSFER_SYNC_TIMEOUT));
        DEBUG_PORT->OUTCLR = DEBUG_PIN4;
		if (ret == 0) {
			break;
		}

        DEBUG_PORT->OUTSET = DEBUG_PIN5;
		trans = usb_ep_get_transfer(ep);
        DEBUG_PORT->OUTCLR = DEBUG_PIN5;
		if (!trans || trans->status != -EBUSY) {
			LOG_WRN("Sync transfer cancelled, ep 0x%02x", ep);
			return -ECANCELED;
		}
	}

	return pdata.tsize;
}

@jfischer-no
Copy link
Collaborator

How ever from then on, it always takes 100ms until ret = k_sem_take(&pdata.sem, K_MSEC(USB_TRANSFER_SYNC_TIMEOUT)); resp. trans = usb_ep_get_transfer(ep); get called again!

usb_ep_get_transfer() is there to check if the transfer is still valid and not cancelled, for example by detach from the host (see cd74614, before that is was just k_sem_take(&pdata.sem, K_FOREVER); .

Because D3 no longer gets toggled, I interprete that it stays in the while loop, how ever I do not understand where it blocks.

See my comment above:

However usb_transfer_sync() would block until endpoint buffer is transferred to the host (HCI_IN_EP). The obvious reason is that the host (host application) does not request an IN transfer, so the host controller does not issue IN tokens, and usb_transfer_sync() blocks. On the host side, does the Linux Kernel complain about something related?

Depending on what tools you are equipped with, you could listen on the bus e.g. with USB protocol analyzer, if the host is still sending IN tockens for the endpoint some time after the stall, then the problem is on Zephyr OS side.
On the host side, does the Linux Kernel complain about something related?
Maybe it helps to run bluetoothd daemon in foreground with debuging, see https://git.kernel.org/pub/scm/bluetooth/bluez.git/tree/HACKING#n83

@caco3
Copy link
Contributor Author

caco3 commented Sep 1, 2021

I do not have an USB-Analyzer at hand, but we ordered one. How ever it will take some weeks until I will have it in my hands.

I run bluetoothd in foreground, debug mode. I can see messages while the device gets connected, but during the streaming and around the stalling not a single message is shown!

bluetoothd -n -d | tee bluetooth.log ```

Start and connecting

Sep 1 07:03:43 wlreceiver daemon.debug bluetoothd[1076]: ../bluez-5.54/src/adapter.c:start_discovery() sender :1.11
Sep 1 07:03:43 wlreceiver daemon.debug bluetoothd[1076]: ../bluez-5.54/src/adapter.c:update_discovery_filter()
Sep 1 07:03:43 wlreceiver daemon.debug bluetoothd[1076]: ../bluez-5.54/src/adapter.c:discovery_filter_to_mgmt_cp()
Sep 1 07:03:43 wlreceiver daemon.debug bluetoothd[1076]: ../bluez-5.54/src/adapter.c:trigger_start_discovery()
Sep 1 07:03:43 wlreceiver daemon.debug bluetoothd[1076]: ../bluez-5.54/src/adapter.c:cancel_passive_scanning()
Sep 1 07:03:43 wlreceiver daemon.debug bluetoothd[1076]: ../bluez-5.54/src/adapter.c:start_discovery_timeout()
Sep 1 07:03:43 wlreceiver daemon.debug bluetoothd[1076]: ../bluez-5.54/src/adapter.c:start_discovery_timeout() adapter->current_discovery_filter == 0
Sep 1 07:03:43 wlreceiver daemon.debug bluetoothd[1076]: ../bluez-5.54/src/adapter.c:start_discovery_complete() status 0x00
Sep 1 07:03:43 wlreceiver daemon.info btman[536]: INFO: Devices discoverying started
Sep 1 07:03:43 wlreceiver daemon.debug bluetoothd[1076]: ../bluez-5.54/src/adapter.c:discovering_callback() hci0 type 6 discovering 1 method 0
Sep 1 07:03:43 wlreceiver daemon.debug bluetoothd[1076]: ../bluez-5.54/src/adapter.c:device_found_callback() hci0 addr 00:07:29:4B:43:B4, rssi -30 flags 0x0000 eir_len 33
Sep 1 07:03:43 wlreceiver daemon.debug bluetoothd[1076]: ../bluez-5.54/src/device.c:device_set_legacy() legacy 0
Sep 1 07:03:43 wlreceiver daemon.debug bluetoothd[1076]: ../bluez-5.54/src/device.c:device_set_rssi_with_delta() rssi -30
Sep 1 07:03:43 wlreceiver daemon.debug bluetoothd[1076]: ../bluez-5.54/src/device.c:device_set_flags() flags 6
Sep 1 07:03:43 wlreceiver daemon.debug bluetoothd[1076]: ../bluez-5.54/src/adapter.c:stop_discovery() sender :1.11
Sep 1 07:03:43 wlreceiver daemon.debug bluetoothd[1076]: ../bluez-5.54/src/adapter.c:stop_discovery_complete() status 0x00
Sep 1 07:03:43 wlreceiver daemon.info btman[536]: INFO: Devices discoverying stopped
Sep 1 07:03:43 wlreceiver daemon.debug bluetoothd[1076]: ../bluez-5.54/src/adapter.c:trigger_passive_scanning()
Sep 1 07:03:43 wlreceiver daemon.debug bluetoothd[1076]: ../bluez-5.54/src/adapter.c:discovery_remove() owner :1.11
Sep 1 07:03:43 wlreceiver daemon.debug bluetoothd[1076]: ../bluez-5.54/src/device.c:device_set_rssi_with_delta() rssi 0
Sep 1 07:03:43 wlreceiver daemon.debug bluetoothd[1076]: ../bluez-5.54/src/adapter.c:discovering_callback() hci0 type 6 discovering 0 method 0
Sep 1 07:03:44 wlreceiver daemon.debug bluetoothd[1076]: ../bluez-5.54/src/device.c:device_connect_le() Connection attempt to: 00:07:29:4B:43:B4
Sep 1 07:03:44 wlreceiver daemon.debug bluetoothd[1076]: ../bluez-5.54/src/adapter.c:connected_callback() hci0 device 00:07:29:4B:43:B4 connected eir_len 21
Sep 1 07:03:44 wlreceiver daemon.debug bluetoothd[1076]: ../bluez-5.54/attrib/gattrib.c:g_attrib_ref() 0x584568: g_attrib_ref=1
Sep 1 07:03:44 wlreceiver daemon.debug bluetoothd[1076]: ../bluez-5.54/src/gatt-client.c:btd_gatt_client_connected() Device connected.
Sep 1 07:03:44 wlreceiver daemon.debug bluetoothd[1076]: ../bluez-5.54/src/device.c:gatt_debug() MTU exchange complete, with MTU: 247
Sep 1 07:03:45 wlreceiver daemon.debug bluetoothd[1076]: ../bluez-5.54/src/device.c:gatt_debug() Primary services found: 7
Sep 1 07:03:45 wlreceiver daemon.debug bluetoothd[1076]: ../bluez-5.54/src/device.c:gatt_debug() start: 0x0001, end: 0x0004, uuid: 00001801-0000-1000-8000-00805f9b34fb
Sep 1 07:03:45 wlreceiver daemon.debug bluetoothd[1076]: ../bluez-5.54/src/device.c:gatt_debug() start: 0x0005, end: 0x000b, uuid: 00001800-0000-1000-8000-00805f9b34fb
Sep 1 07:03:45 wlreceiver daemon.debug bluetoothd[1076]: ../bluez-5.54/src/device.c:gatt_debug() start: 0x000c, end: 0x000f, uuid: 0000180f-0000-1000-8000-00805f9b34fb
Sep 1 07:03:45 wlreceiver daemon.debug bluetoothd[1076]: ../bluez-5.54/src/device.c:gatt_debug() start: 0x0010, end: 0x001c, uuid: 0000180a-0000-1000-8000-00805f9b34fb
Sep 1 07:03:45 wlreceiver daemon.debug bluetoothd[1076]: ../bluez-5.54/src/device.c:gatt_debug() start: 0x001d, end: 0x003f, uuid: 0000010-f5bf-58d5-9d17-172177d1316a
Sep 1 07:03:45 wlreceiver daemon.debug bluetoothd[1076]: ../bluez-5.54/src/device.c:gatt_debug() start: 0x0040, end: 0x0056, uuid: ffffff00-f5bf-58d5-9d17-172177d1316a
Sep 1 07:03:45 wlreceiver daemon.debug bluetoothd[1076]: ../bluez-5.54/src/device.c:gatt_debug() start: 0x0057, end: 0x005a, uuid: 8d53dc1d-1db7-4cd3-868b-8a527460a4
Sep 1 07:03:45 wlreceiver daemon.debug bluetoothd[1076]: ../bluez-5.54/src/device.c:gatt_debug() Characteristics found: 37
Sep 1 07:03:45 wlreceiver daemon.debug bluetoothd[1076]: ../bluez-5.54/src/device.c:gatt_debug() start: 0x0002, end: 0x0005, value: 0x0003, props: 0x20, uuid: 00002a05-0000-1
Sep 1 07:03:45 wlreceiver daemon.debug bluetoothd[1076]: ../bluez-5.54/src/device.c:gatt_debug() start: 0x0006, end: 0x0007, value: 0x0007, props: 0x0a, uuid: 00002a00-0000-1
Sep 1 07:03:45 wlreceiver daemon.debug bluetoothd[1076]: ../bluez-5.54/src/device.c:gatt_debug() start: 0x0008, end: 0x0009, value: 0x0009, props: 0x02, uuid: 00002a01-0000-1
Sep 1 07:03:45 wlreceiver daemon.debug bluetoothd[1076]: ../bluez-5.54/src/device.c:gatt_debug() start: 0x000a, end: 0x000c, value: 0x000b, props: 0x02, uuid: 00002a04-0000-1
Sep 1 07:03:45 wlreceiver daemon.debug bluetoothd[1076]: ../bluez-5.54/src/device.c:gatt_debug() start: 0x000d, end: 0x0010, value: 0x000e, props: 0x12, uuid: 00002a19-0000-1
Sep 1 07:03:45 wlreceiver daemon.debug bluetoothd[1076]: ../bluez-5.54/src/device.c:gatt_debug() start: 0x0011, end: 0x0012, value: 0x0012, props: 0x02, uuid: 00002a24-0000-1
Sep 1 07:03:45 wlreceiver daemon.debug bluetoothd[1076]: ../bluez-5.54/src/device.c:gatt_debug() start: 0x0013, end: 0x0014, value: 0x0014, props: 0x02, uuid: 00002a29-0000-1
Sep 1 07:03:45 wlreceiver daemon.debug bluetoothd[1076]: ../bluez-5.54/src/device.c:gatt_debug() start: 0x0015, end: 0x0016, value: 0x0016, props: 0x02, uuid: 00002a25-0000-1
Sep 1 07:03:45 wlreceiver daemon.debug bluetoothd[1076]: ../bluez-5.54/src/device.c:gatt_debug() start: 0x0017, end: 0x0018, value: 0x0018, props: 0x02, uuid: 00002a26-0000-1
Sep 1 07:03:45 wlreceiver daemon.debug bluetoothd[1076]: ../bluez-5.54/src/device.c:gatt_debug() start: 0x0019, end: 0x001a, value: 0x001a, props: 0x02, uuid: 00002a27-0000-1
Sep 1 07:03:45 wlreceiver daemon.debug bluetoothd[1076]: ../bluez-5.54/src/device.c:gatt_debug() start: 0x001b, end: 0x001d, value: 0x001c, props: 0x02, uuid: 00002a28-0000-1
Sep 1 07:03:45 wlreceiver daemon.debug bluetoothd[1076]: ../bluez-5.54/src/device.c:gatt_debug() start: 0x001e, end: 0x0020, value: 0x001f, props: 0x1a, uuid: 00000101-f5bf-5
Sep 1 07:03:45 wlreceiver daemon.debug bluetoothd[1076]: ../bluez-5.54/src/device.c:gatt_debug() start: 0x0021, end: 0x0023, value: 0x0022, props: 0x1a, uuid: 00000102-f5bf-5
Sep 1 07:03:45 wlreceiver daemon.debug bluetoothd[1076]: ../bluez-5.54/src/device.c:gatt_debug() start: 0x0024, end: 0x0026, value: 0x0025, props: 0x12, uuid: 00000103-f5bf-5
Sep 1 07:03:45 wlreceiver daemon.debug bluetoothd[1076]: ../bluez-5.54/src/device.c:gatt_debug() start: 0x0027, end: 0x0029, value: 0x0028, props: 0x10, uuid: 0000010-f5bf-5
Sep 1 07:03:45 wlreceiver daemon.debug bluetoothd[1076]: ../bluez-5.54/src/device.c:gatt_debug() start: 0x002a, end: 0x002c, value: 0x002b, props: 0x12, uuid: 0000010b-f5bf-5
Sep 1 07:03:45 wlreceiver daemon.debug bluetoothd[1076]: ../bluez-5.54/src/device.c:gatt_debug() start: 0x002d, end: 0x002f, value: 0x002e, props: 0x12, uuid: 0000010e-f5bf-5
Sep 1 07:03:45 wlreceiver daemon.debug bluetoothd[1076]: ../bluez-5.54/src/device.c:gatt_debug() start: 0x0030, end: 0x0031, value: 0x0031, props: 0x08, uuid: 0000010-f5bf-5
Sep 1 07:03:45 wlreceiver daemon.debug bluetoothd[1076]: ../bluez-5.54/src/device.c:gatt_debug() start: 0x0032, end: 0x0033, value: 0x0033, props: 0x0a, uuid: 00000105-f5bf-5
Sep 1 07:03:45 wlreceiver daemon.debug bluetoothd[1076]: ../bluez-5.54/src/device.c:gatt_debug() start: 0x0034, end: 0x0035, value: 0x0035, props: 0x0a, uuid: 00000106-f5bf-5
Sep 1 07:03:45 wlreceiver daemon.debug bluetoothd[1076]: ../bluez-5.54/src/device.c:gatt_debug() start: 0x0036, end: 0x0037, value: 0x0037, props: 0x0a, uuid: 00000107-f5bf-5
Sep 1 07:03:45 wlreceiver daemon.debug bluetoothd[1076]: ../bluez-5.54/src/device.c:gatt_debug() start: 0x0038, end: 0x0039, value: 0x0039, props: 0x08, uuid: 00000108-f5bf-5
Sep 1 07:03:45 wlreceiver daemon.debug bluetoothd[1076]: ../bluez-5.54/src/device.c:gatt_debug() start: 0x003a, end: 0x003b, value: 0x003b, props: 0x02, uuid: 00000109-f5bf-5
Sep 1 07:03:45 wlreceiver daemon.debug bluetoothd[1076]: ../bluez-5.54/src/device.c:gatt_debug() start: 0x003c, end: 0x003d, value: 0x003d, props: 0x0a, uuid: 0000010a-f5bf-5
Sep 1 07:03:45 wlreceiver daemon.debug bluetoothd[1076]: ../bluez-5.54/src/device.c:gatt_debug() start: 0x003e, end: 0x0040, value: 0x003f, props: 0x02, uuid: 0000010c-f5bf-5
Sep 1 07:03:45 wlreceiver daemon.debug bluetoothd[1076]: ../bluez-5.54/src/device.c:gatt_debug() start: 0x0041, end: 0x0042, value: 0x0042, props: 0x08, uuid: ffffff11-f5bf-5
Sep 1 07:03:45 wlreceiver daemon.debug bluetoothd[1076]: ../bluez-5.54/src/device.c:gatt_debug() start: 0x0043, end: 0x0044, value: 0x0044, props: 0x08, uuid: ffffff12-f5bf-5
Sep 1 07:03:45 wlreceiver daemon.debug bluetoothd[1076]: ../bluez-5.54/src/device.c:gatt_debug() start: 0x0045, end: 0x0046, value: 0x0046, props: 0x08, uuid: ffffff13-f5bf-5
Sep 1 07:03:45 wlreceiver daemon.debug bluetoothd[1076]: ../bluez-5.54/src/device.c:gatt_debug() start: 0x0047, end: 0x0048, value: 0x0048, props: 0x08, uuid: ffffff14-f5bf-5
Sep 1 07:03:45 wlreceiver daemon.debug bluetoothd[1076]: ../bluez-5.54/src/device.c:gatt_debug() start: 0x0049, end: 0x004a, value: 0x004a, props: 0x08, uuid: ffffff15-f5bf-5
Sep 1 07:03:45 wlreceiver daemon.debug bluetoothd[1076]: ../bluez-5.54/src/device.c:gatt_debug() start: 0x004b, end: 0x004c, value: 0x004c, props: 0x08, uuid: ffffff16-f5bf-5
Sep 1 07:03:45 wlreceiver daemon.debug bluetoothd[1076]: ../bluez-5.54/src/device.c:gatt_debug() start: 0x004d, end: 0x004e, value: 0x004e, props: 0x0a, uuid: ffffff20-f5bf-5
Sep 1 07:03:45 wlreceiver daemon.debug bluetoothd[1076]: ../bluez-5.54/src/device.c:gatt_debug() start: 0x004f, end: 0x0050, value: 0x0050, props: 0x0a, uuid: ffffff21-f5bf-5
Sep 1 07:03:45 wlreceiver daemon.debug bluetoothd[1076]: ../bluez-5.54/src/device.c:gatt_debug() start: 0x0051, end: 0x0052, value: 0x0052, props: 0x0a, uuid: ffffff22-f5bf-5
Sep 1 07:03:45 wlreceiver daemon.debug bluetoothd[1076]: ../bluez-5.54/src/device.c:gatt_debug() start: 0x0053, end: 0x0054, value: 0x0054, props: 0x08, uuid: ffffff40-f5bf-5
Sep 1 07:03:45 wlreceiver daemon.debug bluetoothd[1076]: ../bluez-5.54/src/device.c:gatt_debug() start: 0x0055, end: 0x0057, value: 0x0056, props: 0x08, uuid: ffffff50-f5bf-5
Sep 1 07:03:45 wlreceiver daemon.debug bluetoothd[1076]: ../bluez-5.54/src/device.c:gatt_debug() start: 0x0058, end: 0x005a, value: 0x0059, props: 0x14, uuid: da2e7828-fbce-4
Sep 1 07:03:45 wlreceiver daemon.debug bluetoothd[1076]: ../bluez-5.54/src/device.c:gatt_client_ready_cb() status: success, error: 10
Sep 1 07:03:45 wlreceiver daemon.debug bluetoothd[1076]: ../bluez-5.54/src/device.c:device_probe_profiles() Probing profiles for device 00:07:29:4B:43:B4
Sep 1 07:03:45 wlreceiver daemon.debug bluetoothd[1076]: ../bluez-5.54/src/device.c:device_probe_profiles() Probing profiles for device 00:07:29:4B:43:B4
Sep 1 07:03:45 wlreceiver daemon.debug bluetoothd[1076]: ../bluez-5.54/profiles/gap/gas.c:gap_probe() GAP profile probe (00:07:29:4B:43:B4)
Sep 1 07:03:45 wlreceiver daemon.debug bluetoothd[1076]: ../bluez-5.54/src/service.c:change_state() 0x58b438: device 00:07:29:4B:43:B4 profile gap-profile state changed: unavailable -> disconnected (0)
Sep 1 07:03:45 wlreceiver daemon.debug bluetoothd[1076]: ../bluez-5.54/profiles/gap/gas.c:gap_accept() GAP profile accept (00:07:29:4B:43:B4)
Sep 1 07:03:45 wlreceiver daemon.debug bluetoothd[1076]: ../bluez-5.54/profiles/gap/gas.c:handle_characteristic() Unsupported characteristic: 00002a04-0000-1000-8000-00805f9b34fb
Sep 1 07:03:45 wlreceiver daemon.debug bluetoothd[1076]: ../bluez-5.54/src/service.c:change_state() 0x58b438: device 00:07:29:4B:43:B4 profile gap-profile state changed: disconnected -> connected (0)
Sep 1 07:03:45 wlreceiver daemon.debug bluetoothd[1076]: ../bluez-5.54/src/device.c:device_probe_profiles() Probing profiles for device 00:07:29:4B:43:B4
Sep 1 07:03:45 wlreceiver daemon.debug bluetoothd[1076]: ../bluez-5.54/profiles/battery/battery.c:batt_probe() BATT profile probe (00:07:29:4B:43:B4)
Sep 1 07:03:45 wlreceiver daemon.debug bluetoothd[1076]: ../bluez-5.54/src/service.c:change_state() 0x584e20: device 00:07:29:4B:43:B4 profile batt-profile state changed: unavailable -> disconnected (0)
Sep 1 07:03:45 wlreceiver daemon.debug bluetoothd[1076]: ../bluez-5.54/profiles/battery/battery.c:batt_accept() BATT profile accept (00:07:29:4B:43:B4)
Sep 1 07:03:45 wlreceiver daemon.debug bluetoothd[1076]: ../bluez-5.54/src/service.c:change_state() 0x584e20: device 00:07:29:4B:43:B4 profile batt-profile state changed: disconnected -> connected (0)
Sep 1 07:03:45 wlreceiver daemon.debug bluetoothd[1076]: ../bluez-5.54/src/device.c:device_probe_profiles() Probing profiles for device 00:07:29:4B:43:B4
Sep 1 07:03:45 wlreceiver daemon.debug bluetoothd[1076]: ../bluez-5.54/src/service.c:change_state() 0x585000: device 00:07:29:4B:43:B4 profile deviceinfo state changed: unavailable -> disconnected (0)
Sep 1 07:03:45 wlreceiver daemon.debug bluetoothd[1076]: ../bluez-5.54/profiles/deviceinfo/deviceinfo.c:deviceinfo_accept() deviceinfo profile accept (00:07:29:4B:43:B4)
Sep 1 07:03:45 wlreceiver daemon.debug bluetoothd[1076]: ../bluez-5.54/profiles/deviceinfo/deviceinfo.c:handle_characteristic() Unsupported characteristic: 00002a24-0000-1000-8000-00805f9b34fb
Sep 1 07:03:45 wlreceiver daemon.debug bluetoothd[1076]: ../bluez-5.54/profiles/deviceinfo/deviceinfo.c:handle_characteristic() Unsupported characteristic: 00002a29-0000-1000-8000-00805f9b34fb
Sep 1 07:03:45 wlreceiver daemon.debug bluetoothd[1076]: ../bluez-5.54/profiles/deviceinfo/deviceinfo.c:handle_characteristic() Unsupported characteristic: 00002a25-0000-1000-8000-00805f9b34fb
Sep 1 07:03:45 wlreceiver daemon.debug bluetoothd[1076]: ../bluez-5.54/profiles/deviceinfo/deviceinfo.c:handle_characteristic() Unsupported characteristic: 00002a26-0000-1000-8000-00805f9b34fb
Sep 1 07:03:45 wlreceiver daemon.debug bluetoothd[1076]: ../bluez-5.54/profiles/deviceinfo/deviceinfo.c:handle_characteristic() Unsupported characteristic: 00002a27-0000-1000-8000-00805f9b34fb
Sep 1 07:03:45 wlreceiver daemon.debug bluetoothd[1076]: ../bluez-5.54/profiles/deviceinfo/deviceinfo.c:handle_characteristic() Unsupported characteristic: 00002a28-0000-1000-8000-00805f9b34fb
Sep 1 07:03:45 wlreceiver daemon.debug bluetoothd[1076]: ../bluez-5.54/src/service.c:change_state() 0x585000: device 00:07:29:4B:43:B4 profile deviceinfo state changed: disconnected -> connected (0)
Sep 1 07:03:45 wlreceiver daemon.debug bluetoothd[1076]: ../bluez-5.54/src/device.c:device_probe_profiles() Probing profiles for device 00:07:29:4B:43:B4
Sep 1 07:03:45 wlreceiver daemon.debug bluetoothd[1076]: ../bluez-5.54/src/device.c:device_probe_profiles() Probing profiles for device 00:07:29:4B:43:B4
Sep 1 07:03:45 wlreceiver daemon.debug bluetoothd[1076]: ../bluez-5.54/src/device.c:device_probe_profiles() Probing profiles for device 00:07:29:4B:43:B4
Sep 1 07:03:45 wlreceiver daemon.debug bluetoothd[1076]: ../bluez-5.54/src/gatt-client.c:btd_gatt_client_ready() GATT client ready
Sep 1 07:03:45 wlreceiver daemon.debug bluetoothd[1076]: ../bluez-5.54/src/gatt-client.c:create_services() Exporting objects for GATT services: 00:07:29:4B:43:B4
Sep 1 07:03:45 wlreceiver daemon.debug bluetoothd[1076]: ../bluez-5.54/src/gatt-client.c:service_create() Exported GATT service: /org/bluez/hci0/dev_00_07_29_4B_43_B4/service0001
Sep 1 07:03:45 wlreceiver daemon.debug bluetoothd[1076]: ../bluez-5.54/src/gatt-client.c:characteristic_create() Exported GATT characteristic: /org/bluez/hci0/dev_00_07_29_4B_43_B4/service0001/char0002
Sep 1 07:03:45 wlreceiver daemon.debug bluetoothd[1076]: ../bluez-5.54/src/gatt-client.c:descriptor_create() Exported GATT characteristic descriptor: /org/bluez/hci0/dev_00_07_29_4B_43_B4/service0001/char0002/desc0004
Sep 1 07:03:45 wlreceiver daemon.debug bluetoothd[1076]: ../bluez-5.54/src/gatt-client.c:service_create() Exported GATT service: /org/bluez/hci0/dev_00_07_29_4B_43_B4/service0010
Sep 1 07:03:45 wlreceiver daemon.debug bluetoothd[1076]: ../bluez-5.54/src/gatt-client.c:characteristic_create() Exported GATT characteristic: /org/bluez/hci0/dev_00_07_29_4B_43_B4/service0010/char0011
Sep 1 07:03:45 wlreceiver daemon.debug bluetoothd[1076]: ../bluez-5.54/src/gatt-client.c:characteristic_create() Exported GATT characteristic: /org/bluez/hci0/dev_00_07_29_4B_43_B4/service0010/char0013
Sep 1 07:03:45 wlreceiver daemon.debug bluetoothd[1076]: ../bluez-5.54/src/gatt-client.c:characteristic_create() Exported GATT characteristic: /org/bluez/hci0/dev_00_07_29_4B_43_B4/service0010/char0015
Sep 1 07:03:45 wlreceiver daemon.debug bluetoothd[1076]: ../bluez-5.54/src/gatt-client.c:characteristic_create() Exported GATT characteristic: /org/bluez/hci0/dev_00_07_29_4B_43_B4/service0010/char0017
Sep 1 07:03:45 wlreceiver daemon.debug bluetoothd[1076]: ../bluez-5.54/src/gatt-client.c:characteristic_create() Exported GATT characteristic: /org/bluez/hci0/dev_00_07_29_4B_43_B4/service0010/char0019
Sep 1 07:03:45 wlreceiver daemon.debug bluetoothd[1076]: ../bluez-5.54/src/gatt-client.c:characteristic_create() Exported GATT characteristic: /org/bluez/hci0/dev_00_07_29_4B_43_B4/service0010/char001b
Sep 1 07:03:45 wlreceiver daemon.debug bluetoothd[1076]: ../bluez-5.54/src/gatt-client.c:service_create() Exported GATT service: /org/bluez/hci0/dev_00_07_29_4B_43_B4/service001d
Sep 1 07:03:45 wlreceiver daemon.debug bluetoothd[1076]: ../bluez-5.54/src/gatt-client.c:characteristic_create() Exported GATT characteristic: /org/bluez/hci0/dev_00_07_29_4B_43_B4/service001d/char001e
Sep 1 07:03:45 wlreceiver daemon.debug bluetoothd[1076]: ../bluez-5.54/src/gatt-client.c:descriptor_create() Exported GATT characteristic descriptor: /org/bluez/hci0/dev_00_07_29_4B_43_B4/service001d/char001e/desc0020
Sep 1 07:03:45 wlreceiver daemon.debug bluetoothd[1076]: ../bluez-5.54/src/gatt-client.c:characteristic_create() Exported GATT characteristic: /org/bluez/hci0/dev_00_07_29_4B_43_B4/service001d/char0021
Sep 1 07:03:45 wlreceiver daemon.debug bluetoothd[1076]: ../bluez-5.54/src/gatt-client.c:descriptor_create() Exported GATT characteristic descriptor: /org/bluez/hci0/dev_00_07_29_4B_43_B4/service001d/char0021/desc0023
Sep 1 07:03:45 wlreceiver daemon.debug bluetoothd[1076]: ../bluez-5.54/src/gatt-client.c:characteristic_create() Exported GATT characteristic: /org/bluez/hci0/dev_00_07_29_4B_43_B4/service001d/char0024
Sep 1 07:03:45 wlreceiver daemon.debug bluetoothd[1076]: ../bluez-5.54/src/gatt-client.c:descriptor_create() Exported GATT characteristic descriptor: /org/bluez/hci0/dev_00_07_29_4B_43_B4/service001d/char0024/desc0026
Sep 1 07:03:45 wlreceiver daemon.debug bluetoothd[1076]: ../bluez-5.54/src/gatt-client.c:characteristic_create() Exported GATT characteristic: /org/bluez/hci0/dev_00_07_29_4B_43_B4/service001d/char0027
Sep 1 07:03:45 wlreceiver daemon.debug bluetoothd[1076]: ../bluez-5.54/src/gatt-client.c:descriptor_create() Exported GATT characteristic descriptor: /org/bluez/hci0/dev_00_07_29_4B_43_B4/service001d/char0027/desc0029
Sep 1 07:03:45 wlreceiver daemon.debug bluetoothd[1076]: ../bluez-5.54/src/gatt-client.c:characteristic_create() Exported GATT characteristic: /org/bluez/hci0/dev_00_07_29_4B_43_B4/service001d/char002a
Sep 1 07:03:45 wlreceiver daemon.debug bluetoothd[1076]: ../bluez-5.54/src/gatt-client.c:descriptor_create() Exported GATT characteristic descriptor: /org/bluez/hci0/dev_00_07_29_4B_43_B4/service001d/char002a/desc002c
Sep 1 07:03:45 wlreceiver daemon.debug bluetoothd[1076]: ../bluez-5.54/src/gatt-client.c:characteristic_create() Exported GATT characteristic: /org/bluez/hci0/dev_00_07_29_4B_43_B4/service001d/char002d
Sep 1 07:03:45 wlreceiver daemon.debug bluetoothd[1076]: ../bluez-5.54/src/gatt-client.c:descriptor_create() Exported GATT characteristic descriptor: /org/bluez/hci0/dev_00_07_29_4B_43_B4/service001d/char002d/desc002f
Sep 1 07:03:45 wlreceiver daemon.debug bluetoothd[1076]: ../bluez-5.54/src/gatt-client.c:characteristic_create() Exported GATT characteristic: /org/bluez/hci0/dev_00_07_29_4B_43_B4/service001d/char0030
Sep 1 07:03:46 wlreceiver daemon.debug bluetoothd[1076]: ../bluez-5.54/src/gatt-client.c:characteristic_create() Exported GATT characteristic: /org/bluez/hci0/dev_00_07_29_4B_43_B4/service001d/char0032
Sep 1 07:03:46 wlreceiver daemon.debug bluetoothd[1076]: ../bluez-5.54/src/gatt-client.c:characteristic_create() Exported GATT characteristic: /org/bluez/hci0/dev_00_07_29_4B_43_B4/service001d/char0034
Sep 1 07:03:46 wlreceiver daemon.debug bluetoothd[1076]: ../bluez-5.54/src/gatt-client.c:characteristic_create() Exported GATT characteristic: /org/bluez/hci0/dev_00_07_29_4B_43_B4/service001d/char0036
Sep 1 07:03:46 wlreceiver daemon.debug bluetoothd[1076]: ../bluez-5.54/src/gatt-client.c:characteristic_create() Exported GATT characteristic: /org/bluez/hci0/dev_00_07_29_4B_43_B4/service001d/char0038
Sep 1 07:03:46 wlreceiver daemon.debug bluetoothd[1076]: ../bluez-5.54/src/gatt-client.c:characteristic_create() Exported GATT characteristic: /org/bluez/hci0/dev_00_07_29_4B_43_B4/service001d/char003a
Sep 1 07:03:46 wlreceiver daemon.debug bluetoothd[1076]: ../bluez-5.54/src/gatt-client.c:characteristic_create() Exported GATT characteristic: /org/bluez/hci0/dev_00_07_29_4B_43_B4/service001d/char003c
Sep 1 07:03:46 wlreceiver daemon.debug bluetoothd[1076]: ../bluez-5.54/src/gatt-client.c:characteristic_create() Exported GATT characteristic: /org/bluez/hci0/dev_00_07_29_4B_43_B4/service001d/char003e
Sep 1 07:03:46 wlreceiver daemon.debug bluetoothd[1076]: ../bluez-5.54/src/gatt-client.c:service_create() Exported GATT service: /org/bluez/hci0/dev_00_07_29_4B_43_B4/service0040
Sep 1 07:03:46 wlreceiver daemon.debug bluetoothd[1076]: ../bluez-5.54/src/gatt-client.c:characteristic_create() Exported GATT characteristic: /org/bluez/hci0/dev_00_07_29_4B_43_B4/service0040/char0041
Sep 1 07:03:46 wlreceiver daemon.debug bluetoothd[1076]: ../bluez-5.54/src/gatt-client.c:characteristic_create() Exported GATT characteristic: /org/bluez/hci0/dev_00_07_29_4B_43_B4/service0040/char0043
Sep 1 07:03:46 wlreceiver daemon.debug bluetoothd[1076]: ../bluez-5.54/src/gatt-client.c:characteristic_create() Exported GATT characteristic: /org/bluez/hci0/dev_00_07_29_4B_43_B4/service0040/char0045
Sep 1 07:03:46 wlreceiver daemon.debug bluetoothd[1076]: ../bluez-5.54/src/gatt-client.c:characteristic_create() Exported GATT characteristic: /org/bluez/hci0/dev_00_07_29_4B_43_B4/service0040/char0047
Sep 1 07:03:46 wlreceiver daemon.debug bluetoothd[1076]: ../bluez-5.54/src/gatt-client.c:characteristic_create() Exported GATT characteristic: /org/bluez/hci0/dev_00_07_29_4B_43_B4/service0040/char0049
Sep 1 07:03:46 wlreceiver daemon.debug bluetoothd[1076]: ../bluez-5.54/src/gatt-client.c:characteristic_create() Exported GATT characteristic: /org/bluez/hci0/dev_00_07_29_4B_43_B4/service0040/char004b
Sep 1 07:03:46 wlreceiver daemon.debug bluetoothd[1076]: ../bluez-5.54/src/gatt-client.c:characteristic_create() Exported GATT characteristic: /org/bluez/hci0/dev_00_07_29_4B_43_B4/service0040/char004d
Sep 1 07:03:46 wlreceiver daemon.debug bluetoothd[1076]: ../bluez-5.54/src/gatt-client.c:characteristic_create() Exported GATT characteristic: /org/bluez/hci0/dev_00_07_29_4B_43_B4/service0040/char004f
Sep 1 07:03:46 wlreceiver daemon.debug bluetoothd[1076]: ../bluez-5.54/src/gatt-client.c:characteristic_create() Exported GATT characteristic: /org/bluez/hci0/dev_00_07_29_4B_43_B4/service0040/char0051
Sep 1 07:03:46 wlreceiver daemon.debug bluetoothd[1076]: ../bluez-5.54/src/gatt-client.c:characteristic_create() Exported GATT characteristic: /org/bluez/hci0/dev_00_07_29_4B_43_B4/service0040/char0053
Sep 1 07:03:46 wlreceiver daemon.debug bluetoothd[1076]: ../bluez-5.54/src/gatt-client.c:characteristic_create() Exported GATT characteristic: /org/bluez/hci0/dev_00_07_29_4B_43_B4/service0040/char0055
Sep 1 07:03:46 wlreceiver daemon.debug bluetoothd[1076]: ../bluez-5.54/src/gatt-client.c:service_create() Exported GATT service: /org/bluez/hci0/dev_00_07_29_4B_43_B4/service0057
Sep 1 07:03:46 wlreceiver daemon.debug bluetoothd[1076]: ../bluez-5.54/src/gatt-client.c:characteristic_create() Exported GATT characteristic: /org/bluez/hci0/dev_00_07_29_4B_43_B4/service0057/char0058
Sep 1 07:03:46 wlreceiver daemon.debug bluetoothd[1076]: ../bluez-5.54/src/gatt-client.c:descriptor_create() Exported GATT characteristic descriptor: /org/bluez/hci0/dev_00_07_29_4B_43_B4/service0057/char0058/desc005a
Sep 1 07:03:46 wlreceiver daemon.debug bluetoothd[1076]: ../bluez-5.54/src/gatt-client.c:btd_gatt_client_ready() Features 0x00
Sep 1 07:03:46 wlreceiver daemon.debug bluetoothd[1076]: ../bluez-5.54/src/gatt-client.c:btd_gatt_client_ready() Update Features 0x00
Sep 1 07:03:46 wlreceiver daemon.debug bluetoothd[1076]: ../bluez-5.54/src/device.c:device_svc_resolved() /org/bluez/hci0/dev_00_07_29_4B_43_B4 err 0
Sep 1 07:03:46 wlreceiver daemon.debug bluetoothd[1076]: ../bluez-5.54/src/device.c:gatt_debug() Registered handler for "Service Changed": 1
Sep 1 07:03:46 wlreceiver daemon.debug bluetoothd[1076]: ../bluez-5.54/profiles/gap/gas.c:read_device_name_cb() GAP Device Name: 9170B SN20
Sep 1 07:03:46 wlreceiver daemon.debug bluetoothd[1076]: ../bluez-5.54/profiles/gap/gas.c:read_appearance_cb() GAP Appearance: 0x0341
Sep 1 07:03:46 wlreceiver daemon.debug bluetoothd[1076]: ../bluez-5.54/profiles/battery/battery.c:parse_battery_level() Battery Level updated: 100%
Sep 1 07:03:46 wlreceiver daemon.debug bluetoothd[1076]: ../bluez-5.54/profiles/battery/battery.c:batt_io_ccc_written_cb() Battery Level: notification enabled
Sep 1 07:03:47 wlreceiver daemon.debug bluetoothd[1076]: ../bluez-5.54/src/gatt-client.c:notify_client_ref() owner :1.31

Start streaming data

Sep 1 07:03:49 wlreceiver daemon.debug bluetoothd[1076]: ../bluez-5.54/src/adapter.c:new_conn_param() hci0 00:07:29:4B:43:B4 (1) min 0x0006 max 0x0006 latency 0x0000 timeout 0x000a
Sep 1 07:03:51 wlreceiver daemon.debug bluetoothd[1076]: ../bluez-5.54/src/gatt-client.c:notify_client_ref() owner :1.31
Sep 1 07:03:52 wlreceiver daemon.debug bluetoothd[1076]: ../bluez-5.54/src/gatt-client.c:create_sock() AcquireNotify: sender :1.31 io 0x590af0

Stalling starts after some seconds (shown time is wrong), but nothing shown in log

Sep 1 07:03:47 wlreceiver daemon.warn wrcd-clientd[599]: fpgainject: WARNING: FIFO underflow!
Sep 1 07:03:48 wlreceiver daemon.err wrcd-clientd[599]: BluezMgmt::getConnectionInformation: ERROR: Failed to validate connection information: Command 49 completed with status: 10
[..]

After a while, Bluez shows the device as disconencted, however the device does not indicate any disconnect!

Sep 1 07:04:17 wlreceiver daemon.debug bluetoothd[1076]: ../bluez-5.54/src/device.c:att_disconnected_cb()
Sep 1 07:04:17 wlreceiver daemon.debug bluetoothd[1076]: ../bluez-5.54/src/device.c:att_disconnected_cb() Success (0)
Sep 1 07:04:17 wlreceiver daemon.debug bluetoothd[1076]: ../bluez-5.54/src/service.c:change_state() 0x58b438: device 00:07:29:4B:43:B4 profile gap-profile state changed: connected -> disconnecting (0)
Sep 1 07:04:17 wlreceiver daemon.debug bluetoothd[1076]: ../bluez-5.54/src/service.c:change_state() 0x58b438: device 00:07:29:4B:43:B4 profile gap-profile state changed: disconnecting -> disconnected (0)
Sep 1 07:04:17 wlreceiver daemon.debug bluetoothd[1076]: ../bluez-5.54/src/service.c:change_state() 0x584e20: device 00:07:29:4B:43:B4 profile batt-profile state changed: connected -> disconnecting (0)
Sep 1 07:04:17 wlreceiver daemon.debug bluetoothd[1076]: ../bluez-5.54/src/service.c:change_state() 0x584e20: device 00:07:29:4B:43:B4 profile batt-profile state changed: disconnecting -> disconnected (0)
Sep 1 07:04:17 wlreceiver daemon.debug bluetoothd[1076]: ../bluez-5.54/src/service.c:change_state() 0x585000: device 00:07:29:4B:43:B4 profile deviceinfo state changed: connected -> disconnecting (0)
Sep 1 07:04:17 wlreceiver daemon.debug bluetoothd[1076]: ../bluez-5.54/src/service.c:change_state() 0x585000: device 00:07:29:4B:43:B4 profile deviceinfo state changed: disconnecting -> disconnected (0)
Sep 1 07:04:17 wlreceiver daemon.debug bluetoothd[1076]: ../bluez-5.54/src/gatt-client.c:btd_gatt_client_disconnected() Device disconnected. Cleaning up.
Sep 1 07:04:17 wlreceiver daemon.debug bluetoothd[1076]: ../bluez-5.54/src/device.c:att_disconnected_cb() Automatic connection disabled
Sep 1 07:04:17 wlreceiver daemon.debug bluetoothd[1076]: ../bluez-5.54/src/device.c:gatt_service_removed() start: 0x0001, end: 0x0004
Sep 1 07:04:17 wlreceiver daemon.debug bluetoothd[1076]: ../bluez-5.54/src/gatt-client.c:btd_gatt_client_service_removed() GATT Services Removed - start: 0x0001, end: 0x0004
Sep 1 07:04:17 wlreceiver daemon.debug bluetoothd[1076]: ../bluez-5.54/src/gatt-client.c:unregister_service() Removing GATT service: /org/bluez/hci0/dev_00_07_29_4B_43_B4/service0001
Sep 1 07:04:17 wlreceiver daemon.debug bluetoothd[1076]: ../bluez-5.54/src/gatt-client.c:unregister_characteristic() Removing GATT characteristic: /org/bluez/hci0/dev_00_07_29_4B_43_B4/service0001/char0002
Sep 1 07:04:17 wlreceiver daemon.debug bluetoothd[1076]: ../bluez-5.54/src/gatt-client.c:unregister_descriptor() Removing GATT descriptor: /org/bluez/hci0/dev_00_07_29_4B_43_B4/service0001/char0002/desc0004
Sep 1 07:04:17 wlreceiver daemon.debug bluetoothd[1076]: ../bluez-5.54/src/device.c:gatt_service_removed() start: 0x0005, end: 0x000b
Sep 1 07:04:17 wlreceiver daemon.debug bluetoothd[1076]: ../bluez-5.54/src/service.c:change_state() 0x58b438: device 00:07:29:4B:43:B4 profile gap-profile state changed: disconnected -> unavailable (0)
Sep 1 07:04:17 wlreceiver daemon.debug bluetoothd[1076]: ../bluez-5.54/profiles/gap/gas.c:gap_remove() GAP profile remove (00:07:29:4B:43:B4)
Sep 1 07:04:17 wlreceiver daemon.debug bluetoothd[1076]: ../bluez-5.54/src/service.c:btd_service_unref() 0x58b438: ref=0
Sep 1 07:04:17 wlreceiver daemon.debug bluetoothd[1076]: ../bluez-5.54/src/gatt-client.c:btd_gatt_client_service_removed() GATT Services Removed - start: 0x0005, end: 0x000b
Sep 1 07:04:17 wlreceiver daemon.debug bluetoothd[1076]: ../bluez-5.54/src/device.c:gatt_service_removed() start: 0x000c, end: 0x000f
Sep 1 07:04:17 wlreceiver daemon.debug bluetoothd[1076]: ../bluez-5.54/src/service.c:change_state() 0x584e20: device 00:07:29:4B:43:B4 profile batt-profile state changed: disconnected -> unavailable (0)
Sep 1 07:04:17 wlreceiver daemon.debug bluetoothd[1076]: ../bluez-5.54/profiles/battery/battery.c:batt_remove() BATT profile remove (00:07:29:4B:43:B4)
Sep 1 07:04:17 wlreceiver daemon.debug bluetoothd[1076]: ../bluez-5.54/src/service.c:btd_service_unref() 0x584e20: ref=0
Sep 1 07:04:17 wlreceiver daemon.debug bluetoothd[1076]: ../bluez-5.54/src/gatt-client.c:btd_gatt_client_service_removed() GATT Services Removed - start: 0x000c, end: 0x000f
Sep 1 07:04:17 wlreceiver daemon.debug bluetoothd[1076]: ../bluez-5.54/src/device.c:gatt_service_removed() start: 0x0010, end: 0x001c
Sep 1 07:04:17 wlreceiver daemon.debug bluetoothd[1076]: ../bluez-5.54/src/service.c:change_state() 0x585000: device 00:07:29:4B:43:B4 profile deviceinfo state changed: disconnected -> unavailable (0)
Sep 1 07:04:17 wlreceiver daemon.debug bluetoothd[1076]: ../bluez-5.54/src/service.c:btd_service_unref() 0x585000: ref=0
Sep 1 07:04:17 wlreceiver daemon.debug bluetoothd[1076]: ../bluez-5.54/src/gatt-client.c:btd_gatt_client_service_removed() GATT Services Removed - start: 0x0010, end: 0x001c
Sep 1 07:04:17 wlreceiver daemon.debug bluetoothd[1076]: ../bluez-5.54/src/gatt-client.c:unregister_service() Removing GATT service: /org/bluez/hci0/dev_00_07_29_4B_43_B4/service0010
Sep 1 07:04:17 wlreceiver daemon.debug bluetoothd[1076]: ../bluez-5.54/src/gatt-client.c:unregister_characteristic() Removing GATT characteristic: /org/bluez/hci0/dev_00_07_29_4B_43_B4/service0010/char0011
Sep 1 07:04:17 wlreceiver daemon.debug bluetoothd[1076]: ../bluez-5.54/src/gatt-client.c:unregister_characteristic() Removing GATT characteristic: /org/bluez/hci0/dev_00_07_29_4B_43_B4/service0010/char0013
Sep 1 07:04:17 wlreceiver daemon.debug bluetoothd[1076]: ../bluez-5.54/src/gatt-client.c:unregister_characteristic() Removing GATT characteristic: /org/bluez/hci0/dev_00_07_29_4B_43_B4/service0010/char0015
Sep 1 07:04:17 wlreceiver daemon.debug bluetoothd[1076]: ../bluez-5.54/src/gatt-client.c:unregister_characteristic() Removing GATT characteristic: /org/bluez/hci0/dev_00_07_29_4B_43_B4/service0010/char0017
Sep 1 07:04:17 wlreceiver daemon.debug bluetoothd[1076]: ../bluez-5.54/src/gatt-client.c:unregister_characteristic() Removing GATT characteristic: /org/bluez/hci0/dev_00_07_29_4B_43_B4/service0010/char0019
Sep 1 07:04:17 wlreceiver daemon.debug bluetoothd[1076]: ../bluez-5.54/src/gatt-client.c:unregister_characteristic() Removing GATT characteristic: /org/bluez/hci0/dev_00_07_29_4B_43_B4/service0010/char001b
Sep 1 07:04:17 wlreceiver daemon.debug bluetoothd[1076]: ../bluez-5.54/src/device.c:gatt_service_removed() start: 0x001d, end: 0x003f
Sep 1 07:04:17 wlreceiver daemon.debug bluetoothd[1076]: ../bluez-5.54/src/gatt-client.c:btd_gatt_client_service_removed() GATT Services Removed - start: 0x001d, end: 0x003f
Sep 1 07:04:17 wlreceiver daemon.debug bluetoothd[1076]: ../bluez-5.54/src/gatt-client.c:unregister_service() Removing GATT service: /org/bluez/hci0/dev_00_07_29_4B_43_B4/service001d
Sep 1 07:04:17 wlreceiver daemon.debug bluetoothd[1076]: ../bluez-5.54/src/gatt-client.c:unregister_characteristic() Removing GATT characteristic: /org/bluez/hci0/dev_00_07_29_4B_43_B4/service001d/char001e
Sep 1 07:04:17 wlreceiver daemon.debug bluetoothd[1076]: ../bluez-5.54/src/gatt-client.c:unregister_descriptor() Removing GATT descriptor: /org/bluez/hci0/dev_00_07_29_4B_43_B4/service001d/char001e/desc0020
Sep 1 07:04:17 wlreceiver daemon.debug bluetoothd[1076]: ../bluez-5.54/src/gatt-client.c:unregister_characteristic() Removing GATT characteristic: /org/bluez/hci0/dev_00_07_29_4B_43_B4/service001d/char0021
Sep 1 07:04:17 wlreceiver daemon.debug bluetoothd[1076]: ../bluez-5.54/src/gatt-client.c:unregister_descriptor() Removing GATT descriptor: /org/bluez/hci0/dev_00_07_29_4B_43_B4/service001d/char0021/desc0023
Sep 1 07:04:17 wlreceiver daemon.debug bluetoothd[1076]: ../bluez-5.54/src/gatt-client.c:unregister_characteristic() Removing GATT characteristic: /org/bluez/hci0/dev_00_07_29_4B_43_B4/service001d/char0024
Sep 1 07:04:17 wlreceiver daemon.debug bluetoothd[1076]: ../bluez-5.54/src/gatt-client.c:unregister_descriptor() Removing GATT descriptor: /org/bluez/hci0/dev_00_07_29_4B_43_B4/service001d/char0024/desc0026
Sep 1 07:04:17 wlreceiver daemon.debug bluetoothd[1076]: ../bluez-5.54/src/gatt-client.c:notify_client_unref() owner :1.31
Sep 1 07:04:17 wlreceiver daemon.debug bluetoothd[1076]: ../bluez-5.54/src/gatt-client.c:notify_client_free() owner :1.31
Sep 1 07:04:17 wlreceiver daemon.debug bluetoothd[1076]: ../bluez-5.54/src/gatt-client.c:unregister_characteristic() Removing GATT characteristic: /org/bluez/hci0/dev_00_07_29_4B_43_B4/service001d/char0027
Sep 1 07:04:17 wlreceiver daemon.debug bluetoothd[1076]: ../bluez-5.54/src/gatt-client.c:unregister_descriptor() Removing GATT descriptor: /org/bluez/hci0/dev_00_07_29_4B_43_B4/service001d/char0027/desc0029
Sep 1 07:04:17 wlreceiver daemon.debug bluetoothd[1076]: ../bluez-5.54/src/gatt-client.c:notify_client_unref() owner :1.31
Sep 1 07:04:17 wlreceiver daemon.debug bluetoothd[1076]: ../bluez-5.54/src/gatt-client.c:notify_client_free() owner :1.31
Sep 1 07:04:17 wlreceiver daemon.debug bluetoothd[1076]: ../bluez-5.54/src/gatt-client.c:unregister_characteristic() Removing GATT characteristic: /org/bluez/hci0/dev_00_07_29_4B_43_B4/service001d/char002a
Sep 1 07:04:17 wlreceiver daemon.debug bluetoothd[1076]: ../bluez-5.54/src/gatt-client.c:unregister_descriptor() Removing GATT descriptor: /org/bluez/hci0/dev_00_07_29_4B_43_B4/service001d/char002a/desc002c
Sep 1 07:04:17 wlreceiver daemon.debug bluetoothd[1076]: ../bluez-5.54/src/gatt-client.c:unregister_characteristic() Removing GATT characteristic: /org/bluez/hci0/dev_00_07_29_4B_43_B4/service001d/char002d
Sep 1 07:04:17 wlreceiver daemon.debug bluetoothd[1076]: ../bluez-5.54/src/gatt-client.c:unregister_descriptor() Removing GATT descriptor: /org/bluez/hci0/dev_00_07_29_4B_43_B4/service001d/char002d/desc002f
Sep 1 07:04:17 wlreceiver daemon.debug bluetoothd[1076]: ../bluez-5.54/src/gatt-client.c:unregister_characteristic() Removing GATT characteristic: /org/bluez/hci0/dev_00_07_29_4B_43_B4/service001d/char0030
Sep 1 07:04:17 wlreceiver daemon.debug bluetoothd[1076]: ../bluez-5.54/src/gatt-client.c:unregister_characteristic() Removing GATT characteristic: /org/bluez/hci0/dev_00_07_29_4B_43_B4/service001d/char0032
Sep 1 07:04:17 wlreceiver daemon.debug bluetoothd[1076]: ../bluez-5.54/src/gatt-client.c:unregister_characteristic() Removing GATT characteristic: /org/bluez/hci0/dev_00_07_29_4B_43_B4/service001d/char0034
Sep 1 07:04:17 wlreceiver daemon.debug bluetoothd[1076]: ../bluez-5.54/src/gatt-client.c:unregister_characteristic() Removing GATT characteristic: /org/bluez/hci0/dev_00_07_29_4B_43_B4/service001d/char0036
Sep 1 07:04:17 wlreceiver daemon.debug bluetoothd[1076]: ../bluez-5.54/src/gatt-client.c:unregister_characteristic() Removing GATT characteristic: /org/bluez/hci0/dev_00_07_29_4B_43_B4/service001d/char0038
Sep 1 07:04:17 wlreceiver daemon.debug bluetoothd[1076]: ../bluez-5.54/src/gatt-client.c:unregister_characteristic() Removing GATT characteristic: /org/bluez/hci0/dev_00_07_29_4B_43_B4/service001d/char003a
Sep 1 07:04:17 wlreceiver daemon.debug bluetoothd[1076]: ../bluez-5.54/src/gatt-client.c:unregister_characteristic() Removing GATT characteristic: /org/bluez/hci0/dev_00_07_29_4B_43_B4/service001d/char003c
Sep 1 07:04:17 wlreceiver daemon.debug bluetoothd[1076]: ../bluez-5.54/src/gatt-client.c:unregister_characteristic() Removing GATT characteristic: /org/bluez/hci0/dev_00_07_29_4B_43_B4/service001d/char003e
Sep 1 07:04:17 wlreceiver daemon.debug bluetoothd[1076]: ../bluez-5.54/src/device.c:gatt_service_removed() start: 0x0040, end: 0x0056
Sep 1 07:04:17 wlreceiver daemon.debug bluetoothd[1076]: ../bluez-5.54/src/gatt-client.c:btd_gatt_client_service_removed() GATT Services Removed - start: 0x0040, end: 0x0056
Sep 1 07:04:17 wlreceiver daemon.debug bluetoothd[1076]: ../bluez-5.54/src/gatt-client.c:unregister_service() Removing GATT service: /org/bluez/hci0/dev_00_07_29_4B_43_B4/service0040
Sep 1 07:04:17 wlreceiver daemon.debug bluetoothd[1076]: ../bluez-5.54/src/gatt-client.c:unregister_characteristic() Removing GATT characteristic: /org/bluez/hci0/dev_00_07_29_4B_43_B4/service0040/char0041
Sep 1 07:04:17 wlreceiver daemon.debug bluetoothd[1076]: ../bluez-5.54/src/gatt-client.c:unregister_characteristic() Removing GATT characteristic: /org/bluez/hci0/dev_00_07_29_4B_43_B4/service0040/char0043
Sep 1 07:04:17 wlreceiver daemon.debug bluetoothd[1076]: ../bluez-5.54/src/gatt-client.c:unregister_characteristic() Removing GATT characteristic: /org/bluez/hci0/dev_00_07_29_4B_43_B4/service0040/char0045
Sep 1 07:04:17 wlreceiver daemon.debug bluetoothd[1076]: ../bluez-5.54/src/gatt-client.c:unregister_characteristic() Removing GATT characteristic: /org/bluez/hci0/dev_00_07_29_4B_43_B4/service0040/char0047
Sep 1 07:04:17 wlreceiver daemon.debug bluetoothd[1076]: ../bluez-5.54/src/gatt-client.c:unregister_characteristic() Removing GATT characteristic: /org/bluez/hci0/dev_00_07_29_4B_43_B4/service0040/char0049
Sep 1 07:04:17 wlreceiver daemon.debug bluetoothd[1076]: ../bluez-5.54/src/gatt-client.c:unregister_characteristic() Removing GATT characteristic: /org/bluez/hci0/dev_00_07_29_4B_43_B4/service0040/char004b
Sep 1 07:04:17 wlreceiver daemon.debug bluetoothd[1076]: ../bluez-5.54/src/gatt-client.c:unregister_characteristic() Removing GATT characteristic: /org/bluez/hci0/dev_00_07_29_4B_43_B4/service0040/char004d
Sep 1 07:04:17 wlreceiver daemon.debug bluetoothd[1076]: ../bluez-5.54/src/gatt-client.c:unregister_characteristic() Removing GATT characteristic: /org/bluez/hci0/dev_00_07_29_4B_43_B4/service0040/char004f
Sep 1 07:04:17 wlreceiver daemon.debug bluetoothd[1076]: ../bluez-5.54/src/gatt-client.c:unregister_characteristic() Removing GATT characteristic: /org/bluez/hci0/dev_00_07_29_4B_43_B4/service0040/char0051
Sep 1 07:04:17 wlreceiver daemon.debug bluetoothd[1076]: ../bluez-5.54/src/gatt-client.c:unregister_characteristic() Removing GATT characteristic: /org/bluez/hci0/dev_00_07_29_4B_43_B4/service0040/char0053
Sep 1 07:04:17 wlreceiver daemon.debug bluetoothd[1076]: ../bluez-5.54/src/gatt-client.c:unregister_characteristic() Removing GATT characteristic: /org/bluez/hci0/dev_00_07_29_4B_43_B4/service0040/char0055
Sep 1 07:04:17 wlreceiver daemon.debug bluetoothd[1076]: ../bluez-5.54/src/device.c:gatt_service_removed() start: 0x0057, end: 0x005a
Sep 1 07:04:17 wlreceiver daemon.debug bluetoothd[1076]: ../bluez-5.54/src/gatt-client.c:btd_gatt_client_service_removed() GATT Services Removed - start: 0x0057, end: 0x005a
Sep 1 07:04:17 wlreceiver daemon.debug bluetoothd[1076]: ../bluez-5.54/src/gatt-client.c:unregister_service() Removing GATT service: /org/bluez/hci0/dev_00_07_29_4B_43_B4/service0057
Sep 1 07:04:17 wlreceiver daemon.debug bluetoothd[1076]: ../bluez-5.54/src/gatt-client.c:unregister_characteristic() Removing GATT characteristic: /org/bluez/hci0/dev_00_07_29_4B_43_B4/service0057/char0058
Sep 1 07:04:17 wlreceiver daemon.debug bluetoothd[1076]: ../bluez-5.54/src/gatt-client.c:unregister_descriptor() Removing GATT descriptor: /org/bluez/hci0/dev_00_07_29_4B_43_B4/service0057/char0058/desc005a
Sep 1 07:04:17 wlreceiver daemon.debug bluetoothd[1076]: ../bluez-5.54/src/gatt-database.c:btd_gatt_database_att_disconnected()
Sep 1 07:04:17 wlreceiver daemon.debug bluetoothd[1076]: ../bluez-5.54/attrib/gattrib.c:g_attrib_unref() 0x584568: g_attrib_unref=0

</details>

@carlescufi
Copy link
Member

carlescufi commented Sep 2, 2021

We have an application based on a nrf52840. We see k_sem_take failed with err -11 assertion when we stress the device with a lot of notifications and read requests at the same time.

To add information to this issue for future reference:

@caco3
Copy link
Contributor Author

caco3 commented Sep 3, 2021

👍

Just for clarification:

The embedded side (peripheral) sends data at high throughput and the central fails to receive it due to the USB issue currently being described

The stalling issue only occures, once I start to do excessive GATT reads from the central to the peripheral while the peripheral still transmitts data at the high throughput

@jfischer-no jfischer-no self-assigned this Sep 3, 2021
@carlescufi
Copy link
Member

I do not have an USB-Analyzer at hand, but we ordered one

Can you please attach the trace once you have it?
Also, could you please add more information about the SBC/Linux board that shows the symptoms? SoC, kernel version, bluez version USB controller, etc. @jfischer-no suspects the Host USB controller to be at fault, so it'd be good to rule that out if it's not the case.

@caco3
Copy link
Contributor Author

caco3 commented Sep 14, 2021

Sorry for the late response.

Below some information about the system:

> cat /proc/cpuinfo
processor       : 0
model name      : ARMv7 Processor rev 2 (v7l)
BogoMIPS        : 597.60
Features        : half thumb fastmult vfp edsp thumbee neon vfpv3 tls vfpd32 
CPU implementer : 0x41
CPU architecture: 7
CPU variant     : 0x3
CPU part        : 0xc08
CPU revision    : 2
Hardware        : Generic AM33XX (Flattened Device Tree)
Revision        : 0000
Serial          : 1

Our system is based on a AM335x. The USB-Controller is built in.
Also there is no other USB device connected to the system:

> lsusb
Bus 002 Device 006: ID 1545:0001 *** *** BLE Adapter     < This is our BLE receiver
Bus 002 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub

I went through the AM335x Errata and found one issue on page 18 that might be related:

  • Advisory 1.0.11 USB: Attached Non-compliant USB Device that Responds to Spurious Invalid Short Packet May Lock Up Bus

I hope to be able to provide some USB traces in the next 1..2 weeks.

@jfischer-no
Copy link
Collaborator

Our system is based on a AM335x. The USB-Controller is built in.

I have an AM335x SBC somewhere. Can you please tell who is the manufacturer of your SoM/SBC, gladly privately if it is confidential.

@caco3
Copy link
Contributor Author

caco3 commented Sep 15, 2021

The module is designed by us, thus very specific and proprietary.

@carlescufi carlescufi added area: USB Universal Serial Bus priority: low Low impact/importance bug and removed priority: medium Medium impact/importance bug labels Sep 15, 2021
@carlescufi
Copy link
Member

Downgrading this from Medium to Low since it now looks it could be a USB Host issue on the Linux SBC side. The actual Bluetooth bug that started this issue is already covered by #25917 already, and is listed as a known issue for now, with a workaround in #26057. Discussion can continue here to try and narrow down whether the USB issue can be attributed exclusively to the Linux side or whether there is potentially an issue on the Zephyr side.

@cfriedt cfriedt removed this from the v2.7.0 milestone Sep 28, 2021
@caco3
Copy link
Contributor Author

caco3 commented Sep 29, 2021

@jfischer-no Sorry for the late response 😒 . I finally got the logic analyzer. How ever I had to realize it only supports USB 1.1 but the BLE dongle runs with USB 2.0. So at the moment, I am not able to provide a logic analyzer trace.

Where you able to investigate something with your board?

@jfischer-no
Copy link
Collaborator

Where you able to investigate something with your board?

No, TBH it would take a lot of time which I do not currently have.

@carlescufi carlescufi removed the Waiting for response Waiting for author's response label Oct 6, 2021
@carlescufi
Copy link
Member

@caco3 it would be good if you could narrow down the problem to find out whether this can indeed be Zephyr related or not. At the moment this doesn't look like it, so I would like to close the issue if possible.

@caco3
Copy link
Contributor Author

caco3 commented Oct 6, 2021

The only way I see is to get an USB 2.0 sniffer. Sadly we don't have one and this issue atm. is not very high on the priority list on our side. 😒
Because of this I agree to close it for now.

@caco3 caco3 closed this as completed Oct 6, 2021
@caco3
Copy link
Contributor Author

caco3 commented Oct 27, 2021

Dear @jfischer-no and @carlescufi

Some new information:

  • We finally found an alternative BLE Adapter which supports the 2MB Phy: EDIMAX BT-8500.
    With this adapter, we no longer can trigger the stalling!
    I see two possible reasons for this:
    1. There is an issue within the Zephyr HCI-USB sample or Zephyr itself.
    2. We run into the Host CPU issue (see TI errata noted in comment above). How ever also here the root cause might be a Zephyr issue.
  • With this EDIMAX BT-8500 adapter the patch no longer is required (most likely because we don't run into the lockup issue anymore at all).

@cvinayak
Copy link
Contributor

@caco3 Thank you for the information, hope in the future we are able to reproduce the issue in a control setup and have a fix it (hope I can remember this issue if in future if any new related issue is created).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: Bluetooth Host area: Bluetooth area: USB Universal Serial Bus bug The issue is a bug, or the PR is fixing a bug priority: low Low impact/importance bug
Projects
None yet
Development

No branches or pull requests

6 participants