Society of Robots - Robot Forum

Software => Software => Topic started by: Admin on November 13, 2007, 03:01:31 PM

Title: mass programming of AVR
Post by: Admin on November 13, 2007, 03:01:31 PM
I want to mass program a huge lot of AVR microcontrollers using probably the AVR ISP2 Programmer to install a bootloader.

The more I can program simultaneously, the better. I will have lots of at least 50 but probably hundreds, and it will take forever to do it one at a time . . .

Then I need to upload a 'hello world' program under that bootloader, either by UART or again the programmer.

What is the best way to do this? Is it as easy as wiring a bunch in parallel? Is there something I can buy to save me wiring/programming effort? Im sure industry has a solution for this . . .
Title: Re: mass programming of AVR
Post by: JonHylands on November 13, 2007, 03:27:30 PM
I would be very surprised if it worked to just wire them in parallel. This sounds like the kind of thing you hire a student to do... Alternatively, you could build a robot to do it   ;D

- Jon
Title: Re: mass programming of AVR
Post by: bens on November 13, 2007, 04:31:34 PM
Your first step should be to program a single AVR with the bootloader, use that bootloader to upload your hello-world program, and then read the hex file from the AVR.  Once you have that combined hex file, you can program all your AVRs with that single hex file (as opposed to the two programming cycles per chip you had planned).

I don't think you can just wire a bunch of AVRs in parallel to program them using ISP since the programming process requires two-way SPI communication between the programmer and the AVR being programmed.  If you have a good programming jig set up, you can probably program a chip every five seconds or so (if you need to change the fuses/lock bits, create a windows batch file that uses avrdude to configure and program each chip).  You should be able to program a few hundred chips in maybe 30 minutes to an hour at most.  The effort involved in working out a parallel programming solution might exceed the effort involved in programming the chips one at a time.
Title: Re: mass programming of AVR
Post by: dunk on November 13, 2007, 05:08:55 PM
Quote
I don't think you can just wire a bunch of AVRs in parallel to program them using ISP since the programming process requires two-way SPI communication between the programmer and the AVR being programmed.
this indeed rules out serial programming but you can also parallel program AVRs in the same way you would program EPROMs.

i have access to this type of device at some pf my work sites although i've never had the need to use it for AVRs:
http://www.equinox-tech.com/products/details.asp?ID=505 (http://www.equinox-tech.com/products/details.asp?ID=505)
it's definitely the tool to use for BIOS EPROMs when you have a few hundred to swap.
you need to use adapters if you want to program chips which are not DIL form factor.

the search keyword you are missing is "gang": http://www.google.com/search?q=avr+gang+programer (http://www.google.com/search?q=avr+gang+programer)

anyway,
the answer appears to be: chuck some money at it and buy a shiny gang programmer.

i get the impression most users of AVRs in industry like to have the microcontroller programmable in circuit though so they can upgrade the firmware on a finished product if necessary.
sounds like that's your plan with the boot loader though...

dunk.
Title: Re: mass programming of AVR
Post by: HDL_CinC_Dragon on November 13, 2007, 06:00:24 PM
1) Ship them to me and Ill do them for you for the small price of $25 plus 2-way shipping =)
(seriously, thats an option for you to consider :P)

2) If you plan on doing this more than once or something you might be able to just hook up some kind of rig where you can just slide the MCU Board, all assembled already, under a little boom with the needed 6 pins but instead of pins use copper plates so when you slide it under, the copper plates contact, program, and push another one in to start the process over

3) Take Bens idea and get the combined .hex file from a programmed one with the bootloader and hello_world program and just slap together a 28-pin DIP socket (or however many pins your AVR has, they go up to 100 for the big ones dont they?) and a 3x2 ISP header. That way you can just leave the ISP plugged in, and just swap out all your AVRs one after another. Assuming each one takes 3 seconds just for programming and 5 seconds to switch them out, you should be able to get about 450 an hour... and thats probably on the higher end of probability :)
Title: Re: mass programming of AVR
Post by: oelewapperke on November 14, 2007, 04:57:48 AM
Just a thought ... you can order them programmed as you wish from atmel ...
Title: Re: mass programming of AVR
Post by: Tsukubadaisei on November 14, 2007, 06:14:36 AM
I do not recommend connecting the controllers in parallel because and because you could burn your parallel or serial port(if it was possible to use the serial). If you have n controllers connected, than the current flowing through the port will increase n times, so it is a dangerous process.
Title: Re: mass programming of AVR
Post by: Half Shell on November 14, 2007, 06:37:50 AM
Out of curiosity, where did you get your single programming cable? And are you planning on doing swarm bots or something? Just curious as to why you need the same program on 50+ AVRs.


