EspTinyUSB
EspTinyUSB copied to clipboard
sd_mscerror
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
Hi, i dont understand what problem do you have, sorry. If you describe it more, maybe i can help.
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:
- 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
- Burn the program to esp32s3
- Copy "000. TXT" to esp32disk.
- Unplug the esp32 and disconnect it from the computer
- Insert esp32 into the computer and connect it to the computer, and open the USB flash drive
- Open "000.TXT" in the USB flash drive, and some contents of the file are lost.
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
Ok, thank you very much for your help