Skip to content

Refactor TDB internal bounds computation #11629

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 13 commits into from
Mar 30, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions UNITTESTS/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,7 @@ set(unittest-includes-base
"${PROJECT_SOURCE_DIR}/../features/mbedtls"
"${PROJECT_SOURCE_DIR}/../features/mbedtls/inc"
"${PROJECT_SOURCE_DIR}/../features/mbedtls/mbed-crypto/inc"
"${PROJECT_SOURCE_DIR}/../features/storage/kvstore/conf"
)

# Create a list for test suites.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ int get_virtual_TDBStore_position(uint32_t conf_start_address, uint32_t conf_si
uint32_t flash_start_address;
uint32_t aligned_start_address;
FlashIAP flash;
static const int STORE_SECTORS = 2;

int ret = flash.init();
if (ret != 0) {
Expand Down Expand Up @@ -93,19 +92,11 @@ int get_virtual_TDBStore_position(uint32_t conf_start_address, uint32_t conf_si
}
}
} else {
// Assumption is that last two sectors are reserved for the TDBStore
aligned_start_address = flash.get_flash_start() + flash.get_flash_size();

for (int i = STORE_SECTORS; i; i--) {
bd_size_t sector_size = flash.get_sector_size(aligned_start_address - 1);
aligned_start_address -= sector_size;
}

if (aligned_start_address < flash_first_writable_sector_address) {
flash.deinit();
return -2;
}
bd_final_size = (flash_end_address - aligned_start_address);
bd_addr_t default_start;
bd_size_t default_size;
kv_get_default_flash_addresses(&default_start, &default_size);
aligned_start_address = (uint32_t)default_start;
bd_final_size = (uint32_t)default_size;
}

(*tdb_start_address) = aligned_start_address;
Expand Down
6 changes: 3 additions & 3 deletions features/storage/kvstore/conf/filesystem/mbed_lib.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
"name": "storage_filesystem",
"config": {
"rbp_internal_size": {
"help": "Default is the size of the 2 last sectors of internal flash",
"help": "Default is the larger of the last 2 sectors or last 14 pages of flash.",
"value": "0"
},
"internal_base_address": {
"help": "If default, base address is the first sector after the application code",
"help": "If default, base address is set to internal_size bytes before the end of flash.",
"value": "0"
},
"filesystem": {
Expand Down Expand Up @@ -36,7 +36,7 @@
},
"target_overrides": {
"MCU_PSOC6": {
"rbp_internal_size": 7168
"rbp_internal_size": "7168"
}
}
}
Loading