Skip to content

Commit 87c78be

Browse files
committed
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
1 parent bccfb8b commit 87c78be

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

ports/esp32s2/supervisor/internal_flash.c

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,16 @@
4343

4444
STATIC const esp_partition_t * _partition;
4545

46+
// TODO: Split the caching out of supervisor/shared/external_flash so we can use it.
47+
#define SECTOR_SIZE 4096
48+
STATIC uint8_t _cache[SECTOR_SIZE];
49+
STATIC uint32_t _cache_lba;
50+
4651
void supervisor_flash_init(void) {
4752
_partition = esp_partition_find_first(ESP_PARTITION_TYPE_DATA,
4853
ESP_PARTITION_SUBTYPE_DATA_FAT,
4954
NULL);
55+
_cache_lba = 0xffffffff;
5056
}
5157

5258
uint32_t supervisor_flash_get_block_size(void) {
@@ -61,11 +67,6 @@ void port_internal_flash_flush(void) {
6167

6268
}
6369

64-
// TODO: Split the caching out of supervisor/shared/external_flash so we can use it.
65-
#define SECTOR_SIZE 4096
66-
STATIC uint8_t _cache[SECTOR_SIZE];
67-
STATIC uint32_t _cache_lba;
68-
6970
mp_uint_t supervisor_flash_read_blocks(uint8_t *dest, uint32_t block, uint32_t num_blocks) {
7071
esp_partition_read(_partition,
7172
block * FILESYSTEM_BLOCK_SIZE,

0 commit comments

Comments
 (0)