Go Down

Topic: Upload to multiple Arduino (Read 531 times) previous topic - next topic

baligena

Is there a way to upload a sketch to more than one arduino on a breadboard at the same time like the method here http://arduino.cc/en/Tutorial/ArduinoToBreadboard

Grumpy_Mike

No.
This is because the arduino is writing to its flash memory. The write time for this is not the same on all arduinos, nor the same thorough the arduino's life time. As the arduino has to signal back to the PC to get the next bytes to load you would have to multiplex all the arduino's serial responses to see when they were all ready.
Not impossible but definitely not worth doing. 

baligena

what if you plug a bunch of USB to the computer with different COM.  Is there a way to upload one sketch do different COM connections at a time

Grumpy_Mike

Only if you write it yourself.

WizenedEE

#4
Sep 02, 2012, 08:50 am Last Edit: Sep 02, 2012, 09:09 am by WizenedEE Reason: 1

what if you plug a bunch of USB to the computer with different COM.  Is there a way to upload one sketch do different COM connections at a time


in bash (or sh) you'd just do this (tested and uploads correctly to an uno and a duemilanove at the same time):
Code: [Select]

#!/bin/sh

FILE_TO_UPLOAD="$1"

ARDUINO_DIR="/home/adam/arduino-unstable"

for CUR_PORT in $(find /dev/ttyACM*)
do
   echo "$CUR_PORT"
   "$ARDUINO_DIR"/hardware/tools/avrdude -C"$ARDUINO_DIR"/hardware/tools/avrdude.conf -q -q -q -q -patmega328p -carduino -P/"$CUR_PORT" -b115200 -D -Uflash:w:"$FILE_TO_UPLOAD":i &
done

for CUR_PORT in $(find /dev/ttyUSB*)
do
   echo "$CUR_PORT"
   "$ARDUINO_DIR"/hardware/tools/avrdude -C"$ARDUINO_DIR"/hardware/tools/avrdude.conf -q -q -q -q -patmega328p -carduino -P"$CUR_PORT" -b57600 -D -Uflash:w:"$FILE_TO_UPLOAD":i &
done

just call the program with the argument being the name of the .hex file to upload.

And sparkfun did a series on it: http://www.sparkfun.com/tutorials/233

EDIT: I just tested the script with a bigger file to upload, and it doesn't work as well (ie fails). It seems like avrdude isn't reentrant. But there's not that big of an advantage to getting it parallelized, so if you just remove the & it works great.

Go Up