添加kl1的下载 打包为exe文件

This commit is contained in:
ranchuan
2024-10-16 11:15:02 +08:00
parent da3964123b
commit e26889c274
6 changed files with 42 additions and 28 deletions

View File

@@ -10,11 +10,11 @@ import time
import xmodem
import os
import binascii
from log import myprint
from log import log_init
from bin_to_hex import bin_to_hex_file
from bin_to_hex import bin_file_decrypt
from bin_to_hex import clear_tmp
from bin.log import myprint
from bin.log import log_init
from bin.bin_to_hex import bin_to_hex_file
from bin.bin_to_hex import bin_file_decrypt
from bin.bin_to_hex import clear_tmp
def init_send(s_port:serial.Serial, send_str:str):
@@ -223,6 +223,14 @@ def burn_fun():
print_device_str(ser_read_data)
# 获取执行文件所在的目录
def bin_path():
if(sys.argv[0].endswith('.exe')):
path=os.path.dirname(os.path.realpath(sys.executable))
else:
path=os.path.abspath(__file__)
path=os.path.split(path)[0]
return os.path.join(path,'bin')
def global_def():
global init_str
@@ -255,24 +263,43 @@ def global_def():
upload=True
else:
print("param err.")
exit(-1)
sys.exit(-1)
if(upload):
ram_file=f'bootram_{sys.argv[2]}.bin'
else:
ram_file=f'{sys.argv[2]}_ram_build.bin'
ram_file=os.path.join('bin',ram_file)
ram_file=os.path.join(bin_path(),ram_file)
iot_flash_file=sys.argv[-1]
def print_help():
help=f'''
Automatically determine whether to upload or download:"
{sys.argv[0]} [com] [kl1/kl3] [upload.bin/download.bin]
Manually specify whether to upload or download:
{sys.argv[0]} [com] [kl1/kl3] [upload/download] [upload.bin/download.bin]
Convert bin file:
{sys.argv[0]} [file.bin] <enc>
'''
print(help)
# 如果不指定上传还是下载 脚本会根据输入文件是否存在来决定上传还是下载
# kunlun.py [com] [kl1/kl3] [upload.bin/download.bin]
# kunlun.py [com] [kl1/kl3] [upload/download] [upload.bin/download.bin]
# kunlun.py [file.bin] <enc>
if __name__ == '__main__':
if(len(sys.argv)<4):
if(len(sys.argv)>=2):
if(sys.argv[1].endswith('.bin')):
if(len(sys.argv)>=3):
enc=1
else:
enc=0
bin_to_hex_file(sys.argv[1],"work/"+sys.argv[1]+".txt",enc)
sys.exit(0)
print("param too less")
exit(-1)
print_help()
sys.exit(-1)
upload=None
time_stamp_start, time_stamp_end = 0, 0
init_str, serial_com, b_rate, nb_rate, ram_file, iot_flash_file, ser = None, None, None, None, None, None, None