From 8267f4fd1e3c750bcec32c25182cd60d9e0a2b4a Mon Sep 17 00:00:00 2001 From: Alex Mikhalev Date: Sat, 21 May 2022 02:02:49 +0000 Subject: [PATCH] scripts: Hotfix px_uploader.py to avoid PX4BL bug Signed-off-by: Alex Mikhalev --- Tools/px_uploader.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/Tools/px_uploader.py b/Tools/px_uploader.py index b35e5bc372..436cff0047 100755 --- a/Tools/px_uploader.py +++ b/Tools/px_uploader.py @@ -136,8 +136,11 @@ class firmware(object): self.image = bytearray(zlib.decompress(base64.b64decode(self.desc['image']))) - # pad image to 4-byte length - while ((len(self.image) % 4) != 0): + # PX4 bootloader in theory requires only 4-byte padding, + # but a bug exists with the flash block caching where if the data + # does not fill up the block, it will not be written (left as all 1s). + # So pad up to the flash block size (8 words). + while ((len(self.image) % (4 * 8)) != 0): self.image.extend(b'\xff') def property(self, propname):