diff --git a/CHANGELOG.md b/CHANGELOG.md index c0433432..dd53fbc8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,14 +2,19 @@ ## [Unreleased] +## [v0.1.0] 2020-01-20 + +* Backport two changes to stm32-rs svdpatch.py +* Set minor version so stm32-rs can potentially rely on this + ## [v0.0.4] 2020-01-12 -* Added `strip` & `_strip_end` patching options for stripping bitfields +* Add `strip` & `_strip_end` patching options for stripping bitfields ## [v0.0.3] 2020-01-10 -* Added missing `black` and `isort` requirements - @jessebraham -* Added `_strip_end` as an option for patching - @jessebraham +* Add missing `black` and `isort` requirements - @jessebraham +* Add `_strip_end` as an option for patching - @jessebraham ## [v0.0.2] 2019-08-20 @@ -18,5 +23,5 @@ ## [v0.0.1] 2019-08-17 * Initial release, importing from `stm32-rs/scripts/svdpatch.py` -* Added `click` CLI, to call as `svd patch ` -* Added packaging +* Add `click` CLI, to call as `svd patch ` +* Add packaging diff --git a/pyproject.toml b/pyproject.toml index 01ec4f01..20550564 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -12,8 +12,8 @@ maintainer-email = "n@stalder.io" home-page = "https://github.com/stm32-rs/svdtools" requires-python = ">=3.6" requires = [ - "click >= 7.0", - "PyYAML", + "click ~= 7.0", + "PyYAML ~= 5.3", ] classifiers=[ "License :: OSI Approved :: MIT License", diff --git a/svdtools/VERSION b/svdtools/VERSION index 81340c7e..6e8bf73a 100644 --- a/svdtools/VERSION +++ b/svdtools/VERSION @@ -1 +1 @@ -0.0.4 +0.1.0 diff --git a/svdtools/patch.py b/svdtools/patch.py index 30f4027c..8549e262 100644 --- a/svdtools/patch.py +++ b/svdtools/patch.py @@ -289,19 +289,29 @@ def derive_peripheral(self, pname, pderive): for p in parent.findall("./peripheral[@derivedFrom='{}']".format(pname)): p.set("derivedFrom", pderive) - def copy_peripheral(self, pname, pmod): + def copy_peripheral(self, pname, pmod, path): """ Create copy of peripheral """ parent = self.device.find("peripherals") ptag = parent.find("./peripheral[name='{}']".format(pname)) - pcopyname = pmod["from"] - pcopy = copy.deepcopy(parent.find("./peripheral[name='{}']".format(pcopyname))) + pcopysrc = pmod["from"].split(":") + pcopyname = pcopysrc[-1] + if len(pcopysrc) == 2: + pcopyfile = abspath(path, pcopysrc[0]) + filedev = Device(ET.parse(pcopyfile)) + source = filedev.device.find("peripherals") + else: + source = parent + pcopy = copy.deepcopy(source.find("./peripheral[name='{}']".format(pcopyname))) if pcopy is None: raise SvdPatchError("peripheral {} not found".format(pcopy)) if ptag is None: pcopy.find("name").text = pname - raise SvdPatchError("unimplemented") + if source is parent: + for value in list(pcopy): + if value.tag in ("interrupt"): + pcopy.remove(value) else: for value in list(ptag): if value.tag in ("name", "baseAddress", "interrupt"): @@ -309,7 +319,7 @@ def copy_peripheral(self, pname, pmod): if tag is not None: pcopy.remove(tag) pcopy.append(value) - parent.remove(ptag) + parent.remove(ptag) parent.append(pcopy) def rebase_peripheral(self, pnew, pold): @@ -885,7 +895,7 @@ def process_device(svd, device, update_fields=True): # Handle any copied peripherals for pname in device.get("_copy", {}): val = device["_copy"][pname] - d.copy_peripheral(pname, val) + d.copy_peripheral(pname, val, device["_path"]) # Handle any modifications for key in device.get("_modify", {}):