From 84fc40085ea825e890d65ce4e5e4d87b51ea588d Mon Sep 17 00:00:00 2001 From: Gareth McMullin Date: Wed, 6 Aug 2014 12:38:57 +1200 Subject: [PATCH] Send a null packet on end of USB transfer if last data packet is full. --- src/platforms/stm32/gdb_if.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/platforms/stm32/gdb_if.c b/src/platforms/stm32/gdb_if.c index 3ea7d14..28bc4c8 100644 --- a/src/platforms/stm32/gdb_if.c +++ b/src/platforms/stm32/gdb_if.c @@ -47,6 +47,18 @@ void gdb_if_putchar(unsigned char c, int flush) } while(usbd_ep_write_packet(usbdev, CDCACM_GDB_ENDPOINT, buffer_in, count_in) <= 0); + + if (flush && (count_in == CDCACM_PACKET_SIZE)) { + /* We need to send an empty packet for some hosts + * to accept this as a complete transfer. */ + /* libopencm3 needs a change for us to confirm when + * that transfer is complete, so we just send a packet + * containing a null byte for now. + */ + while (usbd_ep_write_packet(usbdev, CDCACM_GDB_ENDPOINT, + "\0", 1) <= 0); + } + count_in = 0; } }