...Or are you going to sell 50 dollar bot chips preprogrammed?
Title: Re: mass programming of AVR
Post by: Admin on November 14, 2007, 12:56:05 PM
Quote
Your first step should be to program a single AVR with the bootloader, use that bootloader to upload your hello-world program, and then read the hex file from the AVR.  Once you have that combined hex file, you can program all your AVRs with that single hex file (as opposed to the two programming cycles per chip you had planned).
Interesting idea!
So when I do this, even though its one hex file, it still remains as two 'separate' programs correct? (meaning I can modify the 'hello world' program without re-uploading the bootloader too, correct?)

Quote
if you need to change the fuses/lock bits, create a windows batch file that uses avrdude to configure and program each chip
Ill get back to you on this when/if I decide what fuses I want changed . . .

Quote
you can order them programmed as you wish from atmel ...
I couldn't find info on this on their site . . . would I need to contact one of their sales reps for more info? Know how much they charge for this service off-hand?

Quote
the answer appears to be: chuck some money at it and buy a shiny gang programmer.
Hmmmm they seem to cost from $2k to $5k . . . a random student paid $20/hour (or pizza!) would be significantly cheaper . . . :P
Plus, my 100-pin surface mount AVR's will already be mounted on the PCB . . .

Quote
2) If you plan on doing this more than once or something you might be able to just hook up some kind of rig where you can just slide the MCU Board, all assembled already, under a little boom with the needed 6 pins but instead of pins use copper plates so when you slide it under, the copper plates contact, program, and push another one in to start the process over
I think Ill do this in combo with bens's idea, as I need to do testing of the other pins too - attaching power, servos, etc to test the various functions/components.

Quote
And are you planning on doing swarm bots or something? Just curious as to why you need the same program on 50+ AVRs.

...Or are you going to sell 50 dollar bot chips preprogrammed?
Ill get back to you on this soon ;)
Title: Re: mass programming of AVR
Post by: HDL_CinC_Dragon on November 14, 2007, 04:58:01 PM
Ill get back to you on this soon ;)

Admins got a secret plan/project up his sleeve again! =)

Quote
2) If you plan on doing this more than once or something you might be able to just hook up some kind of rig where you can just slide the MCU Board, all assembled already, under a little boom with the needed 6 pins but instead of pins use copper plates so when you slide it under, the copper plates contact, program, and push another one in to start the process over
I think Ill do this in combo with bens's idea, as I need to do testing of the other pins too - attaching power, servos, etc to test the various functions/components.

