Dump.py 887 B

123456789101112131415161718192021222324252627282930313233343536
  1. #!/usr/bin/env python
  2. # -*- coding: utf-8 -*-
  3. # COPYRIGHT: Openmoko Inc. 2009
  4. # LICENSE: GPL Version 3 or later
  5. # DESCRIPTION: Simple FLASH programmer
  6. # AUTHOR: Christopher Hall <hsw@openmoko.com>
  7. import sys
  8. def hex(list):
  9. a = 0
  10. nl = False
  11. for b in list:
  12. if 0 == a & 0x0f:
  13. if nl:
  14. sys.stdout.write('\n')
  15. nl = True
  16. sys.stdout.write('%04x ' % a)
  17. sys.stdout.write('%02x ' % (ord(b)))
  18. a = a + 1
  19. sys.stdout.write('\n')
  20. def hexcmp(list1, list2):
  21. a = 0
  22. for a in range(0, len(list1)):
  23. if 0 == a & 0x07:
  24. sys.stdout.write('\n%04x ' % a)
  25. b1 = ord(list1[a])
  26. b2 = ord(list2[a])
  27. if b1 == b2:
  28. sys.stdout.write('%02x ' % b1)
  29. else:
  30. sys.stdout.write('%02x[%02x] ' % (b1, b2))
  31. a = a + 1
  32. sys.stdout.write('\n')