在sink工程目录下创建一个目录,用来存放公钥和密钥,假设目录名称为<oem_for_ota>;
在该目录下创建两个python脚本,和自动生成ota文件,这里写成脚本文件,方便每次生成OTA生级包。
gen_key.py,用来自动生成密钥,内容如下:
Gen_ota.py,用来生成ota文件,该脚本会自动先搜索本地目录来查找目标xuv文件,若本地目录没有.xuv文件,则自动搜索父级目录,若找到则打包ota文件,否则报错退出。
其脚本内容如下:
import os, sys,time
os.chdir(os.path.abspath(os.path.dirname(sys.argv[0])))
SRC_DIR = os.path.dirname(os.getcwd())+'\\'
CUR_DIR = os.getcwd()+'\\'
TOOL_DIR = 'C:\\ProgramFilesUser\\Qualcomm\\ADK_QCC300x.WIN.1.0.167\\tools\\bin\\'
#
# Source target file defination
#
TARGET_FILE = 'qcc3004.xuv'
UPG_FILE = 'qcc3004.upg'
UPG_XUV_File= 'qcc3004_upg.xuv'
KEY_FILE = 'oem.private.key'
SIGNED_FILE = 'qcc3004_upg_signed.xuv'
OTA_FILE = 'qcc3004_upg_signed.bin'
DUMP_FILE = 'qcc3004_dump.xuv'
AUDIO_FILE = 'audio_prompts.xuv'
print('***********************************')
print(' Start ')
print('***********************************')
#
# check qcc3004.xuv file. if not exist in current folder, will check is in parent
# folder and copy it to current folder if exist. otherwise ,will exit with 1.
#
ret = os.path.exists(CUR_DIR + TARGET_FILE)
if not ret:
ret = os.path.exists(SRC_DIR + TARGET_FILE)
if not ret:
print('can not find qcc3004.xuv file.')
exit(1)
else:
os.system('XCOPY /Y /F ' + SRC_DIR + TARGET_FILE +' '+ CUR_DIR)
#
# check audio_prompts.xuv file. if not exist in current folder, will check is in parent
# folder and copy it to current folder if exist. otherwise ,will exit with 1.
#
ret = os.path.exists(CUR_DIR + AUDIO_FILE)
if not ret:
ret = os.path.exists(SRC_DIR + AUDIO_FILE)
if not ret:
print('can not find '+AUDIO_FILE+' file.')
exit(1)
else:
os.system('XCOPY /Y /F ' + SRC_DIR + AUDIO_FILE + ' '+CUR_DIR)
#
# generate setting files.
#
ret = os.system(TOOL_DIR+'upgradeFileGen.exe ' + CUR_DIR + UPG_FILE + ' ' + CUR_DIR + UPG_XUV_File)
ret = os.system(TOOL_DIR+'dfusign.exe -v -f -u -h '+CUR_DIR + UPG_XUV_File +' -o '+CUR_DIR + SIGNED_FILE+' -ka '+CUR_DIR + KEY_FILE)
ret = os.system(TOOL_DIR+'xuv2bin.exe -d '+CUR_DIR + SIGNED_FILE+' '+CUR_DIR + OTA_FILE)
print('*************END **********************')