From defaea09b33884a4dd17f89e11c7a565605ae2d2 Mon Sep 17 00:00:00 2001 From: Tilman Sauerbeck Date: Fri, 3 Jan 2020 16:33:15 +0100 Subject: [PATCH] tools: Pad final chunks with 0xff if necessary. The bootloader only accepts chunks whose size is a multiple of four. --- tools/update-firmware | 7 +++++++ 1 file changed, 7 insertions(+) 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 -- 2.30.2