Skip to content

Commit eb29af5

Browse files
author
David Saada
committed
Fix direct access to device key test for small erase/program ratio
This commit fixes the failure in the "Direct access to device key" test, when working with internal flash components, whose erase size to program size ratio is small. In such cases, the last two sectors are not large enough to store the device key.
1 parent 355f09b commit eb29af5

File tree

1 file changed

+13
-1
lines changed
  • features/storage/TESTS/kvstore/direct_access_devicekey_test

1 file changed

+13
-1
lines changed

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

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ void test_direct_access_to_devicekey_tdb_flashiap_remainder()
186186

187187
void test_direct_access_to_devicekey_tdb_last_two_sectors()
188188
{
189-
utest_printf("Test Direct Access To DeviceKey Test Entire FlashIAP Remainder\n");
189+
utest_printf("Test Direct Access To DeviceKey Test Last Two Sectors\n");
190190

191191
uint32_t flash_bd_start_address;
192192
uint32_t flash_bd_end_address;
@@ -198,6 +198,18 @@ void test_direct_access_to_devicekey_tdb_last_two_sectors()
198198
uint32_t flash_bd_size = flash_bd_end_address - flash_bd_start_address;
199199

200200
FlashIAPBlockDevice *flash_bd = new FlashIAPBlockDevice((bd_addr_t)flash_bd_start_address, (bd_size_t)flash_bd_size);
201+
flash_bd->init();
202+
uint32_t sector_addr = flash_bd->size();
203+
for (int i = 0; i < 2; i++) {
204+
uint32_t sector_size = flash_bd->get_erase_size(sector_addr - 1);
205+
uint32_t erase_prog_ratio = sector_size / flash_bd->get_program_size();
206+
if (erase_prog_ratio < 4) {
207+
delete flash_bd;
208+
TEST_SKIP_UNLESS_MESSAGE(false, "Test skipped. Flash program size doesn't support this test.");
209+
}
210+
sector_addr -= sector_size;
211+
}
212+
flash_bd->deinit();
201213

202214
TDBStore *tdb = new TDBStore(flash_bd);
203215
// Start by Init and Reset to TDBStore

0 commit comments

Comments
 (0)