MCPcopy Create free account
hub / github.com/apache/nuttx / main

Function main

tools/flash_writer.py:581–661  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

579
580
581def main():
582 try:
583 config_loader = ConfigArgsLoader()
584 config_loader.update_config()
585 except Exception:
586 return errno.EINVAL
587
588 # Wait to reset the board
589 writer = FlashWriter(ConfigArgs.PROTOCOL_TYPE)
590
591 do_wait_reset = True
592 if ConfigArgs.AUTO_RESET:
593 if subprocess.call("cd " + sys.path[0] + "; ./reset_board.sh", shell=True) == 0:
594 print("auto reset board success!!")
595 do_wait_reset = False
596 bootrom_msg = writer.cancel_autoboot()
597
598 if ConfigArgs.DTR_RESET:
599 do_wait_reset = False
600 bootrom_msg = writer.cancel_autoboot()
601
602 if ConfigArgs.WAIT_RESET is False and do_wait_reset is True:
603 rx = writer.recv()
604 time.sleep(1)
605 for i in range(3):
606 writer.send("")
607 rx = writer.recv()
608 if "updater".encode() in rx:
609 # No need to wait for reset
610 do_wait_reset = False
611 break
612 time.sleep(1)
613
614 if do_wait_reset:
615 # Wait to reset the board
616 print("Please press RESET button on target board")
617 sys.stdout.flush()
618 bootrom_msg = writer.cancel_autoboot() # noqa: F841 unused variable
619
620 # Remove files
621 if ConfigArgs.ERASE_NAME:
622 print(">>> Remove existing files ...")
623 writer.delete_files(ConfigArgs.ERASE_NAME)
624
625 # Install files
626 if (
627 ConfigArgs.PACKAGE_NAME
628 or ConfigArgs.PKGSYS_NAME
629 or ConfigArgs.PKGAPP_NAME
630 or ConfigArgs.PKGUPD_NAME
631 ):
632 print(">>> Install files ...")
633 if ConfigArgs.PACKAGE_NAME:
634 writer.install_files(ConfigArgs.PACKAGE_NAME, "install")
635 if ConfigArgs.PKGSYS_NAME:
636 writer.install_files(ConfigArgs.PKGSYS_NAME, "install")
637 if ConfigArgs.PKGAPP_NAME:
638 writer.install_files(ConfigArgs.PKGAPP_NAME, "install")

Callers 1

flash_writer.pyFile · 0.70

Calls 10

update_configMethod · 0.95
cancel_autobootMethod · 0.95
recvMethod · 0.95
sendMethod · 0.95
delete_filesMethod · 0.95
install_filesMethod · 0.95
save_filesMethod · 0.95
wait_for_promptMethod · 0.95
ConfigArgsLoaderClass · 0.85
FlashWriterClass · 0.85

Tested by

no test coverage detected