mirror of
https://github.com/armink/FlashDB.git
synced 2025-01-29 04:32:53 +08:00
[tsdb][read_sector_info]: fix flash overwrite when abnormal power loss (#316)
This commit is contained in:
parent
f0af0eeda4
commit
714d6159e7
@ -238,10 +238,12 @@ static fdb_err_t read_sector_info(fdb_tsdb_t db, uint32_t addr, tsdb_sec_info_t
|
|||||||
|
|
||||||
tsl.addr.index = sector->empty_idx;
|
tsl.addr.index = sector->empty_idx;
|
||||||
while (read_tsl(db, &tsl) == FDB_NO_ERR) {
|
while (read_tsl(db, &tsl) == FDB_NO_ERR) {
|
||||||
if (tsl.status == FDB_TSL_UNUSED || tsl.status == FDB_TSL_PRE_WRITE) {
|
if (tsl.status == FDB_TSL_UNUSED) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
sector->end_time = tsl.time;
|
if (tsl.status != FDB_TSL_PRE_WRITE) {
|
||||||
|
sector->end_time = tsl.time;
|
||||||
|
}
|
||||||
sector->end_idx = tsl.addr.index;
|
sector->end_idx = tsl.addr.index;
|
||||||
sector->empty_idx += LOG_IDX_DATA_SIZE;
|
sector->empty_idx += LOG_IDX_DATA_SIZE;
|
||||||
sector->empty_data -= FDB_WG_ALIGN(tsl.log_len);
|
sector->empty_data -= FDB_WG_ALIGN(tsl.log_len);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user