mirror of https://github.com/ARMmbed/mbed-os.git
Merge pull request #4782 from marcuschangarm/flash_hal_test
mbed-hal: Fixed flash testpull/4803/head
commit
2d8457e68d
|
@ -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
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue