# Flash via fastbootd (userspace fastboot) - different USB interface than bootloader fastboot $FASTBOOT = "C:\Users\PCOEM\platform-tools\fastboot.exe" $BOOT_IMG = "C:\Users\PCOEM\AeThexOS\magisk_patched_boot.img" Write-Host "=== Flash via fastbootd (userspace fastboot) ===" -ForegroundColor Cyan Write-Host "" # Reboot to fastbootd (NOT bootloader) Write-Host "Rebooting to fastbootd..." -ForegroundColor Yellow adb reboot fastboot 2>&1 | Out-Null Write-Host "Polling for fastboot device..." -ForegroundColor Yellow $found = $false $attempts = 0 while (-not $found -and $attempts -lt 60) { $attempts++ $result = & $FASTBOOT devices 2>&1 | Out-String if ($result -match "\S+\s+fastboot") { $found = $true Write-Host "" Write-Host "DEVICE FOUND IN FASTBOOT!" -ForegroundColor Green Write-Host $result.Trim() } else { if ($attempts % 5 -eq 0) { Write-Host " Waiting... ($attempts`s)" -ForegroundColor DarkGray } Start-Sleep -Seconds 1 } } if (-not $found) { Write-Host "" Write-Host "Timeout. Trying 'fastboot getvar product'..." -ForegroundColor Yellow & $FASTBOOT getvar product 2>&1 Write-Host "" Write-Host "Trying 'fastboot getvar all'..." -ForegroundColor Yellow & $FASTBOOT getvar all 2>&1 exit 1 } # Flash! Write-Host "" Write-Host "Flashing boot_b with Magisk-patched image..." -ForegroundColor Cyan & $FASTBOOT flash boot_b $BOOT_IMG 2>&1 if ($LASTEXITCODE -eq 0) { Write-Host "" Write-Host "SUCCESS!" -ForegroundColor Green Write-Host "Rebooting..." -ForegroundColor Yellow & $FASTBOOT reboot 2>&1 } else { Write-Host "" Write-Host "boot_b failed, trying boot..." -ForegroundColor Yellow & $FASTBOOT flash boot $BOOT_IMG 2>&1 if ($LASTEXITCODE -eq 0) { Write-Host "SUCCESS with 'boot'!" -ForegroundColor Green & $FASTBOOT reboot 2>&1 } else { Write-Host "Failed. Listing partitions..." -ForegroundColor Red & $FASTBOOT getvar all 2>&1 } }