添加pg的bootram; upload flash时自动输入密码
This commit is contained in:
BIN
bin/bootram_kl4.bin
Normal file
BIN
bin/bootram_kl4.bin
Normal file
Binary file not shown.
17
kunlun.py
17
kunlun.py
@@ -25,6 +25,7 @@ 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
|
from bin.crc import CRC16
|
||||||
from bin.get_log import print_log
|
from bin.get_log import print_log
|
||||||
|
from password import bootram_pssword
|
||||||
|
|
||||||
|
|
||||||
def init_send(s_port:serial.Serial, send_str:str):
|
def init_send(s_port:serial.Serial, send_str:str):
|
||||||
@@ -254,6 +255,16 @@ def calc_flash_info_name():
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
# 计算bootram密码
|
||||||
|
def calc_bootram_pssword(info_file:str):
|
||||||
|
with open(info_file,mode='r',encoding='utf-8') as f:
|
||||||
|
lines=f.readlines()
|
||||||
|
for line in lines:
|
||||||
|
if(line.startswith('Chip Id')):
|
||||||
|
chip_id=line.split(':')[-1].strip()
|
||||||
|
password=bootram_pssword(chip_id)
|
||||||
|
return f"{password:08x}"
|
||||||
|
|
||||||
|
|
||||||
# 上传固件
|
# 上传固件
|
||||||
def upload_fun():
|
def upload_fun():
|
||||||
@@ -264,6 +275,12 @@ def upload_fun():
|
|||||||
print_device_str(ser_read_data)
|
print_device_str(ser_read_data)
|
||||||
with open(calc_flash_info_name(),mode='w+',encoding='utf-8') as f:
|
with open(calc_flash_info_name(),mode='w+',encoding='utf-8') as f:
|
||||||
f.writelines(ser_read_data.decode('utf-8').split('\r\n'))
|
f.writelines(ser_read_data.decode('utf-8').split('\r\n'))
|
||||||
|
# 输入密码
|
||||||
|
password=calc_bootram_pssword(calc_flash_info_name())
|
||||||
|
ser.write(f"PSS {password}\n".encode("utf-8"))
|
||||||
|
time.sleep(0.5)
|
||||||
|
ser_read_data=ser.read(4096)
|
||||||
|
print_device_str(ser_read_data)
|
||||||
# 显示image信息
|
# 显示image信息
|
||||||
ser.write(b"f s\n")
|
ser.write(b"f s\n")
|
||||||
time.sleep(1)
|
time.sleep(1)
|
||||||
|
Reference in New Issue
Block a user