Development mbed library for MAX32630FTHR
Dependents: blinky_max32630fthr
tools/dev/intel_hex_utils.py@0:5c4d7b2438d3, 2016-11-11 (annotated)
- Committer:
- switches
- Date:
- Fri Nov 11 20:59:50 2016 +0000
- Revision:
- 0:5c4d7b2438d3
Initial commit
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
switches | 0:5c4d7b2438d3 | 1 | from intelhex import IntelHex |
switches | 0:5c4d7b2438d3 | 2 | from cStringIO import StringIO |
switches | 0:5c4d7b2438d3 | 3 | |
switches | 0:5c4d7b2438d3 | 4 | |
switches | 0:5c4d7b2438d3 | 5 | def sections(h): |
switches | 0:5c4d7b2438d3 | 6 | start, last_address = None, None |
switches | 0:5c4d7b2438d3 | 7 | for a in h.addresses(): |
switches | 0:5c4d7b2438d3 | 8 | if last_address is None: |
switches | 0:5c4d7b2438d3 | 9 | start, last_address = a, a |
switches | 0:5c4d7b2438d3 | 10 | continue |
switches | 0:5c4d7b2438d3 | 11 | |
switches | 0:5c4d7b2438d3 | 12 | if a > last_address + 1: |
switches | 0:5c4d7b2438d3 | 13 | yield (start, last_address) |
switches | 0:5c4d7b2438d3 | 14 | start = a |
switches | 0:5c4d7b2438d3 | 15 | |
switches | 0:5c4d7b2438d3 | 16 | last_address = a |
switches | 0:5c4d7b2438d3 | 17 | |
switches | 0:5c4d7b2438d3 | 18 | if start: |
switches | 0:5c4d7b2438d3 | 19 | yield (start, last_address) |
switches | 0:5c4d7b2438d3 | 20 | |
switches | 0:5c4d7b2438d3 | 21 | |
switches | 0:5c4d7b2438d3 | 22 | def print_sections(h): |
switches | 0:5c4d7b2438d3 | 23 | for s in sections(h): |
switches | 0:5c4d7b2438d3 | 24 | print "[0x%08X - 0x%08X]" % s |
switches | 0:5c4d7b2438d3 | 25 | |
switches | 0:5c4d7b2438d3 | 26 | |
switches | 0:5c4d7b2438d3 | 27 | def decode(record): |
switches | 0:5c4d7b2438d3 | 28 | h = IntelHex() |
switches | 0:5c4d7b2438d3 | 29 | f = StringIO(record) |
switches | 0:5c4d7b2438d3 | 30 | h.loadhex(f) |
switches | 0:5c4d7b2438d3 | 31 | h.dump() |