mothercup/tools/make_dual_package.bat

58 lines
2.5 KiB
Batchfile

@echo off
rem ============================================================
rem make_dual_package.bat - build Boot + APP1 + APP2 and merge
rem one COMPLETE flash image for the appsw bank-switch test:
rem Boot 0x01000000
rem bootsetting 0x01004000 (both bank records, crc filled)
rem APP_DATA 0x01006000 (default params record)
rem APP1 0x01008000 target "N32WB03x" (current version, 112KB bank)
rem APP2 0x01024000 target "APP2" (same release, linked at the
rem APP2 base; banks are told apart via info item 0x07
rem CUR_BANK, see docs/ble_protocol.md section 5)
rem Output: tools\out\caiic_ble_dual.{hex,bin} (+ _ota.bin/_ota.json)
rem Flash: tools\flash_package.bat tools\out\caiic_ble_dual.hex
rem ============================================================
setlocal
set ROOT=%~dp0..
set UV4="D:\Keil_v5\UV4\UV4.exe"
rem Both banks build the SAME release (same version); the running bank is
rem reported via info item 0x07 CUR_BANK (devinfo / read-only characteristic).
echo [1/4] Building bootloader...
%UV4% -r "%ROOT%\Boot\MDK-ARM\caiic_boot.uvprojx" -j0 -o "%ROOT%\Boot\MDK-ARM\build.log"
if errorlevel 1 goto :fail
findstr /C:"0 Error(s), 0 Warning(s)" "%ROOT%\Boot\MDK-ARM\build.log" >nul || goto :fail
echo [2/4] Building APP1 (target N32WB03x)...
%UV4% -r "%ROOT%\mcm-ddc-ble\MDK-ARM\mcm-ddc-ble.uvprojx" -t "N32WB03x" -j0 -o "%ROOT%\mcm-ddc-ble\MDK-ARM\build.log"
if errorlevel 1 goto :fail
findstr /C:"0 Error(s), 0 Warning(s)" "%ROOT%\mcm-ddc-ble\MDK-ARM\build.log" >nul || goto :fail
echo [3/4] Building APP2 (target APP2)...
%UV4% -r "%ROOT%\mcm-ddc-ble\MDK-ARM\mcm-ddc-ble.uvprojx" -t "APP2" -j0 -o "%ROOT%\mcm-ddc-ble\MDK-ARM\build-app2.log"
if errorlevel 1 goto :fail
findstr /C:"0 Error(s), 0 Warning(s)" "%ROOT%\mcm-ddc-ble\MDK-ARM\build-app2.log" >nul || goto :fail
echo [4/4] Merging images...
set PYEXE=
python --version >nul 2>&1 && set PYEXE=python
if not defined PYEXE (
if exist "%LOCALAPPDATA%\Programs\Python\Python312\python.exe" (
set PYEXE="%LOCALAPPDATA%\Programs\Python\Python312\python.exe"
)
)
if not defined PYEXE (
echo python not found - install Python 3 or fix PATH
goto :fail
)
%PYEXE% "%~dp0merge_image.py" "%ROOT%\mcm-ddc-ble\MDK-ARM\bin\mcm-ddc-ble.bin" caiic_ble_dual --app2 "%ROOT%\mcm-ddc-ble\MDK-ARM\bin\mcm-ddc-ble-app2.bin" --with-appdata || goto :fail
echo.
echo Package ready: tools\out\caiic_ble_dual.hex / caiic_ble_dual.bin
goto :eof
:fail
echo.
echo *** FAILED - check the build logs ***
exit /b 1