eclipse-threadx / usbx

Eclipse ThreadX - USBX is a high-performance USB host, device, and on-the-go (OTG) embedded stack, that is fully integrated with Eclipse ThreadX RTOS
https://github.com/eclipse-threadx/rtos-docs/blob/main/rtos-docs/usbx/index.md
MIT License
157 stars 92 forks source link

Can Filex and USBX work on one storage medium at the same time? #32

Closed arilink-tech closed 3 years ago

arilink-tech commented 3 years ago

I have a question. I want to use an SD card or Flash as a storage medium, and then make a USB MSG device so that the PC can read and write the files in it. At the same time, STM32 uses FileX to access the files inside. Is this allowed?

xiaocq2001 commented 3 years ago

No, it's not recommended. USB MSC device modifies sectors which makes conflicts with FileX.

zhangshengping commented 3 years ago

No, it's not recommended. USB MSC device modifies sectors which makes conflicts with FileX.

is any plan to imply mtp class device? @xiaocq2001

xiaocq2001 commented 3 years ago

Please try PIMA class, with UX_PIMA_WITH_MTP_SUPPORT defined.

arilink-tech commented 3 years ago

@xiaocq2001 If it is not operated at the same time, the system starts FileX to operate the SD card at the beginning of the system, and starts USB MSC to update the files on the SD card when needed. FileX only reads the files. Can this avoid conflicts?

xiaocq2001 commented 3 years ago

No, FileX may cache something that could be updated by USBX. Recommended sequence:

  1. Close media (FileX)
  2. Start USBX
  3. host may operate the media
  4. Stop USBX
  5. Open media (FileX)

The key is, FileX should stop media access before USBX modifies media, and re-open the media after modification to confirm all changes are read again.

arilink-tech commented 3 years ago

Ok . i will try as you said

arilink-tech commented 3 years ago

@xiaocq2001 I take the liberty to ask, are you Chinese?

xiaocq2001 commented 3 years ago

Yes.

arilink-tech commented 3 years ago

Can you leave WeChat? Want to learn more from you

derskop commented 3 years ago

hey,sir,can you give me a project about the usbx host msc, recently i am studying how to move it to my project meeting some diffcult. thanks.

xiaocq2001 commented 3 years ago

Maybe you can check https://github.com/azure-rtos/samples. Or you can try to generate USBX host storage demo from STM32 Cube.

yuxin-azrtos commented 3 years ago

Looks like the issue is resolved.