mirror of
https://github.com/espressif/esp-idf.git
synced 2025-08-09 12:35:28 +00:00
fix(fatfs): Fixed fatfsparse.py parsing of FAT boot sector
The fatfsparse.py script was too strict in parsing the FAT boot sector, causing it to fail in certain cases. This commit fixes the issue by making the parsing less strict and allowing for more flexibility in the boot sector format. This change improves the reliability and compatibility of the fatfsparse.py script, ensuring that it can correctly parse a wider range of FAT boot sectors. Docs updated
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
#!/usr/bin/env python
|
||||
# SPDX-FileCopyrightText: 2022 Espressif Systems (Shanghai) CO LTD
|
||||
# SPDX-FileCopyrightText: 2022-2023 Espressif Systems (Shanghai) CO LTD
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
import argparse
|
||||
import os
|
||||
@@ -100,7 +100,7 @@ def remove_wear_levelling_if_exists(fs_: bytes) -> bytes:
|
||||
boot_sector__.parse_boot_sector(fs_)
|
||||
if boot_sector__.boot_sector_state.size == len(fs_):
|
||||
return fs_
|
||||
except construct.core.ConstError:
|
||||
except UnicodeDecodeError:
|
||||
pass
|
||||
plain_fs: bytes = remove_wl(fs_)
|
||||
return plain_fs
|
||||
@@ -124,6 +124,9 @@ if __name__ == '__main__':
|
||||
default=None,
|
||||
help="If detection doesn't work correctly, "
|
||||
'you can force analyzer to or not to assume WL.')
|
||||
argument_parser.add_argument('--verbose',
|
||||
action='store_true',
|
||||
help='Prints details about FAT image.')
|
||||
|
||||
args = argument_parser.parse_args()
|
||||
|
||||
@@ -157,6 +160,10 @@ if __name__ == '__main__':
|
||||
|
||||
boot_sector_ = BootSector()
|
||||
boot_sector_.parse_boot_sector(fs)
|
||||
|
||||
if args.verbose:
|
||||
print(str(boot_sector_))
|
||||
|
||||
fat = FAT(boot_sector_.boot_sector_state, init_=False)
|
||||
|
||||
boot_dir_start_ = boot_sector_.boot_sector_state.root_directory_start
|
||||
|
Reference in New Issue
Block a user