Merge pull request #12645 from mtomczykmobica/IOTSTOR-906

Storage: Use internal flash for KVStore always if default config
pull/12665/head
Martin Kojtal 2020-03-20 08:52:59 +01:00 committed by GitHub
commit 03dab7f9a0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 5 additions and 47 deletions

View File

@ -63,7 +63,7 @@ The following is a list of all storage parameters available and their descriptio
* `FILESYSTEM`.
* `FILESYSTEM_NO_RBP`.
* `default`
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`.
If the `default` configuration is set, the system will choose the type of storage TDB_INTERNAL.
* `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.
* `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.
* `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`.

View File

@ -264,22 +264,10 @@ void test_direct_access_to_device_inject_root()
} else if (strcmp(STR(MBED_CONF_STORAGE_STORAGE_TYPE), "TDB_EXTERNAL") == 0) {
internal_start_address = MBED_CONF_STORAGE_TDB_EXTERNAL_INTERNAL_BASE_ADDRESS;
internal_rbp_size = MBED_CONF_STORAGE_TDB_EXTERNAL_RBP_INTERNAL_SIZE;
} else if (strcmp(STR(MBED_CONF_STORAGE_STORAGE_TYPE), "TDB_INTERNAL") == 0) {
} else if (strcmp(STR(MBED_CONF_STORAGE_STORAGE_TYPE), "TDB_INTERNAL") == 0 ||
strcmp(STR(MBED_CONF_STORAGE_STORAGE_TYPE), "default") == 0) {
internal_start_address = MBED_CONF_STORAGE_TDB_INTERNAL_INTERNAL_BASE_ADDRESS;
internal_rbp_size = MBED_CONF_STORAGE_TDB_INTERNAL_INTERNAL_SIZE;
} else if (strcmp(STR(MBED_CONF_STORAGE_STORAGE_TYPE), "default") == 0) {
#if COMPONENT_QSPIF || COMPONENT_SPIF || COMPONENT_DATAFLASH
internal_start_address = MBED_CONF_STORAGE_TDB_EXTERNAL_INTERNAL_BASE_ADDRESS;
internal_rbp_size = MBED_CONF_STORAGE_TDB_EXTERNAL_RBP_INTERNAL_SIZE;
#elif COMPONENT_SD
internal_start_address = MBED_CONF_STORAGE_FILESYSTEM_INTERNAL_BASE_ADDRESS;
internal_rbp_size = MBED_CONF_STORAGE_FILESYSTEM_RBP_INTERNAL_SIZE;
#elif COMPONENT_FLASHIAP
internal_start_address = MBED_CONF_STORAGE_TDB_INTERNAL_INTERNAL_BASE_ADDRESS;
internal_rbp_size = MBED_CONF_STORAGE_TDB_INTERNAL_INTERNAL_SIZE;
#else
TEST_SKIP_UNLESS_MESSAGE(false, "Test skipped. No KVStore Internal");
#endif
} else {
TEST_SKIP_UNLESS_MESSAGE(false, "Test skipped. No KVStore Internal");
}

View File

@ -1145,24 +1145,7 @@ int _storage_config_filesystem_common()
int _storage_config_default()
{
#if COMPONENT_QSPIF || COMPONENT_SPIF || COMPONENT_DATAFLASH
return _storage_config_TDB_EXTERNAL();
#elif COMPONENT_SD
return _storage_config_FILESYSTEM();
#elif COMPONENT_FLASHIAP
return _storage_config_TDB_INTERNAL();
#else
BlockDevice *bd = get_other_blockdevice();
if (bd) {
if (bd->get_erase_value() != -1) {
return _storage_config_TDB_EXTERNAL();
} else {
return _storage_config_FILESYSTEM();
}
} else {
return MBED_ERROR_UNSUPPORTED;
}
#endif
}
const char *get_filesystemstore_folder_path()

View File

@ -134,27 +134,14 @@ int get_expected_internal_TDBStore_position(uint32_t *out_tdb_start_offset, uin
tdb_size = MBED_CONF_STORAGE_TDB_EXTERNAL_RBP_INTERNAL_SIZE;
#endif
} else if (strcmp(STR(MBED_CONF_STORAGE_STORAGE_TYPE), "TDB_INTERNAL") == 0) {
} else if (strcmp(STR(MBED_CONF_STORAGE_STORAGE_TYPE), "TDB_INTERNAL") == 0 ||
strcmp(STR(MBED_CONF_STORAGE_STORAGE_TYPE), "default") == 0) {
#ifndef MBED_CONF_STORAGE_TDB_INTERNAL_INTERNAL_BASE_ADDRESS
return MBED_ERROR_ITEM_NOT_FOUND;
#else
*out_tdb_start_offset = MBED_CONF_STORAGE_TDB_INTERNAL_INTERNAL_BASE_ADDRESS;
tdb_size = MBED_CONF_STORAGE_TDB_INTERNAL_INTERNAL_SIZE;
#endif
} else if (strcmp(STR(MBED_CONF_STORAGE_STORAGE_TYPE), "default") == 0) {
#ifndef MBED_CONF_STORAGE_TDB_EXTERNAL_INTERNAL_BASE_ADDRESS
return MBED_ERROR_ITEM_NOT_FOUND;
#else
#if COMPONENT_QSPIF || COMPONENT_SPIF || COMPONENT_DATAFLASH
*out_tdb_start_offset = MBED_CONF_STORAGE_TDB_EXTERNAL_INTERNAL_BASE_ADDRESS;
tdb_size = MBED_CONF_STORAGE_TDB_EXTERNAL_RBP_INTERNAL_SIZE;
#elif COMPONENT_SD
tdb_size = MBED_CONF_STORAGE_FILESYSTEM_RBP_INTERNAL_SIZE;
#else
return MBED_ERROR_UNSUPPORTED;
#endif // COMPONENT_QSPIF || COMPONENT_SPIF || COMPONENT_DATAFLASH
#endif // MBED_CONF_STORAGE_TDB_EXTERNAL_INTERNAL_BASE_ADDRESS
} else {
return MBED_ERROR_UNSUPPORTED;
}