mothercup/tools/make_package.bat
evan.liu 57762e50be tools: self-contained portable production package
- tools/python-embed/: embedded Python 3.12.10 runtime with bleak/pyserial
  preinstalled (git-ignored, fetched from the huaweicloud mirror); bats
  resolve Python in order: python-embed -> .venv-ble -> system
- NSpyocd.exe + DFP pack copied into tools/ (git-ignored);
  flash_package.py prefers the in-tools copies
- make_release.bat/ps1: one-click zip to out/mothercup_tools_<ts>.zip
  (staged in TEMP to avoid self-inclusion; zip excluded from git)
- all bats converted to CRLF (LF-only breaks cmd block parsing and %~dp0)
- verified: zip extracted outside the repo runs ble_ota --uart end-to-end
  (PASS, 27 kB/s) and flash_package via the bundled NSpyocd
- docs: dev log section 49, AGENTS.md tools section + heap 18KB fix
2026-09-05 10:34:59 +08:00

59 lines
2.6 KiB
Batchfile
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

@echo off
rem ============================================================
rem make_package.bat - build bootloader + APP1/APP2, then merge
rem into the PRODUCTION package:
rem tools/out/mothercup_ble_prod.{hex,bin} (APP1 only)
rem tools/out/mothercup_ble_ota.bin (OTA release)
rem Run from anywhere: tools\make_package.bat
rem ============================================================
setlocal
set ROOT=%~dp0..
set UV4="D:\Keil_v5\UV4\UV4.exe"
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-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...
rem 优先随包内嵌的 Python 运行时(merge_image.py 只需标准库)
set PYEXE=
if exist "%~dp0python-embed\python.exe" set PYEXE="%~dp0python-embed\python.exe"
if not defined 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" mothercup_ble_prod --ota-app2 "%ROOT%\mcm-ddc-ble\MDK-ARM\bin\mcm-ddc-ble-app2.bin" --combo-name mothercup_ble_ota || goto :fail
echo.
echo Package ready: tools\out\mothercup_ble_prod.hex / mothercup_ble_prod.bin
echo OTA payloads: mothercup_ble_prod_ota.bin (bank1) / mothercup_ble_prod_ota_app2.bin (bank2)
echo OTA release: mothercup_ble_ota.bin (single file, header carries version/size/CRC)
goto :eof
:fail
echo.
echo *** FAILED - check the build logs ***
exit /b 1