Go Down

Topic: Using an Arduino to flash new image? (Read 897 times) previous topic - next topic

maniacbug

I want to set up an automated testing environment with several Arduinos.  The tricky part is flashing them with a new sketch image.  I could connect all of them to a PC using an FTDI cable, but at $15 each, I'd rather avoid that part.

Wondering if I could rig something so that a single Arduino was connected to the PC (actually I'd probably use Ethernet), and then could program several other Arduinos using software serial.

Is it as simple as resetting the target and then just feeding the new HEX file to TX/RX pins?  Or is there a whole complex protocol to work through?

Coding Badly

Quote
I want to set up an automated testing environment with several Arduinos


Will they all have the same sketch loaded?  Are they all the same board (Uno)?

maniacbug


Quote
I want to set up an automated testing environment with several Arduinos

Will they all have the same sketch loaded?  Are they all the same board (Uno)?


They would all be the same board.  would like to have different sketches, but I could work around that by talking to each node in serial afterward and giving a configuration .

Coding Badly

Quote
Is it as simple as resetting the target and then just feeding the new HEX file to TX/RX pins?  Or is there a whole complex protocol to work through?


There is a protocol involved.  It is not complicated and you have access to the source code / documentation for both sides (avrdude, Arduino ISP, bootlader, datasheet).  But there is a protocol.

How many are "several Arduinos"?

maniacbug


There is a protocol involved.  It is not complicated and you have access to the source code / documentation for both sides (avrdude, Arduino ISP, bootlader, datasheet).  But there is a protocol.


Ok, that's what I feared, thanks.  Just wanted to see if this was going to be easy, or wait until I have the patience to dig into a whole big task.  Anything that involves the AVR datasheet means setting aside some long hours!


How many are "several Arduinos"?


6-10 to start, maybe more once it's working really well.

P/S Props on your moderator knighthood ;)

tim7

What about using one Arduino board to multiplex programming to the others?  If your sketch doesn't make use of pins 0 and 1 this could be very simple:



FTDI = USB-to-serial interface
DI = digital input
DO = digital output
DTR = serial signal normally used to auto-reset Arduino prior to re-programming

The multiplexer is an Arduino running a simple sketch which distributes the DTR auto-reset signal to one of the downstream boards.  Whichever board received the reset then runs its bootloader and finds itself talking to AVRDUDE.  Of course the other boards must be sure to keep their serial-ports silent during this process.

It doesn't matter if the Arduinos have onboard serial interfaces or not.  You could use the cheaper Pro-Mini boards for this.

tim7

#6
Jul 15, 2011, 05:57 pm Last Edit: Jul 15, 2011, 06:11 pm by tim7 Reason: 1
...come to think of it, the multiplexer doesn't need to be connected to the TX/RX signals at all.

If all the boards are to run identical sketches, you might skip the multiplexer entirely:


(note that only one board is able to talk back to the serial interface)

maniacbug

That's a cool idea, thanks for the diagrams.  Also uses less pins.

So TX is not needed for downloading a sketch?  When I download a sketch, I seem to see both TX & RX lights on the FTDI board flashing, so I figured TX is needed, too.

I'd still like to talk to each unit when I need to.  Perhaps I can implement a "unit select" pin, so the controller has 2 specific pins for each unit, one to reset a unit, one to 'select' it.  Also I can use port extenders easily for this process, so I could control plenty of units from each controller.

tim7

#8
Jul 16, 2011, 02:58 am Last Edit: Jul 16, 2011, 03:16 am by tim7 Reason: 1
You do need feedback from the board being programmed.  The setup in the 2nd diagram tricks AVRDUDE into thinking it is only talking to one Arduino, when in fact it is talking to many (note that the TX of Arduino-1 is connected).  This relies on all Arduinos being identical.

I have just tried this and it works, except that I needed to buffer the DTR and TX signals from the serial interface.

The 1st diagram is safer, but likely still needs extra buffering.

[on further thinking...]
I was using Unos for my test, which have the TX & RX pins permanently connected to the serial interface by 1k resistors.  When I tried connecting pin-0 on the 1st to pin-0 on the second, the resistors made a divider chain and halved the signal.  This is why I needed a buffer.  If I had used Pro-Minis (or any other board without an integrated serial interface) I wouldn't have needed to buffer the serial, although the reset signal would still need it.

The 1st diagram might be ok as drawn, as long as you're using Arduinos without onboard serial interfaces.

maniacbug

Cool, I will try this.  All of my units have no onboard serial chip, they're all mini-style units, so I should be good.  And then I thought of a way to handle per-node configuration.  I can pipe down an array of configuration to every node, and then each node can know which element of the array to pick up based on an EEPROM node address.  And then as long as one node can talk back, I can get test progress from that one.

Go Up