Newbie AVR programming... the hard way!

Hi allI like exploring things. When a problem occurs, I like finding out what went wrong... and I like correcting mistakes I made!When ArduPilot came in, step 1 was to check if the CKDIV8 fuse setting was correct... It wasn't. CTRL not working.Step 2: set the fuse correctly. For that, I needed an AVR programmer... no programmer in the house (I'm a newbie).Step 3: get an AVR programmer:- option A: buy what was recommanded on this site (easy way)- option B: do one myself (hard way)Step 4 (I chose option B): get information (AVR programming), choose an easy hardware solution (I chose the DAPA parallel cable solution), do it (cutting an end of a DB25 cable, wiring as information found online to an ISP connector)Step 5: get free programmer software from the web which accommodates DAPA AVR cable... found itStep 5: connect the AVR DAPA cable to ArduPilot's ISP pins, load software, try out reading the signature of the ATtiny45 chip... it works!Step 6: take a look at the fuses... seems logic and easy, but there, the newbie mistake happens:I thought "fuse = 1 = set" "fuse = 0 = not set".... MISTAKE, but I did not know at the time!!!Step 7: setting the fuses as recommended on DIYdrones with help of available information understood by a newbie:I turned all fuses = 0.Step 8: checking if CTRL works... nope!Step 9: connecting the ISP again to check the fuses... ATtiny not recognized by the AVR, no signature read!!!Step 10: the newbie is stuck, reads some more online information, finds out that fuses set = 0 are ENABLED (not disabled as previously thought). I find out that the RSTDISBL fuse, once enabled, blocks ISP access to the ATtiny45. I also found out that DWEN enabled can cause problems for ISP. Fortunately, SPIEN was not reprogrammed (not accessible with the programmer software I used).Only solution to get the RSTDISBL fuse set = 1 again is called "High Voltage Programming". But for that, one needs an adapted AVR programmer capable of applying 12V to the RESET pin of the ATtin45. And this probably cannot be done with the chip installed in a 5V circuit.Step 11: the newbie asks for some more help with some simple questions:a) Has someone experienced doing a High Voltage Programming of a uC installed in circuit? What precautions have to be made.b) Is it possible to disconnect the uC from the board to HV program it, and then reinstall it again?c) Would it be easier to buy a new uC, flash it, and setting it on the board?d) Does the ATiny45 need having its EEPROM programmed? Where can I find the necessary EEPROM hex file? Or is the flash hex all it needs?Additional information about my setup:- I ordered an AVRISP STK500, but it could take some time to get in (the item is sold for 80 USD in Switzerland, so I ordered from abroad for 35 USD!- I also ordered an Arduino Duemilanove, breadboard and components... I found someone having done a High Voltage AVR for setting wrong fuses with an Arduino board (another way to learn a lot of things).Well, so far as a newbie, I learned a lot from all this... the hard way. And since I am as I am, I'll probably go on that way.Of course, in the meantime, my Kadet Senior airframe is not getting much further...But in the meantime, if someone is willing to share some experience or help, I'll welcome him.
E-mail me when people leave their comments –

You need to be a member of diydrones to add comments!

Join diydrones

