Raspberry Pi Program Arduino Over Serial/ttyAMA0 by avrdude with auto reset

posted 27 Feb 2017, 09:20 by Nhan Le Duy   [ updated 27 Feb 2017, 09:20 by Lê Duy Nhân ]
1. Googge it to enable serial port uart on Rpi (look at /boot/config.txt and /boot/cmdline.txt)
2. Install Avrdude as this $sudo apt-het install avrdude
    the avrdude.conf is in /etc/avrdude.conf, take a look to read it for extend control later
3. If you need auto reset on programming please install wiringPi for GPIO conrol
4. Create a folder name arduino and create a 'bash' file upload (For eample file below is using for program Arduino Pro Mini at baud=57600)

gpio mode 28 out
gpio write 28 1
gpio write 28 0
gpio write 28 1
avrdude /etc/avrdude.conf -v -V -patmega328p -carduino -P /dev/ttyAMA0 -b57600 -D -Uflash:w:$1:i
gpio mode 28 in

5. Connect Reset Pin to GPIO28
6. For example you need to program modbus.hex to Arduino Pro: 
        pi@raspberrypi:~/arduino $ nano upload modbus.hex
7. Complete