mirror of https://github.com/ARMmbed/mbed-os.git
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.pull/15514/head
parent
95fee2f75a
commit
3082c28b1e
|
@ -374,6 +374,10 @@ int TDBStore::read_record(uint8_t area, uint32_t offset, char *key,
|
|||
|
||||
if (calc_hash) {
|
||||
hash = calc_crc(hash, chunk_size, dest_buf);
|
||||
#ifdef KVSTORE_RAM_TABLE_NO_CRC_CHECK
|
||||
next_offset = align_up(offset + total_size, _prog_size);
|
||||
return ret;
|
||||
#endif /* KVSTORE_RAM_TABLE_NO_CRC_CHECK */
|
||||
}
|
||||
|
||||
user_key_ptr += chunk_size;
|
||||
|
|
Loading…
Reference in New Issue