Yeah thats what I meant, make it so the combined hex files gets transfered onto the AVRs. you could also do a dual boom kind of thing where you push in the AVR and it programs the bootloader, then push another one into the bootloader programmer which pushes the previous one into the HelloWorld programming boom... picture what I mean? Of course this idea is only relevant if the combined hex disallows editing of the HelloWorld without messing up the bootloader.... or perhaps hooking up some kind of circuit that when it detects successful bootloader upload, switches to the HelloWorld program automatically.... dunno :P
Title: Re: mass programming of AVR
Post by: dunk on November 14, 2007, 08:06:52 PM
hey Admin,
Quote
Quote
Your first step should be to program a single AVR with the bootloader, use that bootloader to upload your hello-world program, and then read the hex file from the AVR.  Once you have that combined hex file, you can program all your AVRs with that single hex file (as opposed to the two programming cycles per chip you had planned).
Interesting idea!
So when I do this, even though its one hex file, it still remains as two 'separate' programs correct? (meaning I can modify the 'hello world' program without re-uploading the bootloader too, correct?)
yup.
a bootloader is putting the program it receives into exactly the same kind of memory as any other programmer but in the space *after* the bootloader program.
when the AVR first runs it's code it will run the the bootloader first (as it occupies the first program memory space).
the bootloader looks for input. if it sees no input the bootloader routine will move on to execute the next bit of code which is where the code uploaded by the bootloader is stored.
if you read the hex code from an AVR with bootloader and bootloaded code it will all appear as one as it all exists in the same memory space.
(hope all that made sense. i'm a little tipsy.)

Quote
Hmmmm they seem to cost from $2k to $5k . . . a random student paid $20/hour (or pizza!) would be significantly cheaper . . . Tongue
Plus, my 100-pin surface mount AVR's will already be mounted on the PCB . . .
but gang programmers are SHINY!
students aren't shiny, even when you pay them $20.

if you want to program lots of these quickly you will have either to program the chips before you solder them in place or include serial programing header pins on your project and program in place and flash multiple boards simultaneously.
have you considered getting a bunch of USB parallel (or serial, depending on your programmer) dongles and using your regular programming method in multiple instances?


dunk.
Title: Re: mass programming of AVR
Post by: Admin on November 14, 2007, 10:32:13 PM
Quote
have you considered getting a bunch of USB parallel (or serial, depending on your programmer) dongles and using your regular programming method in multiple instances?
also a very interesting idea . . . i think i got 3 ISP programmers around . . . i bought a few extra for work cause I used to fry stuff too often and replacement shipping takes months with the gov't . . .

with all the above ideas combined, I can probably program one AVR every 2 minutes . . . another minute to run my tests . . . should be able to plow through all of them within just a few hours with little chance of messing up. :)
Title: Re: mass programming of AVR
Post by: bens on November 14, 2007, 11:48:57 PM
So when I do this, even though its one hex file, it still remains as two 'separate' programs correct? (meaning I can modify the 'hello world' program without re-uploading the bootloader too, correct?)
Not exactly.  The AVR flash is a single program space.  You can fill it all with one single program, or you can fill it with a shorter program and a bootloader.  Once you put a bootloader onto the AVR and use it to upload a program, the combined hex file is like a single, unified program.  But you can selectively overwrite a portion of that program just by programming without first issuing a chip erase.

a bootloader is putting the program it receives into exactly the same kind of memory as any other programmer but in the space *after* the bootloader program.
when the AVR first runs it's code it will run the the bootloader first (as it occupies the first program memory space).
the bootloader looks for input. if it sees no input the bootloader routine will move on to execute the next bit of code which is where the code uploaded by the bootloader is stored.
if you read the hex code from an AVR with bootloader and bootloaded code it will all appear as one as it all exists in the same memory space.
(hope all that made sense. i'm a little tipsy.)
Note that for AVRs this is not exactly right (at least not for mega88/168s).  The AVR bootloader space is actually at the end of the flash memory, so when you first start a program running, you will start at the beginning of that program, not in the bootloader space.  If you want to start off in the bootloader space, you must set the fuse bits accordingly (set the BOOTSZ bits for the desired bootloader size and program the BOOTRST bit).  Just make sure your bootloader program is written to the AVR starting at the correct bootloader flash address.

After you create your joint hello-world/bootloader hex file, I recommend you only change your hello-world program by using the bootloader to upload the new version.  Technically you can program the hello-world directly to the AVR using ISP, but you will need to disable any auto-chip-erase involved in your programming sequence.  Doing so will just overwrite the beginning of your AVR's flash (and the old hello-world program) without affecting the bootloader that's at the end of the flash.
Title: Re: mass programming of AVR
Post by: Admin on July 13, 2008, 12:06:22 PM
Just to let you guys know what I ended up doing . . .

In AVR Studio, when you connect to an AVR, there is a tab called 'Auto'.

Basically I connect the ISP and the battery by hand, then just push 'start'. Doing everything, its like a ~7 second process per Axon :D

As for loading the additional bootloader software, I ended up doing that manually - about ~10 seconds per Axon. It doubles as a manufacturing test for both USB and the bootloader.


(when I originally made this post, I hadn't yet publicly announced the Axon)
Title: Re: mass programming of AVR
Post by: bens on July 13, 2008, 07:51:43 PM
The other option would be to run a avrdude command line instructions using a batch file.  That's how I mass program (and sometimes test) AVR-based products.

- Ben
Title: Re: mass programming of AVR
Post by: pomprocker on July 15, 2008, 04:21:29 PM
admin,

maybe this forum thread would be of interest to you?

http://forum.sparkfun.com/viewtopic.php?t=1537 (http://forum.sparkfun.com/viewtopic.php?t=1537)