Skip to content

Commit

Permalink
CMSIS Pack: Use pdsc-relative path for resource files, fixes pyocd#1460
Browse files Browse the repository at this point in the history
This patch will try to read resource files (e.g. FLMs) using
relative path to the pdsc file, which is used when some hardware vendors
places their pdscs under subdirectory of a pack archive, and somehow
valid for Keil MDK.

Signed-off-by: Yilin Sun <imi415@imi.moe>
  • Loading branch information
imi415 committed Oct 22, 2022
1 parent 3042769 commit fbb9236
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions pyocd/target/pack/cmsis_pack.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,13 @@ def get_file(self, filename) -> IO[bytes]:
opened (due to particularities of the ZipFile implementation).
"""
filename = filename.replace('\\', '/')

# Some vendors place their pdsc in some subdirectories of the pack archive,
# use relative directory to the pdsc file while reading other files.
pdsc_base = self._pdscName.rsplit('/', 1)
if len(pdsc_base) == 2:
filename = f'{pdsc_base[0]}/{filename}'

return io.BytesIO(self._pack_file.read(filename))

class CmsisPackDescription:
Expand Down

0 comments on commit fbb9236

Please sign in to comment.