--ram 选项可以在其他目录使用 bin目录中的.bin文件
This commit is contained in:
46
kunlun.py
46
kunlun.py
@@ -296,7 +296,35 @@ def get_upload_cfg(key:str):
|
|||||||
return "all"
|
return "all"
|
||||||
|
|
||||||
|
|
||||||
|
# 列出所有 .bin 文件
|
||||||
|
def list_bin_file():
|
||||||
|
path=os.path.curdir
|
||||||
|
items:list[str]=[]
|
||||||
|
l=os.listdir(path)
|
||||||
|
for item in l:
|
||||||
|
if(os.path.isfile(item)):
|
||||||
|
items.append(item)
|
||||||
|
l=os.listdir(bin_path())
|
||||||
|
for item in l:
|
||||||
|
tmp=os.path.join(bin_path(),item)
|
||||||
|
if(os.path.isfile(tmp)):
|
||||||
|
items.append(item)
|
||||||
|
ret_list:list[str]=[]
|
||||||
|
for item in items:
|
||||||
|
if(item.endswith(".bin")):
|
||||||
|
ret_list.append(item)
|
||||||
|
return ret_list
|
||||||
|
|
||||||
|
# 获取ram文件的路径
|
||||||
|
def ram_file_redirect(file:str):
|
||||||
|
if os.path.exists(file):
|
||||||
|
return file
|
||||||
|
else:
|
||||||
|
p=os.path.join(bin_path(),file)
|
||||||
|
if os.path.exists(p):
|
||||||
|
return p
|
||||||
|
myprint(f"文件不存在 {file}")
|
||||||
|
sys.exit(-1)
|
||||||
|
|
||||||
def global_def():
|
def global_def():
|
||||||
global init_str
|
global init_str
|
||||||
@@ -345,8 +373,8 @@ def global_def():
|
|||||||
upload_key='all'
|
upload_key='all'
|
||||||
elif(args.ram_file is not None):
|
elif(args.ram_file is not None):
|
||||||
function_type='ram'
|
function_type='ram'
|
||||||
ram_file=args.ram_file
|
ram_file=ram_file_redirect(args.ram_file)
|
||||||
iot_flash_file=ram_file
|
iot_flash_file=args.ram_file
|
||||||
elif(args.bin_convert is not None):
|
elif(args.bin_convert is not None):
|
||||||
function_type='convert'
|
function_type='convert'
|
||||||
iot_flash_file=args.bin_convert
|
iot_flash_file=args.bin_convert
|
||||||
@@ -354,7 +382,11 @@ def global_def():
|
|||||||
iot_flash_file=args.console
|
iot_flash_file=args.console
|
||||||
function_type='console'
|
function_type='console'
|
||||||
elif(args.ftm):
|
elif(args.ftm):
|
||||||
|
iot_flash_file=time.strftime("%Y%m%d-%H%M%S")
|
||||||
function_type='ftm'
|
function_type='ftm'
|
||||||
|
elif(args.list):
|
||||||
|
iot_flash_file=time.strftime("%Y%m%d-%H%M%S")
|
||||||
|
function_type='list'
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -375,7 +407,8 @@ def parser_init():
|
|||||||
parser.add_argument('-i','--layout_index',action='store',type=int,help='解析接收到的flash文件或转换bin文件时使用的layout,不指定则不解析')
|
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('--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程序使用的串口波特率')
|
parser.add_argument('--nb_rate',action='store',type=int,default=1500000,help='下载flash程序使用的串口波特率')
|
||||||
parser.add_argument('--ftm',action='store_true',type=bool,default=False,help='进入工厂模式')
|
parser.add_argument('--ftm',action='store_true',default=False,help='进入工厂模式')
|
||||||
|
parser.add_argument('--list',action='store_true',default=False,help='列出所有.bin文件')
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -412,7 +445,12 @@ if __name__ == '__main__':
|
|||||||
if(function_type=='convert'):
|
if(function_type=='convert'):
|
||||||
bin_to_hex_file(iot_flash_file,calc_hex_name(),layout_index)
|
bin_to_hex_file(iot_flash_file,calc_hex_name(),layout_index)
|
||||||
sys.exit(0)
|
sys.exit(0)
|
||||||
|
if(function_type=="list"):
|
||||||
|
l=list_bin_file()
|
||||||
|
myprint("当前目录和bin目录的.bin文件如下")
|
||||||
|
for item in l:
|
||||||
|
myprint(item)
|
||||||
|
sys.exit(0)
|
||||||
if(serial_com is None):
|
if(serial_com is None):
|
||||||
myprint(f"请指定串口 {serial_com}")
|
myprint(f"请指定串口 {serial_com}")
|
||||||
sys.exit(-1)
|
sys.exit(-1)
|
||||||
|
Reference in New Issue
Block a user