diff --git a/FlashFirmware.bat b/FlashFirmware.bat deleted file mode 100644 index d11d3e6..0000000 --- a/FlashFirmware.bat +++ /dev/null @@ -1,65 +0,0 @@ -@echo off -REM ===================================================== -REM SledLink Quick Flash Tool - Windows Launcher -REM Flash pre-compiled firmware - no compilation! -REM ===================================================== - -setlocal enabledelayedexpansion - -echo. -echo ============================================ -echo SledLink Quick Flash Tool -echo Pre-compiled firmware ready to flash -echo ============================================ -echo. - -REM Change to the script directory -cd /d "%~dp0" - -echo Debug: Script directory is "%~dp0" -echo. - -REM Check for flash script -if exist "%~dp0flash_firmware.ps1" ( - echo Launching flash tool... - echo. - PowerShell -ExecutionPolicy Bypass -File "%~dp0flash_firmware.ps1" - goto :end_check -) - -if exist "%~dp0tools\flash_firmware.ps1" ( - echo Launching flash tool from tools... - echo. - PowerShell -ExecutionPolicy Bypass -File "%~dp0tools\flash_firmware.ps1" - goto :end_check -) - -echo. -echo ERROR: flash_firmware.ps1 not found! -echo. -echo Make sure you extracted the entire release ZIP file with -echo all directories and files intact. -echo. -echo The flash script should be at: -echo - flash_firmware.ps1 (in release root), or -echo - tools\flash_firmware.ps1 (in release tools folder) -echo. -echo Debugging info: -echo Script batch file is at: "%~dp0FlashFirmware.bat" -echo Looking for PS1 at: "%~dp0flash_firmware.ps1" -echo Or at: "%~dp0tools\flash_firmware.ps1" -echo. -pause -exit /b 1 - -:end_check - -if %ERRORLEVEL% NEQ 0 ( - echo. - echo ============================================ - echo Flash tool exited with an error - echo ============================================ - echo. -) - -endlocal diff --git a/UPLOAD_GUIDE.md b/UPLOAD_GUIDE.md index b1f1774..a76f7ac 100644 --- a/UPLOAD_GUIDE.md +++ b/UPLOAD_GUIDE.md @@ -9,9 +9,8 @@ The latest SledLink release package is available on GitHub: **[Download Latest Release](https://github.com/thompcd/SledLink/releases/latest)** Each release includes: -- Pre-compiled firmware binaries (ready to flash instantly) - Arduino source code for both controllers -- Upload/flash scripts for Windows +- Upload scripts for Windows, Mac, and Linux - This guide --- @@ -25,51 +24,21 @@ Each release includes: --- -## Flash Your Firmware +## Upload Your Firmware ---- - -## Standard Method: Quick Flash (Recommended) - -Pre-compiled firmware is ready to flash instantly - no compilation needed! - -### Windows - Quick Flash - -1. **Download the SledLink folder** to your computer from GitHub -2. **Extract the ZIP file** to a convenient location -3. **Connect your controller** via USB cable to your computer -4. **Double-click** `FlashFirmware.bat` in the main folder -5. **Select your controller type:** - - Type `1` if flashing a SLED Controller (with encoder) - - Type `2` if flashing a JUDGE Controller (display only) -6. **Flash happens automatically** - takes about 10 seconds -7. **Done!** Your controller restarts automatically - -That's it! Your system is now ready to use. - -### What is "Flashing"? - -Flashing writes the firmware directly to your controller's memory using pre-compiled binaries. It's much faster than compiling (10 seconds vs 60+ seconds) and requires no additional software beyond Windows. +Firmware is compiled fresh from source code during upload. This ensures compatibility with your system and allows for easy customization. --- -## For Advanced Users & Developers +### Windows -### Compile Firmware from Source Code - -If you need to modify the firmware or want the full Arduino development environment, you can compile from source instead of flashing pre-compiled binaries. This takes 60+ seconds instead of ~10 seconds. - ---- - -### Windows - Compile from Source - -1. **Download the SledLink folder** to your computer +1. **Download the SledLink folder** to your computer from GitHub 2. **Extract the ZIP file** to a convenient location -3. **Open the `tools` folder** in the release package -4. **Double-click** `Compile Firmware (Windows).bat` -5. **Follow the prompts** on screen +3. **Double-click** `Upload Firmware (Windows).bat` in the main folder +4. **Follow the prompts** on screen +5. The compilation and upload happens automatically -### Mac - Compile from Source +### Mac 1. **Download the SledLink folder** to your computer 2. **Open Terminal** (press Cmd+Space, type "Terminal", press Enter) @@ -104,7 +73,7 @@ If you need to modify the firmware or want the full Arduino development environm --- -### How Compile-from-Source Works +### How Upload Works 1. **Checks for Arduino CLI** - The build tool. Installs it if needed. 2. **Sets up ESP32 support** - Downloads ESP32 tools (first time only, ~500MB) @@ -116,21 +85,9 @@ If you need to modify the firmware or want the full Arduino development environm ## Troubleshooting -### Flash Method Issues - -#### "FlashFirmware.bat won't run" or Windows Defender blocks it - -- **Windows Defender SmartScreen:** Click **"More info"** then **"Run anyway"** -- **Right-click** the `.bat` file and select **"Run as administrator"** -- **Temporary solution:** Run from Command Prompt: `FlashFirmware.bat` - -#### "esptool.exe not found" - -- Make sure you **extracted the entire release ZIP** with all directories -- The file `firmware/tools/esptool.exe` must be present -- Try **re-downloading the release** if files seem to be missing +### "No serial devices found" -#### "No device found" during flash +Your controller might not be connected or recognized by Windows. Try these in order: @@ -140,19 +97,25 @@ Try these in order: 4. **Check Device Manager:** - Press `Win+X`, select "Device Manager" - Look for your device under "Ports (COM & LPT)" - - If it shows a warning icon, you need USB drivers + - If it shows a warning icon, you need USB drivers (see "USB Driver Issues" below) -#### "Flash failed" or timeout error +### "Upload failed" or timeout error -1. **Hold the BOOT button** on the ESP32 board during the first 5 seconds of flash - - The flash tool will tell you when it's starting +1. **Hold the BOOT button** on the ESP32 board during the first 5 seconds of upload + - The upload tool will tell you when it's starting - You can release BOOT after it begins 2. **Try a different USB cable** (charge-only cables won't work) 3. **Try a different USB port** 4. **Close other programs** that might be using the serial port (Arduino IDE, PuTTY, etc.) 5. **Try restarting your computer** -#### USB Driver Issues +### Windows: "Script won't run" or security error + +- **Right-click** `Upload Firmware (Windows).bat` and select **"Run as administrator"** +- If Windows SmartScreen blocks it, click **"More info"** then **"Run anyway"** +- **Temporary solution:** Run from Command Prompt: `"Upload Firmware (Windows).bat"` + +### USB Driver Issues If Windows doesn't recognize your device: @@ -166,28 +129,6 @@ If Windows doesn't recognize your device: If you're not sure which driver you need, try one - it won't hurt to have both installed. ---- - -### Method 2: Compile from Source - Troubleshooting - -### "No serial devices found" - -- **Try a different USB cable.** Some cables are "charge only" and don't have data wires. -- **Try a different USB port** on your computer. -- **Wait a few seconds** after plugging in for drivers to load. -- **Check Device Manager** (Windows) to see if the device appears with a warning icon. - -### "Upload failed" - -- **Unplug and replug** the USB cable, then try again. -- **Hold the BOOT button** on the ESP32 while the upload starts, then release it. -- **Close other programs** that might be using the serial port (like Arduino IDE or PuTTY). - -### Windows: "Script won't run" or security error - -- **Right-click** the `.bat` file and select **"Run as administrator"** -- If Windows SmartScreen blocks it, click **"More info"** then **"Run anyway"** - ### Mac: "Permission denied" Run this command first: diff --git a/build_release.sh b/build_release.sh index 57be458..3f9f004 100644 --- a/build_release.sh +++ b/build_release.sh @@ -64,68 +64,21 @@ fi echo "" echo "Creating release directory..." rm -rf "$OUTPUT_DIR" -mkdir -p "$OUTPUT_DIR/firmware/SledController" -mkdir -p "$OUTPUT_DIR/firmware/JudgeController" -mkdir -p "$OUTPUT_DIR/firmware/tools" +mkdir -p "$OUTPUT_DIR/firmware" mkdir -p "$OUTPUT_DIR/tools" mkdir -p "$OUTPUT_DIR/source" -# Copy flash tools (main method for users) -echo "Copying flash tools..." -cp "$SCRIPT_DIR/FlashFirmware.bat" "$OUTPUT_DIR/" -cp "$SCRIPT_DIR/flash_firmware.ps1" "$OUTPUT_DIR/" -chmod +x "$OUTPUT_DIR/flash_firmware.ps1" - -# Copy compile/upload tools (advanced method for developers) -echo "Copying advanced compile tools..." +# Copy upload tools for compiling from source +echo "Copying upload tools..." cp "$SCRIPT_DIR/upload_firmware.sh" "$OUTPUT_DIR/tools/" cp "$SCRIPT_DIR/upload_firmware.ps1" "$OUTPUT_DIR/tools/" -cp "$SCRIPT_DIR/Upload Firmware (Windows).bat" "$OUTPUT_DIR/tools/Compile Firmware (Windows).bat" +cp "$SCRIPT_DIR/Upload Firmware (Windows).bat" "$OUTPUT_DIR/" chmod +x "$OUTPUT_DIR/tools/upload_firmware.sh" # Copy source code echo "Copying source code..." cp -r "$SCRIPT_DIR/arduino" "$OUTPUT_DIR/source/" -# Compile firmware binaries -echo "" -echo "Compiling firmware binaries..." -echo " SledController..." -arduino-cli compile --fqbn esp32:esp32:esp32 --export-binaries \ - --output-dir "$SCRIPT_DIR/firmware_binaries/SledController" \ - "$SCRIPT_DIR/arduino/SledController" 2>&1 | grep -E "(Compiling|Archiving|Sketch uses|Global variables)" || true - -echo " JudgeController..." -arduino-cli compile --fqbn esp32:esp32:esp32 --export-binaries \ - --output-dir "$SCRIPT_DIR/firmware_binaries/JudgeController" \ - "$SCRIPT_DIR/arduino/JudgeController" 2>&1 | grep -E "(Compiling|Archiving|Sketch uses|Global variables)" || true - -# Package binaries into release -echo "Packaging firmware binaries..." -for controller in SledController JudgeController; do - BIN_DIR="$SCRIPT_DIR/firmware_binaries/$controller" - OUT_DIR="$OUTPUT_DIR/firmware/$controller" - - if [ -f "$BIN_DIR/${controller}.ino.bin" ]; then - cp "$BIN_DIR/${controller}.ino.bin" "$OUT_DIR/firmware.bin" - cp "$BIN_DIR/${controller}.ino.bootloader.bin" "$OUT_DIR/bootloader.bin" - cp "$BIN_DIR/${controller}.ino.partitions.bin" "$OUT_DIR/partitions.bin" - echo " ✓ $controller" - else - echo " ✗ $controller - binaries not found!" - fi -done - -# Extract and copy esptool -echo "Extracting esptool for Windows..." -ESPTOOL_DIR=$(find ~/.arduino15/packages/esp32/tools/esptool_py -type d -maxdepth 2 2>/dev/null | head -1) -if [ -f "$ESPTOOL_DIR/esptool.exe" ]; then - cp "$ESPTOOL_DIR/esptool.exe" "$OUTPUT_DIR/firmware/tools/" - echo " ✓ esptool.exe bundled" -else - echo " ⚠ esptool.exe not found - Windows flashing may not work" -fi - # Copy documentation echo "Copying documentation..." cp "$SCRIPT_DIR/UPLOAD_GUIDE.md" "$OUTPUT_DIR/" @@ -145,37 +98,35 @@ RELEASE INFORMATION Build Date: $(date +%Y-%m-%d) Download: https://github.com/thompcd/SledLink/releases/tag/$VERSION -This release contains PRE-COMPILED firmware ready to flash instantly! +This release contains source code and tools to compile and upload firmware to the SledLink system. CONTENTS -------- - firmware/ - Pre-compiled firmware binaries (ready to flash) - SledController/ - Sled controller binaries - JudgeController/ - Judge controller binaries - tools/ - esptool.exe for Windows - - Flash Firmware.bat - Main method: Double-click to flash firmware instantly - - source/ - Arduino source code (for advanced users and developers) + source/ - Arduino source code arduino/SledController/ - Sled controller source arduino/JudgeController/ - Judge controller source - tools/ - Advanced tools (for developers) - Compile Firmware (Windows).bat - Compile and upload from source code - upload_firmware.sh - Mac/Linux compile and upload script - upload_firmware.ps1 - Windows PowerShell compile and upload script + tools/ - Upload utilities + upload_firmware.sh - Mac/Linux upload script + upload_firmware.ps1 - Windows PowerShell upload script + Upload Firmware (Windows).bat - Double-click to upload firmware -QUICK START - FLASH FIRMWARE (RECOMMENDED) -------------------------------------------- -Pre-compiled firmware flashes in ~10 seconds - no compilation needed! + +QUICK START - UPLOAD FIRMWARE +----------------------------- +The firmware is compiled fresh from source code during upload. Windows: 1. Connect the controller via USB - 2. Double-click "Flash Firmware.bat" - 3. Select controller type (1=Sled, 2=Judge) - 4. Firmware flashes automatically! - 5. Controller restarts automatically + 2. Double-click "Upload Firmware (Windows).bat" + 3. Follow the prompts + +Mac/Linux: + 1. Connect the controller via USB + 2. Open Terminal in this folder + 3. Run: ./tools/upload_firmware.sh + 4. Follow the prompts WHICH CONTROLLER IS WHICH? @@ -197,13 +148,13 @@ See UPLOAD_GUIDE.md for detailed troubleshooting steps. Common issues: - "No device found" - Try a different USB cable (some are charge-only) - - "Flash failed" - Hold BOOT button on ESP32 during flash + - "Upload failed" - Hold BOOT button on ESP32 during upload - Driver issues - Install CP210x or CH340 USB driver for your OS SUPPORT ------- -For issues, visit: https://github.com/thompcd/SledLink/issues +For issues, visit: https://github.com/tulsasoftware/SledLink/issues ================================================================================ HEREDOC diff --git a/docs/README.md b/docs/README.md index 7ce59fc..23c2b62 100644 --- a/docs/README.md +++ b/docs/README.md @@ -225,13 +225,8 @@ SledLink/ ├── upload_firmware.ps1 # Windows PowerShell upload script ├── Upload Firmware (Windows).bat # Windows launcher (double-click) │ -│ # Flash Tools (pre-compiled binaries) -├── flash_firmware.sh # Mac/Linux flash script -├── flash_firmware.ps1 # Windows PowerShell flash script -├── Flash Firmware (Windows).bat # Windows launcher (double-click) -│ │ # Release & Documentation -├── build_release.sh # Build release package with binaries +├── build_release.sh # Build release package ├── UPLOAD_GUIDE.md # User guide for firmware upload └── release/ # Generated release packages (git-ignored) ``` diff --git a/docs/RELEASE_PROCESS.md b/docs/RELEASE_PROCESS.md index d9ee792..69145e9 100644 --- a/docs/RELEASE_PROCESS.md +++ b/docs/RELEASE_PROCESS.md @@ -41,8 +41,7 @@ git push origin v3.0.1 3. It will: - Validate the tag - Install dependencies - - Compile both firmwares - - Create release package + - Create release package with source code and upload tools - Create GitHub release - Upload ZIP file diff --git a/flash_firmware.ps1 b/flash_firmware.ps1 deleted file mode 100644 index b75f8d3..0000000 --- a/flash_firmware.ps1 +++ /dev/null @@ -1,350 +0,0 @@ -# -# SledLink Quick Flash Script for Windows -# Flashes pre-compiled firmware - no compilation required! -# - -$ErrorActionPreference = "Stop" - -# Get the directory where this script is located -$ScriptDir = Split-Path -Parent $MyInvocation.MyCommand.Path - -# Detect firmware directory location -# Release package root: firmware/ directory at same level as script -# Release package tools/: firmware/ directory at parent level -# Repo: firmware_binaries/ directory at root - -if (Test-Path (Join-Path $ScriptDir "firmware")) { - # Script is at release root - $FirmwareDir = Join-Path $ScriptDir "firmware" -} elseif (Test-Path (Join-Path $ScriptDir ".." "firmware")) { - # Script is in tools/ subdirectory - $FirmwareDir = Join-Path (Split-Path -Parent $ScriptDir) "firmware" -} elseif (Test-Path (Join-Path $ScriptDir "firmware_binaries")) { - # Development mode - use compiled binaries directly - $FirmwareDir = Join-Path $ScriptDir "firmware_binaries" -} else { - Write-Host "" - Write-Host "ERROR: Firmware directory not found!" -ForegroundColor Red - Write-Host "" - Write-Host "This script should be run from the SledLink release package." -ForegroundColor Yellow - Write-Host "Make sure you extracted the entire ZIP file with all directories." -ForegroundColor Yellow - Write-Host "" - Write-Host "Press any key to exit..." -ForegroundColor Gray - $null = $Host.UI.RawUI.ReadKey("NoEcho,IncludeKeyDown") - exit 1 -} - -# Find esptool.exe -$EsptoolPath = Join-Path $FirmwareDir "tools" "esptool.exe" -if (-not (Test-Path $EsptoolPath)) { - # Try alternative location in release package - $EsptoolPath = Join-Path (Split-Path -Parent $FirmwareDir) "firmware" "tools" "esptool.exe" -} - -############################################################################# -# Helper Functions -############################################################################# - -function Write-Header { - Clear-Host - Write-Host "" - Write-Host "================================================================" -ForegroundColor Cyan - Write-Host " SledLink Quick Flash Tool" -ForegroundColor White - Write-Host " Pre-Compiled Firmware (No Compilation Required)" -ForegroundColor Gray - Write-Host "================================================================" -ForegroundColor Cyan - Write-Host "" -} - -function Write-Success { - param([string]$Message) - Write-Host $Message -ForegroundColor Green -} - -function Write-Error-Custom { - param([string]$Message) - Write-Host $Message -ForegroundColor Red -} - -function Get-SerialPorts { - # Get COM ports using .NET which is most reliable - $ports = @() - - try { - # Get all available COM ports - $comPorts = [System.IO.Ports.SerialPort]::GetPortNames() - - if ($comPorts -and $comPorts.Count -gt 0) { - # Try to get friendly names from WMI - try { - $devices = Get-WmiObject Win32_PnPEntity | Where-Object { $_.Name -match "COM\d+" } - $deviceMap = @{} - foreach ($device in $devices) { - if ($device.Name -match "(COM\d+)") { - $deviceMap[$Matches[1]] = $device.Name - } - } - } catch { - $deviceMap = @{} - } - - # Create port objects with both Port and Name - foreach ($comPort in $comPorts) { - $displayName = if ($deviceMap.ContainsKey($comPort)) { - $deviceMap[$comPort] - } else { - $comPort - } - - $ports += @{ - Port = $comPort - Name = $displayName - } - } - } - } catch {} - - # If no ports found, try WMI as fallback - if ($ports.Count -eq 0) { - try { - $devices = Get-WmiObject Win32_PnPEntity | Where-Object { $_.Name -match "COM\d+" } - foreach ($device in $devices) { - if ($device.Name -match "(COM\d+)") { - $ports += @{ - Port = $Matches[1] - Name = $device.Name - } - } - } - } catch {} - } - - return , $ports -} - -function Select-Controller { - Write-Host "Which controller do you want to flash?" -ForegroundColor Cyan - Write-Host "" - Write-Host " 1) SLED Controller" -ForegroundColor White - Write-Host " - Goes on the sled with the measuring wheel" -ForegroundColor Gray - Write-Host " - Has the encoder connected" -ForegroundColor Gray - Write-Host "" - Write-Host " 2) JUDGE Controller" -ForegroundColor White - Write-Host " - Stays at the judge's table" -ForegroundColor Gray - Write-Host " - Displays distance measurements" -ForegroundColor Gray - Write-Host "" - - while ($true) { - $choice = Read-Host "Select controller (1 or 2)" - - switch ($choice) { - "1" { return "SledController" } - "2" { return "JudgeController" } - default { - Write-Host "Please enter 1 or 2" -ForegroundColor Yellow - Write-Host "" - } - } - } -} - -function Select-Port { - Write-Host "" - Write-Host "Connecting to device..." -ForegroundColor Cyan - Write-Host "Make sure your controller is connected via USB." -ForegroundColor Yellow - Write-Host "" - Write-Host "Press ENTER to scan for devices..." - $null = Read-Host - - Write-Host "Scanning for USB devices..." -ForegroundColor Cyan - - $ports = Get-SerialPorts - - if ($ports.Count -eq 0) { - Write-Host "" - Write-Error-Custom "ERROR: No USB devices found!" - Write-Host "" - Write-Host "Troubleshooting:" -ForegroundColor Yellow - Write-Host " 1. Try a different USB cable (some are charge-only)" -ForegroundColor Yellow - Write-Host " 2. Try a different USB port on your computer" -ForegroundColor Yellow - Write-Host " 3. Wait a few seconds and try again" -ForegroundColor Yellow - Write-Host " 4. Install USB drivers (CP210x or CH340)" -ForegroundColor Yellow - Write-Host "" - Write-Host "For more help, see UPLOAD_GUIDE.md in the release package." -ForegroundColor Yellow - Write-Host "" - Write-Host "Press any key to exit..." -ForegroundColor Gray - $null = $Host.UI.RawUI.ReadKey("NoEcho,IncludeKeyDown") - exit 1 - } - - if ($ports.Count -eq 1) { - $port = $ports[0].Port - Write-Success "✓ Found device on $port" - return $port - } - - # Multiple ports - let user choose - Write-Host "" - Write-Host "Multiple devices found:" -ForegroundColor Cyan - for ($i = 0; $i -lt $ports.Count; $i++) { - Write-Host " $($i+1)) $($ports[$i].Port) - $($ports[$i].Name)" -ForegroundColor White - } - Write-Host "" - - while ($true) { - $choice = Read-Host "Select device (1-$($ports.Count))" - - if ($choice -ge 1 -and $choice -le $ports.Count) { - $port = $ports[$choice - 1].Port - Write-Success "✓ Selected $port" - return $port - } else { - Write-Host "Please enter a number between 1 and $($ports.Count)" -ForegroundColor Yellow - } - } -} - -function Flash-Firmware { - param( - [string]$Controller, - [string]$Port - ) - - $controllerDir = Join-Path $FirmwareDir $Controller - $appBin = Join-Path $controllerDir "firmware.bin" - $bootBin = Join-Path $controllerDir "bootloader.bin" - $partBin = Join-Path $controllerDir "partitions.bin" - - # Verify firmware files exist - if (-not (Test-Path $appBin)) { - Write-Host "" - Write-Error-Custom "ERROR: Firmware file not found!" - Write-Host "Expected: $appBin" -ForegroundColor Yellow - Write-Host "" - Write-Host "The release package may be incomplete. Re-download from:" -ForegroundColor Yellow - Write-Host "https://github.com/thompcd/SledLink/releases" -ForegroundColor Yellow - Write-Host "" - Write-Host "Press any key to exit..." -ForegroundColor Gray - $null = $Host.UI.RawUI.ReadKey("NoEcho,IncludeKeyDown") - exit 1 - } - - if (-not (Test-Path $EsptoolPath)) { - Write-Host "" - Write-Error-Custom "ERROR: esptool.exe not found!" - Write-Host "Expected: $EsptoolPath" -ForegroundColor Yellow - Write-Host "" - Write-Host "The release package may be incomplete. Make sure you extracted" -ForegroundColor Yellow - Write-Host "the entire ZIP file with all directories." -ForegroundColor Yellow - Write-Host "" - Write-Host "Press any key to exit..." -ForegroundColor Gray - $null = $Host.UI.RawUI.ReadKey("NoEcho,IncludeKeyDown") - exit 1 - } - - # Show confirmation - Write-Host "" - Write-Host "Ready to flash:" -ForegroundColor Cyan - Write-Host " Controller: $Controller" -ForegroundColor White - Write-Host " Port: $Port" -ForegroundColor White - Write-Host " Firmware: $appBin" -ForegroundColor Gray - Write-Host "" - Write-Host "DO NOT disconnect the USB cable during flashing!" -ForegroundColor Yellow - Write-Host "" - - $confirm = Read-Host "Continue? (yes/no)" - if ($confirm -ne "yes" -and $confirm -ne "y") { - Write-Host "" - Write-Host "Flash cancelled." -ForegroundColor Yellow - Write-Host "" - Write-Host "Press any key to exit..." -ForegroundColor Gray - $null = $Host.UI.RawUI.ReadKey("NoEcho,IncludeKeyDown") - exit 0 - } - - # Flash the firmware - Write-Host "" - Write-Host "Flashing firmware..." -ForegroundColor Cyan - Write-Host "This may take 10-30 seconds..." -ForegroundColor Gray - Write-Host "" - - try { - # Build esptool command - $esptoolArgs = @( - "--chip", "esp32", - "--port", $Port, - "--baud", "460800", - "--before", "default_reset", - "--after", "hard_reset", - "write_flash", - "-z", - "--flash_mode", "dio", - "--flash_freq", "40m", - "--flash_size", "detect", - "0x1000", $bootBin, - "0x8000", $partBin, - "0x10000", $appBin - ) - - # Execute esptool - & $EsptoolPath $esptoolArgs - $exitCode = $LASTEXITCODE - - if ($exitCode -eq 0) { - Write-Host "" - Write-Host "========================================" -ForegroundColor Green - Write-Host " FLASH SUCCESSFUL!" -ForegroundColor Green - Write-Host "========================================" -ForegroundColor Green - Write-Host "" - Write-Host "Your controller will restart automatically." -ForegroundColor White - Write-Host "" - Write-Host "Next steps:" -ForegroundColor Cyan - Write-Host " 1. The controller should boot up in a few seconds" -ForegroundColor White - Write-Host " 2. The LCD display should show SledLink" -ForegroundColor White - Write-Host " 3. Your system is ready to use!" -ForegroundColor White - Write-Host "" - Write-Host "Press any key to exit..." -ForegroundColor Gray - $null = $Host.UI.RawUI.ReadKey("NoEcho,IncludeKeyDown") - } else { - Write-Host "" - Write-Error-Custom "Flash failed! (Exit code: $exitCode)" - Write-Host "" - Write-Host "Troubleshooting:" -ForegroundColor Yellow - Write-Host " 1. Hold the BOOT button on the ESP32 while flashing" -ForegroundColor Yellow - Write-Host " 2. Try a different USB cable (charge-only cables won't work)" -ForegroundColor Yellow - Write-Host " 3. Try a different USB port" -ForegroundColor Yellow - Write-Host " 4. Close other programs using the serial port" -ForegroundColor Yellow - Write-Host "" - Write-Host "For more help, see UPLOAD_GUIDE.md in the release package." -ForegroundColor Yellow - Write-Host "" - Write-Host "Press any key to exit..." -ForegroundColor Gray - $null = $Host.UI.RawUI.ReadKey("NoEcho,IncludeKeyDown") - exit 1 - } - } catch { - Write-Host "" - Write-Error-Custom "Error during flashing: $_" - Write-Host "" - Write-Host "Press any key to exit..." -ForegroundColor Gray - $null = $Host.UI.RawUI.ReadKey("NoEcho,IncludeKeyDown") - exit 1 - } -} - -############################################################################# -# Main Script -############################################################################# - -Write-Header - -Write-Host "This tool flashes pre-compiled firmware to your SledLink controller." -ForegroundColor White -Write-Host "Flashing takes about 10 seconds - no compilation needed!" -ForegroundColor White -Write-Host "" - -# Step 1: Select controller -$controller = Select-Controller - -# Step 2: Select port -$port = Select-Port - -# Step 3: Flash firmware -Flash-Firmware -Controller $controller -Port $port