Fix: tests now process correct. The length of written array now fit to the defined range.

Fix: perfomance mode bugfix for big sector sizes.
This commit is contained in:
Dmitry Yakovlev 2017-08-09 09:35:32 +03:00
parent b8b553d122
commit 8f0f9d8ab0
3 changed files with 15 additions and 12 deletions

View file

@ -20,8 +20,6 @@ choice WL_SECTOR_SIZE
config WL_SECTOR_SIZE_512
bool "512"
# This mode is temporary disabled, until unit test is fixed
depends on false
config WL_SECTOR_SIZE_4096
bool "4096"
endchoice

View file

@ -74,6 +74,7 @@ esp_err_t WL_Ext_Perf::erase_sector(size_t sector)
esp_err_t WL_Ext_Perf::erase_sector_fit(uint32_t start_sector, uint32_t count)
{
ESP_LOGV(TAG, "%s begin, start_sector = 0x%08x, count = %i", __func__, start_sector, count);
// This method works with one flash device sector and able to erase "count" of fatfs sectors from this sector
esp_err_t result = ESP_OK;
@ -140,7 +141,7 @@ esp_err_t WL_Ext_Perf::erase_range(size_t start_address, size_t size)
// Calculate rest
uint32_t rest_check_count = sectors_count - pre_check_count - post_check_count;
if ((pre_check_count == this->size_factor) && (0 == pre_check_start)) {
rest_check_count++;
rest_check_count+=this->size_factor;
pre_check_count = 0;
}
uint32_t rest_check_start = start_address + pre_check_count * this->fat_sector_size;
@ -150,10 +151,14 @@ esp_err_t WL_Ext_Perf::erase_range(size_t start_address, size_t size)
result = this->erase_sector_fit(start_address / this->fat_sector_size, pre_check_count);
WL_EXT_RESULT_CHECK(result);
}
ESP_LOGV(TAG, "%s rest_check_start = %i, pre_check_count=%i, rest_check_count=%i, post_check_count=%i\n", __func__, rest_check_start, pre_check_count, rest_check_count, post_check_count);
if (rest_check_count > 0) {
rest_check_count = rest_check_count / this->size_factor;
result = WL_Flash::erase_range(rest_check_start, rest_check_count * this->flash_sector_size);
WL_EXT_RESULT_CHECK(result);
size_t start_sector = rest_check_start / this->flash_sector_size;
for (size_t i = 0; i < rest_check_count; i++) {
result = WL_Flash::erase_sector(start_sector + i);
WL_EXT_RESULT_CHECK(result);
}
}
if (post_check_count != 0) {
result = this->erase_sector_fit(post_check_start, post_check_count);

View file

@ -55,11 +55,11 @@ typedef struct {
wl_handle_t handle;
} read_write_test_arg_t;
#define READ_WRITE_TEST_ARG_INIT(offset_, seed_, handle_) \
#define READ_WRITE_TEST_ARG_INIT(offset_, seed_, handle_, count_) \
{ \
.offset = offset_, \
.seed = seed_, \
.word_count = 1024, \
.word_count = count_, \
.write = true, \
.done = xSemaphoreCreateBinary(), \
.handle = handle_ \
@ -103,9 +103,9 @@ TEST_CASE("multiple tasks can access wl handle simultaneously", "[wear_levelling
TEST_ESP_OK(wl_mount(partition, &handle));
size_t sector_size = wl_sector_size(handle);
TEST_ESP_OK(wl_erase_range(handle, 0, sector_size * 4));
read_write_test_arg_t args1 = READ_WRITE_TEST_ARG_INIT(0, 1, handle);
read_write_test_arg_t args2 = READ_WRITE_TEST_ARG_INIT(sector_size, 2, handle);
TEST_ESP_OK(wl_erase_range(handle, 0, sector_size * 8));
read_write_test_arg_t args1 = READ_WRITE_TEST_ARG_INIT(0, 1, handle, sector_size/sizeof(uint32_t));
read_write_test_arg_t args2 = READ_WRITE_TEST_ARG_INIT(sector_size, 2, handle, sector_size/sizeof(uint32_t));
const size_t stack_size = 4096;
printf("writing 1 and 2\n");
@ -121,8 +121,8 @@ TEST_CASE("multiple tasks can access wl handle simultaneously", "[wear_levelling
args1.write = false;
args2.write = false;
read_write_test_arg_t args3 = READ_WRITE_TEST_ARG_INIT(2 * sector_size, 3, handle);
read_write_test_arg_t args4 = READ_WRITE_TEST_ARG_INIT(3 * sector_size, 4, handle);
read_write_test_arg_t args3 = READ_WRITE_TEST_ARG_INIT(2 * sector_size, 3, handle, sector_size/sizeof(uint32_t));
read_write_test_arg_t args4 = READ_WRITE_TEST_ARG_INIT(3 * sector_size, 4, handle, sector_size/sizeof(uint32_t));
printf("reading 1 and 2, writing 3 and 4\n");
xTaskCreatePinnedToCore(&read_write_task, "rw3", stack_size, &args3, 3, NULL, 1);