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

  • what im saying is that the ardupilot is a compact arduino that you must program your self? or does it come preprogramed?
  • 3D Robotics
    Craig, I don't understand your question. What do you mean "no programming provided"? ArduPilot is an Arduino-compatible board optimized for autopilot use and very complete software to run it. Please use the tabs above to learn more.
  • So the ardupilot is basiclly a compact arduino with specalised pins for servos ect? No programing provided?
  • 3D Robotics
    Harry, the first thing I'd do is to reload the FTDI driver (I think it's unlikely that you'll need to reload the bootloader with AVRISP). The link is in this troubleshooting post, which you've no doubt already been through (it's linked in the manual). If you've gone through all that and it's still not working, you can turn to the bootloader. The easiest way to load it is through the Arduino IDE, but there's a driver conflict with the AVRISP II driver, so if you need to get to that point I'll walk you through the solution.
  • "Use the at168 pins"... hmmm, that would be to load the bootloader? Just slide the AVRISP mkII connector over to the next 6 pins, same orientation? The red stripe closest to the Attiny side?

    In either case, I have big problems now with the USB/Serial drivers for FTDI and AVRISP mkII. These items were higher on the checklist and in the month that ArduPilot was running, MS did an upgrade. Now, I cant get reliable connection through the USB. Sometimes when I connect, it says unrecognized USB device, other times I get jibberish on hyperterminal, mostly nothing comes through and status light goes out on ArduPilot.

    I dont know where to start to correct it. I want to wipe out all the USB related drivers, but not sure which ones to delete and exactly where they are.

    Should this have it's own thread in ArduPilot? The problem is probably something somebody else will experience eventually.
  • 3D Robotics
    Use the at168 pins
  • I believe my 328 based ardupilot board(red) needs the boot loader reprogrammed. I say this because it was fine and would load programs, then I let it run for a month and now it wont load new versions and I get the stk500 errors that the manual says could be from corrupt boot loader. What I need to know is how to connect the AVRISP mkII cable to the ICSP on the Arduino. "red stripe on the same side as the solder square on the back side" is too ambiguous and "same side as the processor" is too vague because there is more than one processor. I looked at the schematic and I want to put the red stripe on the side closest to the ATtiny45. The ardupilot board has AT168 label and a ATtiny45 label above the ICSP pins. I want to place the red stripe right next to the ATtiny45 label with the stripe next to the "5".

    Is this correct? I dont want to fry my programmer or the Ardupilot.
  • No problem Chris, don't worry.
    I can't imagine how many questions you receive, but shure they are a lot!

    I'm going to buy another one. It will cost me less than a programmer (even if I buy two :-D).

    Best regards.

    Ric
  • 3D Robotics
    Got it. My apologies for forgetting. Given that we've never seen the problem elsewhere, after nearly 1,500 sold, I doubt it would happen to you again. I suspect that getting a replacement board would indeed by the easiest solution--we made the board so cheap that they could be treated as essentially disposable if something goes wrong.
  • Chris,

    my Ardupilot doesn't work. It stopped during a flight.
    I try to describe the behaviour after that:
    - when I leave it off a day it start in the normal way (gps led blinking etc)
    - if I power off and then power on again it no more work and only the power and the mux led on the board light up (the mux not always).
    - the pwr led on the shield light up only briefly

    I read somewhere that if a programming procedure (with the configtool) fail the firmware could be corrupted. This is the reason I would try to reprogram the Attiny.

    Thanks Chris for help.

    Ric
This reply was deleted.