Merge branch 'feature/fatfsgen-enable-512-bytes-sector' into 'master'

fatfsgen.py: enabled 512 sized sectors

Closes IDF-5523

See merge request espressif/esp-idf!20344
This commit is contained in:
Martin Gano 2022-09-28 23:11:12 +08:00
commit 1b3fed3b5c
3 changed files with 10 additions and 2 deletions

View File

@ -47,7 +47,10 @@ FATFS_SECONDS_GRANULARITY: int = 2
LONG_NAMES_ENCODING: str = 'utf-16' LONG_NAMES_ENCODING: str = 'utf-16'
SHORT_NAMES_ENCODING: str = 'utf-8' SHORT_NAMES_ENCODING: str = 'utf-8'
ALLOWED_SECTOR_SIZES: List[int] = [4096] # compatible with WL_SECTOR_SIZE
# choices are WL_SECTOR_SIZE_512 and WL_SECTOR_SIZE_4096
ALLOWED_SECTOR_SIZES: List[int] = [512, 4096]
ALLOWED_SECTORS_PER_CLUSTER: List[int] = [1, 2, 4, 8, 16, 32, 64, 128] ALLOWED_SECTORS_PER_CLUSTER: List[int] = [1, 2, 4, 8, 16, 32, 64, 128]
@ -286,4 +289,5 @@ class FATDefaults:
TEMP_BUFFER_SIZE: int = 32 TEMP_BUFFER_SIZE: int = 32
UPDATE_RATE: int = 16 UPDATE_RATE: int = 16
WR_SIZE: int = 16 WR_SIZE: int = 16
# wear leveling metadata (config sector) contains always sector size 4096
WL_SECTOR_SIZE: int = 4096 WL_SECTOR_SIZE: int = 4096

View File

@ -161,6 +161,8 @@ class FATFS:
def main() -> None: def main() -> None:
args = get_args_for_partition_generator('Create a FAT filesystem and populate it with directory content') args = get_args_for_partition_generator('Create a FAT filesystem and populate it with directory content')
if args.sector_size != 0x1000:
raise NotImplementedError('The sector size not equal to 4096 is currently not supported for read-only mode!')
fatfs = FATFS(sector_size=args.sector_size, fatfs = FATFS(sector_size=args.sector_size,
sectors_per_cluster=args.sectors_per_cluster, sectors_per_cluster=args.sectors_per_cluster,
size=args.partition_size, size=args.partition_size,

View File

@ -82,6 +82,7 @@ class WLFATFS:
def __init__(self, def __init__(self,
size: int = FATDefaults.SIZE, size: int = FATDefaults.SIZE,
sector_size: int = FATDefaults.SECTOR_SIZE,
reserved_sectors_cnt: int = FATDefaults.RESERVED_SECTORS_COUNT, reserved_sectors_cnt: int = FATDefaults.RESERVED_SECTORS_COUNT,
fat_tables_cnt: int = FATDefaults.FAT_TABLES_COUNT, fat_tables_cnt: int = FATDefaults.FAT_TABLES_COUNT,
sectors_per_cluster: int = FATDefaults.SECTORS_PER_CLUSTER, sectors_per_cluster: int = FATDefaults.SECTORS_PER_CLUSTER,
@ -122,7 +123,7 @@ class WLFATFS:
reserved_sectors_cnt=reserved_sectors_cnt, reserved_sectors_cnt=reserved_sectors_cnt,
fat_tables_cnt=fat_tables_cnt, fat_tables_cnt=fat_tables_cnt,
sectors_per_cluster=sectors_per_cluster, sectors_per_cluster=sectors_per_cluster,
sector_size=FATDefaults.WL_SECTOR_SIZE, sector_size=sector_size,
root_entry_count=root_entry_count, root_entry_count=root_entry_count,
hidden_sectors=hidden_sectors, hidden_sectors=hidden_sectors,
long_names_enabled=long_names_enabled, long_names_enabled=long_names_enabled,
@ -221,6 +222,7 @@ if __name__ == '__main__':
wl_fatfs = WLFATFS(sectors_per_cluster=args.sectors_per_cluster, wl_fatfs = WLFATFS(sectors_per_cluster=args.sectors_per_cluster,
size=args.partition_size, size=args.partition_size,
sector_size=args.sector_size,
root_entry_count=args.root_entry_count, root_entry_count=args.root_entry_count,
explicit_fat_type=args.fat_type, explicit_fat_type=args.fat_type,
long_names_enabled=args.long_name_support, long_names_enabled=args.long_name_support,