cancel
Showing results for 
Search instead for 
Did you mean: 

When enable USBHS internal IP DMA, STM32F746 discovery board fail to enumerate.

michaelhuhui
Associate
Posted on February 08, 2017 at 20:27

I use STM32CubeMX to generate STM32F46 discovery board project, just enable 'USBHS internal IP DMA',  Choose CDC class, show as the attached picture 01, when I compile and run the firmware, connect the USB HS port, I use the USBView.exe from win10 to check the USB information, it shows 'FailedEnumeration', show as the pitcture02. If I disable 

'USBHS internal IP DMA', then everything will be fine. Can anybody tell me how use the USBHS internal IP DMA?Is any other setting I should do? Thanks!

4 REPLIES 4
Vito Marolda
Associate III
Posted on April 27, 2017 at 22:57

Facing the same issue here.

Moreover, if I disable 'Enable Internal IP DMA', thenCubeMX automatically #defines _USE_BUFF_WO_ALIGNMENT 1.

This is creating problems in my application, returning incomplete f_reads when FatFs invokes USBH_read, requesting chunks of data on misaligned buffer boundaries (eventually due to file seeks, as in my application).

So, now I am in the situation where the system does not work reliably in either way (

'Enable Internal IP DMA' enabled or disabled).

The only way I got it working is keeping 

'Enable Internal IP DMA' disabled, but then manually forcing the #define _USE_BUFF_WO_ALIGNMENT to 0.

But, in this way, I manually force CubeMX settings, which breaks the alignment.

Anyone got reliable operation in either way with STM32F746?

Vito Marolda
Associate III
Posted on April 28, 2017 at 09:43

Update: I have seen that on example projects for USB Host and FatFs in STM32Cube_FW_F7_V1.7.0, dma is disabled: anyone knows why? Is it known as being defective?

Anyway, with dma disabled there is no need to check for buffer alignment, so I changed the check in USBH_write and USBH_read (in usbh_diskio.c) as follows:

 extern HCD_HandleTypeDef hhcd_USB_OTG_FS;
 if (hhcd_USB_OTG_FS.Init.dma_enable && ((DWORD)buff & 3)) /* DMA Alignment issue, do single up to aligned buffer */
�?�?�?

In this way, the alignment check is only performed if dma was enabled during initialization.

Now I would like to figure out how to modify usbh_diskio.c in a manner that it remains stable if I regenerate the project with CubeMX.

JGerb
Associate III

I can confirm same issue here with STM32CubeMX and USB host, FatFs and the STM32L476 discovery board - if I enable internal IP DMA, it fails to enumerate. I presume this is the correct way to enable DMA transfers to the USB? It would be good to know if there's a significant speed improvement with DMA (as one would expect) as current transfers seem slow. I will ask our local ST guru if this has been solved and revert.

JGerb
Associate III

Response from our local ST rep:

Feedback on this from my ticket:

In fact this parameter should not be set in FS configuration as dedicated DMA controller is only for USB_OTG_HS.

STM32L476VC is USB OTG full-speed ( and not High speed )and in the header of HAL:

uint32_t dma_enable;      /*!< Enable or disable of the USB embedded DMA used only for OTG HS. 

CubeMx should not allowed to set this parameter ( or ignore this value) in your case. I created (Ticket 59316) a ticket internally about this issue and let you know when I receive any information.