From b36e5807564d634ba3e6bc6e3d7871b1ba8af58a Mon Sep 17 00:00:00 2001 From: Dmitry Yakovlev Date: Thu, 13 Jul 2017 08:24:15 +0300 Subject: [PATCH] wear_levelling: fix write and read length for single access was wrong. --- components/wear_levelling/WL_Flash.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/components/wear_levelling/WL_Flash.cpp b/components/wear_levelling/WL_Flash.cpp index 03db083027..eb10fe899e 100644 --- a/components/wear_levelling/WL_Flash.cpp +++ b/components/wear_levelling/WL_Flash.cpp @@ -431,7 +431,7 @@ esp_err_t WL_Flash::write(size_t dest_addr, const void *src, size_t size) uint32_t count = (size - 1) / this->cfg.page_size; for (size_t i = 0; i < count; i++) { size_t virt_addr = this->calcAddr(dest_addr + i * this->cfg.page_size); - result = this->flash_drv->write(this->cfg.start_addr + virt_addr, &((uint8_t *)src)[i * this->cfg.page_size], size); + result = this->flash_drv->write(this->cfg.start_addr + virt_addr, &((uint8_t *)src)[i * this->cfg.page_size], this->cfg.page_size); WL_RESULT_CHECK(result); } size_t virt_addr_last = this->calcAddr(dest_addr + count * this->cfg.page_size); @@ -450,7 +450,7 @@ esp_err_t WL_Flash::read(size_t src_addr, void *dest, size_t size) uint32_t count = (size - 1) / this->cfg.page_size; for (size_t i = 0; i < count; i++) { size_t virt_addr = this->calcAddr(src_addr + i * this->cfg.page_size); - result = this->flash_drv->read(this->cfg.start_addr + virt_addr, &((uint8_t *)dest)[i * this->cfg.page_size], size); + result = this->flash_drv->read(this->cfg.start_addr + virt_addr, &((uint8_t *)dest)[i * this->cfg.page_size], this->cfg.page_size); WL_RESULT_CHECK(result); } size_t virt_addr_last = this->calcAddr(src_addr + count * this->cfg.page_size);