The first thing is to get the firmware re-compiled. For that we need to download and unzip the firmware supplied by Sparkfun. Inside the zip file are three files; main.c, main.h, and a Makefile. The Makefile points to using WinAVR to rebuild this code. A quick trip via the WinAVR website, takes us to the download location on SourceForge. I used the latest installer file called WinAVR-20100110-install.exe Choosing the default install options, and making sure that the PATH environment variable was updated.
Opening up a cmd prompt and navigating to the unzipped firmware, it was then a simple case of using 'make clean' to verify that WinAVR was installed ok. Then 'make all' to rebuild the firmware. From the resulting files we only need the main.hex and main.eep files. These contain the hex dump ready for uploading to flash memory, and the EPROM (eep) file ready to burn into the ROB-09571.
So far so good. The next step was working out how to turn an Arduino into an AVR ISP programmer.
Looking at the Deumilanove and the ROB-09571, they both have ICSP headers breaking out the SPI lines.
On the Duemilanove the 6-pin header is clearly labelled. On the ROB-09571 you need to solder on a header (in my case, design of Project: Burt restricted me to a two row right angle header). On both boards pin 1 is conveniently labelled (top left of each header). A quick look at the Deumilanove schematic and ROB-09571 schematic shows that all the neccesary ICSP lines are connected to the 328p ICs. So it should be a simple case of connected pin 1 to pin 1, pin 2 to pin 2, etc. That sounds far too easy, and it is :)
Next is what code do we need to upload to the Arduino. I'm currently using version 018 of the Arduino SDK Included is a sketch called ArduinoISP. Looking at this code, it recommends adding three LEDs (and current limiting resistors) to three of the Arduino digital pins. A tutorial describing how to connect the LEDs to an Arduino can be found over at LadyAda. Below is my initial wiring setup.
BEWARE: This wiring setup will never work! Read on for why it doesn't work.
All three LEDs use 470 ohm resistors to limit current, connected with a common ground (blue wire). The green LED is connected to D9 (green wire), the red LED connects to D8 (red wire), and the yellow LED connects to D7 (white wire). These LEDs are used by the ArduinoISP sketch to inform you of progress and/or errors. The six green wires connect the two ICSP headers.
Uploading the ArduinoISP sketch to the Duemilanove we are now ready to try reflashing the ROB-09571. But WAIT!! One vital wire is in the wrong place!!
Looking at the Duemilanove schematic it clearly shows that pin 5 of the ICSP header is connected to the 328p RESET pin! This is fine to reset all boards connected via ICSP, but the ArduinoISP sketch requires a seperate slave reset. A quick fix is to disconnect the green wire to pin 5 of the ICSP header, and connect D10 from the Arduino to pin 5 ICSP header on the ROB-09571. This now agrees with the expected wiring connections in the ArduinoISP sketch. An alternative is not to use the ICSP header, and connect to D10, D11, D12, and D13 on the Arduino.
At last. A correct wiring setup! Now it's time to flash that hex file.
We now need to use a program supplied with WinAVR called AVRDude. This communicates with the ArduinoISP sketch, and uploads the hex file to the ROB-09571.
The first thing we need to do is test that the Arduino, plus ArduinoISP sketch, and the wiring is working ok. Use the following cmd prompt line (changing com21 to the port you have your Arduino connected);
avrdude -p m328p -P com21 -b 19200 -c avrisp -vYou should eventually see;
avrdude: AVR device initialized and ready to accept instructionsIf you receive any form of errors (protocol, sync, etc.), check your wiring.
We are now ready to upload our new ROB-09571 firmware. We can simply use the following commands;
avrdude -p m328p -P com21 -b 19200 -c avrisp -v -U flash:w:main.hexAVRDude prints out some nice progress text. And the yellow LED should flash rapidly when the programming occurs.
avrdude -p m328p -P com21 -b 19200 -c avrisp -v -U eeprom:w:main.eep
When AVRDude has finished succesfully, you then have completed uploading new firmware to the ROB-09571 :)