Development mbed library for MAX32630FTHR

Dependents:   blinky_max32630fthr

tools/dev/intel_hex_utils.py

Committer:
switches
Date:
2016-11-11
Revision:
0:5c4d7b2438d3

File content as of revision 0:5c4d7b2438d3:

from intelhex import IntelHex
from cStringIO import StringIO


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:
            yield (start, last_address)
            start = a

        last_address = a

    if start:
        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()