Program two 328's at once?

The goal isn't to program two at once really, I have a stripboard 328 in a robot and I want to program it cheaply, so I don't have to fork out for an FTDI cable or keep taking the chip out and putting it in my duemilanove.

So I was thinking, could you hook up a ground, VCC for both sides of the stripboard chip, hook up the reset buttons and the crystal pins and serial lines together and when you upload one sketch, they would both by in sync and both be programmed at once? I was thinking of a blank DIP socket with wires coming from it that could piggyback on the 328 in the duemilanove when I wanted to program the other stripboard 328.

I'm not going to be programming it millions of times so I don't mind the host 328 getting reprogrammed along with it, even if it is a waste. It saves me taking any chips out and breaking pins on them which I've already done once.

I don't know if this would work though. I can't see it not working without the duemilanove 328 in the 'host', but with the 2 chips, would that work?

I'm not going to be programming it millions of times so I don't mind the host 328 getting reprogrammed along with it, even if it is a waste. It saves me taking any chips out and breaking pins on them which I've already done once.

I don't know if this would work though. I can't see it not working without the duemilanove 328 in the 'host', but with the 2 chips, would that work?

I think your main issue might be current limitations of the FTDI chipset; you might want to look into that. With that said, if there are limitations to doing this, you could possibly set up some kind of buffering system to supply the current needs.

But at that point, it would probably be cheaper to install a header and buy/use an FTDI cable.

Your cheapest method might be to install a header for ISP programming, and use the Arduino you own in this manner (as an ISP programmer - there's a sketch for it on the playground, I think - I think it is also included in the examples folder); of course, that makes things a bit more difficult than simply clicking "upload" in the IDE.

@cr0sh: actually it will be not more complicated if he tells the IDE about the new programmer. That is if he modifies boards.txt accordingly.

Udo

actually it will be not more complicated if he tells the IDE about the new programmer. That is if he modifies boards.txt accordingly.

So you can upload via the bootloader through the ISP (using the upload button) using an ISP programmer (Arduino or otherwise), provided everything is configured properly? I thought the ISP was just for direct hex/binary uploads (like putting a bootloader on)? I haven’t researched this much, as you can tell!

:wink:

No, you upload through the ISP. No need for a bootloader. It will completely bypass the bootloader.

See here: http://www.arduino.cc/en/Hacking/Programmer. This page is somewhat hidden. I think it should be linked from one of the other ISP pages.

Udo

hook up the reset buttons and the crystal pins and serial lines together

This won't work you can parallel up the inputs you can't parallel up the outputs. When you erase flash memory, as happens when you reprogram the chip the processor waits until the internal flag says it is ready to be programmed. The programmer reads this and then continues to re program the chip. This flash erase time is not necessarily identical in any two given devices. So you will have to split the data read from each individual chip and the programing program will then have to wait until both chips are ready before proceeding. Then what happens if one chip reports a programming error and the other does not, you have two outputs trying to drive the line in different directions. Put simply even if you get it to work first time it is not a long term option.

Seems I have insufficient privileges for the playground. Maybe someone else could add a hint from the bootloader page to the programmer page?

Udo

Look at this… seems a interessting attempt.

Cool? hae?

Yes, and it’s a Arduino compatible:
http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1250709267

Greeting ChrisS

No, you upload through the ISP. No need for a bootloader. It will completely bypass the bootloader.

Ok - this is what I thought; you essentially will end up "overwriting" the bootloader, then, right? But you gain back the extra 2k. Also, isn't there an inherent risk in doing this, in that if something goes wrong (you lose power, a cable is disconnected, etc) - that you can "brick" the chip (not sure if you can get around this in some other manner or not)?

You can overwrite or not. This is bascially a fuse setting. By default it will not be overwritten.

If something goes really wrong you can brick it even without a programmer. Unless you start messing with the fuses there is no higher chance to "brick" it. If you have a HV programmer (or some Arduino around) you can "unbrick" it again.

Udo

Fair enough, so the chips won't be in sync making it not possible this way.

What about modifying a DIP socket somehow with a small switch(s) to swap the 5v lines from the host chip to the slave? Basically hook up the important pins and behave as if there is just the one 328 there? Would the duemilanove just recognise the slave chip then?

So I imagine a DIP socket with a small switch and some headers stuck to it. When you want to use it as a programmer, flip the switch and connect a cable from socket to host identical socket.

A DIP socket, micro switch and some wires shouldn't cost to earth, about a quid or so. It could sit fine on the duemilanove with the host 328 in it no problems I guess. It would be quite small though, I'm not sure my hands are stable enough to do work small.

Just thinking out loud really. I'll probably get an FTDI cable at some point but I'd just like a cheapskate way to program external chips using the internal FTDI setup that I already have without swapping chips out.

If you connect two AVRs but disconnect VCC of one chip, the "disconnected" chip may still get power through the clamping diodes --> your idea might not work. Udo

Why not exchange the socket with a textool socket? Or create a textool adapter socket?

Udo

If something goes really wrong you can brick it even without a programmer. Unless you start messing with the fuses there is no higher chance to "brick" it. If you have a HV programmer (or some Arduino around) you can "unbrick" it again.

As long as there is a way to unbrick it - I haven't had a need yet to program an ATMega in this fashion, nor does ISP programming scare me (although I would need to study up on it a bit before I tried); but it is nice to know what could possibly go wrong, and that there is a potential means to reverse the problem. Thanks for the info!

:)

