cancel
Showing results for 
Search instead for 
Did you mean: 

STM32f4 USB HS HAL Driver bugs

Alexey Antipov
Associate
Posted on April 19, 2017 at 23:28

Hello.

I'm working on application of USB communication with high speed (about 50 Mbit/s). So I used ULPI PHY.

For some purpose I used CubeMX (v 4.20.1) and was surprising that my application didn't work.  Enabling DMA on USB controller crashed all communications but I needed it for high speed. I started to trace the code and found some bugs in HAL Driver:

1. DMA doesn't enable properly.

2. Dedicated interrupts for endpoint1 doesn't set properly.

After I fixed these  bugs my application started work properly. I can't find any mention of resolving the same problem in the Internet and I hope that my information is helpful.

I attached two patches for stm32f4xx_hal_pcd.c and stm32f4xx_ll_usb.c files to this message.

#bug #hal-bug
5 REPLIES 5
bhaskarm
Associate II
Posted on June 18, 2017 at 22:45

Hello Alex,

    I would like to thank you for posting these patches on the forum. I was facing the same issue on my design and there is absolutely no information about this bug anywhere. Adding your patches to my code allowed the board to start enumerating again.

    You took the time to write this post and upload the patches which have saved me a lot of time debugging on my own. Anyone trying to use the USB HS DMA on the STM32F429 and facing an issue where the board fails to enumerate after enabling the DMA, should use this patch.

    Anyone from ST reading this thread should report this bug to the CubeMX team and include Alex's patches in the next release.

Thanks for the good work Alex.

Khouloud GARSI
Lead II
Posted on June 19, 2017 at 12:50

Hi

Antipov.Alexey

,

Thank you very much for posting your findings here.

This is reported internally for check and I will keep you posted about any update regarding this point.

Thanks again

Khouloud.

Rajesh Gali
Associate
Posted on June 28, 2017 at 21:36

Hi Alex, 

I am trying to use ULPI Ext PHY with STM32F4 and having difficulties to write/read ext phy registers via ULPI. It seems to be ST doesn't provide any API's to access those registers directly(to send custom PID data packets over ULPI).

I was wondering were you able to access ext phy registers? would you mind to share ext phy part number?

Thank you in advance. 

Regards,

Raj

andre23
Associate II
Posted on August 08, 2017 at 19:55

Thanks for that.

I Had a similar Problem with STM32F429  + ULPI + USB2.0 in Device-Mode.

With CubeF4 1.13.1 all works Fine. After upgrade to 1.16.0 a new VCP-Project on the STM32429I-EVAL with DMA was not Working.  I made a Diff over the Driver-Files and figured out the important change :

In 'stm32f4xx_hal_pcd.c' the Function 'HAL_PCD_EP_Receive' need a surrounding lock to transfer-Function-calls.

From

  if ((ep_addr & 0x7F) == 0)

  {

    USB_EP0StartXfer(hpcd->Instance , ep, hpcd->Init.dma_enable);

  }

  else

  {

    USB_EPStartXfer(hpcd->Instance , ep, hpcd->Init.dma_enable);

  }

To

  __HAL_LOCK(hpcd);

  if ((ep_addr & 0x7F) == 0)

  {

    USB_EP0StartXfer(hpcd->Instance , ep, hpcd->Init.dma_enable);

  }

  else

  {

    USB_EPStartXfer(hpcd->Instance , ep, hpcd->Init.dma_enable);

  }

  __HAL_UNLOCK(hpcd);

With this 2 new (old) Lines , the Enumeration will Proceed in 1.16.0. , but Iam still testing ...

Matthew M
Associate II
Posted on January 21, 2018 at 21:07

Hi,

I started working with AUDIO device class to my DIY project and found similar issue with USB device stackin Cube v1. The audio device did not pass enumeration, just giving up on the device descriptor request. I eventually discovered that disabling DMA in USBD_LL_Init() fixed the problem. I tracked it down by comparing the initialization code with existing CDC examples (which ran without any issues).

I was very fortunate to find this post - the HAL driver patches

Antipov.Alexey

was so kind to share with us seem to solve the problem. This post likely saved me hours of debugging, because I didn't want to give up from DMA. Thanks!

Best regards,

MM

P.S. I used USB_HS_IN_FSmode - not ULPI, BTW