Batch upload of a sketch

I need to upload a sketch to many Arduinos.

The process of:

1) Connecting each to the PC 2) Waiting for Windows to recognize it 3) Change the port in the Arduino IDE 4) Upload

Takes too much time. Is there some "mass production" way to burn/upload the sketch using a programmer or some other external device? If I upload a sketch using a programmer using the ICSP connector, does it mean I will loose the bootloader and in the future, the only way to upload a sketch will be to use the a programmer again?

I don't know of an off-the-shelf solution but I wonder if one of the "arduino makefile" command line make file solutions might be part of the answer.

-br

Step 4 can be faster if you use AVRDUDE.exe to upload the hex file. Then all Arduino's will get the same image. If you want a serial-nr in every copy to make them unique identifiable you need to recompile every copy.

It might be faster when using a programmer and switching the AVR chip.

That said, you can do things in parallel. While writing to device A you can connect B, start writing B and in the meantime connect C etc. Still in the IDE you need to swap COM ports. It should reduce step 2.

Okay, so maybe what's required is a little program on the PC to auto-detect the appearance of a new com: port and fire up avrdude with the correct inputs…

-br

you may be able to adapt

to do what you need. This arduino sketch recognises the kind of board it is connected to it (a second board to have its bootloader updated) and uploads the bootloader to the second board.

Once the sketch is one the first board, it can program the second board independently.

billroy: Okay, so maybe what's required is a little program on the PC to auto-detect the appearance of a new com: port and fire up avrdude with the correct inputs…

-br

AutoHotkey is probably capable of that.

Call me sceptical but I think anything short of a hardware programmer designed to program multiple target devices in parallel and having internal memory to store the image to be burned, is not going to actually work. But maybe someone can amaze me.

I'm not saying one couldn't have some kind of PC batch file driven procedure using AVRDUDE in command line mode and maybe pausing to allow one to unplug and plug in the next board to the USB serial port, possibly that may save some time but it's still basically a serial one chip at time operation.

I guess I would have to know your definition of 'many arduino boards' to decide if there is really a good opportunity to save a lot of time Vs the normal method one might use using the arduino IDE.

Lefty

I need to upload my sketch to a few hundreds of Nanos... I did 70 until now and it's a pain... I have already written a software to automatically find the new COM port and use avrdude to upload my hex file which greatly cuts the time it takes but I was wondering if there is an industrial way to upload the sketch.

I know it's possible to upload a sketch using a programmer. This way, the COM port will not change and I only have to use the ICSP cable. The thing is, I need to have a bootloader on the atmega328 for future uploads using the USB cable. So I wanted to know if uploading a sketch using a programmer means a bootloader will not be burned to the atmega328.

szangvil: I need to upload my sketch to a few hundreds of Nanos... I did 70 until now and it's a pain... I have already written a software to automatically find the new COM port and use avrdude to upload my hex file which greatly cuts the time it takes but I was wondering if there is an industrial way to upload the sketch.

I know it's possible to upload a sketch using a programmer. This way, the COM port will not change and I only have to use the ICSP cable. The thing is, I need to have a bootloader on the atmega328 for future uploads using the USB cable. So I wanted to know if uploading a sketch using a programmer means a bootloader will not be burned to the atmega328.

That is correct, the flash has to be erased before it can start burning flash data to the chip, thus any prior sketch and/or bootloader will be gone. As long as the HEX file you are loading contains both the sketch hex code and the bootloader hex code in one file, that should not be a show stopper, however the IDE will not help you create such a single hex file.

Lefty

I have no idea how to create a hex file that will contain both the sketch and the bootloader...

szangvil: I have no idea how to create a hex file that will contain both the sketch and the bootloader...

Well the method I would use is to load the sketch to a chip via normal arduino IDE serial upload method. Then using AVRDUDE in command line read the flash memory contents and have it save it to a file, which will be a hex file containing both the sketch and the bootloader code.

Lefty

There is a commercial device that does it, I think Crossroads had one.

I have a sketch that uploads a .hex file via ICSP (not using avrdude):

http://www.gammon.com.au/forum/?id=11638

You could modify it to just upload a particular file name when you hit a button, that would make the process pretty fast.

You could concatenate a bootloader to the .hex file (you might need to play with the last couple of lines, or you might not). Basically each line in the .hex file specifies an address, and what to put at that address, so adding in the bootloader stuff at the end should be trivial.

The upload time can be pretty quick, it depends a bit on the number of bytes you are uploading. In the order of a second or so could be achieved.

When I get the next batch, I'll try getting avrdude to read the sketch+bootloader from the nano and then burn is using a programmer.

Thanks all.

Have you considered one of these?

http://www.adafruit.com/products/462

It's designed to program the chip directly but you could easily add a connector so that it plugged to the 6-pin ISP connector on the Arduino. Then you would not need a PC at all - just plug & press. You would still need to make a conjoined .hex file.

Ugi

Maybe you can record a macro.

USBtinyISP or any other programmer will do the same thing...

what i have done is use avr studio for the first time prep of a new chip or new uno i read the contents of the chip that i have that has the good code on it i program the fuses first to match then program the flash, that will get your bootloader and the sketch onto a new chip

when the uno restarts i am prompted on a lcd to input an ip address which is stored in eeprom then i can upload new skethes via tftp

it is still a few steps but the reason i do this waqy is becuase i am actually using a differnet bootloader (TFTP) so for new chips it is the easiest way

after system is running i have about 20 unos connected via ethernet and to upload a new sketch to the uno i have the following

a pc program that comuunicates with uno 24x7 from this pc program i hit a button called upload firmware this in turn sends a command to the uno to force a watchdog timer reset that reboots the uno and puts it in wait for upload mode for 5 secs. during this time the pc program does a tftp put to the ip of the uno and the file uploads, then uno restarts

the program on pc is a custom program i wrote and the sketch looks for the commands i send

i can reprogram all 20 with a new sketch (firmware as i call it) in less than 30 secs infact even if i had 100 unos connected it would take the same amount of time