From 87c78be8f4ba73d2c2745fb563926c9cb655cd7a Mon Sep 17 00:00:00 2001 From: Scott Shawcroft Date: Mon, 10 Aug 2020 17:08:33 -0700 Subject: [PATCH] Fix writing sector 0 as the first write. This was the FS issue I saw when debugging wifi and only happens when the first write is to sector 0. It causes issues because it blanks all of sector 0 after the first block. Fixes #3133 --- ports/esp32s2/supervisor/internal_flash.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/ports/esp32s2/supervisor/internal_flash.c b/ports/esp32s2/supervisor/internal_flash.c index 26774efac8..abc84eb7d9 100644 --- a/ports/esp32s2/supervisor/internal_flash.c +++ b/ports/esp32s2/supervisor/internal_flash.c @@ -43,10 +43,16 @@ STATIC const esp_partition_t * _partition; +// TODO: Split the caching out of supervisor/shared/external_flash so we can use it. +#define SECTOR_SIZE 4096 +STATIC uint8_t _cache[SECTOR_SIZE]; +STATIC uint32_t _cache_lba; + void supervisor_flash_init(void) { _partition = esp_partition_find_first(ESP_PARTITION_TYPE_DATA, ESP_PARTITION_SUBTYPE_DATA_FAT, NULL); + _cache_lba = 0xffffffff; } uint32_t supervisor_flash_get_block_size(void) { @@ -61,11 +67,6 @@ void port_internal_flash_flush(void) { } -// TODO: Split the caching out of supervisor/shared/external_flash so we can use it. -#define SECTOR_SIZE 4096 -STATIC uint8_t _cache[SECTOR_SIZE]; -STATIC uint32_t _cache_lba; - mp_uint_t supervisor_flash_read_blocks(uint8_t *dest, uint32_t block, uint32_t num_blocks) { esp_partition_read(_partition, block * FILESYSTEM_BLOCK_SIZE,