Skip to content

Commit

Permalink
CMSIS Pack: Use pdsc-relative path for resource files (#1461)
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.

Fixes #1460

Signed-off-by: Yilin Sun <imi415@imi.moe>
  • Loading branch information
imi415 authored Oct 23, 2022
1 parent 7d41faf commit 357fdac
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 357fdac

Please sign in to comment.