烧录flash时配置波特率,解决只下载ram时不能下载pg的问题
This commit is contained in:
@@ -47,6 +47,7 @@ _DevType={
|
|||||||
0x01:"devV1kunlun1",
|
0x01:"devV1kunlun1",
|
||||||
0x02:"devV1kunlun2",
|
0x02:"devV1kunlun2",
|
||||||
0x03:"devV1kunlun3",
|
0x03:"devV1kunlun3",
|
||||||
|
0x04:"devV1Pangu",
|
||||||
0xFF:"devV1Max"
|
0xFF:"devV1Max"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
42
kunlun.py
42
kunlun.py
@@ -12,6 +12,7 @@ import os
|
|||||||
import binascii
|
import binascii
|
||||||
import threading
|
import threading
|
||||||
import argparse
|
import argparse
|
||||||
|
import base64
|
||||||
from bin.log import myprint
|
from bin.log import myprint
|
||||||
from bin.log import log_init
|
from bin.log import log_init
|
||||||
from bin.log import mywrite
|
from bin.log import mywrite
|
||||||
@@ -22,6 +23,7 @@ from bin.bin_to_hex import load_flash_info
|
|||||||
from bin.bin_to_hex import check_bin_type
|
from bin.bin_to_hex import check_bin_type
|
||||||
from bin.base import bin_path
|
from bin.base import bin_path
|
||||||
from bin.factory_mode import ftm_handle
|
from bin.factory_mode import ftm_handle
|
||||||
|
from bin.crc import CRC16
|
||||||
|
|
||||||
|
|
||||||
def init_send(s_port:serial.Serial, send_str:str):
|
def init_send(s_port:serial.Serial, send_str:str):
|
||||||
@@ -73,7 +75,8 @@ def burn_flash_bin(s_port:serial.Serial, x_modem:xmodem.XMODEM, f_file):
|
|||||||
continue
|
continue
|
||||||
print_device_str(tmp)
|
print_device_str(tmp)
|
||||||
s_info += tmp
|
s_info += tmp
|
||||||
if(s_info.find(b'CCC')>=0 and bytes2read==1):
|
# if(s_info.find(b'CCC')>=0 and bytes2read==1):
|
||||||
|
if(s_info.find(b'Recieving FLASH-IMAGE in xmodem : C')>=0):
|
||||||
m_flash=True
|
m_flash=True
|
||||||
else:
|
else:
|
||||||
m_flash=False
|
m_flash=False
|
||||||
@@ -280,9 +283,30 @@ def upload_fun():
|
|||||||
myprint("Transform to hex end.")
|
myprint("Transform to hex end.")
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
# 发送配置信息
|
||||||
|
def send_cfg_fun():
|
||||||
|
global nb_rate
|
||||||
|
rate_table={
|
||||||
|
115200:0,
|
||||||
|
460800:1,
|
||||||
|
1500000:2
|
||||||
|
}
|
||||||
|
baud_cfg=f"u_baud={rate_table.get(nb_rate,0)}"
|
||||||
|
cfg_str=base64.b64encode(baud_cfg.encode(encoding='utf-8')).decode(encoding='utf-8')
|
||||||
|
text=f"ram_config:{cfg_str}:gifnoc_mar"
|
||||||
|
crc=CRC16(text.encode('utf-8'))
|
||||||
|
cfg_text=f"{text}#crc={crc}"
|
||||||
|
# print(cfg_text)
|
||||||
|
ser.write(f"{cfg_text}\n".encode("utf-8"))
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# 烧录固件
|
# 烧录固件
|
||||||
def burn_fun():
|
def burn_fun():
|
||||||
time.sleep(3)
|
# time.sleep(1)
|
||||||
|
send_cfg_fun()
|
||||||
|
# time.sleep(0.02)
|
||||||
ser_read_data=ser.read(4096)
|
ser_read_data=ser.read(4096)
|
||||||
print_device_str(ser_read_data)
|
print_device_str(ser_read_data)
|
||||||
ser.baudrate=nb_rate
|
ser.baudrate=nb_rate
|
||||||
@@ -400,6 +424,11 @@ def global_def():
|
|||||||
function_type='ram'
|
function_type='ram'
|
||||||
ram_file=ram_file_redirect(args.ram_file)
|
ram_file=ram_file_redirect(args.ram_file)
|
||||||
log_file=args.ram_file
|
log_file=args.ram_file
|
||||||
|
if(args.kunlun_version is None):
|
||||||
|
print("请指定参数 -k")
|
||||||
|
sys.exit(-1)
|
||||||
|
elif(args.kunlun_version == "4"):
|
||||||
|
init_str="HZPG"
|
||||||
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
|
||||||
@@ -432,7 +461,7 @@ def parser_init():
|
|||||||
parser.add_argument('-t','--timeout',action='store',type=float,default=5,help='启用log时接收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('-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程序使用的串口波特率,支持115200,460800,1500000')
|
||||||
parser.add_argument('--ftm',action='store_true',default=False,help='进入工厂模式')
|
parser.add_argument('--ftm',action='store_true',default=False,help='进入工厂模式')
|
||||||
parser.add_argument('--list',action='store_true',default=False,help='列出所有.bin文件')
|
parser.add_argument('--list',action='store_true',default=False,help='列出所有.bin文件')
|
||||||
parser.add_argument('--skip_ram',action='store_true',default=False,help='下载flash文件时是否跳过下载ram.bin的步骤,默认否')
|
parser.add_argument('--skip_ram',action='store_true',default=False,help='下载flash文件时是否跳过下载ram.bin的步骤,默认否')
|
||||||
@@ -449,10 +478,6 @@ def print_help():
|
|||||||
'''
|
'''
|
||||||
print(help)
|
print(help)
|
||||||
|
|
||||||
# 如果不指定上传还是下载 脚本会根据输入文件是否存在来决定上传还是下载
|
|
||||||
# kunlun.py [com] [kl1/kl3] [upload.bin/download.bin] <key>
|
|
||||||
# kunlun.py [com] [ram.bin]
|
|
||||||
# kunlun.py [file.bin] <enc>
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
function_type=None # 功能类型 "download" 下载,"upload" 上传,"ram" 下载ram,"convert"" 转换bin
|
function_type=None # 功能类型 "download" 下载,"upload" 上传,"ram" 下载ram,"convert"" 转换bin
|
||||||
time_stamp_start, time_stamp_end = 0, 0
|
time_stamp_start, time_stamp_end = 0, 0
|
||||||
@@ -522,4 +547,5 @@ if __name__ == '__main__':
|
|||||||
read_input(ser)
|
read_input(ser)
|
||||||
|
|
||||||
# if __name__ == "__main__":
|
# if __name__ == "__main__":
|
||||||
# read_input(None)
|
# nb_rate=115200
|
||||||
|
# send_cfg_fun()
|
||||||
|
Reference in New Issue
Block a user