nanoflasher.sh 782 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. #!/bin/sh
  2. # Flashing of the Arduino Nano, using avrdude installed like Fedora.
  3. # Usage:
  4. # ${OUTFILE} [-n] [<PORT>]
  5. #
  6. # where -n is for boards with the "new" bootloader, called optiboot.
  7. # <PORT> is the device name, default /dev/ttyUSB0.
  8. if [ "$1" = "-n" ] ; then
  9. BAUD=115200
  10. shift
  11. else
  12. BAUD=57600
  13. fi
  14. if [ $# -eq 1 ] ; then
  15. PORT=/dev/ttyUSB0
  16. elif [ $# -eq 2 ] ; then
  17. PORT=$2
  18. else
  19. echo -e usage: \\n\\t$0 hexfile [device]
  20. exit 1
  21. fi
  22. AVRDUDE=/usr/bin/avrdude
  23. AVRDUDE_CONF=/etc/avrdude/avrdude.conf
  24. PART=atmega328p
  25. PROGRAMMER_ID=arduino
  26. HEXFILE=$1
  27. if [ -f ${AVRDUDE_CONF} ] ; then
  28. AVRDUDE_CONF_OPTION=-C${AVRDUDE_CONF}
  29. fi
  30. ${AVRDUDE} ${AVRDUDE_CONF_OPTION} \
  31. -v -p${PART} -c${PROGRAMMER_ID} -P${PORT} -b${BAUD} -D \
  32. -Uflash:w:${HEXFILE}:i