Atmega328 Rainbowduino Programming via Arduino Issue

Arduino, Seeeduino Serials and mutants. Share your problems and experence on arduino compatible board such as seeeduino/stalker, etc.

Moderators: lily.li, violet, salmanfarisvp

ant9000
Kindergarten
Kindergarten
Posts: 54
Joined: Tue Nov 02, 2010 3:08 pm

Re: Atmega328 Rainbowduino Programming via Arduino Issue

Post by ant9000 » Fri Jan 07, 2011 1:29 am

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.
miso wrote:I still experience problems with uploading the firmware to the rainbowduino through the arduino. The error I get is the following:
avrdude: stk500_paged_write(): (a) protocol error, expect=0x14, resp=0x95
avrdude: failed to write flash memory, rc=-4
avrdude: stk500_disable(): protocol error, expect=0x14, resp=0xf1
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

michu
Kindergarten
Kindergarten
Posts: 55
Joined: Thu Jun 17, 2010 12:36 am
Location: Switzerland
Contact:

Re: Atmega328 Rainbowduino Programming via Arduino Issue

Post by michu » Fri Jan 07, 2011 3:58 pm

hey antonio, thanks for your detailed message - i didnt know that.

however, I flashed my rainbowduino v2 (using an atmega 328) fw at least 50times without any issues using:
-upload clean sketch to arduino
-connect rx+tx (other cables are always connected)
-upload rainbowduino fw
-disconnect cables
-upload arduino fw

what happens if you connect the reset line from the arduino with the rainbowduinos, isn't that like a pass through? (like rx/tx)?

cheers


@miso: strange - I also use an mac book, without any issues...

miso
Pre-kindergarten
Pre-kindergarten
Posts: 20
Joined: Wed Jan 05, 2011 2:15 am

Re: Atmega328 Rainbowduino Programming via Arduino Issue

Post by miso » Sat Jan 08, 2011 7:10 am

Hello michu and antonio. Thanks for the feedback.

Unfortunately I have not managed to upload any sketches to the rainbowduino through the black widow device. I have powered it up using the JST but also through the 5v pin. What I found strange was that some onboard leds on the rainbowduino were still on when only tx,rx and gnd where connected between the two devices (no power was provided through jst).

@antonio - Thanks for the info, this makes sense. I found some posts in the past, where people said that using two atmega328 devices in such a configuration was not possible but this is the best explanation. As far as removing the atmega it is too risky so I prefer not to try it. I believe in some post that I came across in the past someone mentioned something about putting a resistor between some of the pins on the arduino but I cant remember what the purpose was exactly and where i found that post.

@michu - Since your configuration works, I can only think of two things that could be happening. 1) My black widow which is based on the duemilanove does something differently to your device. 2) Something I am doing is not right or I damaged the equipment.
I would like to believe that I am just doing something wrong. If we don't manage to resolve this issue during the weekend I will have to place an order for a UARTSB device like antonio suggested. Please let me know if you have any other suggestions that can help me avoid that.
The link you have provided me in a previous post is great for checking the wiring. In other pictures i found, it was not clear where exactly the pins/wires were connecting and as you know both devices have more than one connections named the same and that brought some confusion as whether my wires were connected correctly.
My wiring is exactly the same as the diagrams with the exeption that I have provided a 9v input through the JST or a 5v input through the arduino.


Thanks,
M

michu
Kindergarten
Kindergarten
Posts: 55
Joined: Thu Jun 17, 2010 12:36 am
Location: Switzerland
Contact:

Re: Atmega328 Rainbowduino Programming via Arduino Issue

Post by michu » Sat Jan 08, 2011 6:08 pm

hey miso - I can confirm upload a firmware to a 328 rainbowduino works with the arduino duemillanove and seeedstudio seeeduino.

looks like a black widow bug?

cheers

miso
Pre-kindergarten
Pre-kindergarten
Posts: 20
Joined: Wed Jan 05, 2011 2:15 am

Re: Atmega328 Rainbowduino Programming via Arduino Issue

Post by miso » Sat Jan 08, 2011 8:14 pm

Hi michu.

Thanks for your efforts.
I have placed an order for a UARTSB device from http://www.airsensor.co.uk/shop.html?pa ... oduct_id=4 as they offer next day delivery and I need to make some faster progress. I would have otherwise order the other device from seeedstudio.

