Skip to content

Commit 03dab7f

Browse files
authored
Merge pull request #12645 from mtomczykmobica/IOTSTOR-906
Storage: Use internal flash for KVStore always if default config
2 parents 4fa9cca + 6a21dfa commit 03dab7f

File tree

4 files changed

+5
-47
lines changed

4 files changed

+5
-47
lines changed

docs/design-documents/features/storage/Configuration/CONFIGURATION.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ The following is a list of all storage parameters available and their descriptio
6363
* `FILESYSTEM`.
6464
* `FILESYSTEM_NO_RBP`.
6565
* `default`
66-
If the `default` configuration is set, the system will choose the type of storage based on the block device component set in `target.json`. If QSPIF, SPIF or DATAFLASH is the block device component in `target.json`, the system chooses `TDB_EXTERNAL` as its storage option. If SD is the block device in `target.json`, the system chooses FILESYSTEM. If FLASHIAP is the only block device component, the system chooses `TDB_INTERNAL`.
66+
If the `default` configuration is set, the system will choose the type of storage TDB_INTERNAL.
6767
* `default_kv` - This is a string representing the path for the default KVStore instantiation. Applications can pass an empty path (only the key name) or pass the generated name for this parameter (`MBED_CONF_STORAGE_DEFAULT_KV`) as the path to use this configuration.
6868
* `internal_size` - The size in bytes for the internal FlashIAP block device. This, together with the `internal_base_address`, adjusts exactly the size and location where the block device resides on memory. If not defined, the block device will try to get the maximum size available.
6969
* `internal_base_address` - The address where the internal FlashIAP blockDevice starts. This helps to prevent collisions with other needs, such as firmware updates. If not defined, the start address will be set to the first sector after the application code ends in `TDB_internal`. In any external configurations with rollback protection support, it will be set to end of flash - `rbp_internal_size`.

features/storage/TESTS/kvstore/direct_access_devicekey_test/main.cpp

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -264,22 +264,10 @@ void test_direct_access_to_device_inject_root()
264264
} else if (strcmp(STR(MBED_CONF_STORAGE_STORAGE_TYPE), "TDB_EXTERNAL") == 0) {
265265
internal_start_address = MBED_CONF_STORAGE_TDB_EXTERNAL_INTERNAL_BASE_ADDRESS;
266266
internal_rbp_size = MBED_CONF_STORAGE_TDB_EXTERNAL_RBP_INTERNAL_SIZE;
267-
} else if (strcmp(STR(MBED_CONF_STORAGE_STORAGE_TYPE), "TDB_INTERNAL") == 0) {
267+
} else if (strcmp(STR(MBED_CONF_STORAGE_STORAGE_TYPE), "TDB_INTERNAL") == 0 ||
268+
strcmp(STR(MBED_CONF_STORAGE_STORAGE_TYPE), "default") == 0) {
268269
internal_start_address = MBED_CONF_STORAGE_TDB_INTERNAL_INTERNAL_BASE_ADDRESS;
269270
internal_rbp_size = MBED_CONF_STORAGE_TDB_INTERNAL_INTERNAL_SIZE;
270-
} else if (strcmp(STR(MBED_CONF_STORAGE_STORAGE_TYPE), "default") == 0) {
271-
#if COMPONENT_QSPIF || COMPONENT_SPIF || COMPONENT_DATAFLASH
272-
internal_start_address = MBED_CONF_STORAGE_TDB_EXTERNAL_INTERNAL_BASE_ADDRESS;
273-
internal_rbp_size = MBED_CONF_STORAGE_TDB_EXTERNAL_RBP_INTERNAL_SIZE;
274-
#elif COMPONENT_SD
275-
internal_start_address = MBED_CONF_STORAGE_FILESYSTEM_INTERNAL_BASE_ADDRESS;
276-
internal_rbp_size = MBED_CONF_STORAGE_FILESYSTEM_RBP_INTERNAL_SIZE;
277-
#elif COMPONENT_FLASHIAP
278-
internal_start_address = MBED_CONF_STORAGE_TDB_INTERNAL_INTERNAL_BASE_ADDRESS;
279-
internal_rbp_size = MBED_CONF_STORAGE_TDB_INTERNAL_INTERNAL_SIZE;
280-
#else
281-
TEST_SKIP_UNLESS_MESSAGE(false, "Test skipped. No KVStore Internal");
282-
#endif
283271
} else {
284272
TEST_SKIP_UNLESS_MESSAGE(false, "Test skipped. No KVStore Internal");
285273
}

