Atmega328 Rainbowduino Programming via Arduino Issue

Michu,
the wiki page is now a very thorough presentation of the Rainbowduino - the one that was missing! So, thanks an awful lot from me too.

I had the very same problem, due to the fact that my Arduino and my Rainbowduino both have the same IC, namely the Atmega 368. Let me try to explain in some detail - bear with me, it takes quite a few words.

Imagine that you have a dual boot machine: at power on time it waits a few seconds for you to select something, and if you don’t touch the keyboard it then goes on with the default OS.

More or less, this is what happens when you power on an Arduino-derived card. The boot loader waits a few instants for a signal on the DTR serial line (marked as RESET on standard Arduinos). If it doesn’t see anything, it starts the sketch on the board. If it sees DTR go low during the boot phase, it will start the flashing routine instead. The latter code talks serially (using just RX/TX) to the flasher utily on your PC (avrdude in your case) and transfers the compiled sketch right into the board flash memory.

Now, back to our situation: the connection described by Michu is intended for using the Arduino as if it were an USB to serial adapter for the Rainbowduino. The trouble arises from the fact that at boot, when you want to flash the Rainbowduino, both cards will receive the reset signal and start their flashing routines.

All goes well if the two boards have different chips (say the 168 on the Arduino and the 368 on the Rainbowduino), because they use different serial protocols for flashing. The Arduino bootloader receives the wrong commands and times out, while the Rainbowduino bootloader goes on: net result, you end up with the sketch to the correct board. When you have the same chip on both cards, on the other hand, they will both happily answer at the same time to avdrude, thus corrupting the firmware upload process.

To avoid this problem, you only need to use a different serial adapter to connect your Rainbowduino to the PC: instead of the Arduino, use anything that drives RX/TX/DTR . I’ve used http://eshop.acmesystems.it/?id=DPI, but anything else would do.

If you only have one with RX/TX, don’t despair: just press the reset button on the Rainbowduino as soon as your IDE finishes compilation, to simulate the DTR low signal. It might take a couple of attempts to get the timing right, but it’s an easy trick.

To end with, I read that you might simply remove the Atmega chip from your Arduino in order to use it as a dumb USB to serial converter: it sounds like a nice idea, but I have not tried and I don’t know if it is really working or not.

HTH,

Antonio