#!/bin/bash
#########################################################################################
# Para o Projeto de Update de Firmware Arduino
#########################################################################################
# instalando o AvrDude:
/usr/bin/apt-get update -y
/usr/bin/apt-get install avrdude -y
# Detectar a Porta USB do arduino: Executar ANTES de conectar a placa na USB da RPi
/usr/bin/lsusb > /tmp/lsusb1.txt
/bin/ls /dev/tty* > /tmp/lstty1.txt
# Detectar a Porta USB do arduino: Executar DEPOIS de conectar a placa na USB da RPi
/usr/bin/lsusb > /tmp/lsusb2.txt
/bin/ls /dev/tty* > /tmp/lstty2.txt
# Modelo do conversor serial-usb de sua placa arduino:
/usr/bin/diff /tmp/lsusb2.txt /tmp/lsusb1.txt
# Porta que seu arduino está conectado: (Normalmente: /dev/ttyUSB0 ou /dev/ttyACM0)
/usr/bin/diff /tmp/lstty2.txt /tmp/lstty1.txt
# Arquivos .hex de exemplo para teste de gravação: (placa Uno ou Nano)
/usr/bin/wget www.lt38c.hturbo.com/tmp/blink1s.hex -O /tmp/blink1s.hex
/usr/bin/wget www.lt38c.hturbo.com/tmp/blink3s.hex -O /tmp/blink3s.hex
/usr/bin/wget www.lt38c.hturbo.com/tmp/blink5s.hex -O /tmp/blink5s.hex
# linha de comando para gravação do hex: * Verificar a porta do seu arduino e bps (57600 - bootloader antigo) *
/usr/bin/avrdude -c arduino -v -p m328p -P /dev/ttyUSB0 -b 115200 -D -U /tmp/blink1s.hex
/usr/bin/avrdude -c arduino -p m328p -P /dev/ttyUSB0 -b 115200 -D -U /tmp/blink3s.hex -q
/usr/bin/avrdude -c arduino -p m328p -P /dev/ttyUSB0 -b 115200 -D -U /tmp/blink5s.hex -q -q
#End