Atmega328 Rainbowduino Programming via Arduino Issue

Has anyone been successful at programming a new Atmega328 Rainbowduino through their Atmega328 Arduino? Everytime I do, I get:

avrdude: stk500_paged_write(): (a) protocol error, expect=0x14, resp=0xfe
avrdude: failed to write flash memory, rc=-4

I have checked double, triple, quadruple…, about 10x checked that my setup is according to the diagram below, but still haven’t figured out what I could be doing wrong, or if it’s an incompatibility issue.
rngtng.com/files/2009/06/ard … wduino.jpg

I’m able to program it through the Uar_SB, but not by using a Duemilanove. Any ideas/help?

Thanks,
-Tommy.

Hi Tommy,
I am sorry, please plug off the Arduino Atmega328.
As Rainbowduino_Atmega328 and Arduino Atmega328 has same bootloader.
And connect as:
Rainbowduino<—>Arduino
TXD<—>TXD
RXD<—>RXD
GND<—>GND
VCC<—>+5v
DTR<—>Reset

thanks
Albert

Hello.

I am experiencing a similar problem and I would appreciate some help.

I have recently purchased a black widow (328 chip) and some rainbowduinos (328 chip).
In some forums, I read that using these two devices with this chip is incompatible. Is this right?

If I was supplying the rainbowduino board with a 6v power from the JST 2 pin connection and did not connect the GND, VCC wires would this be correct?

Thanks.

make sure you first upload an empty sketch to your black widow - this makes sure that the serial port forwarding works fine…

Hello and thanks for the reply. I appreciate the feedback as I want to get this little project of mine completed as soon as I can.

I have already uploaded a sketch on the black widow that has two empty functions (loop and setup) and this did not work. I found this tip on some forum. When you say empty sketch do you mean completely empty? The reason I am asking is because a completely empty sketch does not compile.

I retried the process now just to be sure and I am still having the same issue as before.

I have tried the same process with another rainbowduino which was unused and I got an error which said something like programmer out of sync.
The sketch that I tried uploading was some 3_0 version of a rainbowduino firmware.

The second time onward when trying to upload the sketch it gives me the same type of error that astcoolnameleft reported.

that was i meant yes. if you did so you did the wiring wrong (between black widoww and rainbowduino) OR you selected the wrong board on the arduino ide.

about wiring up, check neophob.com/2010/07/rainbowd … nbowduino/ - 3) Wire Up Arduino/Rainbowduino

make sure you connect all 5 cables!

cheers

Maybe you are right about the wiring. I am expecting some new wires so that I can connect GND and VCC according to the diagram. At the moment I do not have those two connected as I am using an external power supply on the rainbowduino. Do you think that this could be the problem?

Yes - you need to connect the GNZ between arduino and rainbowduino.

check the newly created wiki at: garden.seeedstudio.com/index.php … bowduino_2

cheers

Hello michu. Thanks for the last two links. The new information on the wiki is much improved and very useful.

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 got this when sending the firmware pde file by using the arduino022 ide. The wiring is now as follows:
VCC-5v
GND-GND
RESET-DTR
RX-RX
TX-TX

Therefore I am now no longer trying to power the rainbowduino through the JST connection.
I do first load an empty sketch on the arduino and I do select the duemilanove 328 device on the IDE.

My devices connect to a usb port on a MacBook Pro. I dont know if the IDE on MAC OS could have any issues that is why I am mentioning it. Also sometimes usb ports dont output the voltages/amps as the usb specification mentions. Maybe laptops are worse than desktop pcs?

Do you know any people that have managed to flush a rainbowduino through an arduino where both devices have the ATMEGA328 chip installed on them? I already spend about 150-200 dollars on electronics equipment + other on this project and if possible I would like to avoid spending another £15 on a UartSB (unless if this is the only option).

Thanks,
M

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

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…

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

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

Hi michu.

Thanks for your efforts.
I have placed an order for a UARTSB device from 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

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: garden.seeedstudio.com/index.php … d_firmware

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:

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

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 :wink:

I followed the same path, and used a serial device I already had.

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.

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

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

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?