This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

USB mass storage connect-disconnect handling in STM32429-I Eval running Keil MDK5 USB host stack.

Hi all,

I am a newbie in Keil MDK. I am trying to run some file operations from a USB mass storage connected to my STM32429-i evaluation board. I am using CMSIS RTOS and CMSIS compliant peripheral drivers. Referring the following link: http://www.keil.com/pack/doc/mw/USB/html/index.html, I have written a test application in which there are two threads. One thread is performing some file operation (file open, write, read, copy continuously) and one thread is checking the mass storage connection status periodically.

I need to recover from a usb mass storage disconnect/connect gracefully in this situation. But my observation is, while I am accessing the file over USB (eg: fread() API in FS stack), if a USB disconnect happens, the internal USB core thread created by the USB stack is going to some WAIT state. And all my threads, USB file operation thread and USB connection monitoring thread are also going to some WAIT state. Somewhat like a deadlock.

Please share your valuable thoughts on how can I recover from this situation. Is the USB stack provide any support to know the USB_DISCONNECT event and gracefully handle it.

I understood from the link www.keil.com/.../group___u_s_b_h__port__events.html
CMSIS driver is signalling some event like ARM_USBH_EVENT_DISCONNECT. But how do I know it from USB stack or from my application while I am performing fread()?

Thank you,
Honey S

Parents
  • Generally, you should check return values of file system functions for example Keil's standard USB Host with File System example \Middleware\USB\Host\MassStorage\ example uses fgetc function for reading file and this function specifies that if an error (such as no media because of disconnect) occurred it returns EOF.
    Also, this example terminates the file read when EOF is returned and if USB stick is reconnected file can be accessed again.

Reply
  • Generally, you should check return values of file system functions for example Keil's standard USB Host with File System example \Middleware\USB\Host\MassStorage\ example uses fgetc function for reading file and this function specifies that if an error (such as no media because of disconnect) occurred it returns EOF.
    Also, this example terminates the file read when EOF is returned and if USB stick is reconnected file can be accessed again.

Children