Run the overnight bench test on the spare board, and document it
Track the bench scripts (run_overnight.py and its stages, the link and ITS client libraries, the phone-vs-node comparison) with the first reports. Changes for the spare XIAO (no cell): - run_overnight.py picks the single Espressif board by default and refuses to test a build that is not this checkout's HEAD. - The unsigned soak stops as "transmit path wedged" after 40 resource_limit refusals in a row and tries whether a repeated STATION_CONFIGURE clears it. - "Refused requests put nothing on the radio" counts only own transmissions; frames heard from other stations are copied by RAW_CAPTURE too. - start_overnight.ps1: optional build and flash, host C tests in the background, Windows kept awake. setup_workstation.ps1 checks and installs git, Python 3.11, pyserial, asn1tools, MSYS2 gcc and make, ESP-IDF 6.0.2. - obu-firmware/docs/overnight-bench-test.tex (and PDF) describe the test, the workstation set-up and the findings of the 2026-11-25 runs.
This commit is contained in:
@@ -0,0 +1,104 @@
|
||||
# Checks (and, unless -CheckOnly, installs) everything a PC needs to flash and test the spare micrOBU board overnight:
|
||||
# git, Python 3.11 + pyserial + asn1tools, MSYS2 gcc + make, ESP-IDF 6.0.2 for the ESP32-C5. Safe to run again: a step that is
|
||||
# already satisfied is left alone. Needs internet (winget, GitHub, pacman, Espressif's download servers; about 3 GB, 20-40 min).
|
||||
#
|
||||
# powershell -ExecutionPolicy Bypass -File obu-firmware\test\bench\setup_workstation.ps1 -CheckOnly # just report
|
||||
# powershell -ExecutionPolicy Bypass -File obu-firmware\test\bench\setup_workstation.ps1 # install what is missing
|
||||
# ... -PreventSleep also turns off sleep, display-off and USB selective suspend while on mains (an overnight run needs it)
|
||||
#
|
||||
# What each step is for is in obu-firmware/test/bench/README.md ("Setting up a workstation"). Exit code 1 if something is
|
||||
# still missing at the end.
|
||||
param(
|
||||
[switch]$CheckOnly,
|
||||
[switch]$PreventSleep,
|
||||
[string]$IdfVersion = "v6.0.2",
|
||||
[string]$IdfToolsPath = "C:\Espressif",
|
||||
[string]$Msys = "C:\msys64"
|
||||
)
|
||||
$ErrorActionPreference = "Stop"
|
||||
$report = New-Object System.Collections.Generic.List[object]
|
||||
|
||||
function Add-Row($name, $ok, $detail) { $report.Add([pscustomobject]@{ Step = $name; OK = $(if ($ok) { "ok" } else { "MISSING" }); Detail = $detail }) }
|
||||
function Have-Winget { [bool](Get-Command winget -ErrorAction SilentlyContinue) }
|
||||
function Winget-Install($id) {
|
||||
if (-not (Have-Winget)) { throw "winget is not available: install '$id' by hand (Microsoft Store: App Installer)" }
|
||||
& winget install -e --id $id --accept-source-agreements --accept-package-agreements
|
||||
if ($LASTEXITCODE -ne 0 -and $LASTEXITCODE -ne -1978335189) { throw "winget install $id failed ($LASTEXITCODE)" } # -1978335189: already installed, nothing to do
|
||||
$env:PATH = [Environment]::GetEnvironmentVariable("PATH", "Machine") + ";" + [Environment]::GetEnvironmentVariable("PATH", "User")
|
||||
}
|
||||
function Find-Python {
|
||||
if (Get-Command py -ErrorAction SilentlyContinue) { $v = & py -3.11 --version 2>$null; if ($LASTEXITCODE -eq 0) { return @("py", "-3.11") } }
|
||||
$p = Join-Path $env:LOCALAPPDATA "Programs\Python\Python311\python.exe"
|
||||
if (Test-Path $p) { return @($p) }
|
||||
return $null
|
||||
}
|
||||
function Run-Python($py, [string[]]$a) { $rest = @(); if ($py.Count -gt 1) { $rest = $py[1..($py.Count - 1)] }; & $py[0] @rest @a }
|
||||
|
||||
# ---- 1. git -------------------------------------------------------------------------------------------------------
|
||||
$haveGit = [bool](Get-Command git -ErrorAction SilentlyContinue)
|
||||
if (-not $haveGit -and -not $CheckOnly) { Winget-Install "Git.Git"; $haveGit = [bool](Get-Command git -ErrorAction SilentlyContinue) }
|
||||
Add-Row "git" $haveGit $(if ($haveGit) { (& git --version) } else { "winget install -e --id Git.Git" })
|
||||
if ($haveGit -and -not $CheckOnly) { & git config --global core.longpaths true } # ESP-IDF's tree has paths past 260 characters
|
||||
|
||||
# ---- 2. Python 3.11 + pyserial + asn1tools --------------------------------------------------------------------------
|
||||
$py = Find-Python
|
||||
if (-not $py -and -not $CheckOnly) { Winget-Install "Python.Python.3.11"; $py = Find-Python }
|
||||
Add-Row "python 3.11" ([bool]$py) $(if ($py) { (Run-Python $py @("--version")) } else { "winget install -e --id Python.Python.3.11" })
|
||||
if ($py) {
|
||||
foreach ($pair in @(@("pyserial", "serial"), @("asn1tools", "asn1tools"))) {
|
||||
Run-Python $py @("-c", "import $($pair[1])") 2>$null
|
||||
$have = ($LASTEXITCODE -eq 0)
|
||||
if (-not $have -and -not $CheckOnly) { Run-Python $py @("-m", "pip", "install", "--user", $pair[0]); Run-Python $py @("-c", "import $($pair[1])") 2>$null; $have = ($LASTEXITCODE -eq 0) }
|
||||
Add-Row "pip: $($pair[0])" $have $(if ($have) { "importable" } else { "py -3.11 -m pip install --user $($pair[0])" })
|
||||
}
|
||||
}
|
||||
|
||||
# ---- 3. MSYS2 UCRT64 gcc + make (the PC-side C tests in obu-firmware/test/host) --------------------------------------
|
||||
$gcc = Join-Path $Msys "ucrt64\bin\gcc.exe"
|
||||
$make = Join-Path $Msys "usr\bin\make.exe"
|
||||
if (-not (Test-Path $gcc) -or -not (Test-Path $make)) {
|
||||
if (-not $CheckOnly) {
|
||||
if (-not (Test-Path (Join-Path $Msys "usr\bin\bash.exe"))) { Winget-Install "MSYS2.MSYS2" }
|
||||
$bash = Join-Path $Msys "usr\bin\bash.exe"
|
||||
& $bash -lc "pacman -Syu --noconfirm" # the first run may end the shell after updating pacman itself, so it is run twice
|
||||
& $bash -lc "pacman -Syu --noconfirm"
|
||||
& $bash -lc "pacman -S --needed --noconfirm mingw-w64-ucrt-x86_64-gcc make"
|
||||
}
|
||||
}
|
||||
$haveC = (Test-Path $gcc) -and (Test-Path $make)
|
||||
Add-Row "MSYS2 gcc + make" $haveC $(if ($haveC) { "$gcc, $make" } else { "winget install -e --id MSYS2.MSYS2, then pacman -S mingw-w64-ucrt-x86_64-gcc make" })
|
||||
|
||||
# ---- 4. ESP-IDF (exactly this version: components/microbu_v2x pins the C5 radio driver ABI to it) ---------------------
|
||||
$idfDir = Join-Path $IdfToolsPath "frameworks\esp-idf-$IdfVersion"
|
||||
$idfExport = Join-Path $idfDir "export.ps1"
|
||||
$envDirs = @(Get-ChildItem (Join-Path $IdfToolsPath "python_env") -Directory -ErrorAction SilentlyContinue | Where-Object { $_.Name -like "idf$($IdfVersion.TrimStart('v') -replace '^(\d+\.\d+).*', '$1')_*" })
|
||||
if ((-not (Test-Path $idfExport) -or -not $envDirs) -and -not $CheckOnly -and $haveGit) {
|
||||
if (-not (Test-Path $idfExport)) {
|
||||
New-Item -ItemType Directory -Force (Split-Path $idfDir) | Out-Null
|
||||
& git clone --branch $IdfVersion --depth 1 --recursive --shallow-submodules https://github.com/espressif/esp-idf.git $idfDir
|
||||
if ($LASTEXITCODE -ne 0) { throw "git clone of ESP-IDF $IdfVersion failed" }
|
||||
}
|
||||
$env:IDF_TOOLS_PATH = $IdfToolsPath
|
||||
Push-Location $idfDir
|
||||
try { & .\install.ps1 esp32c5; if ($LASTEXITCODE -ne 0) { throw "ESP-IDF install.ps1 failed" } } finally { Pop-Location }
|
||||
$envDirs = @(Get-ChildItem (Join-Path $IdfToolsPath "python_env") -Directory -ErrorAction SilentlyContinue | Where-Object { $_.Name -like "idf$($IdfVersion.TrimStart('v') -replace '^(\d+\.\d+).*', '$1')_*" })
|
||||
}
|
||||
$haveIdf = (Test-Path $idfExport) -and [bool]$envDirs
|
||||
Add-Row "ESP-IDF $IdfVersion" $haveIdf $(if ($haveIdf) { "$idfDir (python env $($envDirs[0].Name))" } else { "git clone --branch $IdfVersion --recursive https://github.com/espressif/esp-idf.git $idfDir; then .\install.ps1 esp32c5 with IDF_TOOLS_PATH=$IdfToolsPath" })
|
||||
|
||||
# ---- 5. sleep (an overnight run dies when Windows sleeps or suspends the USB port) --------------------------------------
|
||||
if ($PreventSleep -and -not $CheckOnly) {
|
||||
& powercfg /change standby-timeout-ac 0
|
||||
& powercfg /change hibernate-timeout-ac 0
|
||||
& powercfg /change monitor-timeout-ac 0
|
||||
& powercfg /setacvalueindex SCHEME_CURRENT 2a737441-1930-4402-8d77-b2bebba308a3 48e6b7a6-50f5-4782-a5d4-53bb8f07e226 0 # USB selective suspend: disabled
|
||||
& powercfg /setactive SCHEME_CURRENT
|
||||
Add-Row "power plan (on mains)" $true "no sleep, no hibernate, display stays on, USB selective suspend off"
|
||||
} else {
|
||||
Add-Row "power plan (on mains)" $true "unchanged (start_overnight.ps1 keeps Windows awake while it runs; -PreventSleep also fixes USB suspend)"
|
||||
}
|
||||
|
||||
$report | Format-Table -AutoSize -Wrap
|
||||
$missing = @($report | Where-Object { $_.OK -ne "ok" })
|
||||
if ($missing.Count) { Write-Host "$($missing.Count) step(s) still missing." -ForegroundColor Yellow; exit 1 }
|
||||
Write-Host "Workstation ready. Next: start_overnight.ps1 -Flash -Hours 8 (README.md, 'Setting up a workstation')." -ForegroundColor Green
|
||||
Reference in New Issue
Block a user