Skip to content

Commit 3082c28

Browse files
committed
skip CRC when initializing TDBStore
Problem: The build_ram_table() function of TDBStore loops over every entry, calculates the checksum and compares them to the stored checksum in the entry header to ensure integrity. For larger TDBStores (e.g. 8 MiB or more) in external single-SPI flash devices this check can take very long, thus rendering it unusable in some cases. Solution: The suggested solution skips the time consuming CRC of the data. After reading the key and calculating its CRC, it sets next_offset to the beginning of the next entry, thereby skipping the data. While this skips the integrity check, it significantly reduces the initial building of the RAM table. The data CRC can be enabled or disabled with a compiler flag. Contribution is provided on behalf of BIOTRONIK.
1 parent 95fee2f commit 3082c28

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

storage/kvstore/tdbstore/source/TDBStore.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -374,6 +374,10 @@ int TDBStore::read_record(uint8_t area, uint32_t offset, char *key,
374374

375375
if (calc_hash) {
376376
hash = calc_crc(hash, chunk_size, dest_buf);
377+
#ifdef KVSTORE_RAM_TABLE_NO_CRC_CHECK
378+
next_offset = align_up(offset + total_size, _prog_size);
379+
return ret;
380+
#endif /* KVSTORE_RAM_TABLE_NO_CRC_CHECK */
377381
}
378382

379383
user_key_ptr += chunk_size;

0 commit comments

Comments
 (0)