diff --git a/setup_framework.bat b/setup_framework.bat index e4611fa..3e20a14 100644 --- a/setup_framework.bat +++ b/setup_framework.bat @@ -21,7 +21,30 @@ if not exist "%FRAMEWORK_ZEPHYR%" ( ) if not exist "%LORAMAC_NODE%" ( - echo Error: LoRaMAC-Node not found at %LORAMAC_NODE% + echo LoRaMAC-Node not found, need to fix PlatformIO packages first... + echo Cleaning and reinstalling PlatformIO packages... + + echo Removing corrupted packages... + rmdir /s /q "%PIO_PACKAGES%" 2>nul + + echo Updating PlatformIO core... + pio update + + echo Running initial build to download fresh packages... + pio run + if %errorlevel% neq 0 ( + echo [31mError: Build failed after package cleanup[0m + echo [33mTry running: pio platform install ststm32[0m + pause + exit /b 1 + ) + echo [32m✓ Framework modules initialized[0m +) + +REM Double-check after potential build +if not exist "%LORAMAC_NODE%" ( + echo Error: LoRaMAC-Node still not found at %LORAMAC_NODE% + echo Please check PlatformIO installation and project configuration pause exit /b 1 ) diff --git a/setup_framework.ps1 b/setup_framework.ps1 index e4607fc..81f491c 100644 --- a/setup_framework.ps1 +++ b/setup_framework.ps1 @@ -20,7 +20,37 @@ if (-not (Test-Path $FRAMEWORK_ZEPHYR)) { } if (-not (Test-Path $LORAMAC_NODE)) { - Write-Host "Error: LoRaMAC-Node not found at $LORAMAC_NODE" -ForegroundColor Red + Write-Host "LoRaMAC-Node not found, need to fix PlatformIO packages first..." -ForegroundColor Yellow + Write-Host "Cleaning and reinstalling PlatformIO packages..." + + Write-Host "Removing corrupted packages..." + if (Test-Path $PIO_PACKAGES) { + Remove-Item $PIO_PACKAGES -Recurse -Force -ErrorAction SilentlyContinue + } + + Write-Host "Updating PlatformIO core..." + try { + pio update + Write-Host "Running initial build to download fresh packages..." + pio run + if ($LASTEXITCODE -ne 0) { + Write-Host "Error: Build failed after package cleanup" -ForegroundColor Red + Write-Host "Try running: pio platform install ststm32" -ForegroundColor Yellow + Read-Host "Press Enter to exit" + exit 1 + } + Write-Host "✓ Framework modules initialized" -ForegroundColor Green + } catch { + Write-Host "Error: Failed to clean and rebuild packages - $_" -ForegroundColor Red + Read-Host "Press Enter to exit" + exit 1 + } +} + +# Double-check after potential build +if (-not (Test-Path $LORAMAC_NODE)) { + Write-Host "Error: LoRaMAC-Node still not found at $LORAMAC_NODE" -ForegroundColor Red + Write-Host "Please check PlatformIO installation and project configuration" -ForegroundColor Yellow Read-Host "Press Enter to exit" exit 1 }