nxp-mcuxpresso / mcux-sdk-examples

MCUXpresso SDK Examples
Other
46 stars 24 forks source link

Consider support for SD card insertion/removal in MSC #27

Open syoshida0318 opened 2 months ago

syoshida0318 commented 2 months ago

Using the evaluation board(MIMXRT1064-EVK), I am considering a project that incorporates MSC. I added support for SD card insertion and removal to the sample project(evkmimxrt1064_dev_msc_disk_freertos). SD card insertion/removal is coded based on the sample project(evkmimxrt1064_sdcard_fatfs_freertos). It worked, but there is a problem. When an SD card is reinserted, the PC may recognize the drive immediately or it may take a very long time.

I attach the code I created, please show me what the problem is. The project is for gui guider. The attached files are compressed file in the gui guider folder. Since the ZIP file is too large, I attache a 7z file renamed .TXT. guiguider_training_01_2.7z.txt

mcuxsusan commented 2 months ago

Thanks for sharing the modified project. I have forwarded internal team to have a check, the feedback could be delayed and appreciate for your patience.

AidenHu commented 1 month ago

Hi @syoshida0318 Normally we should not remove sdcard during USB connection. Guess the reason why PC takes a very long time to recognize is that PC try to recover from the last failed condition before the SD card is reinserted. The key point is that PC should know your SDcard is removed. Actually, we have provided this way. You can set g_msc.stop flag when sdcard is removed in your code and clear it when your sdcard is ready. Host sends TestUnitReady request by 1s interval. When g_msc.stop flag is set, device will return sense key using 0x20 (NOT READY, see Table 50 - Sense Key Descriptions in usbmass-ufi10.pdf)

syoshida0318 commented 1 month ago

Hi Aiden Hu

Thanks for your advice. I will try the method of using g_msc.stop flag.

Best Regards.

2024年5月9日(木) 16:47 Aiden Hu @.***>:

Hi @syoshida0318 https://github.com/syoshida0318 Normally we should not remove sdcard during USB connection. Guess the reason why PC takes a very long time to recognize is that PC try to recover from the last failed condition before the SD card is reinserted. The key point is that PC should know your SDcard is removed. Actually, we have provided this way. You can set g_msc.stop flag when sdcard is removed in your code and clear it when your sdcard is ready. Host sends TestUnitReady request by 1s interval. When g_msc.stop flag is set, device will return sense key using 0x20 (NOT READY, see Table 50 - Sense Key Descriptions in usbmass-ufi10.pdf)

— Reply to this email directly, view it on GitHub https://github.com/nxp-mcuxpresso/mcux-sdk-examples/issues/27#issuecomment-2102136999, or unsubscribe https://github.com/notifications/unsubscribe-auth/AT2XBTERPCNPUN3AMBAZ7CDZBMSZ7AVCNFSM6AAAAABGDIDOFWVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDCMBSGEZTMOJZHE . You are receiving this because you were mentioned.Message ID: @.***>

AidenHu commented 1 month ago

@syoshida0318, what is the current progress?

syoshida0318 commented 1 month ago

Hi Aiden Hu

After further review, I added error handling to the file system, and cleared the file access mutex in the USB initials, then file access from USB is now normal operation .

Currently I am continuing checks.

Best Regards.

2024年6月4日(火) 18:11 Aiden Hu @.***>:

@syoshida0318 https://github.com/syoshida0318, what is the current progress?

— Reply to this email directly, view it on GitHub https://github.com/nxp-mcuxpresso/mcux-sdk-examples/issues/27#issuecomment-2147010176, or unsubscribe https://github.com/notifications/unsubscribe-auth/AT2XBTAZ6MRZ4TALO7IJIKLZFWADVAVCNFSM6AAAAABGDIDOFWVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDCNBXGAYTAMJXGY . You are receiving this because you were mentioned.Message ID: @.***>