mirror of
https://github.com/espressif/esp-idf.git
synced 2026-09-28 01:04:48 +03:00
fix(fatfs): Calculate max_pos in wl_fatfsgen.py safe mode correctly
This commit is contained in:
@@ -122,9 +122,6 @@ class WLFATFS:
|
||||
# determine the number of required sectors (roundup to sector size)
|
||||
self.wl_state_sectors = (self.wl_state_size + FATDefaults.WL_SECTOR_SIZE - 1) // FATDefaults.WL_SECTOR_SIZE
|
||||
|
||||
self.boot_sector_start = FATDefaults.WL_SECTOR_SIZE # shift by one "dummy" sector
|
||||
self.fat_table_start = self.boot_sector_start + reserved_sectors_cnt * FATDefaults.WL_SECTOR_SIZE
|
||||
|
||||
wl_sectors = (
|
||||
WLFATFS.WL_DUMMY_SECTORS_COUNT
|
||||
+ WLFATFS.WL_CFG_SECTORS_COUNT
|
||||
@@ -133,6 +130,9 @@ class WLFATFS:
|
||||
if self.wl_mode is not None and self.wl_mode == 'safe':
|
||||
wl_sectors += WLFATFS.WL_SAFE_MODE_DUMP_SECTORS
|
||||
|
||||
self.boot_sector_start = FATDefaults.WL_SECTOR_SIZE # shift by one "dummy" sector
|
||||
self.fat_table_start = self.boot_sector_start + reserved_sectors_cnt * FATDefaults.WL_SECTOR_SIZE
|
||||
|
||||
self.plain_fat_sectors = self.total_sectors - wl_sectors
|
||||
self.plain_fatfs = FATFS(
|
||||
explicit_fat_type=explicit_fat_type,
|
||||
@@ -192,7 +192,11 @@ class WLFATFS:
|
||||
wl_state_data = WLFATFS.WL_STATE_T_DATA.build(
|
||||
dict(
|
||||
pos=0,
|
||||
max_pos=self.plain_fat_sectors + WLFATFS.WL_DUMMY_SECTORS_COUNT,
|
||||
max_pos=(
|
||||
self.plain_fat_sectors
|
||||
+ WLFATFS.WL_DUMMY_SECTORS_COUNT
|
||||
+ (WLFATFS.WL_SAFE_MODE_DUMP_SECTORS if self.wl_mode == 'safe' else 0)
|
||||
),
|
||||
move_count=0,
|
||||
access_count=0,
|
||||
max_count=FATDefaults.UPDATE_RATE,
|
||||
@@ -205,10 +209,16 @@ class WLFATFS:
|
||||
wl_state_crc = Int32ul.build(crc)
|
||||
wl_state = wl_state_data + wl_state_crc
|
||||
wl_state_sector_padding: bytes = (FATDefaults.WL_SECTOR_SIZE - WLFATFS.WL_STATE_HEADER_SIZE) * FULL_BYTE
|
||||
wl_state_sector: bytes = (
|
||||
wl_state_sectors: bytes = (
|
||||
wl_state + wl_state_sector_padding + (self.wl_state_sectors - 1) * FATDefaults.WL_SECTOR_SIZE * FULL_BYTE
|
||||
)
|
||||
self.fatfs_binary_image += WLFATFS.WL_STATE_COPY_COUNT * wl_state_sector
|
||||
|
||||
# add 2 extra state-preservation sectors in 'Safe' mode
|
||||
if self.wl_mode is not None and self.wl_mode == 'safe':
|
||||
wl_safe_dummy_sec: bytes = WLFATFS.WL_SAFE_MODE_DUMP_SECTORS * FATDefaults.WL_SECTOR_SIZE * FULL_BYTE
|
||||
self.fatfs_binary_image += wl_safe_dummy_sec
|
||||
|
||||
self.fatfs_binary_image += WLFATFS.WL_STATE_COPY_COUNT * wl_state_sectors
|
||||
|
||||
def wl_write_filesystem(self, output_path: str) -> None:
|
||||
if not self._initialized:
|
||||
|
||||
Reference in New Issue
Block a user