features/storage/kvstore/conf/kv_config.cpp

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1145,24 +1145,7 @@ int _storage_config_filesystem_common()
11451145

11461146
int _storage_config_default()
11471147
{
1148-
#if COMPONENT_QSPIF || COMPONENT_SPIF || COMPONENT_DATAFLASH
1149-
return _storage_config_TDB_EXTERNAL();
1150-
#elif COMPONENT_SD
1151-
return _storage_config_FILESYSTEM();
1152-
#elif COMPONENT_FLASHIAP
11531148
return _storage_config_TDB_INTERNAL();
1154-
#else
1155-
BlockDevice *bd = get_other_blockdevice();
1156-
if (bd) {
1157-
if (bd->get_erase_value() != -1) {
1158-
return _storage_config_TDB_EXTERNAL();
1159-
} else {
1160-
return _storage_config_FILESYSTEM();
1161-
}
1162-
} else {
1163-
return MBED_ERROR_UNSUPPORTED;
1164-
}
1165-
#endif
11661149
}
11671150

11681151
const char *get_filesystemstore_folder_path()

features/storage/kvstore/direct_access_devicekey/DirectAccessDevicekey.cpp

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -134,27 +134,14 @@ int get_expected_internal_TDBStore_position(uint32_t *out_tdb_start_offset, uin
134134
tdb_size = MBED_CONF_STORAGE_TDB_EXTERNAL_RBP_INTERNAL_SIZE;
135135
#endif
136136

137-
} else if (strcmp(STR(MBED_CONF_STORAGE_STORAGE_TYPE), "TDB_INTERNAL") == 0) {
137+
} else if (strcmp(STR(MBED_CONF_STORAGE_STORAGE_TYPE), "TDB_INTERNAL") == 0 ||
138+
strcmp(STR(MBED_CONF_STORAGE_STORAGE_TYPE), "default") == 0) {
138139
#ifndef MBED_CONF_STORAGE_TDB_INTERNAL_INTERNAL_BASE_ADDRESS
139140
return MBED_ERROR_ITEM_NOT_FOUND;
140141
#else
141142
*out_tdb_start_offset = MBED_CONF_STORAGE_TDB_INTERNAL_INTERNAL_BASE_ADDRESS;
142143
tdb_size = MBED_CONF_STORAGE_TDB_INTERNAL_INTERNAL_SIZE;
143144
#endif
144-
145-
} else if (strcmp(STR(MBED_CONF_STORAGE_STORAGE_TYPE), "default") == 0) {
146-
#ifndef MBED_CONF_STORAGE_TDB_EXTERNAL_INTERNAL_BASE_ADDRESS
147-
return MBED_ERROR_ITEM_NOT_FOUND;
148-
#else
149-
#if COMPONENT_QSPIF || COMPONENT_SPIF || COMPONENT_DATAFLASH
150-
*out_tdb_start_offset = MBED_CONF_STORAGE_TDB_EXTERNAL_INTERNAL_BASE_ADDRESS;
151-
tdb_size = MBED_CONF_STORAGE_TDB_EXTERNAL_RBP_INTERNAL_SIZE;
152-
#elif COMPONENT_SD
153-
tdb_size = MBED_CONF_STORAGE_FILESYSTEM_RBP_INTERNAL_SIZE;
154-
#else
155-
return MBED_ERROR_UNSUPPORTED;
156-
#endif // COMPONENT_QSPIF || COMPONENT_SPIF || COMPONENT_DATAFLASH
157-
#endif // MBED_CONF_STORAGE_TDB_EXTERNAL_INTERNAL_BASE_ADDRESS
158145
} else {
159146
return MBED_ERROR_UNSUPPORTED;
160147
}

0 commit comments

Comments
 (0)