bin_to_hex 添加异或解密,添加ReadMe.txt

This commit is contained in:
ranchuan
2024-10-15 14:56:26 +08:00
parent 3057c6f5a1
commit 8b4ac429eb
3 changed files with 26 additions and 5 deletions

12
ReadMe.txt Normal file
View File

@@ -0,0 +1,12 @@
2024.10.15
使用ram.bin 下载程序需要使用build版本因为这个不需要配置串口波特率启动之后会自动进入下载流程
kl3有两个sbl区如果sbl1校验失败会自动运行sbl2但是如果sbl1存在问题则可能导致程序跑不起来
烧录的时候只会擦除烧录区域,未烧录的区域会保持原样
使用bootram.bin时build版本支持全功能
2024.10.15
烧录文件可能会加密bin的第一个字节表示加密方式 第二个字节表示加密种子,加密算法根据这个种子来计算
好像加密方式都用的方式3 异或所以取第一个字节与3异或就能得到加密种子

View File

@@ -203,7 +203,8 @@ def bin_to_hex(bin:bytearray,f):
turned_old=0 turned_old=0
out_text='' out_text=''
if(pkt_header_check(bin)): if(pkt_header_check(bin)):
out_text+=tran_pkg_header(bin[0:96])+'\n' out_text=tran_pkg_header(bin[0:96])+'\n'
f.write(out_text)
while turned < all_size: while turned < all_size:
if(turned+pack_size<=all_size): if(turned+pack_size<=all_size):
data=bin[turned:turned+pack_size] data=bin[turned:turned+pack_size]
@@ -228,9 +229,13 @@ def bin_to_hex(bin:bytearray,f):
def bin_to_hex_file(bin_file_name:str,hex_file_name:str): def bin_to_hex_file(bin_file_name:str,hex_file_name:str,enc=0):
with open(bin_file_name,mode='rb') as f: with open(bin_file_name,mode='rb') as f:
bin=f.read() bin=bytearray(f.read())
if(enc):
pat=(bin[0]^0x03)&0xff
for index in range(len(bin)):
bin[index]=bin[index]^pat
with open(hex_file_name,mode='w+',encoding="utf-8") as f: with open(hex_file_name,mode='w+',encoding="utf-8") as f:
bin_to_hex(bin,f) bin_to_hex(bin,f)
@@ -238,4 +243,8 @@ def bin_to_hex_file(bin_file_name:str,hex_file_name:str):
if __name__ == "__main__": if __name__ == "__main__":
# bin_to_hex_file(sys.argv[1],sys.argv[2],sys.argv[3]) # bin_to_hex_file(sys.argv[1],sys.argv[2],sys.argv[3])
# load_flash_info("work/upload-test.info") # load_flash_info("work/upload-test.info")
bin_to_hex_file(sys.argv[1],sys.argv[2]) if(len(sys.argv)>=3):
enc=1
else:
enc=0
bin_to_hex_file(sys.argv[1],"work/"+sys.argv[1]+".txt",enc)

View File

@@ -9,7 +9,7 @@ import time
''' '''
2024.8.26 2024.8.26
kunlun项目生成vscode配置 kunlun项目根据build_log.log生成vscode配置
在Mainline文件夹中运行 在Mainline文件夹中运行
''' '''