modm_data.dl.microchip

1# Copyright 2026, Niklas Hauser
2# SPDX-License-Identifier: MPL-2.0
3
4from .atpack import download_avr_atdf, download_sam_atdf
5
6__all__ = [
7    "download_avr_atdf",
8    "download_sam_atdf",
9]
def download_avr_atdf( extraction_path: pathlib.Path, with_download: bool = True, with_patch: bool = True) -> bool:
54def download_avr_atdf(extraction_path: Path, with_download: bool = True, with_patch: bool = True) -> bool:
55    """
56    Downloads the latest AVR device packs from Microchip and extracts the ATDF
57    device description files into one folder per pack family.
58
59    :param extraction_path: The folder to extract the ATDF files into.
60    :param with_download: Download the device packs.
61    :param with_patch: Apply the patch with fixes to the ATDF files.
62    :return: Whether the download and patching was successful.
63    """
64    extraction_path = Path(extraction_path)
65    if with_download:
66        pattern = r'(?:data-link|href)="(Microchip\.({})_DFP\.(.*?)\.atpack)"'.format("|".join(_AVR_FAMILIES))
67        packs = _latest_packs(pattern)
68        with ThreadPool(len(packs)) as pool:
69            pool.starmap(_extract_atdf, [(link, extraction_path / f.lower(), False) for f, link in packs.items()])
70
71    if with_patch:
72        LOGGER.info("Patching ATDF files...")
73        from . import data
74
75        return pkg_apply_patch(data, "avr.patch", extraction_path)
76    return True

Downloads the latest AVR device packs from Microchip and extracts the ATDF device description files into one folder per pack family.

Parameters
  • extraction_path: The folder to extract the ATDF files into.
  • with_download: Download the device packs.
  • with_patch: Apply the patch with fixes to the ATDF files.
Returns

Whether the download and patching was successful.

def download_sam_atdf(extraction_path: pathlib.Path, with_download: bool = True) -> bool:
79def download_sam_atdf(extraction_path: Path, with_download: bool = True) -> bool:
80    """
81    Downloads the latest SAM device packs from Microchip and extracts the ATDF
82    device description files into one folder per pack family.
83
84    :param extraction_path: The folder to extract the ATDF files into.
85    :param with_download: Download the device packs.
86    :return: Whether the download was successful.
87    """
88    extraction_path = Path(extraction_path)
89    if with_download:
90        packs = _latest_packs(r'(?:data-link|href)="(Microchip\.(SAM.*?)_DFP\.(.*?)\.atpack)"')
91        with ThreadPool(8) as pool:
92            pool.starmap(_extract_atdf, [(link, extraction_path / f.lower(), True) for f, link in packs.items()])
93    return True

Downloads the latest SAM device packs from Microchip and extracts the ATDF device description files into one folder per pack family.

Parameters
  • extraction_path: The folder to extract the ATDF files into.
  • with_download: Download the device packs.
Returns

Whether the download was successful.