Skip to content

Commit

Permalink
aux_serial: Increase UART DMA buffer sizes for USB HS
Browse files Browse the repository at this point in the history
* usbd_ep_read_packet for a 64 byte FS bulk packet uses a 128-byte DMA bounce buffer okay,
  but for a 512 byte HS bulk packet will overflow it and corrupt adjacent .bss variables.
* Allocate more space for both buffers, fixing stlinkv3.
  • Loading branch information
ALTracer committed Jul 14, 2024
1 parent a265cdc commit 0c4f304
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/platforms/common/aux_serial.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,14 @@

#if defined(STM32F0) || defined(STM32F1) || defined(STM32F3) || defined(STM32F4) || defined(STM32F7)
/* XXX: Does the st_usbfs_v2_usb_driver work on F3 with 128 byte buffers? */
#if defined(STM32F1) || defined(STM32F3) || defined(STM32F4) || defined(STM32F7)
#if defined(STM32F1) || defined(STM32F3) || defined(STM32F4)
#define USART_DMA_BUF_SHIFT 7U
#elif defined(STM32F0)
/* The st_usbfs_v2_usb_driver only works with up to 64-byte buffers on the F0 parts */
#define USART_DMA_BUF_SHIFT 6U
#elif defined(STM32F7)
/* HS bulk packets are 512 bytes, use 2x that */
#define USART_DMA_BUF_SHIFT 10U
#endif

#define USART_DMA_BUF_SIZE (1U << USART_DMA_BUF_SHIFT)
Expand Down

0 comments on commit 0c4f304

Please sign in to comment.