mbed-os/tools/dev/intel_hex_utils.py

32 lines
596 B
Python
Raw Normal View History

2014-03-14 16:07:41 +00:00
from intelhex import IntelHex
from cStringIO import StringIO
2014-03-14 16:07:41 +00:00
def sections(h):
start, last_address = None, None
for a in h.addresses():
if last_address is None:
start, last_address = a, a
continue
if a > last_address + 1:
2014-03-14 16:07:41 +00:00
yield (start, last_address)
start = a
last_address = a
if start:
2014-03-14 16:07:41 +00:00
yield (start, last_address)
def print_sections(h):
for s in sections(h):
print "[0x%08X - 0x%08X]" % s
def decode(record):
h = IntelHex()
f = StringIO(record)
h.loadhex(f)
h.dump()