Squashed 'vendor/ruvector/' content from commit b64c2172
git-subtree-dir: vendor/ruvector git-subtree-split: b64c21726f2bb37286d9ee36a7869fef60cc6900
This commit is contained in:
124
examples/ruvLLM/esp32-flash/scripts/windows/build.ps1
Normal file
124
examples/ruvLLM/esp32-flash/scripts/windows/build.ps1
Normal file
@@ -0,0 +1,124 @@
|
||||
# build.ps1 - Auto-configure and build RuvLLM ESP32
|
||||
# Automatically detects toolchain paths - no manual configuration needed
|
||||
|
||||
param(
|
||||
[string]$Target = "xtensa-esp32-espidf",
|
||||
[switch]$Release = $true,
|
||||
[string]$Features = ""
|
||||
)
|
||||
|
||||
$ErrorActionPreference = "Stop"
|
||||
|
||||
Write-Host "`n=== RuvLLM ESP32 Build ===" -ForegroundColor Cyan
|
||||
Write-Host ""
|
||||
|
||||
# Auto-detect paths
|
||||
$rustupHome = if ($env:RUSTUP_HOME) { $env:RUSTUP_HOME } else { "$env:USERPROFILE\.rustup" }
|
||||
$cargoHome = if ($env:CARGO_HOME) { $env:CARGO_HOME } else { "$env:USERPROFILE\.cargo" }
|
||||
|
||||
# Find ESP toolchain
|
||||
$espToolchain = (Get-ChildItem "$rustupHome\toolchains" -Directory -ErrorAction SilentlyContinue |
|
||||
Where-Object { $_.Name -like "esp*" } |
|
||||
Select-Object -First 1)
|
||||
|
||||
if (-not $espToolchain) {
|
||||
Write-Error "ESP toolchain not found. Run .\setup.ps1 first"
|
||||
}
|
||||
|
||||
$espToolchainPath = $espToolchain.FullName
|
||||
|
||||
# Find libclang dynamically
|
||||
$libclang = Get-ChildItem "$espToolchainPath" -Recurse -Filter "libclang.dll" -ErrorAction SilentlyContinue |
|
||||
Select-Object -First 1
|
||||
|
||||
if (-not $libclang) {
|
||||
Write-Error "libclang.dll not found in $espToolchainPath"
|
||||
}
|
||||
|
||||
# Find Python
|
||||
$python = Get-Command python -ErrorAction SilentlyContinue
|
||||
if (-not $python) {
|
||||
$python = Get-Command python3 -ErrorAction SilentlyContinue
|
||||
}
|
||||
if (-not $python) {
|
||||
Write-Error "Python not found. Please install Python 3.8+"
|
||||
}
|
||||
$pythonPath = Split-Path $python.Source
|
||||
|
||||
# Find clang and xtensa-esp-elf paths
|
||||
$clangBin = Get-ChildItem "$espToolchainPath" -Recurse -Directory -Filter "esp-clang" -ErrorAction SilentlyContinue |
|
||||
Select-Object -First 1
|
||||
$clangBinPath = if ($clangBin) { "$($clangBin.FullName)\bin" } else { "" }
|
||||
|
||||
$xtensaBin = Get-ChildItem "$espToolchainPath" -Recurse -Directory -Filter "xtensa-esp-elf" -ErrorAction SilentlyContinue |
|
||||
Select-Object -First 1
|
||||
$xtensaBinPath = if ($xtensaBin) { "$($xtensaBin.FullName)\bin" } else { "" }
|
||||
|
||||
# Set environment variables
|
||||
$env:LIBCLANG_PATH = Split-Path $libclang.FullName
|
||||
$env:RUSTUP_TOOLCHAIN = "esp"
|
||||
$env:ESP_IDF_VERSION = "v5.1.2"
|
||||
|
||||
# Build PATH with all required directories
|
||||
$pathParts = @(
|
||||
$pythonPath,
|
||||
"$pythonPath\Scripts",
|
||||
$clangBinPath,
|
||||
$xtensaBinPath,
|
||||
"$cargoHome\bin"
|
||||
) | Where-Object { $_ -ne "" }
|
||||
|
||||
$env:PATH = ($pathParts -join ";") + ";" + $env:PATH
|
||||
|
||||
Write-Host "Build Configuration:" -ForegroundColor Gray
|
||||
Write-Host " Target: $Target"
|
||||
Write-Host " Release: $Release"
|
||||
Write-Host " Toolchain: $($espToolchain.Name)"
|
||||
Write-Host " LIBCLANG_PATH: $($env:LIBCLANG_PATH)"
|
||||
Write-Host ""
|
||||
|
||||
# Navigate to project directory
|
||||
$projectDir = Split-Path -Parent (Split-Path -Parent $PSScriptRoot)
|
||||
Push-Location $projectDir
|
||||
|
||||
try {
|
||||
# Build cargo command
|
||||
$cargoArgs = @("build")
|
||||
|
||||
if ($Release) {
|
||||
$cargoArgs += "--release"
|
||||
}
|
||||
|
||||
if ($Features) {
|
||||
$cargoArgs += "--features"
|
||||
$cargoArgs += $Features
|
||||
}
|
||||
|
||||
Write-Host "Running: cargo $($cargoArgs -join ' ')" -ForegroundColor Gray
|
||||
Write-Host ""
|
||||
|
||||
& cargo @cargoArgs
|
||||
|
||||
if ($LASTEXITCODE -ne 0) {
|
||||
throw "Build failed with exit code $LASTEXITCODE"
|
||||
}
|
||||
|
||||
Write-Host ""
|
||||
Write-Host "Build successful!" -ForegroundColor Green
|
||||
|
||||
# Find the built binary
|
||||
$buildDir = if ($Release) { "release" } else { "debug" }
|
||||
$binary = Get-ChildItem "$projectDir\target\$Target\$buildDir" -Filter "*.elf" -ErrorAction SilentlyContinue |
|
||||
Where-Object { $_.Name -notmatch "deps" } |
|
||||
Select-Object -First 1
|
||||
|
||||
if ($binary) {
|
||||
Write-Host "Binary: $($binary.FullName)" -ForegroundColor Cyan
|
||||
}
|
||||
|
||||
Write-Host ""
|
||||
Write-Host "Next: Run .\flash.ps1 to flash to device" -ForegroundColor Yellow
|
||||
|
||||
} finally {
|
||||
Pop-Location
|
||||
}
|
||||
60
examples/ruvLLM/esp32-flash/scripts/windows/env.ps1
Normal file
60
examples/ruvLLM/esp32-flash/scripts/windows/env.ps1
Normal file
@@ -0,0 +1,60 @@
|
||||
# env.ps1 - Set up ESP32 Rust environment for the current session
|
||||
# Source this script: . .\env.ps1
|
||||
|
||||
$ErrorActionPreference = "SilentlyContinue"
|
||||
|
||||
# Find paths
|
||||
$rustupHome = if ($env:RUSTUP_HOME) { $env:RUSTUP_HOME } else { "$env:USERPROFILE\.rustup" }
|
||||
$cargoHome = if ($env:CARGO_HOME) { $env:CARGO_HOME } else { "$env:USERPROFILE\.cargo" }
|
||||
|
||||
# Find ESP toolchain
|
||||
$espToolchain = (Get-ChildItem "$rustupHome\toolchains" -Directory |
|
||||
Where-Object { $_.Name -like "esp*" } |
|
||||
Select-Object -First 1)
|
||||
|
||||
if (-not $espToolchain) {
|
||||
Write-Host "ESP toolchain not found. Run setup.ps1 first." -ForegroundColor Red
|
||||
return
|
||||
}
|
||||
|
||||
$espToolchainPath = $espToolchain.FullName
|
||||
|
||||
# Find libclang
|
||||
$libclang = Get-ChildItem "$espToolchainPath" -Recurse -Filter "libclang.dll" |
|
||||
Select-Object -First 1
|
||||
|
||||
# Find clang bin
|
||||
$clangBin = Get-ChildItem "$espToolchainPath" -Recurse -Directory -Filter "esp-clang" |
|
||||
Select-Object -First 1
|
||||
|
||||
# Find xtensa-esp-elf bin
|
||||
$xtensaBin = Get-ChildItem "$espToolchainPath" -Recurse -Directory -Filter "xtensa-esp-elf" |
|
||||
Select-Object -First 1
|
||||
|
||||
# Find Python
|
||||
$python = Get-Command python -ErrorAction SilentlyContinue
|
||||
$pythonPath = if ($python) { Split-Path $python.Source } else { "" }
|
||||
|
||||
# Set environment variables
|
||||
$env:LIBCLANG_PATH = if ($libclang) { Split-Path $libclang.FullName } else { "" }
|
||||
$env:RUSTUP_TOOLCHAIN = "esp"
|
||||
$env:ESP_IDF_VERSION = "v5.1.2"
|
||||
|
||||
# Build PATH
|
||||
$pathAdditions = @()
|
||||
if ($pythonPath) { $pathAdditions += $pythonPath; $pathAdditions += "$pythonPath\Scripts" }
|
||||
if ($clangBin) { $pathAdditions += "$($clangBin.FullName)\bin" }
|
||||
if ($xtensaBin) { $pathAdditions += "$($xtensaBin.FullName)\bin" }
|
||||
$pathAdditions += "$cargoHome\bin"
|
||||
|
||||
$env:PATH = ($pathAdditions -join ";") + ";" + $env:PATH
|
||||
|
||||
# Display status
|
||||
Write-Host ""
|
||||
Write-Host "ESP32 Rust environment loaded" -ForegroundColor Green
|
||||
Write-Host ""
|
||||
Write-Host " RUSTUP_TOOLCHAIN: $($env:RUSTUP_TOOLCHAIN)" -ForegroundColor Gray
|
||||
Write-Host " LIBCLANG_PATH: $($env:LIBCLANG_PATH)" -ForegroundColor Gray
|
||||
Write-Host " ESP_IDF_VERSION: $($env:ESP_IDF_VERSION)" -ForegroundColor Gray
|
||||
Write-Host ""
|
||||
Write-Host "Ready to build! Run: .\build.ps1" -ForegroundColor Cyan
|
||||
99
examples/ruvLLM/esp32-flash/scripts/windows/flash.ps1
Normal file
99
examples/ruvLLM/esp32-flash/scripts/windows/flash.ps1
Normal file
@@ -0,0 +1,99 @@
|
||||
# flash.ps1 - Auto-detect COM port and flash RuvLLM ESP32
|
||||
# Automatically finds connected ESP32 devices
|
||||
|
||||
param(
|
||||
[string]$Port = "",
|
||||
[switch]$Monitor = $true,
|
||||
[string]$Target = "xtensa-esp32-espidf",
|
||||
[switch]$Release = $true
|
||||
)
|
||||
|
||||
$ErrorActionPreference = "Stop"
|
||||
|
||||
Write-Host "`n=== RuvLLM ESP32 Flash ===" -ForegroundColor Cyan
|
||||
Write-Host ""
|
||||
|
||||
# Auto-detect COM port if not specified
|
||||
if (-not $Port) {
|
||||
# Get available COM ports
|
||||
Add-Type -AssemblyName System.IO.Ports
|
||||
$ports = [System.IO.Ports.SerialPort]::GetPortNames() |
|
||||
Where-Object { $_ -match "COM\d+" } |
|
||||
Sort-Object { [int]($_ -replace "COM", "") }
|
||||
|
||||
if ($ports.Count -eq 0) {
|
||||
Write-Error "No COM ports found. Is the ESP32 connected via USB?"
|
||||
} elseif ($ports.Count -eq 1) {
|
||||
$Port = $ports[0]
|
||||
Write-Host "Auto-detected port: $Port" -ForegroundColor Green
|
||||
} else {
|
||||
Write-Host "Multiple COM ports found:" -ForegroundColor Yellow
|
||||
Write-Host ""
|
||||
for ($i = 0; $i -lt $ports.Count; $i++) {
|
||||
Write-Host " [$i] $($ports[$i])"
|
||||
}
|
||||
Write-Host ""
|
||||
$selection = Read-Host "Select port (0-$($ports.Count - 1))"
|
||||
|
||||
if ($selection -match "^\d+$" -and [int]$selection -lt $ports.Count) {
|
||||
$Port = $ports[[int]$selection]
|
||||
} else {
|
||||
Write-Error "Invalid selection"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Write-Host "Using port: $Port" -ForegroundColor Cyan
|
||||
Write-Host ""
|
||||
|
||||
# Find binary
|
||||
$projectDir = Split-Path -Parent (Split-Path -Parent $PSScriptRoot)
|
||||
$buildDir = if ($Release) { "release" } else { "debug" }
|
||||
$targetDir = "$projectDir\target\$Target\$buildDir"
|
||||
|
||||
# Look for ELF or binary file
|
||||
$binary = Get-ChildItem $targetDir -Filter "*.elf" -ErrorAction SilentlyContinue |
|
||||
Where-Object { $_.Name -notmatch "deps" } |
|
||||
Select-Object -First 1
|
||||
|
||||
if (-not $binary) {
|
||||
$binary = Get-ChildItem $targetDir -Filter "ruvllm-esp32*" -ErrorAction SilentlyContinue |
|
||||
Where-Object { $_.Name -notmatch "\." -or $_.Name -match "\.elf$" } |
|
||||
Select-Object -First 1
|
||||
}
|
||||
|
||||
if (-not $binary) {
|
||||
Write-Host "Available files in $targetDir`:" -ForegroundColor Yellow
|
||||
Get-ChildItem $targetDir -ErrorAction SilentlyContinue | ForEach-Object { Write-Host " $($_.Name)" }
|
||||
Write-Error "No binary found. Run .\build.ps1 first"
|
||||
}
|
||||
|
||||
Write-Host "Binary: $($binary.Name)" -ForegroundColor Gray
|
||||
Write-Host ""
|
||||
|
||||
# Check for espflash
|
||||
$espflash = Get-Command espflash -ErrorAction SilentlyContinue
|
||||
if (-not $espflash) {
|
||||
Write-Error "espflash not found. Run .\setup.ps1 first"
|
||||
}
|
||||
|
||||
# Build espflash command
|
||||
$espflashArgs = @("flash", "--port", $Port, $binary.FullName)
|
||||
|
||||
if ($Monitor) {
|
||||
$espflashArgs += "--monitor"
|
||||
}
|
||||
|
||||
Write-Host "Flashing..." -ForegroundColor Cyan
|
||||
Write-Host "Command: espflash $($espflashArgs -join ' ')" -ForegroundColor Gray
|
||||
Write-Host ""
|
||||
|
||||
# Flash the device
|
||||
& espflash @espflashArgs
|
||||
|
||||
if ($LASTEXITCODE -ne 0) {
|
||||
Write-Error "Flash failed with exit code $LASTEXITCODE"
|
||||
}
|
||||
|
||||
Write-Host ""
|
||||
Write-Host "Flash complete!" -ForegroundColor Green
|
||||
41
examples/ruvLLM/esp32-flash/scripts/windows/monitor.ps1
Normal file
41
examples/ruvLLM/esp32-flash/scripts/windows/monitor.ps1
Normal file
@@ -0,0 +1,41 @@
|
||||
# monitor.ps1 - Open serial monitor for ESP32
|
||||
# Auto-detects COM port
|
||||
|
||||
param(
|
||||
[string]$Port = "",
|
||||
[int]$Baud = 115200
|
||||
)
|
||||
|
||||
$ErrorActionPreference = "Stop"
|
||||
|
||||
Write-Host "`n=== RuvLLM ESP32 Serial Monitor ===" -ForegroundColor Cyan
|
||||
Write-Host ""
|
||||
|
||||
# Auto-detect COM port if not specified
|
||||
if (-not $Port) {
|
||||
Add-Type -AssemblyName System.IO.Ports
|
||||
$ports = [System.IO.Ports.SerialPort]::GetPortNames() |
|
||||
Where-Object { $_ -match "COM\d+" } |
|
||||
Sort-Object { [int]($_ -replace "COM", "") }
|
||||
|
||||
if ($ports.Count -eq 0) {
|
||||
Write-Error "No COM ports found. Is the ESP32 connected?"
|
||||
} elseif ($ports.Count -eq 1) {
|
||||
$Port = $ports[0]
|
||||
Write-Host "Auto-detected port: $Port" -ForegroundColor Green
|
||||
} else {
|
||||
Write-Host "Multiple COM ports found:" -ForegroundColor Yellow
|
||||
for ($i = 0; $i -lt $ports.Count; $i++) {
|
||||
Write-Host " [$i] $($ports[$i])"
|
||||
}
|
||||
$selection = Read-Host "Select port (0-$($ports.Count - 1))"
|
||||
$Port = $ports[[int]$selection]
|
||||
}
|
||||
}
|
||||
|
||||
Write-Host "Opening monitor on $Port at $Baud baud..." -ForegroundColor Cyan
|
||||
Write-Host "Press Ctrl+C to exit" -ForegroundColor Gray
|
||||
Write-Host ""
|
||||
|
||||
# Use espflash monitor
|
||||
& espflash monitor --port $Port --baud $Baud
|
||||
118
examples/ruvLLM/esp32-flash/scripts/windows/setup.ps1
Normal file
118
examples/ruvLLM/esp32-flash/scripts/windows/setup.ps1
Normal file
@@ -0,0 +1,118 @@
|
||||
# setup.ps1 - One-time Windows setup for RuvLLM ESP32
|
||||
# Run this once to install/configure the ESP32 Rust toolchain
|
||||
|
||||
$ErrorActionPreference = "Stop"
|
||||
|
||||
Write-Host "`n=== RuvLLM ESP32 Windows Setup ===" -ForegroundColor Cyan
|
||||
Write-Host ""
|
||||
|
||||
# Find Rust ESP toolchain dynamically
|
||||
$rustupHome = if ($env:RUSTUP_HOME) { $env:RUSTUP_HOME } else { "$env:USERPROFILE\.rustup" }
|
||||
$cargoHome = if ($env:CARGO_HOME) { $env:CARGO_HOME } else { "$env:USERPROFILE\.cargo" }
|
||||
|
||||
# Check if Rust is installed
|
||||
$rustc = Get-Command rustc -ErrorAction SilentlyContinue
|
||||
if (-not $rustc) {
|
||||
Write-Host "Rust not found. Installing rustup..." -ForegroundColor Yellow
|
||||
Invoke-WebRequest -Uri "https://win.rustup.rs/x86_64" -OutFile rustup-init.exe
|
||||
.\rustup-init.exe -y --default-toolchain stable
|
||||
Remove-Item rustup-init.exe
|
||||
$env:PATH = "$cargoHome\bin;" + $env:PATH
|
||||
Write-Host "Rust installed successfully" -ForegroundColor Green
|
||||
}
|
||||
|
||||
# Find or install ESP toolchain
|
||||
$espToolchain = Get-ChildItem "$rustupHome\toolchains" -Directory -ErrorAction SilentlyContinue |
|
||||
Where-Object { $_.Name -like "esp*" } |
|
||||
Select-Object -First 1
|
||||
|
||||
if (-not $espToolchain) {
|
||||
Write-Host "ESP toolchain not found. Installing espup..." -ForegroundColor Yellow
|
||||
|
||||
# Download espup
|
||||
$espupUrl = "https://github.com/esp-rs/espup/releases/latest/download/espup-x86_64-pc-windows-msvc.exe"
|
||||
$espupPath = "$env:TEMP\espup.exe"
|
||||
|
||||
Write-Host "Downloading espup..." -ForegroundColor Gray
|
||||
Invoke-WebRequest -Uri $espupUrl -OutFile $espupPath
|
||||
|
||||
Write-Host "Running espup install (this may take several minutes)..." -ForegroundColor Gray
|
||||
& $espupPath install
|
||||
|
||||
if ($LASTEXITCODE -ne 0) {
|
||||
Write-Error "espup install failed with exit code $LASTEXITCODE"
|
||||
}
|
||||
|
||||
Remove-Item $espupPath -ErrorAction SilentlyContinue
|
||||
|
||||
# Re-check for toolchain
|
||||
$espToolchain = Get-ChildItem "$rustupHome\toolchains" -Directory |
|
||||
Where-Object { $_.Name -like "esp*" } |
|
||||
Select-Object -First 1
|
||||
}
|
||||
|
||||
if (-not $espToolchain) {
|
||||
Write-Error "ESP toolchain installation failed. Please install manually: https://esp-rs.github.io/book/"
|
||||
}
|
||||
|
||||
Write-Host "Found ESP toolchain: $($espToolchain.Name)" -ForegroundColor Green
|
||||
|
||||
# Find Python
|
||||
$python = Get-Command python -ErrorAction SilentlyContinue
|
||||
if (-not $python) {
|
||||
$python = Get-Command python3 -ErrorAction SilentlyContinue
|
||||
}
|
||||
if (-not $python) {
|
||||
Write-Error "Python not found. Please install Python 3.8+ from https://python.org"
|
||||
}
|
||||
Write-Host "Found Python: $($python.Source)" -ForegroundColor Green
|
||||
|
||||
# Find libclang
|
||||
$libclang = Get-ChildItem "$($espToolchain.FullName)" -Recurse -Filter "libclang.dll" -ErrorAction SilentlyContinue |
|
||||
Select-Object -First 1
|
||||
|
||||
if ($libclang) {
|
||||
Write-Host "Found libclang: $($libclang.FullName)" -ForegroundColor Green
|
||||
} else {
|
||||
Write-Host "Warning: libclang.dll not found in toolchain" -ForegroundColor Yellow
|
||||
}
|
||||
|
||||
# Install espflash if not present
|
||||
$espflash = Get-Command espflash -ErrorAction SilentlyContinue
|
||||
if (-not $espflash) {
|
||||
Write-Host "Installing espflash..." -ForegroundColor Yellow
|
||||
cargo install espflash
|
||||
if ($LASTEXITCODE -ne 0) {
|
||||
Write-Error "espflash installation failed"
|
||||
}
|
||||
Write-Host "espflash installed successfully" -ForegroundColor Green
|
||||
} else {
|
||||
Write-Host "Found espflash: $($espflash.Source)" -ForegroundColor Green
|
||||
}
|
||||
|
||||
# Install ldproxy if not present
|
||||
$ldproxy = Get-Command ldproxy -ErrorAction SilentlyContinue
|
||||
if (-not $ldproxy) {
|
||||
Write-Host "Installing ldproxy..." -ForegroundColor Yellow
|
||||
cargo install ldproxy
|
||||
if ($LASTEXITCODE -ne 0) {
|
||||
Write-Error "ldproxy installation failed"
|
||||
}
|
||||
Write-Host "ldproxy installed successfully" -ForegroundColor Green
|
||||
}
|
||||
|
||||
Write-Host ""
|
||||
Write-Host "=== Setup Complete ===" -ForegroundColor Green
|
||||
Write-Host ""
|
||||
Write-Host "Summary:" -ForegroundColor Cyan
|
||||
Write-Host " Toolchain: $($espToolchain.Name)"
|
||||
Write-Host " Python: $($python.Source)"
|
||||
if ($libclang) {
|
||||
Write-Host " Libclang: $($libclang.FullName)"
|
||||
}
|
||||
Write-Host ""
|
||||
Write-Host "Next steps:" -ForegroundColor Yellow
|
||||
Write-Host " 1. Run: .\build.ps1"
|
||||
Write-Host " 2. Connect ESP32 via USB"
|
||||
Write-Host " 3. Run: .\flash.ps1"
|
||||
Write-Host ""
|
||||
Reference in New Issue
Block a user