From 458f5f43f370f7e5c8180ff059da2db00e871c17 Mon Sep 17 00:00:00 2001 From: Veijo Pesonen Date: Wed, 20 Nov 2019 15:18:53 +0200 Subject: [PATCH 1/2] TDBStore: Adds sanity check for storage size when compiled with debug profile --- features/storage/kvstore/tdbstore/TDBStore.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/features/storage/kvstore/tdbstore/TDBStore.cpp b/features/storage/kvstore/tdbstore/TDBStore.cpp index d7166c722e..6595964121 100644 --- a/features/storage/kvstore/tdbstore/TDBStore.cpp +++ b/features/storage/kvstore/tdbstore/TDBStore.cpp @@ -134,6 +134,11 @@ TDBStore::TDBStore(BlockDevice *bd) : _ram_table(0), _max_keys(0), for (int i = 0; i < _max_open_iterators; i++) { _iterator_table[i] = { 0 }; } + + /* Minimum space required by Reserved area and master record */ + MBED_ASSERT(bd->size() + >= (align_up(RESERVED_AREA_SIZE + sizeof(reserved_trailer_t), _prog_size) + + record_size(master_rec_key, sizeof(master_record_data_t)))); } TDBStore::~TDBStore() From 8a0af607f3c211178b1ac2a80f281662abb1e017 Mon Sep 17 00:00:00 2001 From: Veijo Pesonen Date: Thu, 21 Nov 2019 10:02:53 +0200 Subject: [PATCH 2/2] LPC55S69_NS: Sets default TDBStore size to 32kB Previously it was 2 pages - 1kB - which isn't sufficient to store Reserved Area and Master Record. Reserved are requires one page and Master Record takes two pages. With 512B page size and having two areas, active and inactive, the minimum size requirement becomes 2 areas * 3 pages = 3kB. That isn't enough to store any keys though. --- features/storage/kvstore/conf/tdb_internal/mbed_lib.json | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/features/storage/kvstore/conf/tdb_internal/mbed_lib.json b/features/storage/kvstore/conf/tdb_internal/mbed_lib.json index 140f7e5e26..8b1403703e 100644 --- a/features/storage/kvstore/conf/tdb_internal/mbed_lib.json +++ b/features/storage/kvstore/conf/tdb_internal/mbed_lib.json @@ -15,6 +15,10 @@ "internal_size": "0x8000", "internal_base_address": "0x00028000" }, + "LPC55S69_NS": { + "internal_size": "0x8000", + "internal_base_address": "0x00090000" + }, "DISCO_H747I": { "internal_size": "2*FLASH_SECTOR_SIZE", "internal_base_address": "0x080C0000"