From e1584c1cb8eb52c300b4de8c8df3805ba275c1f5 Mon Sep 17 00:00:00 2001 From: vc4 <287920192@qq.com> Date: Wed, 31 Aug 2022 21:22:08 +0800 Subject: [PATCH] add goboot cmd support, for poweron to bootloader --- hc32flash.py | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/hc32flash.py b/hc32flash.py index c58f22a..24e059f 100755 --- a/hc32flash.py +++ b/hc32flash.py @@ -314,6 +314,7 @@ if __name__ == '__main__': parser.add_argument('-L', '--lock', action='store_true', help='Lock. SWD port disabled') parser.add_argument('-R', '--reboot', action='store_true', help='Reboot device') parser.add_argument('-e', '--erase', action='store_true', help='Erase device') + parser.add_argument('-G', '--goboot', action='store_true', help='Goto bootloader') parser.add_argument('-w', metavar='', help='Write data from file to device') parser.add_argument('-r', metavar='', help='Read data from device to file') parser.add_argument('-v', metavar='', help='Verify chksum data in device against file') @@ -351,14 +352,18 @@ if __name__ == '__main__': transport = SerialTransport(args.port, hc32xx['BootloaderBaudrate']) base_dir = os.path.dirname(os.path.realpath(__file__)) - # stage 1. goto bootload + # stage 1. goto bootloader sys.stdout.write("Stage 1. Goto bootloader: ") sys.stdout.flush() - if transport.goto_bootloader(): - sys.stdout.write("succ\n") - else: - sys.stdout.write("error\n") - sys.exit(1) + _err = 0 + while not transport.goto_bootloader(): + sys.stdout.write(".") + sys.stdout.flush() + _err += 1 + if _err > (args.goboot and 100 or 0): + sys.stdout.write("error\n") + sys.exit(1) + sys.stdout.write("succ\n") # state 2. Check device sys.stdout.write("Stage 2. Check device: ")