This commit is contained in:
Tester23
2026-04-15 19:43:11 +02:00
parent 59f6dcbd31
commit a04d0b2556
4 changed files with 274 additions and 0 deletions

View File

@ -0,0 +1,165 @@
@echo off
setlocal EnableDelayedExpansion
pushd "%~dp0\.."
:: Default settings
set APP_VERSION=dev_ln882h
set OBK_VARIANT=2
set ACTION=build
if not "%~1"=="" set APP_VERSION=%~1
if not "%~2"=="" set OBK_VARIANT=%~2
if not "%~3"=="" set ACTION=%~3
echo ==============================================
echo Building OpenBeken LN882H on Windows natively
echo App Version: %APP_VERSION%
echo Variant (2=tuyaMCU): %OBK_VARIANT%
echo Action: %ACTION%
echo ==============================================
:: 1. Check prerequisites
:: Git Bash
set GIT_BASH=
for %%P in (
"C:\Program Files\Git\bin\bash.exe"
"C:\Program Files (x86)\Git\bin\bash.exe"
) do (
if exist "%%~P" (
set "GIT_BASH=%%~P"
goto :found_bash
)
)
echo [ERROR] Git Bash not found! Please install Git for Windows.
exit /b 1
:found_bash
echo [INFO] Using Git Bash: %GIT_BASH%
:: Check CMake
where cmake >nul 2>nul
if %errorlevel% neq 0 (
echo [ERROR] 'cmake' not found in PATH!
echo [INFO] Please install CMake from cmake.org or via your package manager.
exit /b 1
)
:: Check Ninja
where ninja >nul 2>nul
if %errorlevel% neq 0 (
echo [ERROR] 'ninja' not found in PATH!
echo [INFO] LN882H build uses Ninja generator. Please install Ninja and add it to your PATH.
exit /b 1
)
echo [INFO] CMake and Ninja found.
:: 2. Submodules
if not exist "sdk\OpenLN882H\CMakeLists.txt" (
echo [INFO] OpenLN882H submodule not found, checking out...
git submodule update --init --recursive sdk\OpenLN882H
if !errorlevel! neq 0 (
echo [ERROR] Failed to checkout OpenLN882H submodule!
exit /b 1
)
)
echo [INFO] LN882H submodule OK.
if not exist "libraries\berry\src\be_api.c" (
echo [INFO] Berry submodule not found, checking out...
git submodule update --init --depth=1 libraries\berry
)
echo [INFO] Berry submodule OK.
:: 3. Toolchain
set "CROSS_TOOLCHAIN_ROOT=%CD%\sdk\OpenBK7231N\platforms\BK7231N\toolchain\windows\gcc-arm-none-eabi-4_9-2015q1"
if not exist "%CROSS_TOOLCHAIN_ROOT%\bin\arm-none-eabi-gcc.exe" (
echo [ERROR] ARM GCC not found at !CROSS_TOOLCHAIN_ROOT!
echo [INFO] We reuse the BK7231N toolchain. Please ensure BK7231N SDK is updated.
git submodule update --init --depth=1 sdk/OpenBK7231N
)
echo [INFO] Toolchain set to: !CROSS_TOOLCHAIN_ROOT!
:: Export APP_VERSION and OBK_VARIANT for Python and CMake
set APP_VERSION=%APP_VERSION%
set OBK_VARIANT=%OBK_VARIANT%
:: 4. Python3 workaround for subprocess "python3"
echo [INFO] Resolving Python dependency...
for /f "delims=" %%I in ('where python') do (
set "WIN_PYTHON_PATH=%%~fI"
goto found_win_python
)
:found_win_python
set PYTHON_TMP=%CD%\output\tmp_python
if not exist "%PYTHON_TMP%" mkdir "%PYTHON_TMP%"
if not exist "%PYTHON_TMP%\python3.exe" (
copy /y "!WIN_PYTHON_PATH!" "%PYTHON_TMP%\python3.exe" >nul
)
set PATH=%PYTHON_TMP%;%PATH%
:: --- Berry prebuild ---
call build_scripts\berry_prebuild.bat
if "%ACTION%"=="clean" (
pushd sdk\OpenLN882H
python start_build.py clean
popd
echo [INFO] Clean complete!
exit /b 0
)
:: 4. Pre-build script / App Symlink
if not exist "sdk\OpenLN882H\project\OpenBeken\app" (
echo [INFO] Creating junction for app in LN882H OpenBeken project...
mklink /J "%CD%\sdk\OpenLN882H\project\OpenBeken\app" "%CD%" >nul 2>nul
if !errorlevel! neq 0 (
echo [ERROR] Failed to create junction. Try running as Administrator.
exit /b 1
)
)
if exist "platforms\LN882H\pre_build.sh" (
echo [INFO] Running LN882H pre-build bash script...
"%GIT_BASH%" --login -c "cd '%CD:\=/%'; platforms/LN882H/pre_build.sh"
)
:: 5. Compile
echo [INFO] Building LN882H...
pushd sdk\OpenLN882H
python start_build.py %ACTION%
set BUILD_RESULT=!errorlevel!
popd
if !BUILD_RESULT! neq 0 (
echo [ERROR] LN882H build failed with exit code !BUILD_RESULT!
exit /b !BUILD_RESULT!
)
:: Ensure output directory exists
if not exist "output\%APP_VERSION%" mkdir "output\%APP_VERSION%"
set OUT_NAME=OpenLN882H_%APP_VERSION%
:: Package binaries (The python script writes to bin/flashimage.bin inside sdk/OpenLN882H/build)
echo [INFO] Copying binaries...
set BLD_DIR=sdk\OpenLN882H\build-OpenBeken-release\bin
set FACTORY_BIN=output\%APP_VERSION%\%OUT_NAME%.factory.bin
if exist "%BLD_DIR%\flashimage.bin" (
copy /y "%BLD_DIR%\flashimage.bin" "!FACTORY_BIN!" >nul
echo [INFO] Factory binary created at: !FACTORY_BIN!
) else (
echo [WARNING] Flash image not found at %BLD_DIR%\flashimage.bin!
)
:: The OTA image in LN882H
if exist "%BLD_DIR%\OpenBeken.bin" (
copy /y "%BLD_DIR%\OpenBeken.bin" "output\%APP_VERSION%\%OUT_NAME%_OTA.bin" >nul
)
echo ==============================================
echo BUILD SUCCESSFUL!
echo ==============================================
exit /b 0

