px_loader: added --force option

this can be used to override the board type check. Useful when
changing bootloaders
This commit is contained in:
Andrew Tridgell
2015-03-05 22:05:17 +11:00
committed by Lorenz Meier
parent 9495ec4f5a
commit d9b4f5b170

View File

@@ -416,7 +416,12 @@ class uploader(object):
def upload(self, fw):
# Make sure we are doing the right thing
if self.board_type != fw.property('board_id'):
raise IOError("Firmware not suitable for this board")
msg = "Firmware not suitable for this board (board_type=%u board_id=%u)" % (
self.board_type, fw.property('board_id'))
if args.force:
print("WARNING: %s" % msg)
else:
raise IOError(msg)
if self.fw_maxsize < fw.property('image_size'):
raise RuntimeError("Firmware image is too large for this board")
@@ -486,6 +491,7 @@ else:
parser = argparse.ArgumentParser(description="Firmware uploader for the PX autopilot system.")
parser.add_argument('--port', action="store", required=True, help="Serial port(s) to which the FMU may be attached")
parser.add_argument('--baud', action="store", type=int, default=115200, help="Baud rate of the serial port (default is 115200), only required for true serial ports.")
parser.add_argument('--force', action='store_true', default=False, help='Override board type check and continue loading')
parser.add_argument('firmware', action="store", help="Firmware file to be uploaded")
args = parser.parse_args()