Skip to content
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

Add flash sum check #9722

Merged
merged 1 commit into from Feb 15, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
26 changes: 26 additions & 0 deletions TESTS/mbed_drivers/flashiap/main.cpp
Expand Up @@ -29,6 +29,17 @@

#include "mbed.h"

// Debug available
#ifndef FLASHIAP_DEBUG
#define FLASHIAP_DEBUG 0
#endif

#if FLASHIAP_DEBUG
#define DEBUG_PRINTF(...) printf(__VA_ARGS__)
#else
#define DEBUG_PRINTF(...)
#endif

using namespace utest::v1;


Expand All @@ -37,6 +48,21 @@ void flashiap_init_test()
FlashIAP flash_device;
uint32_t ret = flash_device.init();
TEST_ASSERT_EQUAL_INT32(0, ret);

uint32_t flash_start = flash_device.get_flash_start();
uint32_t flash_size = flash_device.get_flash_size();
utest_printf("Flash address: 0x%08x, size: %d\n", flash_start, flash_size);
uint32_t address = flash_start;
int num = 0;
while (flash_size) {
uint32_t sector_size = flash_device.get_sector_size(address);
// Make sure all sectors sum up to the total flash size
TEST_ASSERT(flash_size >= sector_size);
DEBUG_PRINTF("\tsector %3d: address 0x%08x, size %8d\n", num++, address, sector_size);
flash_size -= sector_size;
address += sector_size;
}

ret = flash_device.deinit();
TEST_ASSERT_EQUAL_INT32(0, ret);
}
Expand Down