Upload one Arduino sketch for multple Yuns

Hello,

I am using in my project over 5 Arduino Yuns. Is it somehow possible to automate uploading code for all Yuns in my network? As far as I know, only way for uploading over IP network is with graphical Arduino IDE.

I found Arduino cli project from Arduino/manpage.adoc at ide-1.5.x · arduino/Arduino · GitHub , but it supports only serial connections?

Thank you in advance

sonnyyu:
You need reflash correct bootloader.

nano /usr/bin/run-avrdude
Change the efuse value from FB to CB

#!/bin/sh

echo 1 > /sys/class/gpio/gpio21/value
avrdude -c linuxgpio -C /etc/avrdude.conf -p m32u4 -U lfuse:w:0xFF:m -U hfuse:w:0xD8:m -U efuse:w:0xCB:m -Uflash:w:$1:i $2
echo 0 > /sys/class/gpio/gpio21/value




1. flash bootloader only


/usr/bin/run-avrdude    /etc/arduino/Caterina-Yun.hex





2. flash sketch only ( save memory)


/usr/bin/run-avrdude    /tmp/Blink.cpp.hex





3. flash sketch+bootloader 


cd /tmp
/usr/bin/merge-sketch-with-bootloader.lua  /tmp/Blink.cpp.hex
/usr/bin/run-avrdude    /tmp/Blink.cpp.hex




Blink.cpp.hex 's size is 14450, the new Blink.cpp.hex after merge is 25372. Blink.cpp.hex is from blink example.

How to get hex file from arduino sketch

  1. flash sketch only ( save memory)
/usr/bin/run-avrdude    /tmp/Blink.cpp.hex
  1. flash sketch+bootloader
cd /tmp
/usr/bin/merge-sketch-with-bootloader.lua  /tmp/Blink.cpp.hex
/usr/bin/run-avrdude    /tmp/Blink.cpp.hex

sonnyyu:
3. flash sketch+bootloader

cd /tmp

/usr/bin/merge-sketch-with-bootloader.lua  /tmp/Blink.cpp.hex
/usr/bin/run-avrdude    /tmp/Blink.cpp.hex

Expanding a bit, you could build your sketch, find the .hex file, and put it on a server that the Yuns can access. Then, write a script that is copied to the Linux portion of the Yuns: it fetches the hex file from the server ( using wget, curl, SCP, etc) and then has the lines sonnyyu indicates.

Then, updating the Yuns is a matter of building the sketch and putting it on the server (or shared folder) and the running that script on each Yun. You could even set it up that loading a specific page from the Yun using a web browser would trigger your sketch and start the update.