Add Windows setup scripts for framework configuration
- Add setup_framework.bat for classic Windows batch support - Add setup_framework.ps1 for PowerShell with better error handling - Both scripts handle STM32WL LoRaMAC-Node framework conflicts
This commit is contained in:
parent
1ca573e8cc
commit
acc1334daf
108
setup_framework.bat
Normal file
108
setup_framework.bat
Normal file
@ -0,0 +1,108 @@
|
||||
@echo off
|
||||
REM Script to setup framework modifications for STM32WL LoRaWAN project
|
||||
REM Usage: setup_framework.bat
|
||||
|
||||
echo Setting up framework modifications for STM32WL LoRaWAN build...
|
||||
|
||||
REM Find PlatformIO packages directory
|
||||
set PIO_PACKAGES=%USERPROFILE%\.platformio\packages
|
||||
set FRAMEWORK_ZEPHYR=%PIO_PACKAGES%\framework-zephyr
|
||||
set LORAMAC_NODE=%FRAMEWORK_ZEPHYR%\_pio\modules\lib\loramac-node
|
||||
|
||||
echo PlatformIO packages: %PIO_PACKAGES%
|
||||
echo Framework Zephyr: %FRAMEWORK_ZEPHYR%
|
||||
|
||||
REM Check if framework exists
|
||||
if not exist "%FRAMEWORK_ZEPHYR%" (
|
||||
echo Error: Zephyr framework not found at %FRAMEWORK_ZEPHYR%
|
||||
echo Please run 'pio run' first to download the framework
|
||||
pause
|
||||
exit /b 1
|
||||
)
|
||||
|
||||
if not exist "%LORAMAC_NODE%" (
|
||||
echo Error: LoRaMAC-Node not found at %LORAMAC_NODE%
|
||||
pause
|
||||
exit /b 1
|
||||
)
|
||||
|
||||
echo [32m✓ Framework directories found[0m
|
||||
|
||||
REM 1. Remove conflicting sx126x.c from LoRaMAC-Node
|
||||
set CONFLICTING_FILE=%LORAMAC_NODE%\src\radio\sx126x\sx126x.c
|
||||
if exist "%CONFLICTING_FILE%" (
|
||||
echo Removing conflicting sx126x.c...
|
||||
del "%CONFLICTING_FILE%"
|
||||
echo [32m✓ Removed %CONFLICTING_FILE%[0m
|
||||
) else (
|
||||
echo [32m✓ sx126x.c already removed[0m
|
||||
)
|
||||
|
||||
REM 2. Create radio_sx126x.c from original sx126x.c
|
||||
set RADIO_SX126X=%LORAMAC_NODE%\src\radio\sx126x\radio_sx126x.c
|
||||
if not exist "%RADIO_SX126X%" (
|
||||
echo Creating radio_sx126x.c from git repository...
|
||||
cd /d "%LORAMAC_NODE%"
|
||||
git show HEAD:src/radio/sx126x/sx126x.c > src\radio\sx126x\radio_sx126x.c
|
||||
if %errorlevel% neq 0 (
|
||||
echo [31mError: Failed to create radio_sx126x.c from git[0m
|
||||
echo Please ensure git is available and LoRaMAC-Node is a git repository
|
||||
pause
|
||||
exit /b 1
|
||||
)
|
||||
echo [32m✓ Created radio_sx126x.c[0m
|
||||
) else (
|
||||
echo [32m✓ radio_sx126x.c already exists[0m
|
||||
)
|
||||
|
||||
REM 3. Update CMakeLists.txt
|
||||
set CMAKE_FILE=%FRAMEWORK_ZEPHYR%\modules\loramac-node\CMakeLists.txt
|
||||
echo Updating CMakeLists.txt...
|
||||
|
||||
REM Create backup
|
||||
copy "%CMAKE_FILE%" "%CMAKE_FILE%.backup" >nul
|
||||
|
||||
REM For Windows, we'll use PowerShell for text replacement
|
||||
powershell -Command ^
|
||||
"$content = Get-Content '%CMAKE_FILE%'; ^
|
||||
$newContent = @(); ^
|
||||
$inSection = $false; ^
|
||||
foreach ($line in $content) { ^
|
||||
if ($line -match 'zephyr_library_sources_ifdef\(CONFIG_HAS_SEMTECH_SX126X') { ^
|
||||
$newContent += $line; ^
|
||||
$newContent += ' ${ZEPHYR_LORAMAC_NODE_MODULE_DIR}/src/radio/sx126x/radio.c'; ^
|
||||
$newContent += ' ${ZEPHYR_LORAMAC_NODE_MODULE_DIR}/src/radio/sx126x/radio_sx126x.c'; ^
|
||||
$inSection = $true; ^
|
||||
} elseif ($inSection -and $line -match '^\)') { ^
|
||||
$newContent += $line; ^
|
||||
$inSection = $false; ^
|
||||
} elseif (-not $inSection) { ^
|
||||
$newContent += $line; ^
|
||||
} ^
|
||||
}; ^
|
||||
$newContent | Set-Content '%CMAKE_FILE%'"
|
||||
|
||||
if %errorlevel% neq 0 (
|
||||
echo [31mError: Failed to update CMakeLists.txt[0m
|
||||
pause
|
||||
exit /b 1
|
||||
)
|
||||
|
||||
echo [32m✓ Updated %CMAKE_FILE%[0m
|
||||
|
||||
echo.
|
||||
echo [32m🎉 Framework setup complete![0m
|
||||
echo.
|
||||
echo Summary of changes:
|
||||
echo - Removed: %CONFLICTING_FILE%
|
||||
echo - Created: %RADIO_SX126X%
|
||||
echo - Updated: %CMAKE_FILE%
|
||||
echo.
|
||||
echo You can now run 'pio run' to build the project.
|
||||
echo.
|
||||
echo To restore original framework:
|
||||
echo git restore "%CONFLICTING_FILE%"
|
||||
echo del "%RADIO_SX126X%"
|
||||
echo move "%CMAKE_FILE%.backup" "%CMAKE_FILE%"
|
||||
|
||||
pause
|
||||
113
setup_framework.ps1
Normal file
113
setup_framework.ps1
Normal file
@ -0,0 +1,113 @@
|
||||
# PowerShell script to setup framework modifications for STM32WL LoRaWAN project
|
||||
# Usage: .\setup_framework.ps1
|
||||
|
||||
Write-Host "Setting up framework modifications for STM32WL LoRaWAN build..." -ForegroundColor Cyan
|
||||
|
||||
# Find PlatformIO packages directory
|
||||
$PIO_PACKAGES = "$env:USERPROFILE\.platformio\packages"
|
||||
$FRAMEWORK_ZEPHYR = "$PIO_PACKAGES\framework-zephyr"
|
||||
$LORAMAC_NODE = "$FRAMEWORK_ZEPHYR\_pio\modules\lib\loramac-node"
|
||||
|
||||
Write-Host "PlatformIO packages: $PIO_PACKAGES"
|
||||
Write-Host "Framework Zephyr: $FRAMEWORK_ZEPHYR"
|
||||
|
||||
# Check if framework exists
|
||||
if (-not (Test-Path $FRAMEWORK_ZEPHYR)) {
|
||||
Write-Host "Error: Zephyr framework not found at $FRAMEWORK_ZEPHYR" -ForegroundColor Red
|
||||
Write-Host "Please run 'pio run' first to download the framework" -ForegroundColor Yellow
|
||||
Read-Host "Press Enter to exit"
|
||||
exit 1
|
||||
}
|
||||
|
||||
if (-not (Test-Path $LORAMAC_NODE)) {
|
||||
Write-Host "Error: LoRaMAC-Node not found at $LORAMAC_NODE" -ForegroundColor Red
|
||||
Read-Host "Press Enter to exit"
|
||||
exit 1
|
||||
}
|
||||
|
||||
Write-Host "✓ Framework directories found" -ForegroundColor Green
|
||||
|
||||
# 1. Remove conflicting sx126x.c from LoRaMAC-Node
|
||||
$CONFLICTING_FILE = "$LORAMAC_NODE\src\radio\sx126x\sx126x.c"
|
||||
if (Test-Path $CONFLICTING_FILE) {
|
||||
Write-Host "Removing conflicting sx126x.c..."
|
||||
Remove-Item $CONFLICTING_FILE -Force
|
||||
Write-Host "✓ Removed $CONFLICTING_FILE" -ForegroundColor Green
|
||||
} else {
|
||||
Write-Host "✓ sx126x.c already removed" -ForegroundColor Green
|
||||
}
|
||||
|
||||
# 2. Create radio_sx126x.c from original sx126x.c
|
||||
$RADIO_SX126X = "$LORAMAC_NODE\src\radio\sx126x\radio_sx126x.c"
|
||||
if (-not (Test-Path $RADIO_SX126X)) {
|
||||
Write-Host "Creating radio_sx126x.c from git repository..."
|
||||
Push-Location $LORAMAC_NODE
|
||||
try {
|
||||
$gitOutput = git show HEAD:src/radio/sx126x/sx126x.c 2>&1
|
||||
if ($LASTEXITCODE -eq 0) {
|
||||
$gitOutput | Out-File -FilePath "src\radio\sx126x\radio_sx126x.c" -Encoding utf8
|
||||
Write-Host "✓ Created radio_sx126x.c" -ForegroundColor Green
|
||||
} else {
|
||||
Write-Host "Error: Failed to create radio_sx126x.c from git" -ForegroundColor Red
|
||||
Write-Host "Please ensure git is available and LoRaMAC-Node is a git repository" -ForegroundColor Yellow
|
||||
Pop-Location
|
||||
Read-Host "Press Enter to exit"
|
||||
exit 1
|
||||
}
|
||||
} finally {
|
||||
Pop-Location
|
||||
}
|
||||
} else {
|
||||
Write-Host "✓ radio_sx126x.c already exists" -ForegroundColor Green
|
||||
}
|
||||
|
||||
# 3. Update CMakeLists.txt
|
||||
$CMAKE_FILE = "$FRAMEWORK_ZEPHYR\modules\loramac-node\CMakeLists.txt"
|
||||
Write-Host "Updating CMakeLists.txt..."
|
||||
|
||||
# Create backup
|
||||
Copy-Item $CMAKE_FILE "$CMAKE_FILE.backup" -Force
|
||||
|
||||
try {
|
||||
$content = Get-Content $CMAKE_FILE
|
||||
$newContent = @()
|
||||
$inSection = $false
|
||||
|
||||
foreach ($line in $content) {
|
||||
if ($line -match 'zephyr_library_sources_ifdef\(CONFIG_HAS_SEMTECH_SX126X') {
|
||||
$newContent += $line
|
||||
$newContent += ' ${ZEPHYR_LORAMAC_NODE_MODULE_DIR}/src/radio/sx126x/radio.c'
|
||||
$newContent += ' ${ZEPHYR_LORAMAC_NODE_MODULE_DIR}/src/radio/sx126x/radio_sx126x.c'
|
||||
$inSection = $true
|
||||
} elseif ($inSection -and $line -match '^\)') {
|
||||
$newContent += $line
|
||||
$inSection = $false
|
||||
} elseif (-not $inSection) {
|
||||
$newContent += $line
|
||||
}
|
||||
}
|
||||
|
||||
$newContent | Set-Content $CMAKE_FILE -Encoding utf8
|
||||
Write-Host "✓ Updated $CMAKE_FILE" -ForegroundColor Green
|
||||
} catch {
|
||||
Write-Host "Error: Failed to update CMakeLists.txt - $_" -ForegroundColor Red
|
||||
Read-Host "Press Enter to exit"
|
||||
exit 1
|
||||
}
|
||||
|
||||
Write-Host ""
|
||||
Write-Host "🎉 Framework setup complete!" -ForegroundColor Green
|
||||
Write-Host ""
|
||||
Write-Host "Summary of changes:"
|
||||
Write-Host " - Removed: $CONFLICTING_FILE"
|
||||
Write-Host " - Created: $RADIO_SX126X"
|
||||
Write-Host " - Updated: $CMAKE_FILE"
|
||||
Write-Host ""
|
||||
Write-Host "You can now run 'pio run' to build the project." -ForegroundColor Cyan
|
||||
Write-Host ""
|
||||
Write-Host "To restore original framework:"
|
||||
Write-Host " git restore `"$CONFLICTING_FILE`""
|
||||
Write-Host " Remove-Item `"$RADIO_SX126X`""
|
||||
Write-Host " Move-Item `"$CMAKE_FILE.backup`" `"$CMAKE_FILE`""
|
||||
|
||||
Read-Host "Press Enter to exit"
|
||||
Loading…
Reference in New Issue
Block a user