cancel
Showing results for 
Search instead for 
Did you mean: 

STM32F7 USB library supporting multi-packet mode

jean-pierre
Associate II
Posted on August 15, 2017 at 23:50

Hi,

I need high USB bandwidth in isochronous mode. The STM32F7 is powerful but the bandwidth depends on how the USB packet management is done.

Is there a plan to support multi-packet mode in the HAL/lib/driver that come with STM32CubeMX?

The USB standard allows up to 3 packets per interval [3 x 1024 bytes every 125 ?s in high speed].

This feature is supported in the 'USB On-The-Go Host and Device Library', but it targets only F1/2/3/4 devices and is not easy to mix with CubeMX code.

An equivalent of DCD_EP_Tx, DCD_EP_PrepareRx, and so on. (with DMA support) in the LL layer produced by CubeMX would be ideal.

Thanks for your help.

#stm32f7
4 REPLIES 4
sirius506
Associate III
Posted on August 16, 2017 at 02:37

Hi,

Are you working on device side?

I need attached changes into stm32f4_ll_usb.c when I worked on STM32F446 device side.

I believe similar changes are required to enable multi-packet on F7, too.

DMA is another topic and below thread may help you.

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

With all above changes, I can send two packs in a micro-frame period

(125 μs)

with DMA.

If I sent three packets, it looks DMA doesn't work well.

I confirmed that I can sendthree packets without DMA, but it is really CPU eater. :(

I know that host side code have similar problem to handle ISOC multi-packets, but I don't have the fix now.

________________

Attachments :

stm32f4xx_ll_usb.diff.zip : https://st--c.eu10.content.force.com/sfc/dist/version/download/?oid=00Db0000000YtG6&ids=0680X000006HyV9&d=%2Fa%2F0X0000000b8l%2FMpGd2DF5rKy8sdcj735v6AHDcRCWMdrHtXiCZM_ilQc&asPdf=false
Posted on August 16, 2017 at 15:31

Hi,

Yes, I am working on the device side.

Thank you for the fix but I still don't understand how the multi-packet mode works.

In my stm32f4xx_ll_usb.c this part seems dedicated to 'in' EP. My concern is for 'out'.

I admit that I didn't dig a lot for now; I will do it later.

I have to understand how the packet transmission within a single timeframe is handled.

Ideally I want to send a 3072 byte buffer in 3 packets of 1024 bytes per interval (maximum possible). I wonder at which level the split of the large buffer is done.

Concerning the DMA mode, it didn't work until I changed 

HAL_PCDEx_SetTxFiFo(&hpcd_USB_OTG_HS, 0, 0x80);

into

HAL_PCDEx_SetTxFiFo(&hpcd_USB_OTG_HS, 0, 0x40);

I can't remember the exact explanation that I understood at the time I did it...

Regards,

Jean-Pierre

Posted on August 17, 2017 at 04:37

In my stm32f4xx_ll_usb.c this part seems dedicated to 'in' EP. My concern is for 'out.

Oh, Yes.   My fix is for the 'in ep' behavior which always send only one packet in

DEVICE to HOST direction.

Because it looks USB_EPStartXfer() computes and set correct number of packets (pktpcnt)

into DOEPTSIZ register, I guess your 'out ep' problem is caused by somewhere else.

Sorry, but I've never worked on the 'out ep' with multiple packets.

Ideally I want to send a 3072 byte buffer in 3 packets of 1024 bytes per interval (maximum possible). I wonder at which level the split of the large buffer is done.

Concerning the DMA mode, it didn't work until I changed 

HAL_PCDEx_SetTxFiFo(&hpcd_USB_OTG_HS, 0, 0x80);

into

HAL_PCDEx_SetTxFiFo(&hpcd_USB_OTG_HS, 0, 0x40);

Do you mean you want to send 3 packets from HOST to DEVICE direction?

USB_EPStartXfer() and hardware does the split job. PKTCNT field of DOEPTSIZ register holds

the number of packets and XFRSIZ specifies total number of bytes to transfer.

You can pass large buffer pointer to HAL_PCD_EP_Receive() and/or HAL_PCD_EP_Transmit().

HAL_PCDEx_SetTxFiFo() allocates FIFO space for 'IN' direction.

To increase 'out ep' receive buffer space, you need to use HAL_PCDEx_SetRxFiFo().

If you have already allocated too much space for RXFiFo, you may need to shrink TxFiFo

size, because total FIFO size is 4K limited. Note that HAL_CPDEx_SetRxFiFo() expects

its fifo size argument in words (not bytes).

Regards,

Posted on August 24, 2017 at 23:31

Thanks a lot for your help!

I was wrong about the 'in' and the 'out' EP. I am also in the 'in' case, 'device to host' direction (I thought 'out' from the device point of view forgetting the USB vocabulary).

Indeed,your fix makes the HAL able to send 2 packets per microframe and I also noticed that sending 3 packets needs further exploration.

Nevertheless the available bandwidth with 2x1024 bytes per microframe is quite comfortable.

Regards.

Jean-Pierre