Skip to content

Commit c1a6386

Browse files
committed
programmer/tinyprog: Fallback to roots "addrmap" if "bootmeta" missing
When querying the address map, if the "bootmeta" node does not exist fallback to using the addrmap from the root of the metadata object. This allows for a default SPI flash metadata section to define the address map when there is no "bootmeta" data.
1 parent 4e875f1 commit c1a6386

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

programmer/tinyprog/__init__.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,14 @@ def userdata_addr_range(self):
211211
return self._get_addr_range(u"userdata")
212212

213213
def _get_addr_range(self, name):
214-
addr_str = self.root[u"bootmeta"][u"addrmap"][name]
214+
# get the bootmeta's addrmap or fallback to the root's addrmap.
215+
addr_map = self.root.get(u"bootmeta", {}).get(u"addrmap", self.root.get(u"addrmap", None))
216+
if addr_map is None:
217+
raise Exception("Missing address map from device metadata")
218+
addr_str = addr_map.get(name, None)
219+
if addr_str is None:
220+
raise Exception("Missing address map for '{0}'.".format(name))
221+
215222
m = re.search(
216223
r"^\s*0x(?P<start>[A-Fa-f0-9]+)\s*-\s*0x(?P<end>[A-Fa-f0-9]+)\s*$",
217224
addr_str)

0 commit comments

Comments
 (0)