I'm trying to save lot of files at SD card in the loop with f_write function form FatFs libery, unfortunately after max 50 loop entries f_write returns FR_DISK_ERR.
Making one test took over 30 minutes, so I made Enity Test, which saves 10,000 files on the SD card, the program still saves < 50 files.
for(uint16_t i = 0; i < 10000; ++i){
if(f_mount(&mfs,"0:",0) != FR_OK){
to_int.put_str("Mount error");
break;
}
if(f_chdrive("0:" ) != FR_OK){
to_int.put_str("Oper error");
break;
}
sprintf(f_name, "test%d.txt", i);
if(f_open(&fil, f_name, FA_WRITE | FA_CREATE_ALWAYS)!= FR_OK){
to_int.put_str("Write error");
break;
}
if(f_write(&fil, wtext, sizeof(wtext), (void *)&wbytes) != FR_OK){ //<------FR_DISK_ERR
to_int.put_str("Write Error\n");
break;
}
f_sync(&fil);
f_close(&fil);
f_mount(0, "0:", 0);
to_int.put_str(f_name);\
to_int.put_str(" writed!\n");
}