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

mbed-hal: Fixed flash test #4782

Merged
merged 1 commit into from Jul 24, 2017
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
16 changes: 13 additions & 3 deletions TESTS/mbed_hal/flash/functional_tests/main.cpp
Expand Up @@ -148,7 +148,6 @@ void flash_mapping_alignment_test()
TEST_ASSERT_EQUAL(0, sector_start % sector_size);
// All address in a sector must return the same sector size
TEST_ASSERT_EQUAL(sector_size, end_sector_size);

}

// Make sure unmapped flash is reported correctly
Expand Down Expand Up @@ -185,6 +184,7 @@ void flash_program_page_test()

uint32_t test_size = flash_get_page_size(&test_flash);
uint8_t *data = new uint8_t[test_size];
uint8_t *data_flashed = new uint8_t[test_size];
for (uint32_t i = 0; i < test_size; i++) {
data[i] = 0xCE;
}
Expand All @@ -199,7 +199,9 @@ void flash_program_page_test()

ret = flash_program_page(&test_flash, address, data, test_size);
TEST_ASSERT_EQUAL_INT32(0, ret);
uint8_t *data_flashed = (uint8_t *)address;

ret = flash_read(&test_flash, address, data_flashed, test_size);
TEST_ASSERT_EQUAL_INT32(0, ret);
TEST_ASSERT_EQUAL_UINT8_ARRAY(data, data_flashed, test_size);

// sector size might not be same as page size
Expand All @@ -213,11 +215,15 @@ void flash_program_page_test()
}
ret = flash_program_page(&test_flash, address, data, test_size);
TEST_ASSERT_EQUAL_INT32(0, ret);

ret = flash_read(&test_flash, address, data_flashed, test_size);
TEST_ASSERT_EQUAL_INT32(0, ret);
TEST_ASSERT_EQUAL_UINT8_ARRAY(data, data_flashed, test_size);

ret = flash_free(&test_flash);
TEST_ASSERT_EQUAL_INT32(0, ret);
delete[] data;
delete[] data_flashed;
}

// make sure programming works with an unaligned data buffer
Expand All @@ -230,6 +236,7 @@ void flash_buffer_alignment_test()
const uint32_t page_size = flash_get_page_size(&test_flash);
const uint32_t buf_size = page_size + 4;
uint8_t *data = new uint8_t[buf_size];
uint8_t *data_flashed = new uint8_t[buf_size];
for (uint32_t i = 0; i < buf_size; i++) {
data[i] = i & 0xFF;
}
Expand All @@ -245,13 +252,16 @@ void flash_buffer_alignment_test()
const uint32_t addr = test_addr + i * page_size;
ret = flash_program_page(&test_flash, addr, data + i, page_size);
TEST_ASSERT_EQUAL_INT32(0, ret);
uint8_t *data_flashed = (uint8_t *)addr;

ret = flash_read(&test_flash, addr, data_flashed, page_size);
TEST_ASSERT_EQUAL_INT32(0, ret);
TEST_ASSERT_EQUAL_UINT8_ARRAY(data + i, data_flashed, page_size);
}

ret = flash_free(&test_flash);
TEST_ASSERT_EQUAL_INT32(0, ret);
delete[] data;
delete[] data_flashed;
}

// check the execution speed at the start and end of the test to make sure
Expand Down