diff --git a/components/fatfs/fatfs_utils/utils.py b/components/fatfs/fatfs_utils/utils.py index e869a64064..e7d2e25a7f 100644 --- a/components/fatfs/fatfs_utils/utils.py +++ b/components/fatfs/fatfs_utils/utils.py @@ -42,7 +42,10 @@ FATFS_SECONDS_GRANULARITY: int = 2 LONG_NAMES_ENCODING: str = 'utf-16' 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] @@ -280,4 +283,5 @@ class FATDefaults: TEMP_BUFFER_SIZE: int = 32 UPDATE_RATE: int = 16 WR_SIZE: int = 16 + # wear leveling metadata (config sector) contains always sector size 4096 WL_SECTOR_SIZE: int = 4096 diff --git a/components/fatfs/fatfsgen.py b/components/fatfs/fatfsgen.py index 8976b1567b..d70fb7ec60 100755 --- a/components/fatfs/fatfsgen.py +++ b/components/fatfs/fatfsgen.py @@ -161,6 +161,8 @@ class FATFS: def main() -> None: 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, sectors_per_cluster=args.sectors_per_cluster, size=args.partition_size, diff --git a/components/fatfs/wl_fatfsgen.py b/components/fatfs/wl_fatfsgen.py index 827dfe72a1..b6c5dd4fe7 100755 --- a/components/fatfs/wl_fatfsgen.py +++ b/components/fatfs/wl_fatfsgen.py @@ -82,6 +82,7 @@ class WLFATFS: def __init__(self, size: int = FATDefaults.SIZE, + sector_size: int = FATDefaults.SECTOR_SIZE, reserved_sectors_cnt: int = FATDefaults.RESERVED_SECTORS_COUNT, fat_tables_cnt: int = FATDefaults.FAT_TABLES_COUNT, sectors_per_cluster: int = FATDefaults.SECTORS_PER_CLUSTER, @@ -122,7 +123,7 @@ class WLFATFS: reserved_sectors_cnt=reserved_sectors_cnt, fat_tables_cnt=fat_tables_cnt, sectors_per_cluster=sectors_per_cluster, - sector_size=FATDefaults.WL_SECTOR_SIZE, + sector_size=sector_size, root_entry_count=root_entry_count, hidden_sectors=hidden_sectors, long_names_enabled=long_names_enabled, @@ -221,6 +222,7 @@ if __name__ == '__main__': wl_fatfs = WLFATFS(sectors_per_cluster=args.sectors_per_cluster, size=args.partition_size, + sector_size=args.sector_size, root_entry_count=args.root_entry_count, explicit_fat_type=args.fat_type, long_names_enabled=args.long_name_support,