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

  • Is anyone using AVR Studio4, AVR Dragon and "debugWIRE" to debug ArduPilot code? I just ran into a problem; after switching from ISP mode to debugWire mode and back the Dragon could no longer read the device signature. I had to disconnect both the blue and yellow LEDs (on the SCK/D13 and MISO/D12 pins) to get the Dragon talking again. Is it possible the LED/1K resistors are loading the Dragon outputs too heavily?
    It's strange that the Dragon was able to talk to the chip first with the LEDs connected, but not after.
  • Check out reading the signature with AVR Studio 4. Connect "STK500 or AVRISP" and "Auto", and not "ATK500 mkII".
    I am sure your AVR should work somehow in AVR Studio if it already worked somehow with another soft!
    It is also easier to use AVR Studio to try following others here doing with it. also remember that a fuse set to 0 means "ENABLED" and not the contrary as I supposed not so long ago, before my ArduPilot board looked like a bug nest...
  • damn, spoke to soon, I got the fuses now ;-)
    thanks for your help tho
  • Hi, back again. I just got the programmer thing to work but I doubt it works with AVR studio. Got some odd program with it that allows flashing the chip and "reading the fuses" but not in an way which is clear.
    Do you know which fuses should and should not be set std on this thing? http://www.engbedded.com/fusecalc/ works for figuring out the commands for winavr but it looks to me like not only one but 2 fuses are set different from default on mine...
  • Hi Noth666: it seems you got the FTDI problem solved.
    My MODE led was off with bad ATtiny (in fact, bad me ¦-{ )
    It is a switch led going on when switching the CTRL line. It goes on for short when switching MUX led on or off.
    If your fuses are set wrong, it wont lit, except when you touch the CTRL pigtail somehow with your fingers (I actually could make the MUX switch by hand !!!). It is a sign of wrong/not working AT45.
    As to your chinese AVR, it seems you're stuck and get a better one. Mine, also chinese, worked perfectly as soon as I figured out how to plug the ISP10 - ISP6 pins converter. If you have one of those converters:
    - Vcc red wire on ISP10 end of converter goes to the side with the red wire on the AVR 10 pins female outlet;
    - Vcc red wire on ISP6 end of converter goes into the upper right ISP pin of ArduPilot (when board is seen with ATmega168 on your left and ATtiny45 on your right).
    For me connecting the AVR ISP female outlet directly to ArduPilot ISP pins does NOT work. the converter is needed (I received 2 converter with my AVR programmer).
    Hope this helps a bit.
  • I got the FTDI to work now thanks to Chis on another thread :)
  • maybe I should add it never worked via ftdi so the blinkenlights show is still on, but only LOCK and STAT blink...
  • @Reto:first, awesome story, cool work with the bug too :)
    hey, I'm having some other sort of issues, I am pretty sure my ckdiv8 fuse is set incorrectly, but I was wondering, how did your MODE light behave before you fixed the issue with the ATTiny? Mine is always off, I got a avr programmer of some sort from ebay wich does not work at all, so I am waiting for an AVR Dragon now...
    But I can also not speak to it via FTDI, just get 0x51 errors. hence I am suspecting something else is now toast...
  • This could maybe my last comment on this post, unless it is to try helping someone with my own experience!
    I finally brought my first ArduPilot board back to normal life !!! To make short story long (!) here's a summary:
    1) I ordered and received my first ArduPilot board
    2) It was from the batch with incorrectly CKDIV8 active fuse
    3) I build an home made ISP cable from LPT port (DAPA) and loaded a of free ISP software (nice by the way: ISP Programmer 1.2.0.47, by Adam Dybkowski; thanks Adam).
    4) I could read the ATtiny45, but messed with the fuses (switching off all including RSTDISBL and DWEN)
    5) I could not read the ATtiny45 anymore
    6) Tried some onboard High Voltage Programing by soldering small wires on the ATtiny legs (!), first with the parallel programmer: no success and I could have burnt some other ArduPilot components doing it
    7) Tried to adapt a High Voltage fuse programming for ATtiny85 with an Arduino board to my ATtiny45 but keeping it onboard. Did not have exactly the same components, and probably did not adapt the Arduino code to my purpose well enough. It failed also. I did not know if I again burnt some other stuff on the board applying 12V to the RESET leg onboard!
    8) Received my AVR ISP programmer from Hong Kong. Could not read the ATtiny45, of course (for which cause, I could not tell: RSTDISBL fuse or mistreated/burnt uC?
    9) I then decided to replace the ATTiny45 with a new one. Ordered 3 pieces from an online reseller (catalog without pics...) and received them: those were the ATTINY45-20PU with DIL8 legs!!! For socket!
    10) Said some words again...
    11) Decided not to reorder and wait for the right uC. Instead I have done some morphological adaptation of the large DIL legs to fit them on the (AT)tiny soldering pads of the ArduPilot board.
    12) When done good enough I presoldered the legs of the "new" ATtiny (which looked like an horrible bug) and to the board and went for reading the thing with the AVR ISP: no answer...
    13) checked/rechecked connections with the multimeter and found a bad soldered connection. Unsoldered it, aligned it better (with a toothpick from the opposite side under the uC!), resoldered, rechecked.
    14) plugged to AVR ISP, read the signature, unchecked the CHDIV8 fuse (set factory default), wrote the ver. 15 HEX file, verified, verified, verified Flash
    15) plugged in a receiver and servo and BEC laying around, switch on my FC-28 Tx
    16) the MUX red led went on and off when switching channel 5 switch on my Tx.
    You should have seen the smile on my face!!!
    I would like to add here that in the meantime, Sparkfun had send me a replacement ArduPilot which I received and which perfectly works. I WOULD LIKE TO THANK SPARKFUN AT THIS PLACE FOR THEIR WONDERFUL SUPPORT AND UNDERSTANDING. I mean I have messed up with the fuses when I could have better followed the very clear instructions and recommendations (AVR ISP programmer) by Chris and Jordi. I decided to do it my way and failed at some point incorrectly setting 1-2 critical fuses. THANKS ONCE MORE VERY MUCH TO ALL PEOPLE WHO HELPED ME, they really deserve an ArduPilot statue!
    Now for those interested in taking a look at a WORKING ArduPilot board with soldered on CRAWLING INSECT, here a pair of pics to close my "summary":




  • I've ordered another and will be extra pedantic.Ill get back to you all then...
This reply was deleted.