From 0f842a2ca2867cf4b235fe81c3d111d21c4e5a0e Mon Sep 17 00:00:00 2001 From: "radek.tandler" Date: Wed, 22 Feb 2023 16:13:47 +0100 Subject: [PATCH] wear_levelling: fixed reinitialization of wl status blocks after power off event --- components/wear_levelling/WL_Flash.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/components/wear_levelling/WL_Flash.cpp b/components/wear_levelling/WL_Flash.cpp index 9f81e08315..1486f6a961 100644 --- a/components/wear_levelling/WL_Flash.cpp +++ b/components/wear_levelling/WL_Flash.cpp @@ -153,7 +153,7 @@ esp_err_t WL_Flash::init() WL_RESULT_CHECK(result); result = this->flash_drv->write(this->addr_state2, &this->state, sizeof(wl_state_t)); WL_RESULT_CHECK(result); - for (size_t i = 0; i < ((this->cfg.full_mem_size / this->cfg.sector_size)*this->cfg.wr_size); i++) { + for (size_t i = 0; i < ((this->cfg.full_mem_size / this->cfg.sector_size)); i++) { bool pos_bits; result = this->flash_drv->read(this->addr_state1 + sizeof(wl_state_t) + i * this->cfg.wr_size, this->temp_buff, this->cfg.wr_size); WL_RESULT_CHECK(result); @@ -187,7 +187,7 @@ esp_err_t WL_Flash::init() WL_RESULT_CHECK(result); result = this->flash_drv->write(this->addr_state2, &this->state, sizeof(wl_state_t)); WL_RESULT_CHECK(result); - for (size_t i = 0; i < ((this->cfg.full_mem_size / this->cfg.sector_size) * this->cfg.wr_size); i++) { + for (size_t i = 0; i < ((this->cfg.full_mem_size / this->cfg.sector_size)); i++) { bool pos_bits; result = this->flash_drv->read(this->addr_state1 + sizeof(wl_state_t) + i * this->cfg.wr_size, this->temp_buff, this->cfg.wr_size); WL_RESULT_CHECK(result); @@ -204,7 +204,7 @@ esp_err_t WL_Flash::init() WL_RESULT_CHECK(result); result = this->flash_drv->write(this->addr_state1, state_copy, sizeof(wl_state_t)); WL_RESULT_CHECK(result); - for (size_t i = 0; i < ((this->cfg.full_mem_size / this->cfg.sector_size) * this->cfg.wr_size); i++) { + for (size_t i = 0; i < ((this->cfg.full_mem_size / this->cfg.sector_size)); i++) { bool pos_bits; result = this->flash_drv->read(this->addr_state2 + sizeof(wl_state_t) + i * this->cfg.wr_size, this->temp_buff, this->cfg.wr_size);