Skip to content

Commit a3595ae

Browse files
committed
Add Intel hex utilities
1 parent 9319e1b commit a3595ae

File tree

1 file changed

+18
-5
lines changed

1 file changed

+18
-5
lines changed
Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,31 @@
1-
def print_section(start, end):
2-
print "[0x%08X - 0x%08X]" % (start, end)
1+
from intelhex import IntelHex
2+
from cStringIO import StringIO
33

4-
def print_sections(h):
4+
5+
def sections(h):
56
start, last_address = None, None
67
for a in h.addresses():
78
if last_address is None:
89
start, last_address = a, a
910
continue
1011

1112
if a > last_address + 1:
12-
print_section(start, last_address)
13+
yield (start, last_address)
1314
start = a
1415

1516
last_address = a
1617

1718
if start:
18-
print_section(start, last_address)
19+
yield (start, last_address)
20+
21+
22+
def print_sections(h):
23+
for s in sections(h):
24+
print "[0x%08X - 0x%08X]" % s
25+
26+
27+
def decode(record):
28+
h = IntelHex()
29+
f = StringIO(record)
30+
h.loadhex(f)
31+
h.dump()

0 commit comments

Comments
 (0)