# Aggressive fastboot flash script # Polls fastboot continuously until device appears, then flashes immediately $FASTBOOT = "C:\Users\PCOEM\platform-tools\fastboot.exe" $BOOT_IMG = "C:\Users\PCOEM\AeThexOS\magisk_patched_boot.img" Write-Host "=== AeThex OS - Fastboot Boot Image Flash ===" -ForegroundColor Cyan Write-Host "" # Check image exists if (-not (Test-Path $BOOT_IMG)) { Write-Host "ERROR: $BOOT_IMG not found!" -ForegroundColor Red exit 1 } $size = (Get-Item $BOOT_IMG).Length Write-Host "Boot image: $BOOT_IMG ($size bytes)" -ForegroundColor Green # Reboot to bootloader Write-Host "" Write-Host "Rebooting device to bootloader..." -ForegroundColor Yellow & adb reboot bootloader 2>&1 | Out-Null Write-Host "Waiting for fastboot device (polling every 500ms)..." -ForegroundColor Yellow Write-Host "If stuck, SELECT FASTBOOT on the device screen" -ForegroundColor Yellow Write-Host "" # Poll aggressively $found = $false $attempts = 0 $maxAttempts = 120 # 60 seconds while (-not $found -and $attempts -lt $maxAttempts) { $attempts++ $result = & $FASTBOOT devices 2>&1 | Out-String if ($result -match "fastboot") { $found = $true Write-Host "DEVICE FOUND!" -ForegroundColor Green Write-Host $result.Trim() } else { if ($attempts % 10 -eq 0) { Write-Host " Still waiting... ($([math]::Round($attempts/2))s elapsed)" -ForegroundColor DarkGray } Start-Sleep -Milliseconds 500 } } if (-not $found) { Write-Host "TIMEOUT: No fastboot device detected after 60 seconds" -ForegroundColor Red Write-Host "Try: power off tablet, hold Vol Down + Power to enter fastboot manually" -ForegroundColor Yellow exit 1 } # Flash boot_b (active slot) Write-Host "" Write-Host "Flashing boot_b partition..." -ForegroundColor Cyan & $FASTBOOT flash boot_b $BOOT_IMG 2>&1 $flashResult = $LASTEXITCODE if ($flashResult -eq 0) { Write-Host "" Write-Host "SUCCESS! Boot image flashed to boot_b!" -ForegroundColor Green Write-Host "" Write-Host "Rebooting device..." -ForegroundColor Yellow & $FASTBOOT reboot 2>&1 Write-Host "" Write-Host "=== Magisk root should now be active after boot ===" -ForegroundColor Cyan Write-Host "Open Magisk app to verify root status" -ForegroundColor Cyan } else { Write-Host "" Write-Host "Flash command returned error code $flashResult" -ForegroundColor Red Write-Host "Trying alternative: flash boot (without slot suffix)..." -ForegroundColor Yellow & $FASTBOOT flash boot $BOOT_IMG 2>&1 if ($LASTEXITCODE -eq 0) { Write-Host "SUCCESS with 'boot' partition name!" -ForegroundColor Green & $FASTBOOT reboot 2>&1 } else { Write-Host "Both flash attempts failed." -ForegroundColor Red Write-Host "Try: fastboot --set-active=b flash boot $BOOT_IMG" -ForegroundColor Yellow } }