4 Replies Latest reply on Aug 8, 2017 7:55 PM by lx00n.sh

    STM32f4 USB HS HAL Driver bugs  

    Alexey Antipov

      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.

        • Re: STM32f4 USB HS HAL Driver bugs  
          mukherjee.bhaskar

          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.

          • Re: STM32f4 USB HS HAL Driver bugs  
            Khouloud G

            Hi Alexey Antipov,

             

            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.

            • Re: STM32f4 USB HS HAL Driver bugs  
              Rajesh Gali

              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

              • Re: STM32f4 USB HS HAL Driver bugs  
                lx00n.sh

                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 ...