Feb
19
2007

Make an Arduino NG into an AVR-ISP programmer (for good)

Pushed by several tutorials on the matter, a few forum posts and the need of a programmer to write firmware to bare AVR microprocessors, I decided it was about time to make my own on the cheap.

Now which one is the cheapest option to build one without the need to create a PCB, solder etc?
Well, my friends, it’s our beloved Arduino board with a few hacks on the software and the hardware sides.

If you start from massimo’s post you can already build your own, but he doesn’t have much time to write about a more thorough process. I’m trying to execute this task with my first post on tinker.it, and I shall succeed!

Last week I had time to talk to massimo while in milan, and I had the luck to sit next to him while he was programming a couple of brand-new BT boards for me.
His AVR programmer died on him, and he is using an Arduino hacked to program his boards.

As I was telling him I didn’t have success in turning an Arduino into an AVR-ISP, he was explaining me that replacing the board crystal with a 3.6864 MHz one, would have led to a more successful result.

Today I started tinkering, and this is what I did:

I wrote this firmware to the board using the load.command on mac.
I have one of the boards with a misbehaving FTDI chip that returns the serial port name as a string containing weird characters: mine was cu.usbserial-A10?16il which then turned to be cu.usbserial-A10^P16il. If this is your case, then the load.command script is not going to work.
I overcome the issue with a trick

sudo mv /dev/cu.usbserial-A10?16il /dev/cu.usbserial-A1016il

This basically renames your serial port resource. Up to you if it’s worth doing.
After filling in my root password I finally obtained a usable serial resource that I could type in my load.command script.
Executing the script after resetting the board burned the new firmware into the chip.

Past that essential first step I had to replace the crystal, and I can assume I did a neat job, although removing the original one was not exactly easy, as it decided to get stuck in there…
The new 3.6864 MHz crystal seats nicely on the board.

Arduino’s new crystal

Well, it was time to test the programmer, and since I was told that avrdude has some issues on mac, I launched my Parallels and started AVRStudio on windows XP, which works properly.
AVRStudio sees my programmer as an AVR-ISP release 2.04 and tells me that it needs a firmware upgrade, but of course this is sort of a simulated AVR-ISP, and you can’t upgrade the firmware.
Of course I rang massimo and he told me that if I connect to the serial port with a console application and hit couple times the ENTER key, it asks for a firmware revision parameter.
I entered 2 as Major version and 0A as Minor. This is what AVRStudio 4.12 expects.

After this, well, all my problems were solved, except that I hated the fact I had to use wires from the Arduino Board ports to the ICSP of an eventual board, while instead I wanted to be able to use the ICSP on the arduino programmer board as a programming port.
Guess who I asked to…
Too easy.

My mentor told me that if I cut out the ICSP pin 5 from the board and connected it to pin 10 on the Arduino board, I would have had the programmer automatically reset the programmable board/chip without resetting the programmer itself. Sure this required some more hacks.

Did I get scared? Not at all.

I loaded the Arduino board schematic and started looking at it carefully.
ICSP pin 5 was connected to a resistor that kept it HIGH unless the reset switch was pressed.

arduino_ng_schematic.png

Guess what else was connected to the same resistor to keep a HIGH state…
ATMega8, our board chip. Too bad it was connected throug ICSP pin 5.
This meant that if I simply cut the track from ICSP pin 5 to the resistor, pin 1 of the chip wouldn’t have been kept HIGH and risked to reset the chip randomly. I sure didn’t want this, and luckily someone warned me before it was too late.
There was more tinkering to do here, and things started getting interesting.

I traced every possible connection on the board and managed to find out that 2 cuts were necessary, and with them also 2 jump-wires needed to be put in place.

Here the first track to cut

first track to isolate

and this the second

second track to isolate

At this point, I could restore the HIGH state connection to pin 1 of the ATMega (red wire) and finally connect board’s pin 10 to (isolated) ICSP pin 5 (green wire).
The wires are not clean enough for my OCD and are going to be replaced with much thinner ones today.

connections.jpg

