fix(spiflash): USB storage cannot persist files copied (#7457)

This commit is contained in:
richardclli
2026-07-03 13:05:45 +10:00
committed by GitHub
parent 7b019e969e
commit a6542f9b0e
@@ -91,13 +91,21 @@ static DSTATUS spi_flash_initialize(BYTE lun)
}
#if defined(USE_FLASH_FTL)
int flashSize = flashSpiGetSize();
int flashSizeMB = flashSize / 1024 / 1024;
if (frftlInitDone) {
// Do flush when trying to reinit spi flash,
// because the frftl only need to be initialized once
if (!ftlSync(&_frftl)) {
return STA_NOINIT;
}
} else {
int flashSize = flashSpiGetSize();
int flashSizeMB = flashSize / 1024 / 1024;
if (!ftlInit(&_frftl, &_frftl_cb, flashSizeMB)) {
return STA_NOINIT;
if (!ftlInit(&_frftl, &_frftl_cb, flashSizeMB)) {
return STA_NOINIT;
}
frftlInitDone = true;
}
frftlInitDone = true;
#endif
return 0;