Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 13 additions & 5 deletions radio/src/targets/common/arm/stm32/diskio_spi_flash.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down