cancel
Showing results for 
Search instead for 
Did you mean: 

STM32F7 HAL LL Driver Bug

MDS
Associate III
Posted on December 05, 2017 at 16:40

I am using the USB FS device with the CDC class. I used STM32CubeMX V4.23.0 with the STM32CubeF7 V1.8.0 add-on. The max packet size is set to 64 bytes and the EP TX FIFO buffer for the EP is set to 64 bytes in USBD_LL_Init(). I was sending various sized messages over the IN pipe. When I tried to send a 64-byte message, it failed...no transmit complete callback. Stepping through stm32f7xx_hal_pcd.c, I discovered in PCD_WriteEmptyTxFifo() #1287 (see code below) the packet was not being written to the Tx FIFO for transmission. Here is the code in question:

while

( (USBx_INEP(epnum)->

DTXFSTS

& USB_OTG_DTXFSTS_INEPTFSAV) > len32b &&

// Fixed when changed > to >=

            ep->

xfer_count

< ep->

xfer_len

&&

            ep->

xfer_len

!= 0)

What is happening is that when a packet is rounded to long words and 'len32b' 

equals the Tx FIFO buffer size, the first condition of the above while() fails and the packet is not written to the FIFO. A re-enumeration is required to restore the EP to working.

When the '>' is changed to '>=', it works. I suspect that because packet sizes 61-64 bytes will round to 16 long words, all packets of these sizes will also fail. I verified that 63 byte packet fail. Probably increasing the Tx FIFO size to 128 bytes would also solve the issue, but I am using almost all of the EPs and I have run out of Tx FIFO buffer total size (1280 bytes).

Please correct this error and check for other boundary conditions in the next HAL release.

2 REPLIES 2
MDS
Associate III
Posted on February 23, 2018 at 18:20

I also see the problem with the STM32H7 driver. I am using STM32CubeMX V4.24.0 and STM32H7xx V1.2.0. The line of code is here:

stm32f7xx_hal_pcd.c, PCD_WriteEmptyTxFifo(), #1310.

Posted on February 27, 2018 at 19:09

Re-posted in

https://community.st.com/0D50X00009XkYNTSA3