Skip to main content
Explorer
June 12, 2024
Question

USB MSC recognized under windows but not on mac and android

  • June 12, 2024
  • 1 reply
  • 1255 views

Hi

I have a sensor board with USB MSC and an EMMC memory chip. Under windows every thing works fine but not under MAC or Android.

I am using FATFS and format the card with fomat option = #define FM_ANY 0x07.

Does any one have a clue what is going wrong?

I assume I have wrong settings:

I need to make the card read only for Windows/mac/android, but read/write from STM32 firmware.

So in ffconf.h I write:

#define _FS_READONLY 0 /* 0:Read/Write or 1:Read only */

And in usbd_storage_if.c I write.

int8_t STORAGE_IsWriteProtected_HS(uint8_t lun)

{

/* USER CODE BEGIN 12 */

return (USBD_FAIL);

/* USER CODE END 12 */

}

This fine with windows but not with mac/android.

My card is detected (and works fine) on all platform when it is not write protected. Probably I dont know how to implement write protection.

Actually this post suggests to set a write protect bit in uint8_t Mode_Sense10_data[]. But it doesnt work for me either.

https://community.st.com/t5/stm32-mcus-embedded-software/read-only-mmc-with-usb-fs-device-lib-for-stm32f1xx/td-p/484473

Thx

    This topic has been closed for replies.

    1 reply

    Technical Moderator
    June 18, 2024

    Hello @MK..1 

     

    Please check if there are any hidden files or system files created by Windows that could be causing compatibility issues when the card is accessed on macOS or Android.

    Returning USBD_FAIL is not appropriate in STORAGE_IsWriteProtected_HS; you should return a value that indicates the write protection status. Typically, returning 1 would indicate that the storage is write-protected, and 0 would indicate that it is not.