text
stringlengths
0
834k
set ""python=python ""
:postbuild
::Make sure we have a Binary sub-folder in UserApp folder
if not exist ""%userAppBinary%"" (
mkdir ""%userAppBinary%""
)
::PostBuild is fired if elf has been regenerated from last run, so elf is different from backup elf
if exist %elfbackup% (
fc %elfbackup% %elf% >NUL && (goto nothingtodo) || echo ""elf has been modified, processing required""
)
set ""command=%python%%prepareimage% enc -k %oemkey% -i %iv% %bin% %sfu% > %projectdir%\output.txt 2>&1""
%command%
IF %ERRORLEVEL% NEQ 0 goto :error
set ""command=%python%%prepareimage% sha256 %bin% %sign% >> %projectdir%\output.txt 2>&1""
%command%
IF %ERRORLEVEL% NEQ 0 goto :error
set ""command=%python%%prepareimage% pack -m %magic% -k %ecckey% -r 28 -v %version% -i %iv% -f %sfu% -t %sign% %sfb% -o %offset% >> %projectdir%\output.txt 2>&1""
%command%
IF %ERRORLEVEL% NEQ 0 goto :error
set ""command=%python%%prepareimage% header -m %magic% -k %ecckey% -r 28 -v %version% -i %iv% -f %sfu% -t %sign% -o %offset% %headerbin% >> %projectdir%\output.txt 2>&1""
%command%
IF %ERRORLEVEL% NEQ 0 goto :error
::get Header address when not contiguous with firmware
if exist %projectdir%\header.txt (
del %projectdir%\header.txt
)
set ""command=%python%%prepareimage% extract -d ""__ICFEDIT_SLOT_Active_%fwid%_header__"" %mapping% > %projectdir%\header.txt""
%command%
IF %ERRORLEVEL% NEQ 0 goto :error
set /P header=<%projectdir%\header.txt >> %projectdir%\output.txt 2>>&1
echo header %header% >> %projectdir%\output.txt 2>>&1
set ""command=%python%%prepareimage% merge -v 0 -i %headerbin% -s %sbsfuelf% -x %header% -u %elf% %bigbinary% >> %projectdir%\output.txt 2>&1""
%command%
IF %ERRORLEVEL% NEQ 0 goto :error
::Partial image generation if reference userapp exists
if not exist ""%ref_userapp%"" (
goto :bigelf
)
set ""command=%python%%prepareimage% diff -1 %ref_userapp% -2 %bin% %partialbin% -a %alignment% --poffset %partialoffset% >> %projectdir%\output.txt 2>&1""
%command%
IF %ERRORLEVEL% NEQ 0 goto :error
set ""command=%python%%prepareimage% enc -k %oemkey% -i %iv% %partialbin% %partialsfu% >> %projectdir%\output.txt 2>&1""
%command%
IF %ERRORLEVEL% NEQ 0 goto :error
set ""command=%python%%prepareimage% sha256 %partialbin% %partialsign% >> %projectdir%\output.txt 2>&1""
%command%
IF %ERRORLEVEL% NEQ 0 goto :error
set ""command=%python%%prepareimage% pack -m %magic% -k %ecckey% -r 28 -v %version% -i %iv% -f %sfu% -t %sign% -o %offset% --pfw %partialsfu% --ptag %partialsign% --poffset %partialoffset% %partialsfb%>> %projectdir%\output.txt 2>&1""
%command%
IF %ERRORLEVEL% NEQ 0 goto :error
:bigelf
IF ""%~6""=="""" goto :finish
echo ""Generating the global elf file (SBSFU and userApp)""
echo ""Generating the global elf file (SBSFU and userApp)"" >> %projectdir%\output.txt
set ""command=%programmertool% -ms %elf% %headerbin% %sbsfuelf% >> %projectdir%\output.txt 2>&1""
%command%
IF %ERRORLEVEL% NEQ 0 goto :error
set ""command=copy %elf% %elfbackup% >> %projectdir%\output.txt 2>&1""
%command%
IF %ERRORLEVEL% NEQ 0 goto :error
:finish
::backup and clean up the intermediate file
del %sign%
del %sfu%
del %headerbin%
if exist ""%ref_userapp%"" (
del %partialsign%
del %partialbin%
del %partialsfu%
del %partialoffset%
)
exit 0
:error
echo ""%command% : failed"" >> %projectdir%\\output.txt
:: remove the elf to force the regeneration
if exist %elf%(
del %elf%
)
if exist %elfbackup%(
del %elfbackup%
)
echo %command% : failed
pause
exit 1