bin_to_hex 添加异或解密,添加ReadMe.txt
This commit is contained in:
		
							
								
								
									
										12
									
								
								ReadMe.txt
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										12
									
								
								ReadMe.txt
									
									
									
									
									
										Normal 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异或就能得到加密种子 | ||||
| @@ -203,7 +203,8 @@ def bin_to_hex(bin:bytearray,f): | ||||
|   turned_old=0 | ||||
|   out_text='' | ||||
|   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: | ||||
|     if(turned+pack_size<=all_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: | ||||
|     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: | ||||
|     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__": | ||||
|   # bin_to_hex_file(sys.argv[1],sys.argv[2],sys.argv[3]) | ||||
|   # 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) | ||||
|   | ||||
| @@ -9,7 +9,7 @@ import time | ||||
| ''' | ||||
|  | ||||
| 2024.8.26 | ||||
|   kunlun项目生成vscode配置 | ||||
|   kunlun项目根据build_log.log生成vscode配置 | ||||
|   在Mainline文件夹中运行 | ||||
|  | ||||
| ''' | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 ranchuan
					ranchuan