From c4a0807a025910fba9ee4fa2229b3f44e9f7d0c0 Mon Sep 17 00:00:00 2001 From: Andrew Dona-Couch Date: Tue, 4 Aug 2020 18:28:47 -0400 Subject: [PATCH] svdpatch: Fix peripheral modifications --- patch/svdpatch.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/patch/svdpatch.py b/patch/svdpatch.py index c70c3a3..0d1f592 100644 --- a/patch/svdpatch.py +++ b/patch/svdpatch.py @@ -11,6 +11,7 @@ Additional changes: - Support for _replace_enum to overwrite existing - Fix field modifications not being able to add new elements - Add _write_constraint modifier for changing the + - Fix peripheral modifications not being able to add new elements """ import copy @@ -215,7 +216,12 @@ def process_peripheral_modify(ptag, rspec, rmod): """Modify rspec inside ptag according to rmod.""" for rtag in iter_registers(ptag, rspec): for (key, value) in rmod.items(): - rtag.find(key).text = value + field = rtag.find(key) + if field is not None: + field.text = value + else: + field = ET.SubElement(rtag, key) + field.text = value def process_register_modify(rtag, fspec, fmod): -- 2.48.1