diff --git a/kunlun.py b/kunlun.py index 1f29f2c..54afc94 100644 --- a/kunlun.py +++ b/kunlun.py @@ -253,7 +253,7 @@ def upload_fun(): myprint (f"Total transmission time: {(time_stamp_start+time_stamp_end)} s" ) myprint("Start transform bin to hex.") - bin_to_hex_file(calc_upload_name(), calc_hex_name()) + bin_to_hex_file(calc_upload_name(), calc_hex_name(),layout_index) myprint("Transform to hex end.") @@ -302,14 +302,17 @@ def global_def(): global parser global user_log global log_timeout + global layout_index args = parser.parse_args() init_str="WQKL" serial_com=args.port - b_rate=115200 - nb_rate=1500000 + b_rate=args.b_rate + nb_rate=args.nb_rate user_log=args.log log_timeout=args.timeout + layout_index=args.layout_index + # 上传或者下载flash镜像 if(args.flash_file is not None): @@ -348,14 +351,17 @@ def parser_init(): parser = argparse.ArgumentParser(description='kunlun相关工具脚本') # 添加参数 parser.add_argument('-p','--port',action='store', help='输入使用的串口') - parser.add_argument('-r', '--ram_file', action='store', help='输入使用的ram程序') - parser.add_argument('-f', '--flash_file', action='store', help='输入使用的flash程序') + parser.add_argument('-r', '--ram_file', action='store', help='输入要下载的ram文件名称,此项和 -f 选项不能同时指定') + parser.add_argument('-f', '--flash_file', action='store', help='输入要下载或上传的flash文件名称,如果文件存在则下载;不存在则上传') parser.add_argument('-c', '--console', action='store', help='指定控制台保存的文件名,不指定则不进入控制台') parser.add_argument('-u','--upload_key',action='store',help='上传时保存分区的关键字,不指定则上传所有') parser.add_argument('-k','--kunlun_version',action='store',help='上传下载时的kunlun版本 3或者1') parser.add_argument('-b','--bin_convert',action='store',help='转换bin文件') parser.add_argument('-l','--log',action='store_true',default=False, help='下载ram或flash程序之后是否进入log界面,默认否') parser.add_argument('-t','--timeout',action='store',type=float,default=5,help='启用log时接收log的时间') + parser.add_argument('-i','--layout_index',action='store',type=int,help='解析接收到的flash文件或转换bin文件时使用的layout,不指定则不解析') + parser.add_argument('--b_rate',action='store',type=int,default=115200,help='下载ram程序 上传flash数据 控制台 接收log等 使用的串口波特率') + parser.add_argument('--nb_rate',action='store',type=int,default=1500000,help='下载flash程序使用的串口波特率') @@ -381,6 +387,7 @@ if __name__ == '__main__': parser=None user_log=False log_timeout=0 + layout_index=None parser_init() global_def() if(function_type is None): @@ -389,7 +396,7 @@ if __name__ == '__main__': sys.exit(-1) log_init(calc_log_file_name()) if(function_type=='convert'): - bin_to_hex_file(iot_flash_file,calc_hex_name()) + bin_to_hex_file(iot_flash_file,calc_hex_name(),layout_index) sys.exit(0) if(serial_com is None):