diff options
author | Luca Burelli <l.burelli@arduino.cc> | 2023-09-21 11:40:26 +0200 |
---|---|---|
committer | Luca Burelli <l.burelli@arduino.cc> | 2023-09-21 17:49:48 +0200 |
commit | dd58be19eef0be304e1b0530fe6e7408ab9b9b84 (patch) | |
tree | 98d863b97371bad3c054442ca94e1e0fb049cb12 /ports/esp32/esp32_partition.c | |
parent | a3862e726728725248d42ea9173675d523c13911 (diff) | |
download | micropython-dd58be19eef0be304e1b0530fe6e7408ab9b9b84.tar.gz micropython-dd58be19eef0be304e1b0530fe6e7408ab9b9b84.zip |
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: Luca Burelli <l.burelli@arduino.cc>
Diffstat (limited to 'ports/esp32/esp32_partition.c')
-rw-r--r-- | ports/esp32/esp32_partition.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/ports/esp32/esp32_partition.c b/ports/esp32/esp32_partition.c index 17aa34e560..3bca3b5273 100644 --- a/ports/esp32/esp32_partition.c +++ b/ports/esp32/esp32_partition.c @@ -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; |