Do you know if this device can be used through the arduino ide in the same way as any arduino type device? I am right to assume that you just plug it in the rainbowduino, connect the usb to it and just upload the sketch?

Thanks,
M

michu
Kindergarten
Kindergarten
Posts: 55
Joined: Thu Jun 17, 2010 12:36 am
Location: Switzerland
Contact:

Re: Atmega328 Rainbowduino Programming via Arduino Issue

Post by michu » Sat Jan 08, 2011 10:09 pm

thats correct, plug in usb and in the rainbowduino and you're set. I'll add a description to the wiki soon.

cheers


Edit: DONE: http://garden.seeedstudio.com/index.php ... d_firmware

ant9000
Kindergarten
Kindergarten
Posts: 54
Joined: Tue Nov 02, 2010 3:08 pm

Re: Atmega328 Rainbowduino Programming via Arduino Issue

Post by ant9000 » Sun Jan 09, 2011 10:25 pm

michu wrote:I flashed my rainbowduino v2 (using an atmega 328) fw at least 50times without any issues using:
-upload clean sketch to arduino
-connect rx+tx (other cables are always connected)
-upload rainbowduino fw
-disconnect cables
-upload arduino fw
what happens if you connect the reset line from the arduino with the rainbowduinos, isn't that like a pass through? (like rx/tx)?
Hello Michu,
I tried exactly the same thing with my Arduino Duemilanove (368 based) and Rainbowduino v2 (same chip) with no luck (it was the very reason that lead me to study the Arduino bootloader process, in fact). What I can tell is that in theory your setup with identical chips should not work, since they share the same bootloader. One possibility is that one of the two boards uses the old 19200 baud bootloader, while the other has the new running at 57600 - the Arduino IDE is smart enough to notice when programming the board, and you won't even know it.

For your reference:
michu wrote:what happens if you connect the reset line from the arduino with the rainbowduinos, isn't that like a pass through? (like rx/tx)?
It passes the reset signal on to the connected board; but the signal also arrives to the Arduino IC (as you can see from the L led flashing).

Antonio

ant9000
Kindergarten
Kindergarten
Posts: 54
Joined: Tue Nov 02, 2010 3:08 pm

Re: Atmega328 Rainbowduino Programming via Arduino Issue

Post by ant9000 » Sun Jan 09, 2011 10:35 pm

miso wrote:@antonio - Thanks for the info, this makes sense. I found some posts in the past, where people said that using two atmega328 devices in such a configuration was not possible but this is the best explanation.
You're welcome; I gathered the info looking a bit further in the Arduino docs, everything was already there - if you only know where to look, as usual ;-)
miso wrote:As far as removing the atmega it is too risky so I prefer not to try it.
I followed the same path, and used a serial device I already had.
@michu - Since your configuration works, I can only think of two things that could be happening. 1) My black widow which is based on the duemilanove does something differently to your device. 2) Something I am doing is not right or I damaged the equipment.
I have an original Arduino 2009 and a Rainbowduino v2 - my results are the same as yours, and from the various posts on the forum you see that quite a lot of people have had the same problem in the past.
Please let me know if you have any other suggestions that can help me avoid that.
The only thing I can think of is reflashing one of the two bootloaders and use a different version (maybe the older one, which was slower). But you would need an AVR programmer of some sort for that, AFAIK.

Antonio

miso
Pre-kindergarten
Pre-kindergarten
Posts: 20
Joined: Wed Jan 05, 2011 2:15 am

Re: Atmega328 Rainbowduino Programming via Arduino Issue

Post by miso » Mon Jan 10, 2011 12:57 am

Hello Antonio.
Thanks for the new information.
As I already purchased a new device, I think for the time being I will not spend time learning more staff about bootloaders but start having some fun with programming some LED effects.
I will start some new posts regarding my project in the near future.

Thanks,
M

michu
Kindergarten
Kindergarten
Posts: 55
Joined: Thu Jun 17, 2010 12:36 am
Location: Switzerland
Contact:

Re: Atmega328 Rainbowduino Programming via Arduino Issue

Post by michu » Mon Jan 10, 2011 4:01 pm

thanks for this answer ant9000, I just added it to the wiki. what do you think happens with an arduino UNO - as this device uses a different bootloader is there a chance the firmware upload will work fine?

Post Reply