Skip to content

Commit

Permalink
rtt: fix hang when aux serial not read
Browse files Browse the repository at this point in the history
  • Loading branch information
koendv authored and dragonmux committed Sep 18, 2023
1 parent c7ebdb7 commit 42f4a29
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/platforms/common/stm32/rtt_if.c
Original file line number Diff line number Diff line change
Expand Up @@ -121,8 +121,11 @@ uint32_t rtt_write(const char *buf, uint32_t len)
if (len != 0 && usbdev && usb_get_config() && gdb_serial_get_dtr()) {
for (uint32_t p = 0; p < len; p += CDCACM_PACKET_SIZE) {
uint32_t plen = MIN(CDCACM_PACKET_SIZE, len - p);
while (usbd_ep_write_packet(usbdev, CDCACM_UART_ENDPOINT, buf + p, plen) <= 0)
continue;
uint32_t start_ms = platform_time_ms();
while (usbd_ep_write_packet(usbdev, CDCACM_UART_ENDPOINT, buf + p, plen) <= 0) {
if (platform_time_ms() - start_ms >= 25)
return 0; /* drop silently */
}
}
/* flush 64-byte packet on full-speed */
if (CDCACM_PACKET_SIZE == 64 && (len % CDCACM_PACKET_SIZE) == 0)
Expand Down

0 comments on commit 42f4a29

Please sign in to comment.