app启动时如果boot魔数校验错误则自动升级bootloader

This commit is contained in:
andy
2023-10-12 23:37:12 +08:00
parent 17b4ebf188
commit fda9545130
18 changed files with 2865 additions and 1408 deletions

View File

@@ -2,7 +2,7 @@ import sys
import os
import datetime
from datetime import datetime, timedelta
import mycopy
@@ -15,6 +15,7 @@ SOFT_VERION = "0.03"
MOD_FILE="mod_signals.c"
MOD_PATH="./source/task/"
INFO_FILE="./source/main/compiler_info.h"
BOOTCODE_ARRAY="./source/main/bootcode.txt"
# 找到文件夹中指定后缀的文件
@@ -137,9 +138,31 @@ def creat_compile_info(dst:str):
f.write("\n\n\n\n\n\n\n#endif\n")
# 生成bootcode数组
def creat_bootcode(dst:str):
if os.path.exists(dst):
os.remove(dst)
data=bytearray()
boot_file=mycopy.BOOT_FILE_SRC+".bin"
if(os.path.exists(boot_file)):
with open(boot_file,"rb") as f:
data=f.read()
with open(dst,"w") as f:
while len(data)>0:
if(len(data)>=20):
t=data[0:20]
data=data[20:]
else:
t=data
data=[]
s=t.hex(" ")
s="0x"+s.replace(" ",",0x")+",\n"
f.write(s)
def main():
creat_bootcode(BOOTCODE_ARRAY)
creat_compile_info(INFO_FILE)
mod_file_creat(MOD_PATH+MOD_FILE)
print("prepare success.\n")