Tools: added --no-extf option to uploader.py

needed for PX4 bootloader
This commit is contained in:
Andrew Tridgell 2021-10-07 11:50:42 +11:00
parent e0d23c6495
commit 130f26c49a

View File

@ -246,7 +246,8 @@ class uploader(object):
target_system=None,
target_component=None,
source_system=None,
source_component=None):
source_component=None,
no_extf=False):
self.MAVLINK_REBOOT_ID1 = bytearray(b'\xfe\x21\x72\xff\x00\x4c\x00\x00\x40\x40\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xf6\x00\x01\x00\x00\x53\x6b') # NOQA
self.MAVLINK_REBOOT_ID0 = bytearray(b'\xfe\x21\x45\xff\x00\x4c\x00\x00\x40\x40\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xf6\x00\x00\x00\x00\xcc\x37') # NOQA
if target_component is None:
@ -255,6 +256,7 @@ class uploader(object):
source_system = 255
if source_component is None:
source_component = 1
self.no_extf = no_extf
# open the port, keep the default timeout short so we can poll quickly
self.port = serial.Serial(portname, baudrate_bootloader, timeout=2.0)
@ -679,11 +681,14 @@ class uploader(object):
self.board_type = self.__getInfo(uploader.INFO_BOARD_ID)
self.board_rev = self.__getInfo(uploader.INFO_BOARD_REV)
self.fw_maxsize = self.__getInfo(uploader.INFO_FLASH_SIZE)
try:
self.extf_maxsize = self.__getInfo(uploader.INFO_EXTF_SIZE)
except Exception:
print("Could not get external flash size, assuming 0")
if self.no_extf:
self.extf_maxsize = 0
else:
try:
self.extf_maxsize = self.__getInfo(uploader.INFO_EXTF_SIZE)
except Exception:
print("Could not get external flash size, assuming 0")
self.extf_maxsize = 0
def dump_board_info(self):
# OTP added in v4:
@ -1062,6 +1067,7 @@ def main():
)
parser.add_argument('--download', action='store_true', default=False, help='download firmware from board')
parser.add_argument('--identify', action="store_true", help="Do not flash firmware; simply dump information about board")
parser.add_argument('--no-extf', action="store_true", help="Do not attempt external flash operations")
parser.add_argument('--erase-extflash', type=lambda x: int(x, 0), default=None,
help="Erase sectors containing specified amount of bytes from ext flash")
parser.add_argument('firmware', nargs="?", action="store", default=None, help="Firmware file to be uploaded")
@ -1100,7 +1106,8 @@ def main():
args.target_system,
args.target_component,
args.source_system,
args.source_component)
args.source_component,
args.no_extf)
except Exception as e:
if not is_WSL: