3D Robotics

How to program the Attiny on ArduPilot

To load the failsafe firmware on ArduPilot's Attiny chip, you need to do the following. 1) You'll need an ICSP AVR programmer. We recommend AVRSIP2. Connect the cable to the correct ICSP port on your board, as shown above. The red stripe on the cable should be on the same side of the connector as the square solder pad on the back of the board. (On our boards that means that the red strip is on the side closest to the processor) 2) Now you'll need to change (turn off) one of the default "fuse" settings in the Attiny45, which divides the internal clock by 8 so it only runs at 1 Mhz. (Explanation of all that and more about fuses are in the excellent Sparkfun tutorial here). Run the AVR Studio program that came with the AVRSIP2 programmer. Ensure that the board is powered on by connecting it to an ESC or other power source! The red LED on the board should be on. 3) To change the fuse with AVR Studio, connect the programmer and go to Tools/Program AVR/Connect. Choose AVRISP mkII. You may get an error (choose cancel). On the "Main" tab of the dialog, click the "Settings" button and pick 125khz and click "Write". Then make sure "Device" is Attiny45 and "Read signature". At the bottom it should say that all's okay. If so, switch to "Fuses" tab and uncheck CKDIV8. Press "Progam", then "Verify" to make sure it's woking. [Note for those who are curious: the AVR programmer can only work at 1/4 of the clock speed of the chip. The Attiny ships with a 8Mhz internal clock, but when that DIV8 fuse is set it's only running at 1Mhz, so the programmer must be running at less than 250khz. Once you clear that fuse and the chip is running at full speed, the programmer can run at 2Mhz, which is 1/4 of 8Mhz]. Your processor is working fine and ready to program. 4) Now you'll need to burn the firmware. Still in the AVR Studio dialog box you used above, go to the Program tab. Where it says "Flash", input our firmware hex file. If you've already downloaded it in some folder, you can select that here. If not, switch to your browser and download this file. Click "Program". All should go well and you'll see the OKs below. If you want to make sure it's working, you can click "Verify". Now you can go back to the "Main" tab and change the Settings to 2Mhz. That's it! The failsafe should be working now. Connect the CTRL lead to channel 5 or 6 of your RC receiver and power on the ArduPilot board. When you toggle that channel a red LED should go on and off on the ArduPilot board, indicating that control of the output channels is being switched from the RC receiver to the autopilot or vice versa. For extra fun, toggle it back and forth fast five times. That should reset the autopilot (for in-air recovery).
E-mail me when people leave their comments –

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

Join diydrones

Comments

  • 3D Robotics
    Nick, I'm afraid I don't know anything about that. We only support the AVRISPII and the Adafruit USBTinyISP; we've never used a parallel programmer (we've never even seen one!). These things are really cheap these days ($14.95); can't you get a modern one so we can help you?
  • Sorry, I have few more questions. I don't have AVRISPII programmer, but I have AT-ISP parallel programmer. It is not recognized by AVR Studio, but it works with PonyProg. Which security bits have to be turned ON? A snapshot of the ponyprog application would be great. Alternatively, what is needed for the AVR Studion to support parallel programmers? Thanks.
  • Hey, Chris, where can we find the information about what has to be changed in the code for our Tx in order to support v1.6 failsafe? Thanks.
  • 3D Robotics
    The boards all come with the original version 1.5 MUX code. We don't load them with V1.6 (with failsafe) at the factory because you need to tweak the code for your own Tx and so you'll need an AVR programmer anyway. If we loaded with V1.6, many people would be complaining that it didn't work with their Tx. Better to leave it to those who are more technically capable.
  • Chris ,
    i am unclear is the new Atmega 328 ardupilot board Attinny 45 already programed with the Failsafe or not ?
  • 3D Robotics
    Not sure what toasted the Attiny, if that's what happened, but if you can't communicate with the chip at all (even at a slow programmer speed like 250k hz) you will have to replace it. No bootloader. (might be cheaper, easier and better just to get one of the new boards, which have been upgraded to the Atmega328)
  • Has no one got an idea?

    The only remedy I see is changing the Attiny45. Do I need a boatloader afterwards?
  • Hi!
    A friend of mine gave me ohne of his boards (he had two). Unfortunately it was one of the boards with the incorrect code and the wrong fuses. I fixed the problem with ponyprog2000.
    What I did was to disable the CKDIV8 and load the Fail_Safe_v15.hex.
    After this I saw that my aim failed to use the Ardupilot for backupsystem.
    Then I found the hex which starts the Ardupilot after signal lost.
    Now I tried to load the new hex but I didn´t get any connection to the ATTiny45. I also can´t read the fuses.
    Has anyone got an idea what the reason can be?
  • 3D Robotics
    Mike: Yes, the original boards needed a jumper on PSEL to select power source (we switched to a solder jumper, defaulting to RC power, in the later versions of the board to avoid exactly this kind of confusion)
  • OK spotted the problem - old boards seem to need the PSEL sorting out.
This reply was deleted.