@echo off rem ============================================================ rem make_package.bat - build bootloader + APP, then merge into rem one flash package (tools/out/caiic_ble_full.*) rem Run from anywhere: tools\make_package.bat rem ============================================================ setlocal set ROOT=%~dp0.. set UV4="D:\Keil_v5\UV4\UV4.exe" echo [1/3] 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-linked OTA payload (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 ) rem --ota-app2: emit a second OTA payload linked for the APP2 bank rem (OTA writes the bank opposite to the running one, so both link rem variants must ship; the client picks by info item 0x07 CUR_BANK). %PYEXE% "%~dp0merge_image.py" "%ROOT%\mcm-ddc-ble\MDK-ARM\bin\mcm-ddc-ble.bin" caiic_ble_full --ota-app2 "%ROOT%\mcm-ddc-ble\MDK-ARM\bin\mcm-ddc-ble-app2.bin" || goto :fail echo. echo Package ready: tools\out\caiic_ble_full.hex / caiic_ble_full.bin echo OTA payloads: caiic_ble_full_ota.bin (bank1) / caiic_ble_full_ota_app2.bin (bank2) goto :eof :fail echo. echo *** FAILED - check the build logs *** exit /b 1