From 3057c6f5a1fcc0fbd46b3565a9751ff9e0726018 Mon Sep 17 00:00:00 2001 From: andy <1414772332@qq.com> Date: Mon, 14 Oct 2024 22:01:52 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8F=90=E9=AB=98bin=5Fto=5Fhex=E7=9A=84?= =?UTF-8?q?=E9=80=9F=E5=BA=A6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- bin_to_hex.py | 48 ++++++++++++------------------------------------ kunlun.py | 11 +---------- 2 files changed, 13 insertions(+), 46 deletions(-) diff --git a/bin_to_hex.py b/bin_to_hex.py index 87a5a19..6f6caba 100644 --- a/bin_to_hex.py +++ b/bin_to_hex.py @@ -50,6 +50,8 @@ _DevType={ _PKT_HEADER_MAGIC_NO = 0x00005566 _IMG_HEADER_MAGIC_NO = 0xa4e49a17 + +# 从info文件读取flash信息 def load_flash_info(file_name:str): flash_info_list:list[dict]=[] with open(file_name,mode='r',encoding='utf-8') as f: @@ -193,30 +195,8 @@ def img_header_check(data:bytearray): return "" -def bin_to_hex(bin:bytearray,flash_info:list[dict]=[]): - all_size=len(bin) - pack_size=32 - turned=0 - turned_old=0 - out_text='' - index=0 - while turned < all_size: - if(turned+pack_size<=all_size): - data=bin[turned:turned+pack_size] - turned_old=turned - turned+=pack_size - else: - data=bin[turned:] - turned=all_size - if(index