It's pretty simple, really, but the uses are endless. The most immediate use for me is that I could have a RPi onboard my ROV and I could flash new Arduino software to my ROV without having to turn it off or open it up. That alone would save my robotics team a lot of time!
Here's a quick little tutorial on how to do this.
Step 0: Install AVRDUDE on Your RPi
This step is very simple. Connect your RPi to the interent and type sudo apt-get install avrdude. That will install all of the necessary packages (assuming SSH is already installed and enabled).
Step 1: Write and Compile Your Code
Write your code as normal and compile it as normal using the Arduino IDE. The only catch here is that you'll want to go into settings and turn on the verbose mode for compilation so that you can find the hex file that the avr-gcc makes. It moves around each time, just FYI. The highlighted line (also the second to last line) is the path to the hex file.
Step 2: Copy the Hex File onto the RPi
This step should be pretty simple for any SSH familiar users. Just use the scp fileToCopy user@hostname:/fileToCopyTo command. In the screenshot above, you can see that I copied over two different hex files. Remember where you copied the hex file to!
Step 3: Burn the Hex File
First off, you'll need to SSH into your RPi. Just type ssh user@hostname into your command line. It'll ask you for user's password, so enter that. If you need help SSHing, you can find some awesome tutorials for your OS by using Google. Once you're in, you can burn the hex file using avrdude. For my Arduino Duemilanove, I know that it is in /dev/ttyUSB0. You can find out which USB port your Arduino is under by typing ls /dev/tty* before plugging in your Arduino and then again afterwards. Compare the results to find out the name of your Arduino. Keep in mind that it should always stay the same unless you plug in another Arduino. Now for burning the software. The command for the Arduino Duemilanove is avrdude -b 57600 -p m328p -c arduino -P /dev/ttyUSB0 -U flash:w:fileToBurn -v. That "v" is there for verbose output. Let's break down that command.
avrdude: the application being called
-b 57600: sets the baud rate to 57600, which is what the Arduino Duemilanove
-p m328p: sets the part number of the processor (the atmega328p in this case)
-c arduino: sets the programmer type to "arduino" (which should be used for ALL "normal" Arduino software flashing)
-P /dev/ttyUSB0: this sets the port
-U flash:w:fileToBurn: this tells avrdude to "perform a memory operation" that involves the writing of the specified file to the flash memory of the microprocessor
-v: verbose output
And that's all there is to it!
Enjoy!
Chris Konstad