#!/usr/bin/env python3 import argparse import struct from pathlib import Path MAGIC = b"TSLUPD1\0" HEADER_SIZE = 32 def main(): parser = argparse.ArgumentParser(description="Create a combined ESP32 update package.") parser.add_argument("--firmware", default=".pio/build/seeed_xiao_esp32c3/firmware.bin") parser.add_argument("--filesystem", default=".pio/build/seeed_xiao_esp32c3/littlefs.bin") parser.add_argument("--output", default=".pio/build/seeed_xiao_esp32c3/update.tslpkg") args = parser.parse_args() firmware_path = Path(args.firmware) filesystem_path = Path(args.filesystem) output_path = Path(args.output) firmware = firmware_path.read_bytes() filesystem = filesystem_path.read_bytes() output_path.parent.mkdir(parents=True, exist_ok=True) header = MAGIC + struct.pack("