From 572cce207c0f8b658301f3015fcaa37f58508132 Mon Sep 17 00:00:00 2001 From: Christian Pointner Date: Sun, 7 Jul 2013 22:07:29 +0000 Subject: ignoring all data beyond of flash git-svn-id: https://svn.spreadspace.org/pic/trunk@53 a09c6847-51d9-44de-8ef2-e725cf50f3c7 --- downloader/downloader.py | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) (limited to 'downloader') diff --git a/downloader/downloader.py b/downloader/downloader.py index 86a41c9..8c5f15c 100755 --- a/downloader/downloader.py +++ b/downloader/downloader.py @@ -61,12 +61,17 @@ def get_highest_flash_addr(codedata, fss): def create_flash_image(codedata, fss, sa, ea): img = ( sa, [0xFFFF]*(ea-sa) ) for a,d in codedata.items(): - img[1][a-sa] = d + if a < ea: + img[1][a-sa] = d return img -def create_flash_segments(codedata, fss): +def create_flash_segments(codedata, fs, fss): sa = get_lowest_flash_addr(codedata, fss) ea = get_highest_flash_addr(codedata, fss) + if ea >= fs: + print "WARNING: the hex file contains data after end of flash, these words will be ignored" + ea = fs + img = create_flash_image(codedata, fss, sa, ea) for i in xrange(0, ea, fss): slice = img[1][i:i+fss] @@ -169,7 +174,7 @@ def identify(dev): print "FSS value is 0 " sys.exit(4) - print "connected with Bootloader '%s' Version %d.%d, (ID=%04X, %d bytes Flash, FSS=%d, %d bytes EEPROM, MESS=%d)" % \ + print "connected with Bootloader '%s' Version %d.%d, (ID=%04X, %d words Flash, FSS=%d, %d bytes EEPROM, MESS=%d)" % \ (id['name'], id['ver_maj'], id['ver_min'], id['devid'], id['fs'], id['fss'], id['es'], id['mess']) return id @@ -262,5 +267,5 @@ Options: codedata = load_hex(args[0]) id = identify(dev) - # for segment in create_flash_segments(codedata, id['fss']): - # print "%05X: %s" % (segment[0], ''.join('%04X'%i for i in segment[1])) + for segment in create_flash_segments(codedata, id['fs'], id['fss']): + print "%05X: %s" % (segment[0], ''.join('%04X'%i for i in segment[1])) -- cgit v1.2.3