From: Tilman Sauerbeck Date: Fri, 3 Jan 2020 15:33:15 +0000 (+0100) Subject: tools: Pad final chunks with 0xff if necessary. X-Git-Url: http://git.code-monkey.de/?a=commitdiff_plain;h=defaea09b33884a4dd17f89e11c7a565605ae2d2;p=gps-watch.git tools: Pad final chunks with 0xff if necessary. The bootloader only accepts chunks whose size is a multiple of four. --- diff --git a/tools/update-firmware b/tools/update-firmware index f610343..cd71124 100755 --- a/tools/update-firmware +++ b/tools/update-firmware @@ -168,6 +168,13 @@ class Application: sys.stderr.write('File too large.\n') return 3 + # The bootloader only accepts chunks whose size is word-aligned: + num_extra = len(chunks[-1]) & 3 + + if num_extra != 0: + num_pad = 4 - extra + chunks[-1] += b'\xff' * num_pad + # Defaulting to zero seems too dangerous: if self._offset is None: sector0 = None