From 2a0ea8703de2658003f54a3413944c4cb3f7b648 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Ga=C5=88o?= Date: Mon, 26 Sep 2022 13:23:59 +0200 Subject: [PATCH] fatfsgen.py: enabled 512 sized sectors --- components/fatfs/fatfs_utils/utils.py | 6 +++++- components/fatfs/fatfsgen.py | 2 ++ components/fatfs/wl_fatfsgen.py | 4 +++- 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/components/fatfs/fatfs_utils/utils.py b/components/fatfs/fatfs_utils/utils.py index 839dedbfe0..837f9443d3 100644 --- a/components/fatfs/fatfs_utils/utils.py +++ b/components/fatfs/fatfs_utils/utils.py @@ -47,7 +47,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] @@ -286,4 +289,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,