Skip to main content
MZoli.1
Associate
April 5, 2023
Question

USB Mass Storage (Flash Drive) doesn’t become ready occasionally?

  • April 5, 2023
  • 1 reply
  • 3224 views

Recently I’ve run a code with stm32f429 in freertos in which usb host fs is enabled for mass storage class. I generated the init code with stm32cubemx ver. 6.4. At first only usb host is enabled and when the flash drive is inserted the usb host core detects it and shows its state as “APPLICATION_READY�?.

But when I add other tasks with different priorities and runtimes, sometimes the usb flash drive detection doesn’t complete. It means that when usb host core reaches “HOST_CLASS�? state and calls the class process function (USBH_MSC_Process) to handle the class background process, it can’t detect the MSC device as “ready�?. In MSC request state machine when the USBH_MSC_SCSI_Inquiry function is called to test if media ready or not, the ready_state remains busy (USBH_BUSY) and no longer becomes ready (USBH_OK), so the application state remains as “APPLICATION_START�?.

Clearly, some changes in other parts of the code has impacts on usb msc readiness in an irrelevant way. This may be aroused from stack memory or timing issues or using rtos. As I’ve tested, this issue doesn’t necessarily depend on the number of tasks or ram usage and something like that.  

I don’t know how I can solve this issue, please help me.

Thanks.

This topic has been closed for replies.

1 reply

Tesla DeLorean
Guru
April 5, 2023

Instrument so you can understand the flow dynamics without a debugger.​

Tips, Buy me a coffee, or three.. PayPal VenmoUp vote any posts that you find helpful, it shows what's working..
MZoli.1
MZoli.1Author
Associate
April 6, 2023

I use Keil uVision5 and ST-link debugger.