Keyboard firmwares for Atmel AVR and Cortex-M
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

intel_hex_utils.py 596B

12345678910111213141516171819202122232425262728293031
  1. from intelhex import IntelHex
  2. from cStringIO import StringIO
  3. def sections(h):
  4. start, last_address = None, None
  5. for a in h.addresses():
  6. if last_address is None:
  7. start, last_address = a, a
  8. continue
  9. if a > last_address + 1:
  10. yield (start, last_address)
  11. start = a
  12. last_address = a
  13. if start:
  14. yield (start, last_address)
  15. def print_sections(h):
  16. for s in sections(h):
  17. print "[0x%08X - 0x%08X]" % s
  18. def decode(record):
  19. h = IntelHex()
  20. f = StringIO(record)
  21. h.loadhex(f)
  22. h.dump()