删除打包工具
This commit is contained in:
parent
7b7ca405b0
commit
7db820fb0a
|
@ -5,6 +5,7 @@
|
||||||
*.bin
|
*.bin
|
||||||
*.hex
|
*.hex
|
||||||
*.axf
|
*.axf
|
||||||
|
*.exe
|
||||||
*.pdb
|
*.pdb
|
||||||
*.idb
|
*.idb
|
||||||
*.ilk
|
*.ilk
|
||||||
|
|
|
@ -12,30 +12,39 @@
|
||||||
|
|
||||||
@rem if debug_info=1, Debugging Print Information will be turned on
|
@rem if debug_info=1, Debugging Print Information will be turned on
|
||||||
set debug_info=0
|
set debug_info=0
|
||||||
|
@rem if make_fal=1, Partition tables are put into firmware
|
||||||
|
set make_fal=0
|
||||||
@rem Setting firmware output directory
|
@rem Setting firmware output directory
|
||||||
set out_path=.\Bin
|
set out_path=.\Bin
|
||||||
@rem Setting the bin file path
|
@rem Setting the bin file path
|
||||||
set bin_file=.\rtthread.bin
|
set bin_file=.\rtthread.bin
|
||||||
|
@rem Setting winnermicro libraries path
|
||||||
|
set wmlib_path=.\packages\wm_libraries-
|
||||||
|
@rem Setting the 1M flash layout file
|
||||||
|
set layout_1M_file=.
|
||||||
|
@rem Setting the 2M flash layout file
|
||||||
|
set layout_2M_file=.
|
||||||
|
@rem Setting the makeimg by adding rtt flash original fls
|
||||||
|
set makeimg_new_fls=.
|
||||||
|
|
||||||
|
@rem find winnermicro libraries full path
|
||||||
|
for /f "delims=" %%i in ('dir /ad /b /s %wmlib_path%*') do (set wmlib_path_full=%%i)
|
||||||
@rem Setting the version.txt file path
|
@rem Setting the version.txt file path
|
||||||
set version_file=.\tools\version.txt
|
set version_file=%wmlib_path_full%\Tools\version.txt
|
||||||
@rem Setting the secboot.img file path
|
@rem Setting the secboot.img file path
|
||||||
set secboot_file=.\tools\secboot.img
|
set secboot_file=%wmlib_path_full%\Tools\secboot.img
|
||||||
@rem Setting the wm_gzip.exe file path
|
@rem Setting the wm_gzip.exe file path
|
||||||
set wm_gzip_file=.\tools\wm_gzip.exe
|
set wm_gzip_file=%wmlib_path_full%\Tools\wm_gzip.exe
|
||||||
@rem Setting the makeimg.exe file path
|
@rem Setting the makeimg.exe file path
|
||||||
set makeimg_file=.\tools\makeimg.exe
|
set makeimg_file=%wmlib_path_full%\Tools\makeimg.exe
|
||||||
@rem Setting the makeimg_all.exe file path
|
@rem Setting the makeimg_all.exe file path
|
||||||
set makeimg_all_file=.\tools\makeimg_all.exe
|
set makeimg_all_file=%wmlib_path_full%\Tools\makeimg_all.exe
|
||||||
|
|
||||||
@rem Prepare to generate firmware
|
@rem Prepare to generate firmware
|
||||||
|
|
||||||
|
@rem Get the full path
|
||||||
if "%out_path:~0,1%" == "." (set out_path=%~dp0%out_path%)
|
if "%out_path:~0,1%" == "." (set out_path=%~dp0%out_path%)
|
||||||
if "%bin_file:~0,1%" == "." (set bin_file=%~dp0%bin_file%)
|
if "%bin_file:~0,1%" == "." (set bin_file=%~dp0%bin_file%)
|
||||||
if "%version_file:~0,1%" == "." (set version_file=%~dp0%version_file%)
|
|
||||||
if "%secboot_file:~0,1%" == "." (set secboot_file=%~dp0%secboot_file%)
|
|
||||||
if "%wm_gzip_file:~0,1%" == "." (set wm_gzip_file=%~dp0%wm_gzip_file%)
|
|
||||||
if "%makeimg_file:~0,1%" == "." (set makeimg_file=%~dp0%makeimg_file%)
|
|
||||||
if "%makeimg_all_file:~0,1%" == "." (set makeimg_all_file=%~dp0%makeimg_all_file%)
|
|
||||||
|
|
||||||
@rem Create output folder
|
@rem Create output folder
|
||||||
if not exist "%out_path%" (md "%out_path%")
|
if not exist "%out_path%" (md "%out_path%")
|
||||||
|
@ -63,14 +72,14 @@ if not "%debug_info%"=="0" (echo bin_file_name:%bin_file_name% & echo bin_name:%
|
||||||
echo makeimg 1M Flash...
|
echo makeimg 1M Flash...
|
||||||
|
|
||||||
@rem Start making 1M flash firmware
|
@rem Start making 1M flash firmware
|
||||||
set file_pos=_1M
|
set file_pos_1M=_1M
|
||||||
|
|
||||||
@rem Create command parameters
|
@rem Create command parameters
|
||||||
set wm_gzip_cmd="%out_path%\%bin_file_name%"
|
set wm_gzip_cmd="%out_path%\%bin_file_name%"
|
||||||
set makeimg_img_cmd="%out_path%\%bin_file_name%" "%out_path%\%bin_name%%file_pos%.img" 0 0 "%out_path%\%version_file_name%" 90000 10100
|
set makeimg_img_cmd="%out_path%\%bin_file_name%" "%out_path%\%bin_name%%file_pos_1M%.img" 0 0 "%out_path%\%version_file_name%" 90000 10100
|
||||||
set makeimg_gz_img_cmd="%out_path%\%bin_file_name%.gz" "%out_path%\%bin_name%_GZ%file_pos%.img" 0 1 "%out_path%\%version_file_name%" 90000 10100 "%out_path%\%bin_file_name%"
|
set makeimg_gz_img_cmd="%out_path%\%bin_file_name%.gz" "%out_path%\%bin_name%_GZ%file_pos_1M%.img" 0 1 "%out_path%\%version_file_name%" 90000 10100 "%out_path%\%bin_file_name%"
|
||||||
set makeimg_sec_img_cmd="%out_path%\%bin_file_name%" "%out_path%\%bin_name%_SEC%file_pos%.img" 0 0 "%out_path%\%version_file_name%" 90000 10100
|
set makeimg_sec_img_cmd="%out_path%\%bin_file_name%" "%out_path%\%bin_name%_SEC%file_pos_1M%.img" 0 0 "%out_path%\%version_file_name%" 90000 10100
|
||||||
set makeimg_all_cmd="%out_path%\%secboot_file_name%" "%out_path%\%bin_name%%file_pos%.img" "%out_path%\%bin_name%%file_pos%.FLS"
|
set makeimg_all_cmd="%out_path%\%secboot_file_name%" "%out_path%\%bin_name%%file_pos_1M%.img" "%out_path%\%bin_name%%file_pos_1M%.FLS"
|
||||||
|
|
||||||
@rem Print command Information
|
@rem Print command Information
|
||||||
if not "%debug_info%"=="0" (echo wm_gzip %wm_gzip_cmd%)
|
if not "%debug_info%"=="0" (echo wm_gzip %wm_gzip_cmd%)
|
||||||
|
@ -87,20 +96,20 @@ if not "%debug_info%"=="0" (echo makeimg_all %makeimg_all_cmd%)
|
||||||
"%makeimg_all_file%" %makeimg_all_cmd%
|
"%makeimg_all_file%" %makeimg_all_cmd%
|
||||||
|
|
||||||
@rem Delete temporary files
|
@rem Delete temporary files
|
||||||
if exist "%out_path%\%bin_name%%file_pos%.img" (del "%out_path%\%bin_name%%file_pos%.img")
|
if exist "%out_path%\%bin_name%%file_pos_1M%.img" (del "%out_path%\%bin_name%%file_pos_1M%.img")
|
||||||
if exist "%out_path%\%bin_file_name%.gz" (del "%out_path%\%bin_file_name%.gz")
|
if exist "%out_path%\%bin_file_name%.gz" (del "%out_path%\%bin_file_name%.gz")
|
||||||
|
|
||||||
@rem Start making 2M flash firmware
|
@rem Start making 2M flash firmware
|
||||||
echo makeimg 2M Flash...
|
echo makeimg 2M Flash...
|
||||||
|
|
||||||
set file_pos=_2M
|
set file_pos_2M=_2M
|
||||||
|
|
||||||
@rem Create command parameters
|
@rem Create command parameters
|
||||||
set wm_gzip_cmd="%out_path%\%bin_file_name%"
|
set wm_gzip_cmd="%out_path%\%bin_file_name%"
|
||||||
set makeimg_img_cmd="%out_path%\%bin_file_name%" "%out_path%\%bin_name%%file_pos%.img" 3 0 "%out_path%\%version_file_name%" 90000 10100
|
set makeimg_img_cmd="%out_path%\%bin_file_name%" "%out_path%\%bin_name%%file_pos_2M%.img" 3 0 "%out_path%\%version_file_name%" 100000 10100
|
||||||
set makeimg_gz_img_cmd="%out_path%\%bin_file_name%.gz" "%out_path%\%bin_name%_GZ%file_pos%.img" 3 1 "%out_path%\%version_file_name%" 90000 10100 "%out_path%\%bin_file_name%"
|
set makeimg_gz_img_cmd="%out_path%\%bin_file_name%.gz" "%out_path%\%bin_name%_GZ%file_pos_2M%.img" 3 1 "%out_path%\%version_file_name%" 100000 10100 "%out_path%\%bin_file_name%"
|
||||||
set makeimg_sec_img_cmd="%out_path%\%bin_file_name%" "%out_path%\%bin_name%_SEC%file_pos%.img" 3 0 "%out_path%\%version_file_name%" 90000 10100
|
set makeimg_sec_img_cmd="%out_path%\%bin_file_name%" "%out_path%\%bin_name%_SEC%file_pos_2M%.img" 3 0 "%out_path%\%version_file_name%" 100000 10100
|
||||||
set makeimg_all_cmd="%out_path%\%secboot_file_name%" "%out_path%\%bin_name%%file_pos%.img" "%out_path%\%bin_name%%file_pos%.FLS"
|
set makeimg_all_cmd="%out_path%\%secboot_file_name%" "%out_path%\%bin_name%%file_pos_2M%.img" "%out_path%\%bin_name%%file_pos_2M%.FLS"
|
||||||
|
|
||||||
@rem Print command Information
|
@rem Print command Information
|
||||||
if not "%debug_info%"=="0" (echo wm_gzip %wm_gzip_cmd%)
|
if not "%debug_info%"=="0" (echo wm_gzip %wm_gzip_cmd%)
|
||||||
|
@ -117,8 +126,35 @@ if not "%debug_info%"=="0" (echo makeimg_all %makeimg_all_cmd%)
|
||||||
"%makeimg_all_file%" %makeimg_all_cmd%
|
"%makeimg_all_file%" %makeimg_all_cmd%
|
||||||
|
|
||||||
@rem Delete temporary files
|
@rem Delete temporary files
|
||||||
if exist "%out_path%\%bin_name%%file_pos%.img" (del "%out_path%\%bin_name%%file_pos%.img")
|
if exist "%out_path%\%bin_name%%file_pos_2M%.img" (del "%out_path%\%bin_name%%file_pos_2M%.img")
|
||||||
if exist "%out_path%\%bin_file_name%.gz" (del "%out_path%\%bin_file_name%.gz")
|
if exist "%out_path%\%bin_file_name%.gz" (del "%out_path%\%bin_file_name%.gz")
|
||||||
|
|
||||||
|
@rem Partition tables are put into firmware
|
||||||
|
if not "%make_fal%"=="1" ( goto end)
|
||||||
|
|
||||||
|
@rem Get the full path
|
||||||
|
if "%layout_1M_file:~0,1%" == "." (set layout_1M_file=%~dp0%layout_1M_file%)
|
||||||
|
if "%layout_2M_file:~0,1%" == "." (set layout_2M_file=%~dp0%layout_2M_file%)
|
||||||
|
if "%makeimg_new_fls:~0,1%" == "." (set makeimg_new_fls=%~dp0%makeimg_new_fls%)
|
||||||
|
|
||||||
|
@rem Check whether the file exists
|
||||||
|
if not exist "%layout_1M_file%" (echo makeimg err! No makeimg file found: "%layout_1M_file%" & goto end)
|
||||||
|
if not exist "%layout_2M_file%" (echo makeimg err! No makeimg file found: "%layout_2M_file%" & goto end)
|
||||||
|
if not exist "%makeimg_new_fls%" (echo makeimg err! No makeimg file found: "%makeimg_new_fls%" & goto end)
|
||||||
|
|
||||||
|
@rem Create command parameters to new fls
|
||||||
|
set makeimg_new_cmd_1M="%out_path%\%bin_name%%file_pos_1M%.FLS" "%layout_1M_file%" "%out_path%\%bin_name%_layout%file_pos_1M%.FLS"
|
||||||
|
@rem Execute generation fls cmd
|
||||||
|
"%makeimg_new_fls%" %makeimg_new_cmd_1M%
|
||||||
|
|
||||||
|
@rem Create command parameters to new fls
|
||||||
|
set makeimg_new_cmd_2M="%out_path%\%bin_name%%file_pos_2M%.FLS" "%layout_2M_file%" "%out_path%\%bin_name%_layout%file_pos_2M%.FLS"
|
||||||
|
@rem Execute generation fls cmd
|
||||||
|
"%makeimg_new_fls%" %makeimg_new_cmd_2M%
|
||||||
|
|
||||||
|
@rem Delete temporary files
|
||||||
|
if exist "%out_path%\%bin_name%_1M.FLS" (del "%out_path%\%bin_name%%file_pos_1M%.FLS")
|
||||||
|
if exist "%out_path%\%bin_name%_2M.FLS" (del "%out_path%\%bin_name%%file_pos_2M%.FLS")
|
||||||
|
|
||||||
:end
|
:end
|
||||||
echo end
|
echo end
|
||||||
|
|
|
@ -9,21 +9,20 @@ import platform
|
||||||
|
|
||||||
# if debug_info=True, Debugging Print Information will be turned on
|
# if debug_info=True, Debugging Print Information will be turned on
|
||||||
debug_info=False
|
debug_info=False
|
||||||
|
# if make_fal=True, Partition tables are put into firmware
|
||||||
|
make_fal=False
|
||||||
# Setting firmware output directory
|
# Setting firmware output directory
|
||||||
out_path='./Bin'
|
out_path='./Bin'
|
||||||
# Setting the bin file path
|
# Setting the bin file path
|
||||||
bin_file='./rtthread.bin'
|
bin_file='./rtthread.bin'
|
||||||
|
# Setting winnermicro libraries path
|
||||||
# Setting the version.txt file path
|
wmlib_path='./packages/wm_libraries-'
|
||||||
version_file='./tools' + '/version.txt'
|
# Setting the 1M flash layout file
|
||||||
# Setting the secboot.img file path
|
layout_1M_file='.'
|
||||||
secboot_file='./tools' + '/secboot.img'
|
# Setting the 2M flash layout file
|
||||||
# Setting the wm_gzip.exe file path
|
layout_2M_file='.'
|
||||||
wm_gzip_file='./tools' + '/wm_gzip.exe'
|
# Setting the makeimg by adding rtt flash original fls
|
||||||
# Setting the makeimg.exe file path
|
makeimg_new_fls='.'
|
||||||
makeimg_file='./tools' + '/makeimg.exe'
|
|
||||||
# Setting the makeimg_all.exe file path
|
|
||||||
makeimg_all_file='./tools' + '/makeimg_all.exe'
|
|
||||||
|
|
||||||
def execute_command(cmdstring, cwd=None, shell=True):
|
def execute_command(cmdstring, cwd=None, shell=True):
|
||||||
"""Execute the system command at the specified address."""
|
"""Execute the system command at the specified address."""
|
||||||
|
@ -82,11 +81,27 @@ def do_makeimg(tool_path, param):
|
||||||
|
|
||||||
execute_command(str)
|
execute_command(str)
|
||||||
|
|
||||||
|
def get_wmlib_path_full(path):
|
||||||
|
(_wmlib_path,_wmlib_name) = os.path.split(path)
|
||||||
|
files = os.listdir(_wmlib_path)
|
||||||
|
for f in files:
|
||||||
|
if _wmlib_name in f:
|
||||||
|
return _wmlib_path + '/' + f
|
||||||
|
return path
|
||||||
|
|
||||||
if __name__=='__main__':
|
if __name__=='__main__':
|
||||||
# Get the execution file name
|
# find winnermicro libraries full path
|
||||||
wm_gzip_file = get_exec_path(wm_gzip_file)
|
wmlib_path_full = get_wmlib_path_full(wmlib_path)
|
||||||
makeimg_file = get_exec_path(makeimg_file)
|
# Setting the version.txt file path
|
||||||
makeimg_all_file = get_exec_path(makeimg_all_file)
|
version_file=wmlib_path_full + '/Tools/version.txt'
|
||||||
|
# Setting the secboot.img file path
|
||||||
|
secboot_file=wmlib_path_full + '/Tools/secboot.img'
|
||||||
|
# Setting the wm_gzip.exe file path
|
||||||
|
wm_gzip_file=wmlib_path_full + '/Tools/wm_gzip.exe'
|
||||||
|
# Setting the makeimg.exe file path
|
||||||
|
makeimg_file=wmlib_path_full + '/Tools/makeimg.exe'
|
||||||
|
# Setting the makeimg_all.exe file path
|
||||||
|
makeimg_all_file=wmlib_path_full + '/Tools/makeimg_all.exe'
|
||||||
|
|
||||||
# Get absolute path
|
# Get absolute path
|
||||||
out_path = os.path.abspath(out_path).replace('\\', '/');
|
out_path = os.path.abspath(out_path).replace('\\', '/');
|
||||||
|
@ -109,23 +124,23 @@ if __name__=='__main__':
|
||||||
if not is_exists('wm_gzip', wm_gzip_file): exit(0)
|
if not is_exists('wm_gzip', wm_gzip_file): exit(0)
|
||||||
if not is_exists('makeimg', makeimg_file): exit(0)
|
if not is_exists('makeimg', makeimg_file): exit(0)
|
||||||
if not is_exists('makeimg_all', makeimg_all_file): exit(0)
|
if not is_exists('makeimg_all', makeimg_all_file): exit(0)
|
||||||
|
|
||||||
# Get File Names and File Extensions
|
# Get File Names and File Extensions
|
||||||
(bin_file_path,bin_file_name) = os.path.split(bin_file)
|
(bin_file_path,bin_file_name) = os.path.split(bin_file)
|
||||||
(bin_name,bin_extend) = os.path.splitext(bin_file_name)
|
(bin_name,bin_extend) = os.path.splitext(bin_file_name)
|
||||||
(version_file_path,version_file_name) = os.path.split(version_file)
|
(version_file_path,version_file_name) = os.path.split(version_file)
|
||||||
(secboot_file_path,secboot_file_name) = os.path.split(secboot_file)
|
(secboot_file_path,secboot_file_name) = os.path.split(secboot_file)
|
||||||
|
|
||||||
# print debug Information
|
# print debug Information
|
||||||
if debug_info: print('bin_file_name:' + bin_file_name + 'bin_name:' + bin_name + 'bin_extend:' + bin_extend + 'version_file_name:' + version_file_name + 'secboot_file_name:' + secboot_file_name)
|
if debug_info: print('bin_file_name:' + bin_file_name + 'bin_name:' + bin_name + 'bin_extend:' + bin_extend + 'version_file_name:' + version_file_name + 'secboot_file_name:' + secboot_file_name)
|
||||||
|
|
||||||
print('makeimg 1M Flash...')
|
print('makeimg 1M Flash...')
|
||||||
file_pos='_1M'
|
file_pos_1M='_1M'
|
||||||
gzip_param = "\"" + out_path + '/' + bin_file_name + "\""
|
gzip_param = "\"" + out_path + '/' + bin_file_name + "\""
|
||||||
make_img_param = "\"" + out_path + '/' + bin_file_name + "\"" + ' ' + "\"" + out_path + '/' + bin_name + file_pos + '.img' + "\"" + ' 0' + ' 0' + ' ' + "\"" + out_path + '/' + version_file_name + "\"" + ' 90000' + ' 10100'
|
make_img_param = "\"" + out_path + '/' + bin_file_name + "\"" + ' ' + "\"" + out_path + '/' + bin_name + file_pos_1M + '.img' + "\"" + ' 0' + ' 0' + ' ' + "\"" + out_path + '/' + version_file_name + "\"" + ' 90000' + ' 10100'
|
||||||
make_GZ_param = "\"" + out_path + '/' + bin_file_name + '.gz' + "\"" + ' ' + "\"" + out_path + '/' + bin_name + '_GZ' + file_pos + '.img' +"\"" + ' 0' + ' 1' + ' ' + "\"" + out_path + '/' + version_file_name + "\"" + ' 90000' + ' 10100' + ' ' + "\"" + out_path + '/' + bin_file_name + "\""
|
make_GZ_param = "\"" + out_path + '/' + bin_file_name + '.gz' + "\"" + ' ' + "\"" + out_path + '/' + bin_name + '_GZ' + file_pos_1M + '.img' +"\"" + ' 0' + ' 1' + ' ' + "\"" + out_path + '/' + version_file_name + "\"" + ' 90000' + ' 10100' + ' ' + "\"" + out_path + '/' + bin_file_name + "\""
|
||||||
make_SEC_param = "\"" + out_path + '/' + bin_file_name + "\"" + ' ' + "\"" + out_path + '/' + bin_name + '_SEC' + file_pos + '.img' + "\"" + ' 0' + ' 0' + ' ' + "\"" + out_path + '/' + version_file_name + "\"" + ' 90000' + ' 10100'
|
make_SEC_param = "\"" + out_path + '/' + bin_file_name + "\"" + ' ' + "\"" + out_path + '/' + bin_name + '_SEC' + file_pos_1M + '.img' + "\"" + ' 0' + ' 0' + ' ' + "\"" + out_path + '/' + version_file_name + "\"" + ' 90000' + ' 10100'
|
||||||
make_FLS_param = "\"" + out_path + '/' + secboot_file_name + "\"" + ' ' + "\"" + out_path + '/' + bin_name + file_pos + '.img' + "\"" + ' ' + "\"" + out_path + '/' + bin_name + file_pos + '.FLS' + "\""
|
make_FLS_param = "\"" + out_path + '/' + secboot_file_name + "\"" + ' ' + "\"" + out_path + '/' + bin_name + file_pos_1M + '.img' + "\"" + ' ' + "\"" + out_path + '/' + bin_name + file_pos_1M + '.FLS' + "\""
|
||||||
|
|
||||||
if debug_info:
|
if debug_info:
|
||||||
print('gzip_param' + gzip_param)
|
print('gzip_param' + gzip_param)
|
||||||
|
@ -140,7 +155,7 @@ if __name__=='__main__':
|
||||||
do_makeimg(makeimg_file, make_SEC_param)
|
do_makeimg(makeimg_file, make_SEC_param)
|
||||||
do_makeimg(makeimg_all_file, make_FLS_param)
|
do_makeimg(makeimg_all_file, make_FLS_param)
|
||||||
|
|
||||||
rm_file = out_path + '/' + bin_name + file_pos + '.img'
|
rm_file = out_path + '/' + bin_name + file_pos_1M + '.img'
|
||||||
if os.path.exists(rm_file):
|
if os.path.exists(rm_file):
|
||||||
os.remove(rm_file)
|
os.remove(rm_file)
|
||||||
rm_file = out_path + '/' + bin_file_name + '.gz'
|
rm_file = out_path + '/' + bin_file_name + '.gz'
|
||||||
|
@ -148,12 +163,12 @@ if __name__=='__main__':
|
||||||
os.remove(rm_file)
|
os.remove(rm_file)
|
||||||
|
|
||||||
print('makeimg 2M Flash...')
|
print('makeimg 2M Flash...')
|
||||||
file_pos='_2M'
|
file_pos_2M='_2M'
|
||||||
gzip_param = "\"" + out_path + '/' + bin_file_name + "\""
|
gzip_param = "\"" + out_path + '/' + bin_file_name + "\""
|
||||||
make_img_param = "\"" + out_path + '/' + bin_file_name + "\"" + ' ' + "\"" + out_path + '/' + bin_name + file_pos + '.img' + "\"" + ' 3' + ' 0' + ' ' + "\"" + out_path + '/' + version_file_name + "\"" + ' 90000' + ' 10100'
|
make_img_param = "\"" + out_path + '/' + bin_file_name + "\"" + ' ' + "\"" + out_path + '/' + bin_name + file_pos_2M + '.img' + "\"" + ' 3' + ' 0' + ' ' + "\"" + out_path + '/' + version_file_name + "\"" + ' 100000' + ' 10100'
|
||||||
make_GZ_param = "\"" + out_path + '/' + bin_file_name + '.gz' + "\"" + ' ' + "\"" + out_path + '/' + bin_name + '_GZ' + file_pos + '.img' +"\"" + ' 3' + ' 1' + ' ' + "\"" + out_path + '/' + version_file_name + "\"" + ' 90000' + ' 10100' + ' ' + "\"" + out_path + '/' + bin_file_name + "\""
|
make_GZ_param = "\"" + out_path + '/' + bin_file_name + '.gz' + "\"" + ' ' + "\"" + out_path + '/' + bin_name + '_GZ' + file_pos_2M + '.img' +"\"" + ' 3' + ' 1' + ' ' + "\"" + out_path + '/' + version_file_name + "\"" + ' 100000' + ' 10100' + ' ' + "\"" + out_path + '/' + bin_file_name + "\""
|
||||||
make_SEC_param = "\"" + out_path + '/' + bin_file_name + "\"" + ' ' + "\"" + out_path + '/' + bin_name + '_SEC' + file_pos + '.img' + "\"" + ' 3' + ' 0' + ' ' + "\"" + out_path + '/' + version_file_name + "\"" + ' 90000' + ' 10100'
|
make_SEC_param = "\"" + out_path + '/' + bin_file_name + "\"" + ' ' + "\"" + out_path + '/' + bin_name + '_SEC' + file_pos_2M + '.img' + "\"" + ' 3' + ' 0' + ' ' + "\"" + out_path + '/' + version_file_name + "\"" + ' 100000' + ' 10100'
|
||||||
make_FLS_param = "\"" + out_path + '/' + secboot_file_name + "\"" + ' ' + "\"" + out_path + '/' + bin_name + file_pos + '.img' + "\"" + ' ' + "\"" + out_path + '/' + bin_name + file_pos + '.FLS' + "\""
|
make_FLS_param = "\"" + out_path + '/' + secboot_file_name + "\"" + ' ' + "\"" + out_path + '/' + bin_name + file_pos_2M + '.img' + "\"" + ' ' + "\"" + out_path + '/' + bin_name + file_pos_2M + '.FLS' + "\""
|
||||||
|
|
||||||
if debug_info:
|
if debug_info:
|
||||||
print('gzip_param' + gzip_param)
|
print('gzip_param' + gzip_param)
|
||||||
|
@ -168,11 +183,32 @@ if __name__=='__main__':
|
||||||
do_makeimg(makeimg_file, make_SEC_param)
|
do_makeimg(makeimg_file, make_SEC_param)
|
||||||
do_makeimg(makeimg_all_file, make_FLS_param)
|
do_makeimg(makeimg_all_file, make_FLS_param)
|
||||||
|
|
||||||
rm_file = out_path + '/' + bin_name + file_pos + '.img'
|
rm_file = out_path + '/' + bin_name + file_pos_2M + '.img'
|
||||||
if os.path.exists(rm_file):
|
if os.path.exists(rm_file):
|
||||||
os.remove(rm_file)
|
os.remove(rm_file)
|
||||||
rm_file = out_path + '/' + bin_file_name + '.gz'
|
rm_file = out_path + '/' + bin_file_name + '.gz'
|
||||||
if os.path.exists(rm_file):
|
if os.path.exists(rm_file):
|
||||||
os.remove(rm_file)
|
os.remove(rm_file)
|
||||||
|
|
||||||
|
if make_fal:
|
||||||
|
# Get absolute path
|
||||||
|
layout_1M_file = os.path.abspath(layout_1M_file).replace('\\', '/');
|
||||||
|
layout_2M_file = os.path.abspath(layout_2M_file).replace('\\', '/');
|
||||||
|
makeimg_new_fls = os.path.abspath(makeimg_new_fls).replace('\\', '/');
|
||||||
|
|
||||||
|
# Create command parameters to new fls
|
||||||
|
makeimg_new_cmd="\"" + out_path + '/' + bin_name + file_pos_1M + '.FLS' + "\"" + ' ' + "\"" + layout_1M_file + "\"" + ' ' + "\"" + out_path + '/'+ bin_name + '_layout' + file_pos_1M+'.FLS' +"\""
|
||||||
|
do_makeimg(makeimg_new_fls, makeimg_new_cmd)
|
||||||
|
|
||||||
|
makeimg_new_cmd="\"" + out_path + '/' + bin_name + file_pos_2M + '.FLS' + "\"" + ' ' + "\"" + layout_2M_file + "\"" + ' ' + "\"" + out_path + '/'+ bin_name + '_layout' + file_pos_2M+'.FLS' +"\""
|
||||||
|
do_makeimg(makeimg_new_fls, makeimg_new_cmd)
|
||||||
|
|
||||||
|
# Delete temporary files
|
||||||
|
rm_file = out_path + '/' + bin_name + file_pos_1M + '.FLS'
|
||||||
|
if os.path.exists(rm_file):
|
||||||
|
os.remove(rm_file)
|
||||||
|
rm_file = out_path + '/' + bin_name + file_pos_2M + '.FLS'
|
||||||
|
if os.path.exists(rm_file):
|
||||||
|
os.remove(rm_file)
|
||||||
|
|
||||||
print('end')
|
print('end')
|
Binary file not shown.
Binary file not shown.
|
@ -1,137 +0,0 @@
|
||||||
# -*- coding:utf-8 -*-
|
|
||||||
#
|
|
||||||
# W600 make img script
|
|
||||||
# Copyright (c) 2018 Winner Micro Electronic Design Co., Ltd.
|
|
||||||
# All rights reserved.
|
|
||||||
#
|
|
||||||
# image header structure
|
|
||||||
# --------------------------------------------------------------------------------------------
|
|
||||||
# | magic number(4B) | image type(2B)| zip type(2B) | run image addr(4B) | run image len(4B) |
|
|
||||||
# --------------------------------------------------------------------------------------------
|
|
||||||
# | run image crc(4B) | update image addr(4B) | update image len(4B) | update image crc(4B) |
|
|
||||||
# ---------------------------------------------------------------------------------------------
|
|
||||||
# | update no(4B) | ver(16B) |
|
|
||||||
# ---------------------------------------------------------------------------------------------
|
|
||||||
# | run code |
|
|
||||||
# ---------------------------------------------------------------------------------------------
|
|
||||||
#
|
|
||||||
|
|
||||||
import sys
|
|
||||||
import os
|
|
||||||
import struct
|
|
||||||
from zlib import crc32
|
|
||||||
|
|
||||||
magic_no = 0xA0FFFF9F
|
|
||||||
|
|
||||||
def main(argv):
|
|
||||||
if(len(argv) < 8):
|
|
||||||
print("param cnt error")
|
|
||||||
print("param 0: .py")
|
|
||||||
print("param 1: input .bin file.(uncompressed file or compressed file)")
|
|
||||||
print("param 2: output file")
|
|
||||||
print("param 3: image type ,0:old param user image,1:reserved,2:secboot,3: new param user image")
|
|
||||||
print("param 4: compressed type,0:uncompressed file,1.compressed file")
|
|
||||||
print("param 5: firmware version file")
|
|
||||||
print("param 6: input image storage address")
|
|
||||||
print("param 7: input image running address")
|
|
||||||
print("param 8: input original image file")
|
|
||||||
raise Exception("param cnt error!")
|
|
||||||
|
|
||||||
# version
|
|
||||||
try:
|
|
||||||
f_ver = open(argv[5], "r+")
|
|
||||||
except IOError:
|
|
||||||
print("not find %s file" % argv[5])
|
|
||||||
raise
|
|
||||||
else:
|
|
||||||
version = f_ver.readline(20)
|
|
||||||
p = version.rfind('.')
|
|
||||||
if p == -1:
|
|
||||||
version = '1.0.00'
|
|
||||||
newversion = '1.0.01'
|
|
||||||
else:
|
|
||||||
newversion = version[:p+1]
|
|
||||||
ver = int(version[p+1:]) + 1
|
|
||||||
newversion = newversion + '{:0>2d}'.format(ver)
|
|
||||||
#print(newversion)
|
|
||||||
if len(newversion) < 16:
|
|
||||||
newversion = newversion + '\0' * (16 - len(newversion))
|
|
||||||
#print(len(newversion), newversion)
|
|
||||||
else:
|
|
||||||
newversion = newversion[:15] + '\0'
|
|
||||||
f_ver.close()
|
|
||||||
|
|
||||||
# bin file crc
|
|
||||||
try:
|
|
||||||
f_bin = open(argv[1], mode='rb')
|
|
||||||
except IOError:
|
|
||||||
print("not find %s file" % argv[1])
|
|
||||||
raise
|
|
||||||
else:
|
|
||||||
bin_data = f_bin.read()
|
|
||||||
bin_len = os.path.getsize(argv[1])
|
|
||||||
bin_crc = crc32(bin_data) ^ (0xFFFFFFFF)
|
|
||||||
# print(hex(bin_crc))
|
|
||||||
|
|
||||||
magic = struct.pack('<I', magic_no)
|
|
||||||
img_type = struct.pack('<H', int(argv[3]))
|
|
||||||
zip_type = struct.pack('<H', int(argv[4]))
|
|
||||||
# print(argv[7], int(argv[7] ,16))
|
|
||||||
run_img_addr = struct.pack('<I', int(argv[7], 16))
|
|
||||||
upd_img_addr = struct.pack('<I', int(argv[6], 16))
|
|
||||||
upd_img_len = struct.pack('<I', bin_len)
|
|
||||||
upd_checksum = struct.pack('<I', bin_crc)
|
|
||||||
upd_no = struct.pack('<I', 0)
|
|
||||||
ver_name = newversion.encode('utf-8')
|
|
||||||
# non-zip image
|
|
||||||
if not int(argv[4]):
|
|
||||||
run_img_len = struct.pack('<I', bin_len)
|
|
||||||
run_org_checksum = struct.pack('<I', bin_crc)
|
|
||||||
else:
|
|
||||||
# zip image
|
|
||||||
try:
|
|
||||||
f_src = open(argv[8], 'rb+')
|
|
||||||
except IOError:
|
|
||||||
f_bin.close()
|
|
||||||
print("not find %s file" % argv[8])
|
|
||||||
raise
|
|
||||||
else:
|
|
||||||
src_data = f_src.read()
|
|
||||||
src_len = os.path.getsize(argv[8])
|
|
||||||
src_crc = crc32(src_data) ^ (0xFFFFFFFF)
|
|
||||||
# print(src_data)
|
|
||||||
f_src.close()
|
|
||||||
|
|
||||||
run_img_len = struct.pack('<I', src_len)
|
|
||||||
run_org_checksum = struct.pack('<I', src_crc)
|
|
||||||
|
|
||||||
#image header crc
|
|
||||||
image_header = magic + img_type + zip_type + run_img_addr + run_img_len \
|
|
||||||
+ run_org_checksum + upd_img_addr + upd_img_len + upd_checksum \
|
|
||||||
+ upd_no + ver_name
|
|
||||||
|
|
||||||
header_crc = crc32(image_header) ^ (0xFFFFFFFF)
|
|
||||||
|
|
||||||
try:
|
|
||||||
f_img = open(argv[2], "wb+")
|
|
||||||
except IOError:
|
|
||||||
f_bin.close()
|
|
||||||
print("create %s file fail" % argv[2])
|
|
||||||
raise
|
|
||||||
else:
|
|
||||||
f_img.write(image_header)
|
|
||||||
f_img.write(struct.pack('<I', header_crc))
|
|
||||||
f_img.write(bin_data)
|
|
||||||
|
|
||||||
# write dummy data to pad 4byte-aligned
|
|
||||||
dummy = len(bin_data) % 4
|
|
||||||
if dummy != 0:
|
|
||||||
dummy = 4 - len(bin_data) % 4
|
|
||||||
f_img.write(struct.pack('<B', 0) * dummy)
|
|
||||||
|
|
||||||
f_img.close()
|
|
||||||
f_bin.close()
|
|
||||||
print("image %s create success!" % argv[2])
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
|
||||||
main(sys.argv)
|
|
Binary file not shown.
|
@ -1,159 +0,0 @@
|
||||||
# -*- coding:utf-8 -*_
|
|
||||||
#
|
|
||||||
# W600 make img script
|
|
||||||
# Copyright (c) 2018 Winner Micro Electronic Design Co., Ltd.
|
|
||||||
# All rights reserved.
|
|
||||||
#
|
|
||||||
# image header structure
|
|
||||||
# --------------------------------------------------------------------------------------------
|
|
||||||
# | magic number(4B) | image type(2B)| zip type(2B) | run image addr(4B) | run image len(4B) |
|
|
||||||
# --------------------------------------------------------------------------------------------
|
|
||||||
# | run image crc(4B) | update image addr(4B) | update image len(4B) | update image crc(4B) |
|
|
||||||
# ---------------------------------------------------------------------------------------------
|
|
||||||
# | update no(4B) | ver(16B) |
|
|
||||||
# ---------------------------------------------------------------------------------------------
|
|
||||||
#
|
|
||||||
#
|
|
||||||
# FLS File structure
|
|
||||||
# ----------------------------------------------
|
|
||||||
# | FLS file header (image header) |
|
|
||||||
# ------------------------------------
|
|
||||||
# | secboot header (image header) |
|
|
||||||
# ------------------------------------
|
|
||||||
# | 256-sizeof(image header) pad 0xFF |
|
|
||||||
# ------------------------------------
|
|
||||||
# | secboot img area-(56*1024 - 256) |
|
|
||||||
# ------------------------------------
|
|
||||||
# | application image header (image header) |
|
|
||||||
# ------------------------------------
|
|
||||||
# | 256-sizeof(image heager)-pad 0xFF |
|
|
||||||
# ------------------------------------
|
|
||||||
# | application image |
|
|
||||||
# ------------------------------------------------
|
|
||||||
#
|
|
||||||
#
|
|
||||||
|
|
||||||
import sys
|
|
||||||
import os
|
|
||||||
import struct
|
|
||||||
from zlib import crc32
|
|
||||||
|
|
||||||
secboot_img_addr = 0x2100
|
|
||||||
secboot_header_len = 0x100
|
|
||||||
secboot_header_pos = secboot_img_addr - secboot_header_len
|
|
||||||
secboot_img_total_len = 56*1024
|
|
||||||
run_img_header_len = 0x100
|
|
||||||
magic_no = 0xA0FFFF9F
|
|
||||||
|
|
||||||
|
|
||||||
def main(argv):
|
|
||||||
if(len(argv) != 4):
|
|
||||||
print("param cnt error")
|
|
||||||
print("param 0: .py")
|
|
||||||
print("param 1: input \"secboot.img\" file")
|
|
||||||
print("param 2: input image file")
|
|
||||||
print("param 3: output FLS file")
|
|
||||||
raise Exception("param cnt error!")
|
|
||||||
|
|
||||||
# second boot
|
|
||||||
try:
|
|
||||||
f_sec = open(argv[1], "rb+")
|
|
||||||
except IOError:
|
|
||||||
print("not find %s file" % argv[1])
|
|
||||||
raise
|
|
||||||
else:
|
|
||||||
magic_word = f_sec.read(4)
|
|
||||||
magic, = struct.unpack('<I', magic_word)
|
|
||||||
if magic != magic_no:
|
|
||||||
f_sec.close()
|
|
||||||
raise Exception("input %s file error" % argv[1])
|
|
||||||
|
|
||||||
# app image
|
|
||||||
try:
|
|
||||||
f_app=open(argv[2], "rb+")
|
|
||||||
except IOError:
|
|
||||||
f_sec.close()
|
|
||||||
print("not find %s file" % argv[2])
|
|
||||||
raise
|
|
||||||
else:
|
|
||||||
magic_word=f_app.read(4)
|
|
||||||
magic, = struct.unpack('<I', magic_word)
|
|
||||||
if magic != magic_no:
|
|
||||||
f_sec.close()
|
|
||||||
f_app.close()
|
|
||||||
raise Exception("input %s file error" % argv[1])
|
|
||||||
|
|
||||||
appimg_len=os.path.getsize(argv[2])
|
|
||||||
|
|
||||||
# create outfile
|
|
||||||
try:
|
|
||||||
f_out=open(argv[3], 'wb+')
|
|
||||||
except IOError:
|
|
||||||
f_app.close()
|
|
||||||
f_sec.close()
|
|
||||||
print("create %s file error" % argv[3])
|
|
||||||
raise
|
|
||||||
else:
|
|
||||||
final_len=secboot_img_total_len + appimg_len
|
|
||||||
data = struct.pack('<B', 0xff) * final_len
|
|
||||||
f_out.write(data)
|
|
||||||
|
|
||||||
# Write SECBOOT header to output file
|
|
||||||
f_out.seek(56)
|
|
||||||
f_sec.seek(0)
|
|
||||||
f_out.write(f_sec.read(56))
|
|
||||||
|
|
||||||
# Write SECBOOT image to output file
|
|
||||||
f_out.seek(56 + 256)
|
|
||||||
f_out.write(f_sec.read())
|
|
||||||
|
|
||||||
# Write run img header to output file
|
|
||||||
f_out.seek(56 + secboot_img_total_len)
|
|
||||||
f_app.seek(0)
|
|
||||||
f_out.write(f_app.read(56))
|
|
||||||
|
|
||||||
# Write run img to output file
|
|
||||||
f_out.seek(56 + secboot_img_total_len + run_img_header_len)
|
|
||||||
f_out.write(f_app.read())
|
|
||||||
|
|
||||||
# Calculate CRC from secboot header
|
|
||||||
f_out.seek(56)
|
|
||||||
out_data = f_out.read()
|
|
||||||
out_crc = crc32(out_data) ^ (0xFFFFFFFF)
|
|
||||||
out_len = len(out_data)
|
|
||||||
#print(hex(out_crc))
|
|
||||||
|
|
||||||
magic = struct.pack('<I', magic_no)
|
|
||||||
img_type = struct.pack('<H', 0)
|
|
||||||
zip_type = struct.pack('<H', 0)
|
|
||||||
run_img_addr = struct.pack('<I', secboot_header_pos)
|
|
||||||
upd_img_addr = struct.pack('<I', 0)
|
|
||||||
upd_img_len = struct.pack('<I', 0)
|
|
||||||
upd_checksum = struct.pack('<I', 0)
|
|
||||||
upd_no = struct.pack('<I', 0)
|
|
||||||
version = '\0' * 16
|
|
||||||
ver_name = version.encode('utf-8')
|
|
||||||
run_img_len = struct.pack('<I', out_len)
|
|
||||||
run_org_checksum = struct.pack('<I', out_crc)
|
|
||||||
|
|
||||||
# image header crc
|
|
||||||
image_header=magic + img_type + zip_type + run_img_addr + run_img_len \
|
|
||||||
+ run_org_checksum + upd_img_addr + upd_img_len + upd_checksum \
|
|
||||||
+ upd_no + ver_name
|
|
||||||
|
|
||||||
header_crc=crc32(image_header) ^ (0xFFFFFFFF)
|
|
||||||
|
|
||||||
# Write fls's header to output file
|
|
||||||
f_out.seek(0)
|
|
||||||
f_out.write(image_header)
|
|
||||||
f_out.write(struct.pack('<I', header_crc))
|
|
||||||
|
|
||||||
f_sec.close()
|
|
||||||
f_app.close()
|
|
||||||
f_out.close()
|
|
||||||
print("create %s file success!" % argv[3])
|
|
||||||
print("%s size:%dKB. %s size:%dKB" % (argv[2], appimg_len / 1024.0 , argv[3], final_len / 1024.0))
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
|
||||||
main(sys.argv)
|
|
Binary file not shown.
Binary file not shown.
|
@ -1 +0,0 @@
|
||||||
1.0.06
|
|
|
@ -1,16 +0,0 @@
|
||||||
# -*- coding:utf-8 -*-
|
|
||||||
#
|
|
||||||
# W600 make gzip file
|
|
||||||
# Copyright (c) 2018 Winner Micro Electronic Design Co., Ltd.
|
|
||||||
# All rights reserved.
|
|
||||||
|
|
||||||
import sys
|
|
||||||
import gzip
|
|
||||||
|
|
||||||
file_name = sys.argv[1]
|
|
||||||
file_prefix = file_name + '.gz'
|
|
||||||
with open(file_name, 'rb') as f_in:
|
|
||||||
with gzip.open(file_prefix, 'wb') as f_out:
|
|
||||||
f_out.writelines(f_in)
|
|
||||||
f_in.close()
|
|
||||||
f_out.close()
|
|
Loading…
Reference in New Issue