updated the power shell script to be simpler

This commit is contained in:
jakeg00dwin 2023-12-09 09:18:39 -08:00
parent bf4636d994
commit decabdf75f
1 changed files with 4 additions and 51 deletions

View File

@ -1,54 +1,7 @@
# PowerShell script to flash a precompiled HEX file via avrdude.exe with a USBasp programmer
# Path to avrdude.exe
# $AvrdudePath = "C:\path\to\avrdude.exe"
$AvrdudePath = "avrdude.exe"
$Mcu = "t13"
$HexFile ="\pre_built\attiny13_4-8Mhz.hex"
$Programmer="usbasp"
# Path to the USBasp configuration file (avrdude.conf)
$AvrdudeConf = "avrdude.conf"
# Path to the HEX file to be flashed
$HexFile = "pre_built\atiny13_4-8.hex"
# USBasp programmer options
$ProgrammerOptions = "-c usbasp"
# Microcontroller options (replace with the appropriate values for your microcontroller)
$MCU = "-p attiny13"
$BaudRate = "-B 10"
# Check if avrdude.exe exists
if (-not (Test-Path $AvrdudePath -PathType Leaf)) {
Write-Error "Error: avrdude.exe not found. Please set AvrdudePath in the script."
exit 1
}
# Check if the avrdude configuration file exists
if (-not (Test-Path $AvrdudeConf -PathType Leaf)) {
Write-Error "Error: avrdude.conf not found. Please set AvrdudeConf in the script."
exit 1
}
# Check if the HEX file exists
if (-not (Test-Path $HexFile -PathType Leaf)) {
Write-Error "Error: HEX file not found. Please set HexFile in the script."
exit 1
}
# Build avrdude command
$AvrdudeCommand = "$AvrdudePath -C $AvrdudeConf $ProgrammerOptions $MCU $BaudRate -U flash:w:$HexFile"
# Run avrdude command
Write-Host "Flashing HEX file..."
Invoke-Expression $AvrdudeCommand
# Check avrdude exit code
if ($LASTEXITCODE -eq 0) {
Write-Host "Flashing completed successfully."
} else {
Write-Host "Flashing failed. Check avrdude output for details."
}
# Exit with avrdude exit code
exit $LASTEXITCODE
.\avrdude.exe -p $Mxu -B 10 -c $Programmer -U flash:w:$HexFile