Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sd_mscerror #138

Open
755516538 opened this issue Feb 26, 2023 · 4 comments
Open

sd_mscerror #138

755516538 opened this issue Feb 26, 2023 · 4 comments

Comments

@755516538
Copy link

Hello, I encountered an error when using the tinyusb example "sd_msc.ino". An error will occur if the file size of the SD card exceeds 512 bytes. Can you teach me how to repair it

@chegewara
Copy link
Owner

Hi,
i dont understand what problem do you have, sorry.
If you describe it more, maybe i can help.

@755516538
Copy link
Author

Thank you for your reply.
Preparation for problem recurrence:
1.esp32s3
2. Text file larger than 512 bytes (000.txt)
3.sd_ Msc sample code
Step:

  1. Modify the example to read and write the SD card correctly.
    #define SD_ MISO 37
    #define SD_ MOSI 39
    #define SD_ SCK 38
    #define SD_ CS 40
  2. Burn the program to esp32s3
  3. Copy "000. TXT" to esp32disk.
  4. Unplug the esp32 and disconnect it from the computer
  5. Insert esp32 into the computer and connect it to the computer, and open the USB flash drive
  6. Open "000.TXT" in the USB flash drive, and some contents of the file are lost.
    image

@chegewara
Copy link
Owner

chegewara commented Feb 28, 2023

Its because you did not unmount device under system properly.
Im not sure, but this small snippet in your .ino may help to fix it:

#include "ff.h"
#include "diskio.h"
void tud_msc_write10_complete_cb(uint8_t lun)
{
    if (disk_ioctl(0, CTRL_SYNC, NULL) != RES_OK)
    {
        Serial.printf("failed to sync\n");
    }
}

PS you also has to make sure all data are transferred to esp32 before you unplug it

@755516538
Copy link
Author

Ok, thank you very much for your help

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants