Skip to content

CFSTORE Integration with Storage-Volume-Manager and Flash-Journal API Latest Versions #2701

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

Merged
merged 2 commits into from
Sep 21, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 21 additions & 10 deletions TESTS/storage_abstraction/basicAPI/basicAPI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@

using namespace utest::v1;

extern ARM_DRIVER_STORAGE ARM_Driver_Storage_(0);
ARM_DRIVER_STORAGE *drv = &ARM_Driver_Storage_(0);
extern ARM_DRIVER_STORAGE ARM_Driver_Storage_MTD_K64F;
ARM_DRIVER_STORAGE *drv = &ARM_Driver_Storage_MTD_K64F;

/* temporary buffer to hold data for testing. */
static const unsigned BUFFER_SIZE = 16384;
Expand Down Expand Up @@ -112,6 +112,7 @@ void test_getInfo()

TEST_ASSERT_EQUAL(0, info.security.reserved1);
TEST_ASSERT_EQUAL(0, info.security.reserved2);
TEST_ASSERT((info.program_cycles == ARM_STORAGE_PROGRAM_CYCLES_INFINITE) || (info.program_cycles > 0));
TEST_ASSERT(info.total_storage > 0);
}

Expand Down Expand Up @@ -373,7 +374,7 @@ control_t test_programDataUsingProgramUnit(const size_t call_count)
return (call_count < REPEAT_INSTANCES) ? CaseTimeout(200) + CaseRepeatAll: CaseTimeout(200);
} else {
TEST_ASSERT_EQUAL(firstBlock.attributes.erase_unit, rc);
verifyBytePattern(addr, firstBlock.attributes.erase_unit, (uint8_t)0xFF);
verifyBytePattern(addr, firstBlock.attributes.erase_unit, info.erased_value ? (uint8_t)0xFF : (uint8_t)0);

static const uint32_t BYTE_PATTERN = 0xAA551122;
size_t sizeofData = info.program_unit;
Expand Down Expand Up @@ -495,7 +496,7 @@ control_t test_programDataUsingOptimalProgramUnit(const size_t call_count)
return (call_count < REPEAT_INSTANCES) ? CaseTimeout(200) + CaseRepeatAll: CaseTimeout(200);
} else {
TEST_ASSERT_EQUAL(firstBlock.attributes.erase_unit, rc);
verifyBytePattern(addr, firstBlock.attributes.erase_unit, (uint8_t)0xFF);
verifyBytePattern(addr, firstBlock.attributes.erase_unit, info.erased_value ? (uint8_t)0xFF : (uint8_t)0);

static const uint8_t BYTE_PATTERN = 0xAA;
size_t sizeofData = info.optimal_program_unit;
Expand Down Expand Up @@ -579,10 +580,12 @@ void eraseCompleteCallback(int32_t status, ARM_STORAGE_OPERATION operation)
const uint64_t addr = firstBlock.addr + eraseIteration * ERASE_UNITS_PER_ITERATION * firstBlock.attributes.erase_unit;
++eraseIteration;

#ifndef __CC_ARM
printf("testing erased sector at addr %lu\n", (uint32_t)addr);
#endif
verifyBytePattern(addr, ERASE_UNITS_PER_ITERATION * firstBlock.attributes.erase_unit, (uint8_t)0xFF);
ARM_STORAGE_INFO info;
int32_t rc = drv->GetInfo(&info);
TEST_ASSERT_EQUAL(ARM_DRIVER_OK, rc);

//printf("testing erased sector at addr %lu", (uint32_t)addr);
verifyBytePattern(addr, ERASE_UNITS_PER_ITERATION * firstBlock.attributes.erase_unit, info.erased_value ? (uint8_t)0xFF : (uint8_t)0);

Harness::validate_callback();
}
Expand Down Expand Up @@ -628,6 +631,10 @@ control_t test_erase(const size_t call_count)
} else {
TEST_ASSERT_EQUAL(ERASE_UNITS_PER_ITERATION * firstBlock.attributes.erase_unit, rc);

ARM_STORAGE_INFO info;
rc = drv->GetInfo(&info);
TEST_ASSERT_EQUAL(ARM_DRIVER_OK, rc);

/* test that the actual sector has been erased */
printf("testing erased sector at addr %lu\n", (uint32_t)addr);
verifyBytePattern(addr, ERASE_UNITS_PER_ITERATION * firstBlock.attributes.erase_unit, (uint8_t)0xFF);
Expand Down Expand Up @@ -708,8 +715,12 @@ control_t test_eraseAll(const size_t call_count)
unsigned index = 0;
static const unsigned MAX_VERIFY_ITERATIONS = 5;
while ((index < MAX_VERIFY_ITERATIONS) && (addr < (firstBlock.addr + firstBlock.size))) {
printf("testing erased chip at addr %lu\n", (uint32_t)addr);
verifyBytePattern(addr, firstBlock.attributes.erase_unit, (uint8_t)0xFF);
//printf("testing erased chip at addr %lu", (uint32_t)addr);
ARM_STORAGE_INFO info;
rc = drv->GetInfo(&info);
TEST_ASSERT_EQUAL(ARM_DRIVER_OK, rc);

verifyBytePattern(addr, firstBlock.attributes.erase_unit, info.erased_value ? (uint8_t)0xFF : (uint8_t)0);

index++;
addr += firstBlock.attributes.erase_unit;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,7 @@ control_t cfstore_add_del_test_04(const size_t call_count)
return CaseNext;
}

/** @brief Delete and attribute after an internal realloc of the cfstore memory area
/** @brief Delete an attribute after an internal realloc of the cfstore memory area
*
* This test case goes through the following steps:
* 1. Creates attribute att_1 of size x, and write some data. This causes an internal
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,6 @@ typedef enum cfstore_ex_state_t {
CFSTORE_EX_STATE_UNINIT_DONE
} cfstore_ex_state_t;


typedef struct cfstore_example1_ctx_t
{
ARM_CFSTORE_CAPABILITIES caps;
Expand Down Expand Up @@ -263,7 +262,87 @@ static void cfstore_ex_fms_update(cfstore_example1_ctx_t* ctx);
/// @endcond


/* @brief test startup code to reset flash
#ifdef CFSTORE_CONFIG_BACKEND_FLASH_ENABLED

#define CFSTORE_FLASH_START_FORMAT (FLASH_JOURNAL_OPCODE_RESET + 0x00010000)

typedef enum cfstore_ex_flash_state_t {
CFSTORE_EX_FLASH_STATE_STARTING = 1,
CFSTORE_EX_FLASH_STATE_FORMATTING,
CFSTORE_EX_FLASH_STATE_INITIALIZING,
CFSTORE_EX_FLASH_STATE_RESETTING,
CFSTORE_EX_FLASH_STATE_READY,
} cfstore_ex_flash_state_t;

typedef struct cfstore_example1_flash_ctx_t
{
volatile cfstore_ex_flash_state_t state;
} cfstore_example1_flash_ctx_t;

static cfstore_example1_flash_ctx_t cfstore_example1_flash_ctx_g;


static void cfstore_ex_flash_journal_callback(int32_t status, FlashJournal_OpCode_t cmd_code)
{
static FlashJournal_t jrnl;
extern ARM_DRIVER_STORAGE ARM_Driver_Storage_MTD_K64F;
const ARM_DRIVER_STORAGE *drv = &ARM_Driver_Storage_MTD_K64F;


if(cmd_code == (FlashJournal_OpCode_t) CFSTORE_FLASH_START_FORMAT) {
CFSTORE_EX1_LOG("FORMATTING%s", "\n");
status = flashJournalStrategySequential_format(drv, 4, cfstore_ex_flash_journal_callback);
CFSTORE_EX1_TEST_ASSERT_MSG(status >= JOURNAL_STATUS_OK, "%s:Error: FlashJournal_format() failed (status=%d)\r\n", __func__, (int) status);
if(status == 0) {
/* async completion pending */
return;
}
/* status > 0 implies operation completed synchronously
* intentional fall through */
}

switch(cmd_code)
{
case FLASH_JOURNAL_OPCODE_FORMAT:
/* format done */
CFSTORE_EX1_TEST_ASSERT_MSG(status > JOURNAL_STATUS_OK, "%s:Error: FlashJournal_format() failed (status=%d)\r\n", __func__, (int) status);
cfstore_example1_flash_ctx_g.state = CFSTORE_EX_FLASH_STATE_INITIALIZING;

CFSTORE_EX1_LOG("FLASH INITIALIZING%s", "\n");
status = FlashJournal_initialize(&jrnl, drv, &FLASH_JOURNAL_STRATEGY_SEQUENTIAL, NULL);
CFSTORE_EX1_TEST_ASSERT_MSG(status >= JOURNAL_STATUS_OK, "%s:Error: FlashJournal_initialize() failed (status=%d)\r\n", __func__, (int) status);
if(status == 0) {
/* async completion pending */
break;
}
/* status > 0 implies operation completed synchronously
* intentional fall through */
case FLASH_JOURNAL_OPCODE_INITIALIZE:
/* initialize done */
CFSTORE_EX1_TEST_ASSERT_MSG(status > JOURNAL_STATUS_OK, "%s:Error: FlashJournal_initialize() failed (status=%d)\r\n", __func__, (int) status);
cfstore_example1_flash_ctx_g.state = CFSTORE_EX_FLASH_STATE_RESETTING;

CFSTORE_EX1_LOG("FLASH RESETTING%s", "\n");
status = FlashJournal_reset(&jrnl);
CFSTORE_EX1_TEST_ASSERT_MSG(status >= JOURNAL_STATUS_OK, "%s:Error: FlashJournal_reset() failed (status=%d)\r\n", __func__, (int) status);
/* intentional fall through */
case FLASH_JOURNAL_OPCODE_RESET:
/* reset done */
CFSTORE_EX1_LOG("FLASH RESET DONE%s", "\n");
cfstore_example1_flash_ctx_g.state = CFSTORE_EX_FLASH_STATE_READY;
break;

default:
CFSTORE_EX1_LOG("%s:Error: notification of unsupported cmd_code event (status=%d, cmd_code=%d)\n", __func__, (int) status, (int) cmd_code);
return;
}
return;
}
#endif /* CFSTORE_CONFIG_BACKEND_FLASH_ENABLED */



/* @brief test startup code to reset flash for testing purposes.
*/
static int32_t cfstore_test_startup(void)
{
Expand All @@ -272,16 +351,13 @@ static int32_t cfstore_test_startup(void)

#ifdef CFSTORE_CONFIG_BACKEND_FLASH_ENABLED

int32_t ret = ARM_DRIVER_ERROR;
static FlashJournal_t jrnl;
extern ARM_DRIVER_STORAGE ARM_Driver_Storage_(0);
const ARM_DRIVER_STORAGE *drv = &ARM_Driver_Storage_(0);

ret = FlashJournal_initialize(&jrnl, drv, &FLASH_JOURNAL_STRATEGY_SEQUENTIAL, NULL);
CFSTORE_EX1_TEST_ASSERT_MSG(ret >= JOURNAL_STATUS_OK, "%s:Error: FlashJournal_initialize() failed (ret=%d)\r\n", __func__, (int) ret);
memset(&cfstore_example1_flash_ctx_g, 0, sizeof(cfstore_example1_flash_ctx_g));
cfstore_example1_flash_ctx_g.state = CFSTORE_EX_FLASH_STATE_STARTING;
cfstore_ex_flash_journal_callback(JOURNAL_STATUS_OK, (FlashJournal_OpCode_t) CFSTORE_FLASH_START_FORMAT);
while(cfstore_example1_flash_ctx_g.state != CFSTORE_EX_FLASH_STATE_READY) {
/* spin */
}

ret = FlashJournal_reset(&jrnl);
CFSTORE_EX1_TEST_ASSERT_MSG(ret >= JOURNAL_STATUS_OK, "%s:Error: FlashJournal_reset() failed (ret=%d)\r\n", __func__, (int) ret);
#endif /* CFSTORE_CONFIG_BACKEND_FLASH_ENABLED */

return ARM_DRIVER_OK;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ static control_t cfstore_example3_app_start(const size_t call_count)
ctx->hkey_prev = ctx->hkey_prev_buf;
ctx->caps = cfstore_drv->GetCapabilities();
CFSTORE_EX1_LOG("%s:INITIALIZING: caps.asynchronous_ops=%lu\n", __func__, ctx->caps.asynchronous_ops);
if(ctx->caps.asynchronous_ops == true){
if(ctx->caps.asynchronous_ops == 1){
/* This is a sync mode only test. If this test is not built for sync mode, then skip testing return true
* This means the test will conveniently pass when run in CI as part of async mode testing */
CFSTORE_EX1_LOG("*** Skipping test as binary built for flash journal async mode, and this test is sync-only%s", "\n");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ static control_t cfstore_example4_test_00(const size_t call_count)
/* initialise the context */
caps = gCfStoreDriver->GetCapabilities();
CFSTORE_LOG("%s:INITIALIZING: caps.asynchronous_ops=%lu\n", __func__, caps.asynchronous_ops);
if(caps.asynchronous_ops == true){
if(caps.asynchronous_ops == 1){
/* This is a sync mode only test. If this test is not built for sync mode, then skip testing return true
* This means the test will conveniently pass when run in CI as part of async mode testing */
CFSTORE_LOG("*** Skipping test as binary built for flash journal async mode, and this test is sync-only%s", "\n");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -167,8 +167,8 @@ int32_t cfstore_test_startup(void)
#ifdef CFSTORE_CONFIG_BACKEND_FLASH_ENABLED
int32_t ret = ARM_DRIVER_ERROR;
static FlashJournal_t jrnl;
extern ARM_DRIVER_STORAGE ARM_Driver_Storage_(0);
const ARM_DRIVER_STORAGE *drv = &ARM_Driver_Storage_(0);
extern ARM_DRIVER_STORAGE ARM_Driver_Storage_MTD_K64F;
const ARM_DRIVER_STORAGE *drv = &ARM_Driver_Storage_MTD_K64F;

ret = FlashJournal_initialize(&jrnl, drv, &FLASH_JOURNAL_STRATEGY_SEQUENTIAL, NULL);
CFSTORE_EX5_TEST_ASSERT_MSG(ret >= JOURNAL_STATUS_OK, "%s:Error: FlashJournal_initialize() failed (ret=%d)\r\n", __func__, (int) ret);
Expand Down Expand Up @@ -278,7 +278,7 @@ static control_t cfstore_EXAMPLE5_app_start(const size_t call_count)
ctx->hkey_prev = ctx->hkey_prev_buf;
ctx->caps = cfstore_drv->GetCapabilities();
CFSTORE_EX5_LOG("%s:INITIALIZING: caps.asynchronous_ops=%lu\n", __func__, ctx->caps.asynchronous_ops);
if(ctx->caps.asynchronous_ops == true){
if(ctx->caps.asynchronous_ops){
/* This is a sync mode only test. If this test is not built for sync mode, then skip testing return true
* This means the test will conveniently pass when run in CI as part of async mode testing */
CFSTORE_EX5_LOG("*** Skipping test as binary built for flash journal async mode, and this test is sync-only%s", "\n");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,8 @@ char cfstore_flash_utest_msg_g[CFSTORE_FLASH_UTEST_MSG_BUF_SIZE];

#ifdef CFSTORE_CONFIG_BACKEND_FLASH_ENABLED
uint16_t cfstore_flash_mtd_async_ops_g = 0;
extern ARM_DRIVER_STORAGE ARM_Driver_Storage_(0);
extern ARM_DRIVER_STORAGE ARM_Driver_Storage_MTD_K64F;


/* KV data for test_01 */
static cfstore_kv_data_t cfstore_flush_test_01_kv_data[] = {
Expand Down Expand Up @@ -279,7 +280,7 @@ void cfstore_flash_test_01_callback(int32_t status, FlashJournal_OpCode_t cmd_co
static void cfstore_flash_fsm_init_on_entry(void* context)
{
/* round up cfstore_flash_data_blob_t to nearest k64f program unit size */
const ARM_DRIVER_STORAGE *drv = &ARM_Driver_Storage_(0);
const ARM_DRIVER_STORAGE *drv = &ARM_Driver_Storage_MTD_K64F;
FlashJournal_Info_t info;
FlashJournal_Status_t status = JOURNAL_STATUS_ERROR;
cfstore_flash_ctx_t* ctx = (cfstore_flash_ctx_t*) context;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -844,7 +844,7 @@ static control_t cfstore_flush3_test_00(const size_t call_count)
/* initialise the context */
caps = drv->GetCapabilities();
CFSTORE_LOG("%s:INITIALIZING: caps.asynchronous_ops=%lu\n", __func__, caps.asynchronous_ops);
if(caps.asynchronous_ops == true){
if(caps.asynchronous_ops == 1){
/* This is a sync mode only test. If this test is not built for sync mode, then skip testing return true
* This means the test will conveniently pass when run in CI as part of async mode testing */
CFSTORE_LOG("*** Skipping test as binary built for flash journal async mode, and this test is sync-only%s", "\n");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ static control_t cfstore_init_app_start(const size_t call_count)
memset(ctx, 0, sizeof(cfstore_init_ctx_t));
ctx->caps = cfstore_drv->GetCapabilities();
CFSTORE_LOG("%s:INITIALIZING: caps.asynchronous_ops=%lu\n", __func__, ctx->caps.asynchronous_ops);
if(ctx->caps.asynchronous_ops == true){
if(ctx->caps.asynchronous_ops == 1){
/* This is a sync mode only test. If this test is not built for sync mode, then skip testing return true
* This means the test will conveniently pass when run in CI as part of async mode testing */
CFSTORE_LOG("*** Skipping test as binary built for flash journal async mode, and this test is sync-only%s", "\n");
Expand Down
6 changes: 3 additions & 3 deletions features/storage/FEATURE_STORAGE/TESTS/cfstore/misc/misc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@ control_t cfstore_misc_test_04_start(const size_t call_count)

status = drv->GetStatus();
CFSTORE_TEST_UTEST_MESSAGE(cfstore_misc_utest_msg_g, CFSTORE_UTEST_MSG_BUF_SIZE, "%s:Error: GetStatus() before initialisation should have reported error, but reported no error.\r\n", __func__);
TEST_ASSERT_MESSAGE(status.error == true, cfstore_misc_utest_msg_g);
TEST_ASSERT_MESSAGE(status.error == 1, cfstore_misc_utest_msg_g);

ret = drv->Initialize(cfstore_utest_default_callback, NULL);
CFSTORE_TEST_UTEST_MESSAGE(cfstore_misc_utest_msg_g, CFSTORE_UTEST_MSG_BUF_SIZE, "%s:Error: failed to initialize CFSTORE (ret=%d)\n", __func__, (int) ret);
Expand All @@ -295,10 +295,10 @@ control_t cfstore_misc_test_04_end(const size_t call_count)

status = drv->GetStatus();
CFSTORE_TEST_UTEST_MESSAGE(cfstore_misc_utest_msg_g, CFSTORE_UTEST_MSG_BUF_SIZE, "%s:Error: GetStatus() but reported error.\r\n", __func__);
TEST_ASSERT_MESSAGE(status.error == false, cfstore_misc_utest_msg_g);
TEST_ASSERT_MESSAGE(status.error == 0, cfstore_misc_utest_msg_g);

CFSTORE_TEST_UTEST_MESSAGE(cfstore_misc_utest_msg_g, CFSTORE_UTEST_MSG_BUF_SIZE, "%s:Error: GetStatus() reported operation in progress.\r\n", __func__);
TEST_ASSERT_MESSAGE(status.in_progress == false, cfstore_misc_utest_msg_g);
TEST_ASSERT_MESSAGE(status.in_progress == 0, cfstore_misc_utest_msg_g);

ret = drv->Uninitialize();
CFSTORE_TEST_UTEST_MESSAGE(cfstore_misc_utest_msg_g, CFSTORE_UTEST_MSG_BUF_SIZE, "%s:Error: Uninitialize() call failed.\n", __func__);
Expand Down
Loading