Skip to content

Commit 44bc754

Browse files
committed
tools: Allow all flash algos to be retrieved
Add an 'all' parameter to get_flash_algorthim_binary. When set an enumerator of all flash algorithms is returned. rather than just the first flash algorithm.
1 parent 684fcc1 commit 44bc754

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

tools/arm_pack_manager/__init__.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -246,19 +246,23 @@ def _generate_aliases_helper(self, d) :
246246
self.counter += 1
247247
self.display_counter("Scanning for Aliases")
248248

249-
def get_flash_algorthim_binary(self, device_name) :
249+
def get_flash_algorthim_binary(self, device_name, all=False) :
250250
"""Retrieve the flash algorithm file for a particular part.
251251
252252
Assumes that both the PDSC and the PACK file associated with that part are in the cache.
253253
254254
:param device_name: The exact name of a device
255+
:param all: Return an iterator of all flash algos for this device
255256
:type device_name: str
256257
:return: A file-like object that, when read, is the ELF file that describes the flashing algorithm
257-
:rtype: ZipExtFile
258+
:return: A file-like object that, when read, is the ELF file that describes the flashing algorithm.
259+
When "all" is set to True then an iterator for file-like objects is returned
260+
:rtype: ZipExtFile or ZipExtFile iterator if all is True
258261
"""
259262
device = self.index[device_name]
260263
pack = self.pack_from_cache(device)
261-
return pack.open(device['algorithm'].keys()[0])
264+
algo_itr = (pack.open(path) for path in device['algorithm'].keys())
265+
return algo_itr if all else algo_itr.next()
262266

263267
def get_svd_file(self, device_name) :
264268
"""Retrieve the flash algorithm file for a particular part.

0 commit comments

Comments
 (0)