Replace sdkconfig with device.properties (#411)

This commit is contained in:
Ken Van Hoeylandt
2025-11-12 22:36:08 +01:00
committed by GitHub
parent 8335611796
commit 7918451699
85 changed files with 1022 additions and 2379 deletions
+35 -26
View File
@@ -5,7 +5,8 @@ from dataclasses import dataclass, asdict
import json
import shutil
verbose = False
VERBOSE = False
DEVICES_FOLDER = "Boards"
@dataclass
class IndexEntry:
@@ -71,8 +72,8 @@ def read_properties_file(path):
config.read(path)
return config
def read_mapping_file():
mapping_file_path = os.path.join(os.path.dirname(os.path.realpath(__file__)), "devices.properties")
def read_device_properties(device_id):
mapping_file_path = os.path.join(DEVICES_FOLDER, device_id, "device.properties")
if not os.path.isfile(mapping_file_path):
exit_with_error(f"Mapping file not found: {mapping_file_path}")
return read_properties_file(mapping_file_path)
@@ -84,12 +85,20 @@ def to_manifest_chip_name(name):
return "ESP32-S2"
elif name == "esp32s3":
return "ESP32-S3"
elif name == "esp32c2":
return "ESP32-C2"
elif name == "esp32c3":
return "ESP32-C3"
elif name == "esp32c5":
return "ESP32-C5"
elif name == "esp32c6":
return "ESP32-C6"
elif name == "esp32c61":
return "ESP32-C61"
elif name == "esp32h2":
return "ESP32-H2"
elif name == "esp32h4":
return "ESP32-H4"
elif name == "esp32p4":
return "ESP32-P4"
else:
@@ -97,7 +106,7 @@ def to_manifest_chip_name(name):
return ""
def process_board(in_path: str, out_path: str, device_directory: str, device_id: str, device_mapping: configparser, version: str):
def process_device(in_path: str, out_path: str, device_directory: str, device_id: str, device_properties: configparser, version: str):
in_device_path = os.path.join(in_path, device_directory)
in_device_binaries_path = os.path.join(in_device_path, "Binaries")
assert os.path.isdir(in_device_binaries_path)
@@ -108,7 +117,7 @@ def process_board(in_path: str, out_path: str, device_directory: str, device_id:
json_data.close()
flash_files = flasher_args["flash_files"]
manifest = Manifest(
name=f"Tactility for {device_mapping["vendor"]} {device_mapping["boardName"]}",
name=f"Tactility for {device_properties["general"]["vendor"]} {device_properties["general"]["name"]}",
version=version,
new_install_prompt_erase="true",
funding_url="https://github.com/sponsors/ByteWelder",
@@ -125,7 +134,7 @@ def process_board(in_path: str, out_path: str, device_directory: str, device_id:
in_flash_file_path = os.path.join(in_device_binaries_path, flash_file_entry)
out_flash_file_name = f"{device_id}-{flash_file_entry_name}"
out_flash_file_path = os.path.join(out_path, out_flash_file_name)
if verbose:
if VERBOSE:
print(f"Copying {in_flash_file_path} -> {out_flash_file_path}")
shutil.copy(in_flash_file_path, out_flash_file_path)
manifest.builds[0].parts.append(
@@ -146,34 +155,34 @@ def main(in_path: str, out_path: str, version: str):
if os.path.exists(out_path):
shutil.rmtree(out_path)
os.mkdir(out_path)
mapping = read_mapping_file()
device_directories = os.listdir(in_path)
device_index = DeviceIndex(version, [])
for device_directory in device_directories:
if not device_directory.endswith("-symbols"):
device_id = device_directory[10:]
if device_id not in mapping.sections():
exit_with_error(f"Mapping for {device_id} not found in mapping file")
device_properties = mapping[device_id]
process_board(in_path, out_path, device_directory, device_id, device_properties, version)
if "warningMessage" in device_properties.keys():
warning_message = device_properties["warningMessage"]
else:
warning_message = None
if "infoMessage" in device_properties.keys():
info_message = device_properties["infoMessage"]
else:
info_message = None
if "incubating" in device_properties.keys():
incubating = device_properties["incubating"].lower() == 'true'
device_properties = read_device_properties(device_id)
device_properties_general = device_properties["general"]
process_device(in_path, out_path, device_directory, device_id, device_properties, version)
if device_properties.has_section("cdn"):
device_properties_cdn = device_properties["cdn"]
if "warningMessage" in device_properties_cdn.keys():
warning_message = device_properties_cdn["warningMessage"]
else:
warning_message = None
if "infoMessage" in device_properties_cdn.keys():
info_message = device_properties_cdn["infoMessage"]
else:
info_message = None
if "incubating" in device_properties_general.keys():
incubating = device_properties_general["incubating"].lower() == 'true'
else:
incubating = False
board_names = device_properties["boardName"].split(',')
for board_name in board_names:
device_names = device_properties_general["name"].split(',')
for device_name in device_names:
device_index.devices.append(asdict(IndexEntry(
id=device_id,
name=board_name,
vendor=device_properties["vendor"],
name=device_name,
vendor=device_properties_general["vendor"],
incubating=incubating,
warningMessage=warning_message,
infoMessage=info_message
@@ -193,6 +202,6 @@ if __name__ == "__main__":
print_help()
sys.exit()
if "--verbose" in sys.argv:
verbose = True
VERBOSE = True
sys.argv.remove("--verbose")
main(in_path=sys.argv[1], out_path=sys.argv[2], version=sys.argv[3])