mirror of
https://github.com/espressif/esp-idf.git
synced 2026-10-02 11:10:54 +03:00
Merge branch 'bugfix/c3_uhci_rx_fail_v6.0' into 'release/v6.0'
fix(ble): fix(ble): fix assert caused by ringbuffer read size not matching controller expected rx size(v6.0) See merge request espressif/esp-idf!44623
This commit is contained in:
@@ -161,20 +161,29 @@ static void uhci_rx_done_process_task(void *arg)
|
|||||||
{
|
{
|
||||||
size_t item_size = 0;
|
size_t item_size = 0;
|
||||||
uint8_t *data = NULL;
|
uint8_t *data = NULL;
|
||||||
while (1) {
|
size_t items_waiting = 0;
|
||||||
xSemaphoreTake(uart_env.rx_process_sema, portMAX_DELAY);
|
|
||||||
data = xRingbufferReceiveUpTo(uart_env.ringbufhandle, &item_size, portMAX_DELAY, uart_env.rx.size);
|
|
||||||
if (item_size != uart_env.rx.size) {
|
|
||||||
assert(0);
|
|
||||||
}
|
|
||||||
memcpy(uart_env.rx.buf, data, item_size);
|
|
||||||
vRingbufferReturnItem(uart_env.ringbufhandle, data);
|
|
||||||
|
|
||||||
|
xSemaphoreTake(uart_env.rx_process_sema, portMAX_DELAY);
|
||||||
|
while (1) {
|
||||||
|
data = xRingbufferReceiveUpTo(uart_env.ringbufhandle, &item_size, portMAX_DELAY, uart_env.rx.size);
|
||||||
|
// prepare next receive
|
||||||
if (uart_env.rx_eof) {
|
if (uart_env.rx_eof) {
|
||||||
uhci_receive(uart_env.uhci_handle, uart_env.rx_data_buffer, UHCI_MAX_RX_BUFFER_SIZE);
|
uhci_receive(uart_env.uhci_handle, uart_env.rx_data_buffer, UHCI_MAX_RX_BUFFER_SIZE);
|
||||||
uart_env.rx_eof = false;
|
uart_env.rx_eof = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
memcpy(uart_env.rx.buf, data, item_size);
|
||||||
|
vRingbufferReturnItem(uart_env.ringbufhandle, data);
|
||||||
|
uart_env.rx.size -= item_size;
|
||||||
|
uart_env.rx.buf += item_size;
|
||||||
|
if (uart_env.rx.size) {
|
||||||
|
vRingbufferGetInfo(uart_env.ringbufhandle, NULL, NULL, NULL, NULL, &items_waiting);
|
||||||
|
if (items_waiting < uart_env.rx.size) {
|
||||||
|
ESP_LOGW(tag, "Ring buffer items size less than expected");
|
||||||
|
}
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
assert(uart_env.rx.callback != NULL);
|
assert(uart_env.rx.callback != NULL);
|
||||||
esp_bt_hci_tl_callback_t callback = uart_env.rx.callback;
|
esp_bt_hci_tl_callback_t callback = uart_env.rx.callback;
|
||||||
void *arg = uart_env.rx.arg;
|
void *arg = uart_env.rx.arg;
|
||||||
@@ -182,13 +191,14 @@ static void uhci_rx_done_process_task(void *arg)
|
|||||||
// clear callback pointer
|
// clear callback pointer
|
||||||
uart_env.rx.callback = NULL;
|
uart_env.rx.callback = NULL;
|
||||||
uart_env.rx.arg = NULL;
|
uart_env.rx.arg = NULL;
|
||||||
uart_env.rx.size = 0;
|
|
||||||
|
|
||||||
// call handler
|
// call handler
|
||||||
callback(arg, ESP_BT_HCI_TL_STATUS_OK);
|
callback(arg, ESP_BT_HCI_TL_STATUS_OK);
|
||||||
|
|
||||||
// send notification to Bluetooth Controller task
|
// send notification to Bluetooth Controller task
|
||||||
esp_bt_h4tl_eif_io_event_notify(1);
|
esp_bt_h4tl_eif_io_event_notify(1);
|
||||||
|
|
||||||
|
xSemaphoreTake(uart_env.rx_process_sema, portMAX_DELAY);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user