Go Down

Topic: Upload to multiple Arduino (Read 763 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.

dtr

Hi, this is an old thread but hope someone's stil reading. I'm trying to efficiently upload to a large number of Arduino Mini 328's using a USB hub and multiple FTDI cables. I adapted the above solution. My ports are listed correctly but I get the dreaded stk500 errors (I'm trying to upload to 2 boards in this test):

Code: [Select]
dtrMBP:~ dtr$ sudo bash  /Users/dtr/Sync/130407\ Lampyridae/code/_uploader.sh /var/folders/f8/r94b4krn73l43xj2z_xh11z40000gn/T/build4006946049764176321.tmp/Blink.cpp.hex
/dev/tty.usbserial-A400C24Z
avrdude: stk500_recv(): programmer is not responding
/dev/tty.usbserial-FTF3M94C
avrdude: stk500_getsync(): not in sync: resp=0x1c
dtrMBP:~ dtr$


My script:

Code: [Select]

#!/bin/bash

FILE_TO_UPLOAD="$1"

ARDUINO_DIR="/Applications/Arduino"

for CUR_PORT in $(find /dev/tty.usbserial*)
do
    echo "$CUR_PORT"
    /Applications/Arduino.app/Contents/Resources/Java/hardware/tools/avr/bin/avrdude -C/Applications/Arduino.app/Contents/Resources/Java/hardware/tools/avr/etc/avrdude.conf -q -q -q -q -patmega328p -carduino -P"$CUR_PORT" -b57600 -D -Uflash:w:"$FILE_TO_UPLOAD":i
done



Any ideas? Need different settings for the Mini's perhaps?
I'm using Arduino 1.0.5 on OSX 10.7.5

Thanks D.

dtr

Nevermind, this works:

Code: [Select]

#!/bin/bash

FILE_TO_UPLOAD="$1"

ARDUINO_DIR="/Applications/Arduino"

for CUR_PORT in $(find /dev/tty.usbserial*)
do
    echo "$CUR_PORT"
    /Applications/Arduino.app/Contents/Resources/Java/hardware/tools/avr/bin/avrdude -C/Applications/Arduino.app/Contents/Resources/Java/hardware/tools/avr/etc/avrdude.conf -v -v -v -v -patmega328p -carduino -P"$CUR_PORT" -b115200 -D -V -Uflash:w:"$FILE_TO_UPLOAD":i
done

dtr

I've had to move to a Windows laptop so my bash script won't work anymore. Does anyone have a Windows cmd script for this? Or some pointers in the right direction?

Go Up