From d6bfa87c8df20adc6e7448b03697a09547ac4812 Mon Sep 17 00:00:00 2001 From: dongjiuzhu1 Date: Thu, 22 Feb 2024 22:34:47 +0800 Subject: [PATCH] drivers/usbdev: support send ZLP(zero length packet) data packet in bulkin status = write(g_usb_ep_in, (void*)0xFEE1DEAD, 0); sched_backtrace nuttx/arch/arm/src/../../../sched/sched/sched_backtrace.c:57 _assert nuttx/arch/arm/src/../../../sched/misc/assert.c:659 __assert nuttx/arch/arm/src/../../../libs/libc/assert/lib_assert.c:36 usbdev_fs_write nuttx/arch/arm/src/../../../drivers/usbdev/usbdev_fs.c:770 (discriminator 1) file_write nuttx/arch/arm/src/../../../fs/vfs/fs_write.c:91 nx_write nuttx/arch/arm/src/../../../fs/vfs/fs_write.c:148 ffs_transport_thread_usb_write nuttx/arch/arm/src/../../../../external/mtp-responder/mtp-responder/src/mtp_usb_driver_nuttx.c:224 _transport_thread_usb_write nuttx/arch/arm/src/../../../../external/mtp-responder/mtp-responder/src/mtp_usb_driver.c:80 pthread_startup nuttx/arch/arm/src/../../../libs/libc/pthread/pthread_create.c:59 (discriminator 2) Signed-off-by: dongjiuzhu1 --- drivers/usbdev/usbdev_fs.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/drivers/usbdev/usbdev_fs.c b/drivers/usbdev/usbdev_fs.c index 5d889948b9..9d3697316d 100644 --- a/drivers/usbdev/usbdev_fs.c +++ b/drivers/usbdev/usbdev_fs.c @@ -721,7 +721,7 @@ static ssize_t usbdev_fs_write(FAR struct file *filep, /* Device ready for write */ - while (len > 0 && !sq_empty(&fs_ep->reqq)) + while (!sq_empty(&fs_ep->reqq)) { uint16_t cur_len; @@ -764,9 +764,12 @@ static ssize_t usbdev_fs_write(FAR struct file *filep, wlen += cur_len; len -= cur_len; + if (len == 0) + { + break; + } } - assert(wlen > 0); ret = wlen; errout: