@@ -180,13 +180,19 @@ int _calculate_blocksize_match_tdbstore(BlockDevice *bd)
180
180
{
181
181
bd_size_t size = bd->size ();
182
182
bd_size_t erase_size = bd->get_erase_size ();
183
+ bd_size_t page_size = bd->get_program_size ();
183
184
bd_size_t number_of_sector = size / erase_size;
184
-
185
- if (number_of_sector < 2 ) {
185
+ bd_size_t number_of_page = size / page_size;
186
+ if (number_of_sector < TDBStore::STORE_SECTORS ) {
186
187
tr_warning (" KV Config: There are less than two sectors - TDBStore will not work." );
187
188
return -1 ;
188
189
}
189
190
191
+ if (number_of_page < TDBStore::STORE_PAGES) {
192
+ tr_warning (" KV Config: There are less than ten pages sectors - TDBStore will not work." );
193
+ return -1 ;
194
+ }
195
+
190
196
191
197
if (number_of_sector % 2 != 0 ) {
192
198
tr_warning (" KV Config: Number of sectors is not an even number. Consider changing the BlockDevice size" );
@@ -586,9 +592,9 @@ int _create_internal_tdb(BlockDevice **internal_bd, KVStore **internal_tdb, bd_s
586
592
return MBED_ERROR_FAILED_OPERATION ;
587
593
}
588
594
589
- // Check if TDBStore has at least 2 sector .
595
+ // Check if TDBStore has at least 2 sectors or 10 pages .
590
596
if (_calculate_blocksize_match_tdbstore (*internal_bd) != MBED_SUCCESS) {
591
- tr_error (" KV Config: Can not create TDBStore with less then 2 sector ." );
597
+ tr_error (" KV Config: Can not create TDBStore with less then 2 sectors or 10 pages ." );
592
598
return MBED_ERROR_INVALID_ARGUMENT;
593
599
}
594
600
@@ -754,9 +760,9 @@ int _storage_config_tdb_external_common()
754
760
return MBED_ERROR_FAILED_OPERATION ;
755
761
}
756
762
757
- // Check that there is at least 2 sector for the external TDBStore
763
+ // Check that there is at least 2 sectors for the external TDBStore
758
764
if (_calculate_blocksize_match_tdbstore (kvstore_config.external_bd ) != MBED_SUCCESS) {
759
- tr_error (" KV Config: Can not create TDBStore with less then 2 sector ." );
765
+ tr_error (" KV Config: Can not create TDBStore with less then 2 sectors or 10 pages ." );
760
766
return MBED_ERROR_INVALID_SIZE;
761
767
}
762
768
0 commit comments