Backup 1

Committer:
borlanic
Date:
Tue Apr 24 11:45:18 2018 +0000
Revision:
0:02dd72d1d465
BaBoRo_test2 - backup 1

Who changed what in which revision?

UserRevisionLine numberNew contents of line
borlanic 0:02dd72d1d465 1 from intelhex import IntelHex
borlanic 0:02dd72d1d465 2 from cStringIO import StringIO
borlanic 0:02dd72d1d465 3
borlanic 0:02dd72d1d465 4
borlanic 0:02dd72d1d465 5 def sections(h):
borlanic 0:02dd72d1d465 6 start, last_address = None, None
borlanic 0:02dd72d1d465 7 for a in h.addresses():
borlanic 0:02dd72d1d465 8 if last_address is None:
borlanic 0:02dd72d1d465 9 start, last_address = a, a
borlanic 0:02dd72d1d465 10 continue
borlanic 0:02dd72d1d465 11
borlanic 0:02dd72d1d465 12 if a > last_address + 1:
borlanic 0:02dd72d1d465 13 yield (start, last_address)
borlanic 0:02dd72d1d465 14 start = a
borlanic 0:02dd72d1d465 15
borlanic 0:02dd72d1d465 16 last_address = a
borlanic 0:02dd72d1d465 17
borlanic 0:02dd72d1d465 18 if start:
borlanic 0:02dd72d1d465 19 yield (start, last_address)
borlanic 0:02dd72d1d465 20
borlanic 0:02dd72d1d465 21
borlanic 0:02dd72d1d465 22 def print_sections(h):
borlanic 0:02dd72d1d465 23 for s in sections(h):
borlanic 0:02dd72d1d465 24 print "[0x%08X - 0x%08X]" % s
borlanic 0:02dd72d1d465 25
borlanic 0:02dd72d1d465 26
borlanic 0:02dd72d1d465 27 def decode(record):
borlanic 0:02dd72d1d465 28 h = IntelHex()
borlanic 0:02dd72d1d465 29 f = StringIO(record)
borlanic 0:02dd72d1d465 30 h.loadhex(f)
borlanic 0:02dd72d1d465 31 h.dump()