@@ -176,13 +176,19 @@ int _calculate_blocksize_match_tdbstore(BlockDevice *bd)
176
176
{
177
177
bd_size_t size = bd->size ();
178
178
bd_size_t erase_size = bd->get_erase_size ();
179
+ bd_size_t page_size = bd->get_program_size ();
179
180
bd_size_t number_of_sector = size / erase_size;
180
-
181
- if (number_of_sector < 2 ) {
181
+ bd_size_t number_of_page = size / page_size;
182
+ if (number_of_sector < TDBStore::STORE_SECTORS ) {
182
183
tr_warning (" KV Config: There are less than two sectors - TDBStore will not work." );
183
184
return -1 ;
184
185
}
185
186
187
+ if (number_of_page < TDBStore::STORE_PAGES) {
188
+ tr_warning (" KV Config: There are less than ten pages sectors - TDBStore will not work." );
189
+ return -1 ;
190
+ }
191
+
186
192
187
193
if (number_of_sector % 2 != 0 ) {
188
194
tr_warning (" KV Config: Number of sectors is not an even number. Consider changing the BlockDevice size" );
@@ -575,9 +581,9 @@ int _create_internal_tdb(BlockDevice **internal_bd, KVStore **internal_tdb, bd_s
575
581
return MBED_ERROR_FAILED_OPERATION ;
576
582
}
577
583
578
- // Check if TDBStore has at least 2 sector .
584
+ // Check if TDBStore has at least 2 sectors or 10 pages .
579
585
if (_calculate_blocksize_match_tdbstore (*internal_bd) != MBED_SUCCESS) {
580
- tr_error (" KV Config: Can not create TDBStore with less then 2 sector ." );
586
+ tr_error (" KV Config: Can not create TDBStore with less then 2 sectors or 10 pages ." );
581
587
return MBED_ERROR_INVALID_ARGUMENT;
582
588
}
583
589
@@ -743,9 +749,9 @@ int _storage_config_tdb_external_common()
743
749
return MBED_ERROR_FAILED_OPERATION ;
744
750
}
745
751
746
- // Check that there is at least 2 sector for the external TDBStore
752
+ // Check that there is at least 2 sectors for the external TDBStore
747
753
if (_calculate_blocksize_match_tdbstore (kvstore_config.external_bd ) != MBED_SUCCESS) {
748
- tr_error (" KV Config: Can not create TDBStore with less then 2 sector ." );
754
+ tr_error (" KV Config: Can not create TDBStore with less then 2 sectors or 10 pages ." );
749
755
return MBED_ERROR_INVALID_SIZE;
750
756
}
751
757
0 commit comments