ISP is far superior.

1) Faster than bootloader 2) More free memory 3) Serial console can stay connected while programming

(3) in turn saves me some typing --> this and (1) are the main reasons I prefer ISP over bootloader.

And of course: ISP can change fuses :)

Udo

ISP is far superior.

Would you say it is better to use a dedicated ISP programmer over the Arduino ISP sketch? Or is the sketch "just as good"?

I recently bought parts for a ZIF-based holder/programmer for some bare DIP ATMegas (168/328) that I have (well, they're bare in that they aren't part of an Arduino board; they have bootloaders on them, though) - I was thinking about making a jig to hold them for quick programming for later "embedding". If I could set things up to use the jig both in an ISP programming mode and bootloader programming mode (by tapping off the Arduino properly), that would be interesting and likely useful...

:)

I would always recommend the AVRISPmkII. By now I own two of those. I also have two other ISPs and some Arduinos around. The mkII is better than all others.

1) It is faster 2) It is THE standard thus 100% compatible with AVRstudio 3) It is THE standard thus you will find help in forums 4) It is not really much more expensive. Especially if you consider how much you would have to charge for your time. There is no point in saving 10 Euros and then wasting hours to figure how the cheap programmer really works (happened to me). And then buy in frustration the mkII. 5) The mkII has good output protection 6) The mkII has some neat features like remembering the target speed or reading out the target voltage

7) I can NOT recommend the STK500. Either I do not get it or I managed to break it. The STK500 always gives me a headache.

If I "brick" a controller I do the following: put a label to it and put it in a box. Once the box contains more than 10 I will think about unbricking. Right now the box contains 2 pieces. Controllers without bootloader are cheap. So this is not an issue. "unbricking" is not an issue either but I just do not care to much.

There is one additional point: once you go for ISP and get the hang of it you have much more freedom than with Arduino. There is no reasonable means that I know of to flash a Tiny 13V Arduino style. No issue with an ISP though.

The Arduino is nice for beginners but once you get used to the ISP you will see the advantages. Especially if you want to embedd you results. Then Arduino is a waste of money. I still use the Arduino for quick prototypes though. To be more precise I mostly use the Boarduino.

Udo

I'm not as this level yet. My goal is to program one basic arduino bootloaded 328 on stripboard in the easiest and cheapest method possible, ie using the arduino duemilanove I currently have. It's got all the circuitry needed right there, I just don't want to fork out £15 for an FTDI cable, that's a lot for duplicating what I already have.

But, if it was easy to do I guess someone would have done it already?

Would it be possible to write a sketch that takes data coming in on the hardware serial and outout it via softserial? and vice versa? Of course you'd need to disable the autoreset function on the duemilanove and implement something that reset the homebrew arduiino.

My goal is to program one basic arduino bootloaded 328 on stripboard in the easiest and cheapest method possible

In that case the boot cloner will work:- http://www.arduino.cc/playground/BootCloner/BootCloner

Just put a header of the spi pins on the strip board. A note on that page says the 386 won't work but I have a version that will if you want it.