View File

@ -0,0 +1,105 @@
@echo off
setlocal EnableDelayedExpansion
set APP_VERSION=dev_rtl8710b
set APP_NAME=OpenBK7231T_App
set ACTION=all
if not "%~1"=="" set APP_VERSION=%~1
if not "%~2"=="" set OBK_VARIANT=%~2
if not "%~3"=="" set ACTION=%~3
echo ==============================================
echo Building OpenBeken RTL8710B on Windows natively
echo App Version: %APP_VERSION%
echo Action: %ACTION%
echo ==============================================
:: 1. Check for GNU make (requires MSYS2 or similar for Windows natively)
set "MSYS_MAKE="
for %%P in (
"C:\msys64\usr\bin\make.exe"
"C:\ProgramData\chocolatey\bin\make.exe"
"W:\TOOLS\msys64\usr\bin\make.exe"
) do (
if exist "%%~P" (
set "MSYS_MAKE=%%~dpP"
goto :found_make
)
)
echo [ERROR] GNU make not found. Please install GNU make (e.g. MSYS2 or choco).
exit /b 1
:found_make
echo [INFO] GNU make found at %MSYS_MAKE%
:: 2. Check for Git Bash bins (to provide cp, rm, bash for make natively)
set "GIT_USR_BIN="
if exist "C:\Program Files\Git\usr\bin\sh.exe" set "GIT_USR_BIN=C:\Program Files\Git\usr\bin"
if exist "C:\Program Files\Git\bin\sh.exe" set "GIT_USR_BIN=C:\Program Files\Git\bin"
if not "%GIT_USR_BIN%"=="" (
echo [INFO] Unix Utilities found at: %GIT_USR_BIN%
)
:: 3. Check for toolchain
set "TOOLCHAIN_ROOT=%CD%\sdk\OpenBK7231N\platforms\BK7231N\toolchain\windows\gcc-arm-none-eabi-4_9-2015q1"
if not exist "%TOOLCHAIN_ROOT%\bin\arm-none-eabi-gcc.exe" (
echo [ERROR] GCC 4.9 toolchain not found at %TOOLCHAIN_ROOT%
exit /b 1
)
echo [INFO] Toolchain set to: %TOOLCHAIN_ROOT%
:: 3. Submodule Sync Check (OpenRTL8710A_B and libraries/berry)
if not exist "sdk\OpenRTL8710A_B\project\obk_amebaz\GCC-RELEASE\Makefile" (
echo [INFO] OpenRTL8710A_B submodule missing or empty. Initializing...
git submodule update --init sdk/OpenRTL8710A_B
) else (
echo [INFO] RTL8710B submodule OK.
)
if not exist "libraries\berry\src\be_api.c" (
echo [INFO] Berry submodule missing or empty. Initializing...
git submodule update --init libraries/berry
) else (
echo [INFO] Berry submodule OK.
)
echo [INFO] Resolving Berry paths...
call build_scripts\berry_prebuild.bat
if !errorlevel! neq 0 (
echo [ERROR] Berry prebuild failed.
exit /b 1
)
:: 5. Compile RTL8710B
echo [INFO] Building RTL8710B using OS=CYGWIN to enable Native Windows .exe parsing...
echo [INFO] Entering compilation phase...
:: Inject Make, SysUtils, and Toolchain into PATH just before make (to avoid MSYS python conflicts)
set "PATH=%MSYS_MAKE%;%GIT_USR_BIN%;%TOOLCHAIN_ROOT%\bin;%PATH%"
pushd sdk\OpenRTL8710A_B\project\obk_amebaz\GCC-RELEASE
make OS=CYGWIN %ACTION%
set BUILD_RESULT=!errorlevel!
popd
if %BUILD_RESULT% neq 0 (
echo [ERROR] Build failed with code %BUILD_RESULT%
exit /b %BUILD_RESULT%
)
:: 6. Copy Binaries
echo [INFO] Copying binaries...
if not exist "output\%APP_VERSION%" mkdir "output\%APP_VERSION%"
set "BIN_DIR=sdk\OpenRTL8710A_B\project\obk_amebaz\GCC-RELEASE\application\Debug\bin"
if exist "%BIN_DIR%\image2_all_ota1.bin" (
copy /y "%BIN_DIR%\image2_all_ota1.bin" "output\%APP_VERSION%\%APP_VERSION%_RTL8710B_OTA.bin" >nul
) else (
echo [WARNING] OTA image not found at %BIN_DIR%\image2_all_ota1.bin
)
echo ==============================================
echo BUILD SUCCESSFUL
echo ==============================================
exit /b 0

2
obk_ln882h_build.bat Normal file
View File

@ -0,0 +1,2 @@
@echo off
call build_scripts\build_ln882h.bat %*

2
obk_rtl8710b_build.bat Normal file
View File

@ -0,0 +1,2 @@
@echo off
call build_scripts\build_rtl8710b.bat %*