Skip to content

Commit c52d452

Browse files
author
Kyle Kearney
committed
Reuse TDBStore default size computation in devicekey test
Replace custom caluation that always assumed two sectors with the standard calculation exposed on TDBStore.
1 parent 7095ac0 commit c52d452

File tree

1 file changed

+5
-14
lines changed
  • features/storage/TESTS/kvstore/direct_access_devicekey_test

1 file changed

+5
-14
lines changed

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+
TDBStore::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;

0 commit comments

Comments
 (0)