Skip to content

Commit 3abb6c9

Browse files
ledvinapde-nordic
authored andcommitted
[nrf fromtree] imgtool: handle .hex in dumpinfo
Signed-off-by: Petr Ledvina <ledvinap@gmail.com> (cherry picked from commit 6faf53a) Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
1 parent 87765d6 commit 3abb6c9

1 file changed

Lines changed: 7 additions & 2 deletions

File tree

scripts/imgtool/dumpinfo.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222

2323
import click
2424
import yaml
25+
from intelhex import IntelHex
2526

2627
from imgtool import image
2728

@@ -127,9 +128,13 @@ def dump_imginfo(imgfile, outfile=None, silent=False):
127128
trailer = {}
128129
key_field_len = None
129130

131+
ext = os.path.splitext(imgfile)[1][1:].lower()
130132
try:
131-
with open(imgfile, "rb") as f:
132-
b = f.read()
133+
if ext == image.INTEL_HEX_EXT:
134+
b = IntelHex(imgfile).tobinstr()
135+
else:
136+
with open(imgfile, "rb") as f:
137+
b = f.read()
133138
except FileNotFoundError:
134139
raise click.UsageError(f"Image file not found ({imgfile})")
135140

0 commit comments

Comments
 (0)