mirror of
https://github.com/espressif/esp-idf.git
synced 2025-08-01 03:34:32 +02:00
Merge branch 'bugfix/wl_ext_size_test' into 'master'
wear_levelling: fix unit test, fix sector erase in performance mode See merge request !1093
This commit is contained in:
@@ -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
|
||||
|
@@ -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);
|
||||
|
@@ -89,7 +89,7 @@ esp_err_t WL_Ext_Safe::recover()
|
||||
WL_Ext_Safe_State state;
|
||||
result = WL_Flash::read(this->state_addr, &state, sizeof(WL_Ext_Safe_State));
|
||||
WL_EXT_RESULT_CHECK(result);
|
||||
ESP_LOGI(TAG, "%s recover, start_addr = 0x%08x, local_addr_base = 0x%08x, local_addr_shift = %i, count=%i", __func__, state.erase_begin, state.local_addr_base, state.local_addr_shift, state.count);
|
||||
ESP_LOGV(TAG, "%s recover, start_addr = 0x%08x, local_addr_base = 0x%08x, local_addr_shift = %i, count=%i", __func__, state.erase_begin, state.local_addr_base, state.local_addr_shift, state.count);
|
||||
|
||||
// check if we have transaction
|
||||
if (state.erase_begin == WL_EXT_SAFE_OK) {
|
||||
|
@@ -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);
|
||||
|
Reference in New Issue
Block a user