FlashDB icon indicating copy to clipboard operation
FlashDB copied to clipboard

New partitions are formatted twice on first run

Open amitv87 opened this issue 3 years ago • 0 comments

In function check_sec_hdr_cb variable failed_count is incremented irrespective of return code from format_sector. For new partitions failed_count gets incremented for all sectors https://github.com/armink/FlashDB/blob/0b5ac0039b5c6dfb834ca8a5b958dd1a79a6bb5a/src/fdb_kvdb.c#L1432-L1448

In function _fdb_kv_load condition check_failed_count == SECTOR_NUM ends up being true for first run and triggers fdb_kv_set_default which reformats all the sectors again. https://github.com/armink/FlashDB/blob/0b5ac0039b5c6dfb834ca8a5b958dd1a79a6bb5a/src/fdb_kvdb.c#L1499-L1539

amitv87 avatar May 06 '22 14:05 amitv87