summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorroland <roland@van-straten.org>2018-07-18 12:29:44 +0200
committerDamien George <damien.p.george@gmail.com>2018-07-20 14:23:11 +1000
commit6e50df4e21f13dc62858afbb927e563b721433b8 (patch)
tree6805d374b9ed0b1b9b926e304f009cafb27cbd44
parentb7004efe369f3aa005b019d6a8afcbfb399607d6 (diff)
tools/dfu.py: Pad image data to 8 byte alignment to support L476.
Thanks to @dhylands for this patch to pad the image to 8-byte boundaries.
-rwxr-xr-xtools/dfu.py4
1 files changed, 4 insertions, 0 deletions
diff --git a/tools/dfu.py b/tools/dfu.py
index 54b602438..ee89c7541 100755
--- a/tools/dfu.py
+++ b/tools/dfu.py
@@ -60,6 +60,10 @@ def build(file,targets,device=DEFAULT_DEVICE):
for t,target in enumerate(targets):
tdata = b''
for image in target:
+ # pad image to 8 bytes (needed at least for L476)
+ pad = (8 - len(image['data']) % 8 ) % 8
+ image['data'] = image['data'] + bytes(bytearray(8)[0:pad])
+ #
tdata += struct.pack('<2I',image['address'],len(image['data']))+image['data']
tdata = struct.pack('<6sBI255s2I',b'Target',0,1, b'ST...',len(tdata),len(target)) + tdata
data += tdata