Skip to content

Commit 4c6e59d

Browse files
authored
Merge pull request #11629 from kyle-cypress/pr/tdb-bounds-refactor
Refactor TDB internal bounds computation
2 parents 8392613 + 85d2e8f commit 4c6e59d

File tree

9 files changed

+268
-332
lines changed

9 files changed

+268
-332
lines changed

UNITTESTS/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,7 @@ set(unittest-includes-base
145145
"${PROJECT_SOURCE_DIR}/../features/mbedtls"
146146
"${PROJECT_SOURCE_DIR}/../features/mbedtls/inc"
147147
"${PROJECT_SOURCE_DIR}/../features/mbedtls/mbed-crypto/inc"
148+
"${PROJECT_SOURCE_DIR}/../features/storage/kvstore/conf"
148149
)
149150

150151
# Create a list for test suites.

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

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,6 @@ int get_virtual_TDBStore_position(uint32_t conf_start_address, uint32_t conf_si
5858
uint32_t flash_start_address;
5959
uint32_t aligned_start_address;
6060
FlashIAP flash;
61-
static const int STORE_SECTORS = 2;
6261

6362
int ret = flash.init();
6463
if (ret != 0) {
@@ -93,19 +92,11 @@ int get_virtual_TDBStore_position(uint32_t conf_start_address, uint32_t conf_si
9392
}
9493
}
9594
} else {
96-
// Assumption is that last two sectors are reserved for the TDBStore
97-
aligned_start_address = flash.get_flash_start() + flash.get_flash_size();
98-
99-
for (int i = STORE_SECTORS; i; i--) {
100-
bd_size_t sector_size = flash.get_sector_size(aligned_start_address - 1);
101-
aligned_start_address -= sector_size;
102-
}
103-
104-
if (aligned_start_address < flash_first_writable_sector_address) {
105-
flash.deinit();
106-
return -2;
107-
}
108-
bd_final_size = (flash_end_address - aligned_start_address);
95+
bd_addr_t default_start;
96+
bd_size_t default_size;
97+
kv_get_default_flash_addresses(&default_start, &default_size);
98+
aligned_start_address = (uint32_t)default_start;
99+
bd_final_size = (uint32_t)default_size;
109100
}
110101

111102
(*tdb_start_address) = aligned_start_address;

features/storage/kvstore/conf/filesystem/mbed_lib.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@
22
"name": "storage_filesystem",
33
"config": {
44
"rbp_internal_size": {
5-
"help": "Default is the size of the 2 last sectors of internal flash",
5+
"help": "Default is the larger of the last 2 sectors or last 14 pages of flash.",
66
"value": "0"
77
},
88
"internal_base_address": {
9-
"help": "If default, base address is the first sector after the application code",
9+
"help": "If default, base address is set to internal_size bytes before the end of flash.",
1010
"value": "0"
1111
},
1212
"filesystem": {
@@ -36,7 +36,7 @@
3636
},
3737
"target_overrides": {
3838
"MCU_PSOC6": {
39-
"rbp_internal_size": 7168
39+
"rbp_internal_size": "7168"
4040
}
4141
}
4242
}

0 commit comments

Comments
 (0)