Comments

  • Moderator
    This post helps, I hope! I got mine together the other day and today I tried to setup and program the ATTiny45 and could not. Seems the same as copperclad but not positive. I've looped the connections and all look good but I'll try to resolder the connections. Hopefully I'll be able to connect after that within AVR Studio.

    Should it be necessary to replace the ATTiny45, how much heat do you use on the iron? Pre-tin connections on pads or pins before attempting to solder or ? I think I'll check the vids on Sparkfun but experiance from others is good input too.
  • 3D Robotics
    @Reto: I was kinda hoping nobody would have to deal with fuses and AVR programmers, so I wanted to spare them that step. Turns out I was wrong, due to production gremlins in the first batches, but going forward I hope they won't be necessary. My worry is that including them in the instructions now will just confuse/scare more than it helps.
  • Cool way running after complicated problems coppeclad. I wish it would help me in my case, but I fear I have done much worse than cold solder my pins! Expecting zeros to means "off" in the fuses was probably a lot more troublesome newbie error conception. As soon as RSTDISBL is on, ISP is gone!!! But Your lesson will help me: every first time I run into some connection error, I'll keep my soldering iron on to remelt my pins. Thanks much for sharing your trouble. Finallym I know some people shall come up with similar kind of obstacle in the future, so what you learned us here is for sure not for the wind.
    @ Chris: good to know that testing well set fuses can take place easily before soldering pins. I didn't read about that anywhere, but newbies like me should know this. Why not adding this in the "ArduPilot Assembly Instructions" entry?
  • 3D Robotics
    Nice debugging, Copperclad! FWIW, I always test the boards and set fuses, etc, before I've soldered on anything. I just put two pins in a Rx battery and hold them in one of the servo holes for power, then stick a six-pin header in the AVR connector and hold that in the ISCP holes. Just tilt them a little bit so they make good contact with the sides of the holes. Easy to do with one hand.

    That's the way it's done in the factory, BTW.
  • Hi Reto
    i just wanted to report back that i sorted my board out , i hope this will help someone

    this was the first ArduPilot board i ordered and at the time , people were still figuring out there was a problem with the tiny being flashed and the CKDIV8 fuse being cleared , there was also some talk about whether the boards would work with JR radios

    my board went together and looked fine , but when i tried to switch into failsafe the MUX LED would not come on , it was showing that , if CTRL was left un-plugged and touched with a finger the MUX LED would turn on , untill the board was powered down , i thought about it for a day or two and realized that the brand of radio would not , should not , could not , make any difference and that the problem must be the way the tiny was flashed

    i ordered the AVRISP mkII programmer and had it in hand , so hooking up the board was showing problems with reading the signature , i would get a ERROR dialog box when i tried to read the signature and when i would switch to the fuse screen , , but in messing around , i saw that it appeared that the RSTDISBL was set , and that this was keeping me from ISP programming , and looking into it a bit , i was afraid to try HV programming in circuit

    so i ordered a couple new tiny 45 chips from didi-key and swapped one out , but when i went to program the new chip i got the same ERROR measages , this pointed out that the chip , fuse was not the problem and that left something else on the board was causing trouble , i had used a loop to look at the solder joints on the ICSP pins , and i looked at the schematic and ran a continuity check to be sure my connections were good and that all tested good

    so this got me thinking it could be the input from the 74LS157D , and again looking at the schematic i could see there were two traces connecting the tiny to the other chips on the board and if they were cut , that would leave just the tiny and its ICSP connector , my thinking was that this would let me track down the issue and at least see why there was trouble

    so i use an X-acto knife and cut the two traces connecting the tiny to the 74LS157D and the ATMEGA 168 , again i go to program and have the exact same problem , so i know the 74LS157D isn't dragging down the TMISO pin and the ATMEGA 168 isn't the problem either

    this leaves the ICSP connecter , so i hit the pins with a hot iron again to reflow the solder , and try it all one more time , and now the chip programs just like you think it should , no errors , read the signature , read the fuses , program the fuses , flash the chip , all smooth as glass , and i am thinking " cold solder joint " :-( , I am an idiot ;-(

    i know with trouble shooting there are two ways to go , start with the easiest stuff first and work your way up , and then there is the the way i just did it , half fast and backwards , so lesson learned , i solder bridged my two cut traces and the board is running fine

    hope this is some help to someone , my mom always used to say " if it doesn't hurt , it's not a lesson " :-)

    .
  • I see that toasting chips is part if the learning process!
    Thanks Chris. I'll do it right with the replacement board and STK500.
    But I still want to try to resurrect this uC before I take it off the board (I still can read the EEPROM and Flash content from it, although signature is missing and I cannot change fuses or write new Flash). I mean the beast's heart is still beating).
    Finally, if I have to replace the uC with a new one, I'll probably prefer to program the new one on the Duemilenove that I ordered before soldering it on the circuit.
    Thanks for your feedback.
  • 3D Robotics
    I'm afraid that the easiest thing to do at this point is to replace the chip--I don't think you can recover it in situ. Use a sharp exacto knife and carefully, cut the leads, one by one, without disturbing the traces underneath it. Then use your soldering iron and tweezers to unsolder the remainders. Solder in a new ATtiny and restart the fuse programming process. Fuses are really dangerous, and if you don't know what you're doing you can easily kill the chip (I've toasted my share). That's why we recommend AVR Studio, which makes it easy.
  • thanks Reto
    i haven't used the STK-200 in a couple of years , and that was just for out of circuit programming , i didn't look into if it would do HV programming or not , because i wasn't sure you could HV in circuit , when i look at the schematic , i see reset is tyed to VCC through a resistor , and i was afraid the 12 volts would backfeed to the rest of the board , i am thinking someone here will be able to jump in , with first hand knowledge on this

    my board is a different problem , i knew once i tried swapping the tiny , i would not be able to send it back , but for the $24.00 i would rather play around trying to fix it and get a lesson out of it , i am thinking if i cut the tracing that runs to pin 1 of the 74LS157D , i could eliminate that as a problem , as i can see it could be effecting the TMISO pin on the tiny

    it is great to have this forum , on the ArduPilot , and be able to see what others are up against and how they are dealing with it , i will be interested to hear if you can HV program the tiny in circuit , best of luck

    .
  • Thanks copperclad for sharing this. So I know I am not alone with such problems.
    The fact is I know the ATTiny45 was ok before I disabled the fuses! So I will not ship it back to Sparkfun for exchange; instead I proposed them to pay for the replacement board they are sending me if someone there helps me trying to get the problematic uC working.
    You stated the STK200 can do HV programing. I am not sure about that. In what I read, only the STK500 and Dragon (excepting here hi-end programmers) would do the job. But maybe I am wrong on this.
    I'll receive a STK500 in two weeks I hope. So I'll try to resurrect this uC then.
    You were afraid doing the HV programing with the uC i circuit. The more I read, the more I think it shouldn't be a problem. High voltage programming is feeding 12V to the RESET pin while 5V is fed to VCC. As in my case, I'll probably have to use an external oscillator on the SCK pin because I disabled internal crystal fuses. It seems 12V is only applied to RESET for a short time at the beginning of the programing (50 or 100ms) and then there's some delay (I read 50s) before next commands can be sent to set fuses. After deconnection the uC should again be accessible for ISP.
    In the meantime, I'll also probably get the Arduino board with which some HV fuse setting should also be possible (before trying to do more interesting experiments with it, of course).
    Maybe some other user will share thoughts about those topics here.
    Thanks once more and good luck with your setup.
  • Hi Reto
    the first board i ordered would not let me switch into MUX , so i hooked it up to an AVR programmer and found out i could not read the signature , i assumed the RSTDISBL was set and stopping me from ISP programming , i have a SK200 that i think will let me do high voltage programming , but i was afraid to try it with the chip in the board

    i saw that i could order Tiny45s for $2.00 from digi-key , and i figured this would be a good time to try swapping out a soic chip , i was afraid i would rip up a tracing removing the old chip , so i cut the legs free first , and then it was easy to pick the legs up one at a time with the soldering tip , it was not too hard to solder the new chip to the board , and of coarse at this point i am thinking i am home free and just about to pat myself on the back , but the AVR programmer won't read the new chip either

    i had already ordered a second ArduPilot , and reflashed the tiny and it was working fine , so i know that my programmer works and that i am following the right procedure , and as a project , i cut a small circuit board and setup a spare Tiny45 with an ICSP plug and was able to program it correctly , so i was pretty sure there was some other problem with my first board , but i have not spent any more time trying to run it down , there are no bridges on the board , and all connection points check out , i was thinking of cutting some traces to see if i could figure out where the problem was , but hate to waste any more time on a bad board

    i know this is not much help for your problem , but i thought you might benefit from it , best regards

    .
This reply was deleted.