summaryrefslogtreecommitdiff
path: root/bootloader/downloader.py
diff options
context:
space:
mode:
authorChristian Pointner <equinox@spreadspace.org>2013-07-10 01:59:51 +0000
committerChristian Pointner <equinox@spreadspace.org>2013-07-10 01:59:51 +0000
commit57657a44bef969f2ef900a8aafd48e8313630b6c (patch)
tree1c22331ff5abb66133b13b08675c7415410c7f83 /bootloader/downloader.py
parentdrop requirment for intelhex library (diff)
reenabled read flash
git-svn-id: https://svn.spreadspace.org/pic/trunk@66 a09c6847-51d9-44de-8ef2-e725cf50f3c7
Diffstat (limited to 'bootloader/downloader.py')
-rwxr-xr-xbootloader/downloader.py40
1 files changed, 21 insertions, 19 deletions
diff --git a/bootloader/downloader.py b/bootloader/downloader.py
index 260ff7e..27b15c3 100755
--- a/bootloader/downloader.py
+++ b/bootloader/downloader.py
@@ -42,13 +42,16 @@ def load_hex(file):
hexdata.load_from_file(fin)
return hexdata
-# TODO: re-add this as soon as write_hex_file works
-# def write_hex(file, hexdata):
-# fout = file
-# if fout == '-':
-# fout = sys.stdout
+def write_hex(file, codedata):
+ from ihexpic import IHexPic
+
+ fout = file
+ if fout == '-':
+ fout = sys.stdout
-# hexdata.write_hex_file(fout)
+ hexdata = IHexPic()
+ hexdata.load_from_dict(codedata)
+ hexdata.write_to_file(fout)
def get_lowest_flash_addr(hexdata, fss):
lowest_code_addr = hexdata.get_lowest_addr()
@@ -222,18 +225,17 @@ def write_flash(dev, id, file):
# print >> sys.stderr, "%05X: %s" % (segment[0], ''.join('%04X '%i for i in segment[1]))
cmd_write_flash_segment(dev, id, segment[0], segment[1])
-# TODO: re-add this as soon as write_hex_file works
-# def read_flash(dev, id, file):
-# codedata = {}
-# for addr in xrange(0, id['fs'], id['fss']):
-# data = cmd_read_flash_segment(dev, id, addr)
-# # print >> sys.stderr, "%05X: %s" % (addr, ''.join('%04X '%i for i in data))
-# a = addr
-# for d in data:
-# codedata[a] = d
-# a += 1
-
-# write_hex(file, codedata)
+def read_flash(dev, id, file):
+ codedata = {}
+ for addr in xrange(0, id['fs'], id['fss']):
+ data = cmd_read_flash_segment(dev, id, addr)
+# print >> sys.stderr, "%05X: %s" % (addr, ''.join('%04X '%i for i in data))
+ a = addr
+ for d in data:
+ if d != 0x3FFF:
+ codedata[a] = d
+ a += 1
+ write_hex(file, codedata)
def verify_flash(dev, id, file):
hexdata = load_hex(file)
@@ -260,7 +262,7 @@ def verify_flash(dev, id, file):
commands = {
'boot': boot,
'write': write_flash,
-# 'read': read_flash, # TODO: re-add this as soon as write_hex_file works
+ 'read': read_flash,
'verify': verify_flash
}