Commit dd58be19 authored by Luca Burelli's avatar Luca Burelli

esp32: Fix Partition.writeblocks() partial write corruption.

To simulate a partial erase, the code reads a native block, erases it,
and writes back the data before and after the erased area. However, the
current logic was filling the area after the erased block with data
from the beginning of the native block-aligned data, instead of applying
the proper offset.

Fixes #12474.
Signed-off-by: default avatarLuca Burelli <l.burelli@arduino.cc>
parent a3862e72
......@@ -200,7 +200,7 @@ STATIC mp_obj_t esp32_partition_writeblocks(size_t n_args, const mp_obj_t *args)
check_esp_err(esp_partition_write(self->part, addr, self->cache, o));
}
if (top_addr < addr + NATIVE_BLOCK_SIZE_BYTES) {
check_esp_err(esp_partition_write(self->part, top_addr, self->cache, addr + NATIVE_BLOCK_SIZE_BYTES - top_addr));
check_esp_err(esp_partition_write(self->part, top_addr, self->cache + (top_addr - addr), addr + NATIVE_BLOCK_SIZE_BYTES - top_addr));
}
o = 0;
addr += NATIVE_BLOCK_SIZE_BYTES;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment