2023-09-01 04:55 AM
Dear All,
I am developing an application for USB host mass storage class for STM32U575.
I am using STM32HAL APIs for developing USB host and using TinyUSB open-source USB stack.
I am able to enumerate flash drive successfully, but not able to perform some of the file operations.
I am facing below issue.
while sending the command for file sync for FAT32 file system.
My code hits below statement in the code, here "hc->xfer_len" is 512 bytes and this makes len_words = 128.
The highlighted if statement gets true and due to that NPTXFEM, interrupt is getting enabled.
As soon as the interrupt is enabled we are continuesly getting NPTXFEM interrupt and code gets hang in HAL_HCD_IRQHandler(),
In stm32u5xx_hal_hcd.c file this interrupt is not handled.
Could some one please help me in understanding how to handle this interrupt? and what should be the ideal size for bulk endpoints?
Thanks in advance!
2023-09-04 08:58 PM
Hi,
Any one from ST can respond to my query?
2023-09-08 04:02 AM
could someone please respond to my query?
2023-09-08 04:36 AM - edited 2023-09-10 06:08 AM
The snippet that you're quoting is here in function USB_HC_StartXfer() , correct?
Is it called in context when the USB interrupts are enabled ?
2023-09-08 10:11 AM - edited 2023-09-08 10:39 AM
Hi @Pavel A.
Thanks for the response.
1. Yes, correct the snippet is from USB_HC_StartXfer().
2. Yes interrupts are enabled while calling that function.
2023-09-08 12:14 PM
Try to disable interrupts (at least the USB interrupt) around calling USB_HC_StartXfer.
2023-09-09 02:35 AM
Thank you very much for the response @Pavel A.
But my query was related to NPTXFEM interrupt which is getting enabled whenever we are trying to write data more than the space available in non-periodic transmit FIFO, and it generates NPTXFE interrupt which is currently not handled in stm32 HAL library (HAL_HCD_IRQHandler).
Also As per data sheet of STM32U575 max size for DIEPTXF0_HNPTXFSIZ (Non periodic transmit FIFO) is 512 bytes, but HAL library allocates only for 128 bytes in USB_HostInit().
Could you please let me know how to handle that interrupt?
2023-09-09 03:40 AM - edited 2023-09-09 03:44 AM
> but HAL library allocates only for 128 bytes in USB_HostInit().
Is the USB working in full speed or high speed mode? If FS, there's no way to send a 512 byte packet.
The software can send more than the endpoint size (which is limited by the mode, either FS or HS ), then the interrupt handler should automatically forward the used data pointer and send the next portion. If this does not work, please report a bug.
Again, try to disable USB (or global) interrupts around the USB TX function calls, so that it is executed uninterrupted. There were reports that it helps for other STM32 models.