fix(storage/fatfs): make wl_fatfsgen.py safe mode aware

This commit is contained in:
Tomáš Rohlínek
2024-03-13 12:36:28 +01:00
parent 2a9c03d2f1
commit 7854b955a1
2 changed files with 33 additions and 8 deletions

View File

@@ -1,15 +1,18 @@
# SPDX-FileCopyrightText: 2021-2024 Espressif Systems (Shanghai) CO LTD
# SPDX-License-Identifier: Apache-2.0
import argparse
import binascii
import os
import re
import uuid
from datetime import datetime
from typing import List, Optional, Tuple
from typing import List
from typing import Optional
from typing import Tuple
from construct import BitsInteger, BitStruct, Int16ul
from construct import BitsInteger
from construct import BitStruct
from construct import Int16ul
# the regex pattern defines symbols that are allowed by long file names but not by short file names
INVALID_SFN_CHARS_PATTERN = re.compile(r'[.+,;=\[\]]')
@@ -211,6 +214,11 @@ def get_args_for_partition_generator(desc: str, wl: bool) -> argparse.Namespace:
type=int,
choices=[1, 2],
help='Number of file allocation tables (FATs) in the filesystem.')
parser.add_argument('--wl_mode',
default=None,
type=str,
choices=['safe', 'perf'],
help='Wear levelling mode to use. Safe or performance. Only for sector size of 512')
args = parser.parse_args()
if args.fat_type == 0:
@@ -220,6 +228,9 @@ def get_args_for_partition_generator(desc: str, wl: bool) -> argparse.Namespace:
args.partition_size = int(str(args.partition_size), 0)
if not os.path.isdir(args.input_directory):
raise NotADirectoryError(f'The target directory `{args.input_directory}` does not exist!')
if args.wl_mode is not None:
if args.sector_size != 512:
raise ValueError('Wear levelling mode can be set only for sector size 512')
return args