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
This commit is contained in:
Scott Shawcroft 2020-08-10 17:08:33 -07:00
parent bccfb8b4cd
commit 87c78be8f4
No known key found for this signature in database
GPG Key ID: 0DFD512649C052DA
1 changed files with 6 additions and 5 deletions

View File

@ -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,