Skip to content

Instantly share code, notes, and snippets.

@victornpb
Last active May 27, 2024 19:05
Show Gist options
  • Save victornpb/292c93ce517c18a706d7dd53dadb8de4 to your computer and use it in GitHub Desktop.
Save victornpb/292c93ce517c18a706d7dd53dadb8de4 to your computer and use it in GitHub Desktop.
Arduino backup

Set these variables

Arduino Uno:

export BOARD=atmega328p
export PORT=/dev/tty.usbmodem14201
export BAUD=115200
export PROGRAMMER=arduino
export AVR_DIR=/Applications/Arduino.app/Contents/Java/hardware/tools/avr/bin

Arduino Mega:

export BOARD=m2560
export PORT=/dev/tty.usbmodem14101
export BAUD=115200
export PROGRAMMER=stk500v2
export AVR_DIR=/Applications/Arduino.app/Contents/Java/hardware/tools/avr/bin

CD to a folder like:

mkdir $HOME/Desktop/Backup_Arduino
cd $HOME/Desktop/Backup_Arduino

Backup

$AVR_DIR/avrdude -n -C $AVR_DIR/../etc/avrdude.conf -c $PROGRAMMER -p $BOARD -P $PORT -b$BAUD -U eeprom:r:eeprom.bin:r -U flash:r:flash.bin:r -v
echo "Restore with: $AVR_DIR/avrdude -C $AVR_DIR/../etc/avrdude.conf -c $PROGRAMMER -p $BOARD -P $PORT -b$BAUD -D -U eeprom:w:eeprom.bin:r -U flash:w:flash.bin:r -v -v" > readme.md
zip fw_backup.zip readme.md eeprom.bin flash.bin -T

Restore

$AVR_DIR/avrdude -C $AVR_DIR/../etc/avrdude.conf -c $PROGRAMMER -p $BOARD -P $PORT -b$BAUD -D -U eeprom:w:eeprom.bin:r -U flash:w:flash.bin:r -v -v
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment