summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorScott Shawcroft <scott@tannewt.org>2020-08-10 17:08:33 -0700
committerScott Shawcroft <scott@tannewt.org>2020-08-10 17:14:49 -0700
commit87c78be8f4ba73d2c2745fb563926c9cb655cd7a (patch)
treefabcf6f1d5d814210804733cd829426082ce54c3
parentbccfb8b4cdd604fcaa41bc36851141ca751d2d79 (diff)
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
-rw-r--r--ports/esp32s2/supervisor/internal_flash.c11
1 files changed, 6 insertions, 5 deletions
diff --git a/ports/esp32s2/supervisor/internal_flash.c b/ports/esp32s2/supervisor/internal_flash.c
index 26774efac..abc84eb7d 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,