From e7fe8f7268bb1952b0169ef63b7f0ba2ef23de2a Mon Sep 17 00:00:00 2001 From: Lorenz Meier Date: Mon, 1 Jan 2018 15:04:13 +0100 Subject: [PATCH] Uploader: Enforce matching maximum flash sizes The goal is to force developers to use the correct target with the correct flash size. This prevents criticial functionality missing and is in particular important for FMUv2/FMUv3 boards. It is unmaintainable otherwise for the Pixhawk series. --- Tools/px_uploader.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/Tools/px_uploader.py b/Tools/px_uploader.py index a8f0b7ed44..1154506a11 100755 --- a/Tools/px_uploader.py +++ b/Tools/px_uploader.py @@ -488,9 +488,18 @@ class uploader(object): print("FORCED WRITE, FLASHING ANYWAY!") else: raise IOError(msg) + + # Prevent uploads where the image would overflow the flash if self.fw_maxsize < fw.property('image_size'): raise RuntimeError("Firmware image is too large for this board") + # Prevent uploads where the maximum image size of the board config is smaller than the flash + # of the board. This is a hint the user chose the wrong config and will lack features + # for this particular board. + if self.fw_maxsize > fw.property('image_maxsize'): + raise RuntimeError("Board can accept larger flash images (%u bytes) than board config (%u bytes). Please use the correct board configuration to avoid lacking critical functionality." + % (self.fw_maxsize, fw.property('image_maxsize'))) + # OTP added in v4: if self.bl_rev > 3: for byte in range(0, 32*6, 4):