From e2eb773c3052ab302d4d9f700f4909870667197e Mon Sep 17 00:00:00 2001 From: Cao Sen Miao Date: Mon, 4 Sep 2023 11:55:48 +0800 Subject: [PATCH] fix(usb_serial_jtag): Fix usb_serial_jtag wrong return value, vfs lose data randomly, Closes https://github.com/espressif/esp-idf/issues/12119, Closes https://github.com/espressif/esp-idf/pull/11344, Closes https://github.com/espressif/esp-idf/issues/9318 Closes https://github.com/espressif/esp-idf/issues/11192 --- components/driver/usb_serial_jtag.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/components/driver/usb_serial_jtag.c b/components/driver/usb_serial_jtag.c index 3f7db5ee8f..2e4f7be0f6 100644 --- a/components/driver/usb_serial_jtag.c +++ b/components/driver/usb_serial_jtag.c @@ -171,10 +171,10 @@ int usb_serial_jtag_write_bytes(const void* src, size_t size, TickType_t ticks_t const uint8_t *buff = (const uint8_t *)src; // Blocking method, Sending data to ringbuffer, and handle the data in ISR. - xRingbufferSend(p_usb_serial_jtag_obj->tx_ring_buf, (void*) (buff), size, ticks_to_wait); + BaseType_t result = xRingbufferSend(p_usb_serial_jtag_obj->tx_ring_buf, (void*) (buff), size, ticks_to_wait); // Now trigger the ISR to read data from the ring buffer. usb_serial_jtag_ll_ena_intr_mask(USB_SERIAL_JTAG_INTR_SERIAL_IN_EMPTY); - return size; + return (result == pdFALSE) ? 0 : size; } esp_err_t usb_serial_jtag_driver_uninstall(void)