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

fix: reduce file system corruption from standalone Lua scripts #5148

Merged
merged 1 commit into from
Jun 21, 2024
Merged
Show file tree
Hide file tree
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
24 changes: 9 additions & 15 deletions radio/src/targets/common/arm/stm32/diskio_sdio.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -270,15 +270,12 @@ static DRESULT sdio_read(BYTE lun, BYTE * buff, DWORD sector, UINT count)
res = _read_dma(buff, sector, count);
if (res != RES_OK) return res;

uint32_t timeout = HAL_GetTick();
while((HAL_GetTick() - timeout) < SD_TIMEOUT) {
if (sdio_check_card_state() == SD_TRANSFER_OK) {
return RES_OK;
}
if (sdio_check_card_state_with_timeout(SD_TIMEOUT) < 0) {
TRACE("SD getstatus timeout, s:%u c:%u", sector, (uint32_t)count);
return RES_ERROR;
}

TRACE("SD getstatus timeout, s:%u c:%u", sector, (uint32_t)count);
return RES_ERROR;
return RES_OK;
}

static DRESULT _write_dma(const BYTE *buff, DWORD sector, UINT count)
Expand Down Expand Up @@ -329,16 +326,13 @@ static DRESULT sdio_write(BYTE lun, const BYTE *buff, DWORD sector, UINT count)

res = _write_dma(buff, sector, count);
if (res != RES_OK) return res;

uint32_t timeout = HAL_GetTick();
while((HAL_GetTick() - timeout) < SD_TIMEOUT) {
if (sdio_check_card_state() == SD_TRANSFER_OK) {
return RES_OK;
}

if (sdio_check_card_state_with_timeout(SD_TIMEOUT) < 0) {
TRACE("SD getstatus timeout, s:%u c: %u", sector, (uint32_t)count);
return RES_ERROR;
}

TRACE("SD getstatus timeout, s:%u c: %u", sector, (uint32_t)count);
return RES_ERROR;
return RES_OK;
}

static DRESULT sdio_get_sector_count(DWORD* sectors)
Expand Down
2 changes: 1 addition & 1 deletion radio/src/thirdparty/FatFs/ffconf.h
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@
/ System Configurations
/---------------------------------------------------------------------------*/

#define FF_FS_TINY 0
#define FF_FS_TINY 1
/* This option switches tiny buffer configuration. (0:Normal or 1:Tiny)
/ At the tiny configuration, size of file object (FIL) is shrinked FF_MAX_SS bytes.
/ Instead of private sector buffer eliminated from the file object, common sector
Expand Down