feat(wear_levelling): Added BDL support

This commit is contained in:
Martin Vychodil
2026-03-24 07:28:16 +01:00
parent 82cded2700
commit 2ea61a5cee
19 changed files with 940 additions and 106 deletions
+9 -19
View File
@@ -1,12 +1,12 @@
/*
* SPDX-FileCopyrightText: 2015-2023 Espressif Systems (Shanghai) CO LTD
* SPDX-FileCopyrightText: 2015-2026 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
#include <inttypes.h>
#include "esp_log.h"
#include "Partition.h"
#include <inttypes.h>
static const char *TAG = "wl_partition";
@@ -22,34 +22,25 @@ size_t Partition::get_flash_size()
esp_err_t Partition::erase_sector(size_t sector)
{
esp_err_t result = ESP_OK;
result = erase_range(sector * this->partition->erase_size, this->partition->erase_size);
return result;
return erase_range(sector * this->partition->erase_size, this->partition->erase_size);
}
esp_err_t Partition::erase_range(size_t start_address, size_t size)
{
esp_err_t result = esp_partition_erase_range(this->partition, start_address, size);
if (result == ESP_OK) {
ESP_LOGV(TAG, "erase_range - start_address=0x%08" PRIx32 ", size=0x%08" PRIx32 ", result=0x%08x", (uint32_t) start_address, (uint32_t) size, result);
} else {
ESP_LOGE(TAG, "erase_range - start_address=0x%08" PRIx32 ", size=0x%08" PRIx32 ", result=0x%08x", (uint32_t) start_address, (uint32_t) size, result);
}
return result;
ESP_LOGV(TAG, "%s - start_address=0x%08" PRIx32 ", size=0x%08" PRIx32, __func__, (uint32_t)start_address, (uint32_t)size);
return esp_partition_erase_range(this->partition, start_address, size);
}
esp_err_t Partition::write(size_t dest_addr, const void *src, size_t size)
{
esp_err_t result = ESP_OK;
result = esp_partition_write(this->partition, dest_addr, src, size);
return result;
ESP_LOGV(TAG, "%s - dest_addr=0x%08" PRIx32 ", size=0x%08" PRIx32, __func__, (uint32_t)dest_addr, (uint32_t)size);
return esp_partition_write(this->partition, dest_addr, src, size);
}
esp_err_t Partition::read(size_t src_addr, void *dest, size_t size)
{
esp_err_t result = ESP_OK;
result = esp_partition_read(this->partition, src_addr, dest, size);
return result;
ESP_LOGV(TAG, "%s - src_addr=0x%08" PRIx32 ", size=0x%08" PRIx32, __func__, (uint32_t)src_addr, (uint32_t)size);
return esp_partition_read(this->partition, src_addr, dest, size);
}
size_t Partition::get_sector_size()
@@ -64,5 +55,4 @@ bool Partition::is_readonly()
Partition::~Partition()
{
}