添加U盘升级功能
This commit is contained in:
52
updata/creat_slave_boot.py
Normal file
52
updata/creat_slave_boot.py
Normal file
@@ -0,0 +1,52 @@
|
||||
import shutil
|
||||
import sys
|
||||
import os
|
||||
import json
|
||||
|
||||
import prottcp
|
||||
|
||||
BOOT_PATH ="file/checker_slave_boot_can.bin"
|
||||
APP_PATH ="file/checker_slave_app_can.bin"
|
||||
SCHEME_PATH = "file/YM硬件EX工厂注码091902--9.json"
|
||||
OUT_PATH = "file/checker_slave_boot_can_.bin"
|
||||
|
||||
# 创建离线下载器的镜像
|
||||
|
||||
|
||||
# 填充指定个数的byte
|
||||
def arr_byte_copy(byte:int,num:int):
|
||||
t=bytearray()
|
||||
for i in range(num):
|
||||
t.append(byte)
|
||||
return t
|
||||
# int转数组
|
||||
def arr_from_int(num:int):
|
||||
return bytearray([num&0xff,(num>>8)&0xff,(num>>16)&0xff,(num>>24)&0xff])
|
||||
|
||||
|
||||
def creat():
|
||||
boot=BOOT_PATH
|
||||
app=APP_PATH
|
||||
scheme=SCHEME_PATH
|
||||
d=bytearray()
|
||||
with open(boot,"rb") as f:
|
||||
d+=f.read()
|
||||
d+=arr_byte_copy(0xff,0x4000-len(d))
|
||||
with open(app,"rb") as f:
|
||||
d+=f.read()
|
||||
d+=arr_byte_copy(0xff,0x3f000-len(d))
|
||||
with open(scheme,"rb") as f:
|
||||
json_obj=json.loads(f.read())
|
||||
d+=prottcp.scheme_to_byte(json_obj)
|
||||
d+=arr_byte_copy(0xff,0x3f800-len(d))
|
||||
d+=arr_from_int(0x669955aa)
|
||||
with open(OUT_PATH,"wb+") as f:
|
||||
f.write(d)
|
||||
print(OUT_PATH+" create boot file success.")
|
||||
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
creat()
|
||||
|
||||
|
Reference in New Issue
Block a user