mirror of
https://github.com/Klipper3d/klipper.git
synced 2025-07-07 23:17:37 -06:00
scripts: Support SDIO in flash-sdcard using split verification step
Signed-off-by: Donna Whisnant <dewhisna@dewtronics.com>
This commit is contained in:
parent
f4440267e6
commit
a0457f79e4
2 changed files with 48 additions and 10 deletions
|
@ -785,6 +785,13 @@ class SDCardSPI:
|
|||
if err_msgs:
|
||||
raise OSError("\n".join(err_msgs))
|
||||
|
||||
SDIO_WARNING = """
|
||||
This board requires a manual reboot to complete the flash process.
|
||||
If the board's bootloader uses SDIO mode for its SDCard, then a full
|
||||
power cycle is required. Please perform the power cycle now and then
|
||||
rerun this utility with the 'check' option to verify flash.
|
||||
"""
|
||||
|
||||
class MCUConnection:
|
||||
def __init__(self, k_reactor, device, baud, board_cfg):
|
||||
self.reactor = k_reactor
|
||||
|
@ -989,6 +996,9 @@ class MCUConnection:
|
|||
return sd_chksm
|
||||
|
||||
def verify_flash(self, req_chksm, old_dictionary, req_dictionary):
|
||||
if bool(self.board_config.get('skip_verify', False)):
|
||||
output_line(SDIO_WARNING)
|
||||
return
|
||||
output("Verifying Flash...")
|
||||
validation_passed = False
|
||||
msgparser = self._serial.get_msgparser()
|
||||
|
@ -1063,6 +1073,7 @@ class SPIFlash:
|
|||
self.firmware_checksum = None
|
||||
self.task_complete = False
|
||||
self.need_upload = True
|
||||
self.need_verify = True
|
||||
self.old_dictionary = None
|
||||
self.new_dictionary = None
|
||||
if args['klipper_dict_path'] is not None:
|
||||
|
@ -1092,7 +1103,7 @@ class SPIFlash:
|
|||
raise SPIFlashError("Unable to reconnect")
|
||||
output_line("Done")
|
||||
|
||||
def run_reset(self, eventtime):
|
||||
def run_reset_upload(self, eventtime):
|
||||
# Reset MCU to default state if necessary
|
||||
self.mcu_conn.connect()
|
||||
if self.mcu_conn.check_need_restart():
|
||||
|
@ -1102,6 +1113,16 @@ class SPIFlash:
|
|||
self.need_upload = False
|
||||
self.run_sdcard_upload(eventtime)
|
||||
|
||||
def run_reset_verify(self, eventtime):
|
||||
# Reset MCU to default state if necessary
|
||||
self.mcu_conn.connect()
|
||||
if self.mcu_conn.check_need_restart():
|
||||
self.mcu_conn.reset()
|
||||
self.task_complete = True
|
||||
else:
|
||||
self.need_verify = False
|
||||
self.run_verify(eventtime)
|
||||
|
||||
def run_sdcard_upload(self, eventtime):
|
||||
# Reconnect and upload
|
||||
if not self.mcu_conn.connected:
|
||||
|
@ -1121,7 +1142,8 @@ class SPIFlash:
|
|||
|
||||
def run_verify(self, eventtime):
|
||||
# Reconnect and verify
|
||||
self.mcu_conn.connect()
|
||||
if not self.mcu_conn.connected:
|
||||
self.mcu_conn.connect()
|
||||
self.mcu_conn.configure_mcu()
|
||||
self.mcu_conn.verify_flash(self.firmware_checksum, self.old_dictionary,
|
||||
self.new_dictionary)
|
||||
|
@ -1148,12 +1170,18 @@ class SPIFlash:
|
|||
self.mcu_conn = k_reactor = None
|
||||
|
||||
def run(self):
|
||||
self.run_reactor_task(self.run_reset)
|
||||
self._wait_for_reconnect()
|
||||
if self.need_upload:
|
||||
self.run_reactor_task(self.run_sdcard_upload)
|
||||
if not bool(self.board_config.get('verify_only', False)):
|
||||
self.run_reactor_task(self.run_reset_upload)
|
||||
self._wait_for_reconnect()
|
||||
self.run_reactor_task(self.run_verify)
|
||||
if self.need_upload:
|
||||
self.run_reactor_task(self.run_sdcard_upload)
|
||||
self._wait_for_reconnect()
|
||||
self.run_reactor_task(self.run_verify)
|
||||
else:
|
||||
self.run_reactor_task(self.run_reset_verify)
|
||||
if self.need_verify:
|
||||
self._wait_for_reconnect()
|
||||
self.run_reactor_task(self.run_verify)
|
||||
|
||||
def main():
|
||||
parser = argparse.ArgumentParser(
|
||||
|
@ -1177,6 +1205,9 @@ def main():
|
|||
parser.add_argument(
|
||||
"-d", "--dict_path", metavar="<klipper.dict>", type=str,
|
||||
default=None, help="Klipper firmware dictionary")
|
||||
parser.add_argument(
|
||||
"-c","--check", action="store_true",
|
||||
help="Perform flash check/verify only")
|
||||
parser.add_argument(
|
||||
"device", metavar="<device>", help="Device Serial Port")
|
||||
parser.add_argument(
|
||||
|
@ -1195,6 +1226,10 @@ def main():
|
|||
flash_args['baud'] = args.baud
|
||||
flash_args['klipper_bin_path'] = args.klipper_bin_path
|
||||
flash_args['klipper_dict_path'] = args.dict_path
|
||||
flash_args['verify_only'] = args.check
|
||||
if args.check:
|
||||
# override board_defs setting when doing verify-only:
|
||||
flash_args['skip_verify'] = False
|
||||
check_need_convert(args.board, flash_args)
|
||||
fatfs_lib.check_fatfs_build(output)
|
||||
try:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue