-
Notifications
You must be signed in to change notification settings - Fork 47
Open
Description
Here is an example using AVRDUDE, based on the way Arduino IDE flashes after compilation.
Save the script to flash.sh, run chmod +x flash.sh, then call it like ./flash.sh firmware.hex. If avr is not installed, first install it with brew tap osx-cross/avr and brew install avr-gcc. Make sure to close uArmStudio and ArduinoIDE as they might interfere with the connection while flashing is in progress.
#!/bin/bash
# default location from `brew tap osx-cross/avr` and `brew install avr-gcc`
export AVR_PATH=/Applications/Arduino.app/Contents/Java/hardware/tools/avr/
export PROGRAM="$1"
# search for connected device
for i in $(seq 1 10); do
export DEVICE_ID=$(ls /dev/tty.usb* 2>&1 | grep -v "No such")
if [ -z "$DEVICE_ID" ]; then
echo -ne "[$i of 10] Looking for device, connect USB and double tap the button to put it in flash mode \033[0K\r"
sleep 1.5
else
echo "Found device, flashing ${PROGRAM} to ${DEVICE_ID}"
# flash the hex program to the device
$AVR_PATH/bin/avrdude \
-C$AVR_PATH/etc/avrdude.conf \
-v \
-patmega2560 \
-cwiring \
-P${DEVICE_ID} \
-b115200 \
-D \
-Uflash:w:${PROGRAM}:i
break
fi
doneMetadata
Metadata
Assignees
Labels
No labels