Do you think it worked after all this?
Judge from AVRStudio screenshots at the bottom.
What I can tell you is I dumped the firmware from an ATMega128 I had lying around.

Hope you enjoyed my first article.
Maybe more to come if massimo allows me to keep the editor account.

ciao.ubi

avrisp_prg.png

avrisp_fss.png

avrisp_prg1.png

Written by Massimo Banzi in: Arduino, Physical Computing, hacks |

15 Comments »

  • sam

    Very interesting post. I have been burning firmware successfully on OS X using AVRDUDE and a $29 ARISP mkII with little difficulty. I’m not exactly eager to try out this method, but I am interested in seeing how/if this develops in the future.

    Comment | 19 February 2007
  • Jeremy

    So, basically we’re saying that on the mac, massimo’s solution of using an unmodified Arduino NG as a programmer just isn’t going to happen?

    Comment | 28 February 2007
  • hi, jeremy.
    you can use a partially unmodified (except for the crystal) arduino to make an avrisp programmer.
    my hard modifications came out because I wanted to use a direct ICSP connection between the programmer arduino and any AVR chip.

    Comment | 28 February 2007
  • Jeremy

    ahh…

    So, I’ve gone thru the steps defined by massimo to attempt to make one arduino board into a bootloader programmer for another. When I attempt to burn the bootloader onto a blank atmega8 or 168 I get a “Programmer Not Responding” return from avrdude. Is that because I need to replace the crystal?

    Comment | 1 March 2007
  • hi, jeremy.
    yeah. it’s definitely that.
    I had the same issue first time.
    now I do everything with my modified arduino board. I use it to program the AVR I’m experimenting with: ATmega8, ATmega168, ATmega32, ATmega128

    it works lime a charm, if you haven’t been fiddling too much with the fuse (I’ve destroyed 3 AVR with that).

    Comment | 1 March 2007
  • Carl

    I was pleased when this article came out as I am a mac user and a newbe to programming avr’s. Thank you for the article. I attempted the mod:

    I get an error msg: “Programmer is not responding” I got the initial impression that you needed to replace the crystal then upload the firmware. I re-read it and got a second impression that one uploads then replaces the crystal. Did I get it backwards? Or is there some other potential explanation.

    The old program (led blink) seems to work still. I attempted to load example code and get the same error using the Ardiuino software.

    Comment | 8 April 2007
  • hi, carl.

    basically you first write the firmware, then change the crystal.
    remember that once this board is converted to a programmer, it’s not showing up as an avr chip.
    it’s just a programmer.
    usually that error is generated when a µC is not connected to the programmer.
    if you attach the ISP connector to an atmel µC you’ll be able to use the programmer.
    a programmer alone is not going to be “usable”.

    hope this clears your mind.

    thank you.
    ubi

    Comment | 8 April 2007
  • Carl

    Got it. Thank you for your helpfull comments.

    Comment | 9 April 2007
  • carl

    i’ve connected the arduino board to a breadboard and would like to use mac/parallels/avrstudio combination. it occurs to me that i do not have a serial port from which to adjust firmware designation at the console (unsure how to do). at any rate i physically connect the board and then attempt a software connect an communication fails to see a board
    . there is not msg about a firmware discrepency. it doesn’t see a board.

    do i have a faulty solder connection. i will try a continuity test. i am sure of a successful upload of firmware and that i’ve correctly done the breadboard connections based on the datasheets for atmega168.

    thank you for your help.

    Comment | 13 April 2007
  • if you’re running it on parallels, make sure that the USB device is connected, using the “device” item in the parallels top menu.
    once this is done, you should be able to use the programmer.
    are you trying to read/write to a bare chip or to another arduino board?
    are the chip’s fuses already set?
    if so, you might need the right crystal/oscillator connected to the chip’s xtal pins using the required capacitors (except for some micros).
    if the chip is brand-new then you should be good to go.
    if you’ve burnt the fuses already, you might have locked the RESET pin which prevents every reset operation and following firmware burning.

    why don’t you try it first with avrdude?
    this is the command I use to simply read

    avrdude -v -V -F -p m168 -c avrispmkII -P /dev/cu.usbserial-XXXXXX
    (being XXXXXX the FTDI id of your new programmer)

    let me know and we’ll try to sort this out.
    if you’re sure that the soldering and the trace cuts have been done properly, there should be nothing wrong.

    Comment | 13 April 2007
  • carl

    Thank you for your patience.

    I am using a breadboard with a “virgin” atmega168-16PU (not sure about 16PU as the writting on the chip is very light). I don’t use a crystal/capacitors on the breadboard. If need, what type of crystal/capacitors are needed on the bread board.

    My fear was that I may have managled and comprised the connection for the crystal. Given that the board is seen as a UART Dev in the window xp with parallels is I think a good sign. is this a good assumption.

    I tried avrdude and get “stk500_2_ReceiveMessage(): timeout” Check an internet said perhaps crystal is “not oscillating at all, or not at any kind of reliable frequency” is this the problem.

    again, thanks.

    Comment | 14 April 2007
  • mh… this is strange and not really good news.
    you might have done something wrong on the process.
    is the crystal soldered properly on the converted arduino board?
    if the chip is brandnew, then no crystal/oscillator is needed at all.
    the chip runs on its internal clock.

    you should track down if there’s a good connection between the crystal pins and the next trace point. use a simple Meter.

    as I told you, if the conversion process was done properly (firmware burning > crystal replacement > traces cuts where necessary > jumpers between the right pins) then it has to work.
    one of the key parts are the jump-wires.
    if you fail to solder them properly then you have no connection where needed.
    for instance, if the wire that takes to pin 5 on the ICSP connector is not soldered properly, then your bare chip cannot be reset by the signal and your process times out.
    make sure you have connections between the shorted points on the board.

    Comment | 14 April 2007
  • Carl

    Thank you for your help above.

    I think I ended up frying the capacitor and definitely damaged the via connection with the desoldering/soldering process. I am truly a neophyte. I’ve been reading the material on Arduino.cc and “Designing Embedded Hardware” by Catsoulis. Can you recommend any good book/primer on electronics with embedded design in mind?

    This leads to a second question regarding crystal selection. I notice the schematics for Arduino board are16MHz Crystal / 22pF Capacitor combination and a schematic for avrusb500 have a 3.6864MHz / 18pF combination. Can one use 16 MHz and 3.6864MHz crystals with loads of 20pF? I am not sure how flexible the design can be. This is why I want a good electronics book.

    About resisters in embedded designs, what watts are recommended 1/2 W or 1/4 W and % tolerance?

    Am I allowed to ask is there a recommended vendor for buying electronic components? Also, I hope these are fair questions for this forum.

    Thank you.

    Comment | 23 April 2007
  • carl, I’ve been reading Catsoulis’ book as well.
    I’m a newbie too and this book is quite clear on many things.
    I’m not an engineer, so I have no idea about the “rules” to use on designs.
    I’m a hacker/tinkerer, and use the trial-error praxis.

    as a vendor, in europe I use Farnell as they have a huge catalog.

    about your “fried” board, I’d got through the vias with a tester trying to recover it with jump-wires etc.
    try restoring the original crystal (16MHz) and see if you can still use it as an arduino board.
    then maybe you can go back through the steps.

    Comment | 23 April 2007
  • macsimski

    i’m following this “tutorial”, but have a few questions remaining: i can talk to the programmer after using the load.command script with the stock 16Mhz xtal, but as soon as i change the xtal, i am unable to communicate with it. I assume that this is caused by the different serial speed required. but it makes no difference in selecting the speed. what speed should i use when running on the slower xtal? i was able to change the firmware version setting when running on 16Mhz, but it is now a 2a version? it omits the leading zero in the minor firmware version.

    should you be able to select the programmer from within avrstudio without a atmega chip connected, or will it only work with a chip attached?

    and is it correct that mosi is connected to mosi? should that not cross to miso?

    a lot of questions…

    Comment | 15 May 2008

RSS feed for comments on this post. TrackBack URL

Leave a comment

Powered by WordPress | © 2008 Tinker.it! Limited | London & Milan