From 926423c109219e759a19b5c150fd9c3f5424d56b Mon Sep 17 00:00:00 2001 From: Kyle Kearney Date: Fri, 8 Nov 2019 18:10:31 -0800 Subject: [PATCH] Reuse TDBStore default size computation in devicekey test Replace custom caluation that always assumed two sectors with the standard calculation exposed on TDBStore. --- .../direct_access_devicekey_test/main.cpp | 19 +++++-------------- 1 file changed, 5 insertions(+), 14 deletions(-) diff --git a/features/storage/TESTS/kvstore/direct_access_devicekey_test/main.cpp b/features/storage/TESTS/kvstore/direct_access_devicekey_test/main.cpp index 8a695eb590..e58983716b 100644 --- a/features/storage/TESTS/kvstore/direct_access_devicekey_test/main.cpp +++ b/features/storage/TESTS/kvstore/direct_access_devicekey_test/main.cpp @@ -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) { @@ -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; + TDBStore::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;