添加kl1的下载 打包为exe文件
This commit is contained in:
3
.gitignore
vendored
3
.gitignore
vendored
@@ -1,3 +1,6 @@
|
|||||||
work/
|
work/
|
||||||
__pycache__/
|
__pycache__/
|
||||||
history/
|
history/
|
||||||
|
build/
|
||||||
|
dist/
|
||||||
|
*.spec
|
@@ -3,7 +3,7 @@ import os
|
|||||||
import sys
|
import sys
|
||||||
import struct
|
import struct
|
||||||
import json
|
import json
|
||||||
from log import myprint
|
from bin.log import myprint
|
||||||
|
|
||||||
|
|
||||||
# kunlun1,kunlun2,kunlun3的img类型
|
# kunlun1,kunlun2,kunlun3的img类型
|
||||||
@@ -285,10 +285,8 @@ def clear_tmp():
|
|||||||
os.remove(item)
|
os.remove(item)
|
||||||
|
|
||||||
|
|
||||||
# bin_to_hex.py input_file output_file
|
# bin_to_hex.py input_file
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
# bin_to_hex_file(sys.argv[1],sys.argv[2],sys.argv[3])
|
|
||||||
# load_flash_info("work/upload-test.info")
|
|
||||||
if(len(sys.argv)>=3):
|
if(len(sys.argv)>=3):
|
||||||
enc=1
|
enc=1
|
||||||
else:
|
else:
|
BIN
bin/kl1_ram_build.bin
Normal file
BIN
bin/kl1_ram_build.bin
Normal file
Binary file not shown.
45
kunlun.py
45
kunlun.py
@@ -10,11 +10,11 @@ import time
|
|||||||
import xmodem
|
import xmodem
|
||||||
import os
|
import os
|
||||||
import binascii
|
import binascii
|
||||||
from log import myprint
|
from bin.log import myprint
|
||||||
from log import log_init
|
from bin.log import log_init
|
||||||
from bin_to_hex import bin_to_hex_file
|
from bin.bin_to_hex import bin_to_hex_file
|
||||||
from bin_to_hex import bin_file_decrypt
|
from bin.bin_to_hex import bin_file_decrypt
|
||||||
from bin_to_hex import clear_tmp
|
from bin.bin_to_hex import clear_tmp
|
||||||
|
|
||||||
|
|
||||||
def init_send(s_port:serial.Serial, send_str:str):
|
def init_send(s_port:serial.Serial, send_str:str):
|
||||||
@@ -223,6 +223,14 @@ def burn_fun():
|
|||||||
print_device_str(ser_read_data)
|
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():
|
def global_def():
|
||||||
global init_str
|
global init_str
|
||||||
@@ -255,24 +263,43 @@ def global_def():
|
|||||||
upload=True
|
upload=True
|
||||||
else:
|
else:
|
||||||
print("param err.")
|
print("param err.")
|
||||||
exit(-1)
|
sys.exit(-1)
|
||||||
if(upload):
|
if(upload):
|
||||||
ram_file=f'bootram_{sys.argv[2]}.bin'
|
ram_file=f'bootram_{sys.argv[2]}.bin'
|
||||||
else:
|
else:
|
||||||
ram_file=f'{sys.argv[2]}_ram_build.bin'
|
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]
|
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.bin/download.bin]
|
||||||
# kunlun.py [com] [kl1/kl3] [upload/download] [upload.bin/download.bin]
|
# kunlun.py [com] [kl1/kl3] [upload/download] [upload.bin/download.bin]
|
||||||
|
# kunlun.py [file.bin] <enc>
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
if(len(sys.argv)<4):
|
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")
|
print("param too less")
|
||||||
exit(-1)
|
print_help()
|
||||||
|
sys.exit(-1)
|
||||||
upload=None
|
upload=None
|
||||||
time_stamp_start, time_stamp_end = 0, 0
|
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
|
init_str, serial_com, b_rate, nb_rate, ram_file, iot_flash_file, ser = None, None, None, None, None, None, None
|
||||||
|
@@ -1,14 +0,0 @@
|
|||||||
###################################################################################################################
|
|
||||||
# #
|
|
||||||
# Xmodem Config #
|
|
||||||
# #
|
|
||||||
###################################################################################################################
|
|
||||||
|
|
||||||
init_str = WQKL
|
|
||||||
|
|
||||||
serial_port_num = 11
|
|
||||||
baud_rate = 115200
|
|
||||||
new_baud_rate = 468000
|
|
||||||
|
|
||||||
ram_file = bootram_kl3_build.bin
|
|
||||||
iot_flash_file = HTZD_STA_xts.bin
|
|
Reference in New Issue
Block a user