From 2fd65c259b44a9a2e1794f8bc270f2558fff8afe Mon Sep 17 00:00:00 2001 From: Sven Steckmann Date: Mon, 11 May 2015 16:11:51 +0200 Subject: [PATCH] dfu-convert now supports handling multiple non continues sections. The convert utility was not able to generate multiple blocks for programming, it just generates a big block with default values in between. This can be dangerous if there are sections which should not be programed. Now these sections will be left out. --- dfu-convert | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/dfu-convert b/dfu-convert index 3d8eefd..84f6263 100755 --- a/dfu-convert +++ b/dfu-convert @@ -118,7 +118,25 @@ if __name__=="__main__": except ValueError: print "Address %s invalid." % address sys.exit(1) - target.append({ 'address': address, 'data': data }) + # The file may contain multiple sections with empty addresses in between + # which can be supported by the file so leave them out. + addrStart = None + addLast = None + for addr in ih.addresses(): + ih[addr] = addr & 0xFF + if addrStart == None: + addrStart = addr + elif addr != (addrLast + 1): + # Block end! + data = ih.tobinstr(start=addrStart, end=addrLast) + target.append({ 'address': addrStart, 'data': data }) + addrStart = addr + addrLast = addr + else: + data = ih.tobinstr(start=addrStart, end=addrLast) + target.append({ 'address': addrStart, 'data': data }) + + outfile = args[0] device = DEFAULT_DEVICE