Thread Tools
This thread is privately moderated by HappyKillmore, who may elect to delete unwanted replies.
Jun 03, 2010, 01:28 PM
Suspended Account
Thread OP

Unbricking/reloading the bootloader and failsafe on your ArduPilot

In the course of my testing, I managed to completely mess up my ArduPilot. Several of the red lights would come on with power but I could no longer upload the software using the Arduino Development environment that I had used hundreds of times before. It continued to give me an avrdude error message very similar to the one you get when "Set RTS on Close" is not set correctly on your FTDI cable. Obviously, these instructions are intended for those of you who have been able to upload the firmware in the past, but all of a sudden can't get it to work anymore. Pressing the button on the ArduPilot has no effect (red lights just stay on solid) and it won't upload no matter what you try.

For this project, you're going to need an AVRISP MKII programmer. You can buy them from DigiKey or Mouser for about $35 plus shipping. Ok, so the first and most obvious question is why would I pay $35 for a programmer when I can buy a new ArduPilot for $25? Well... that's up to you. But if what you did to brick your first ArduPilot manages to brick the second one, then you're out $50 and you still can't solve the problem.

You'll also need some .1" headers. You only really need 2 rows by 3 columns (or 6 pins) for this project.

Step 1: Install AVR Studio. You can download it from the website. You'll need to register to download it, but the download is free. At the time of this writing, there were 2 additional service packs. It is my suggestion to install AVR Studio, then SP1 then SP2 in that order. I tried to just jump ahead and install SP2 to the AVR Studio I already had installed (came with the AVRISP MKII) and after it completed, gave me all sorts of errors about missing drivers.

Step 2: Connect your AVRISP MKII to your computer. Again, I assume you've had this working in the past, so you should have the arduino development environment already installed. You'll need to go into that folder (ie arduino-0018) and find this path: arduino-0018\hardware\tools\avr\utils\libusb\bin and run the program inf-wizard.exe. Click Next and then find the AVRISP MKII in the list and click next, next and then enter something like "AVRISP_MKII" in the save as box that appears. Then click Save and Finish. This just created an .inf file (installer file) for your AVRISP MKII that we'll be using in the next step.

Step 3: Disconnect your AVRISP MKII. Click Start, Run and enter devmgmt.msc and click OK. Open the branch called "Jungo" and right click the AVRISP MKII entry and select "Uninstall." Now plug your AVRISP MKII back in to your computer. You should get a "Found New Hardware" box that pops up. You'll want to select "Install from a specific location (Advanced)" and click Next Now make sure that only "Include this location in the search" is selected and click Browse and find the arduino-0018\hardware\tools\avr\utils\libusb\bin folder on your computer and click Next. When the wizard completes hit Finish. You should have one green light on your AVRISP MKII.

So what did we just do and why? In my reading, the steps you just followed are supposed to make your AVRISP MKII compatible with the Arduino development environment. There is an option under tools, burn bootloader, w/AVRISP mkII... but even after following these steps, it still won't work. I'm hoping at some point, the development team from Arduino fixes it...and I'm hoping when they do, you've already followed the steps you need to to make it work.

Step 4: Connect your AVRISP MKII to your ArduPilot and connect some form of power to the ArduPilot. I'm using my FTDI cable to power my board in the example here. There are two different processors on the ArduPilot. One is the ATiny45 which is the failsafe chip. It's labelled "1AT45" on the ArduPilot and the other is the main processor, the ATMega168 which is labelled "1AT168". You need to put the arrow printed on the plastic housing for the AVRISP MKII on the square hole on the ArduPilot. Let's start with the AT45. If you do not solder the header pins on the board, you'll need to hold them at an angle so they all make contact with the board. In the photos below, I have a battery sitting on the cable to hold the header pins so that they touch. The second green light should turn on and the blue light on your ArduPilot should start blinking. If the light on the AVRISP MKII is red then there's no connection. If it's blinking orange then you've got it backwards.

Step 5: Click Start, All Programs, AVR Atmel Tools, AVR Studio 4. Click cancel on the next screen that appears. Next Click Tools, Program AVR, Auto Connect.

Step 6: Click the "Main" tab and select "ATiny45" in the device list. Next click "Read Signature." You should get some numbers in the signature box. If you get an error box that says "ISP Mode Error" but you have 2 green lights on the AVRISP MKII and a blinking blue on the ArduPilot then skip below to the "Optional ISP Frequency setting" step.

Step 7: Click the Fuses tab and make sure they match the settings below

Step 8: Open a web browser and download the latest Failsafe source code. Don't worry, we only need the hex file in the zip so you won't have to compile anything. ArduPilot Source Code Page. You want to download something like "". Open this zip and extract the Fail_Safe.hex file somewhere you can find it on your computer (like your desktop).

Step 9: Back in AVR Studio, click the Program tab. Under "Flash" click the "..." button to browse for the hex file you just saved in step 8.

Step 10: Click "Program" under the flash section. If you get an error message that says "ISP Mode Error" but you have 2 green lights on the AVRISP MKII and a blinking blue on the ArduPilot then skip below to the "Optional ISP Frequency setting" step. You should get a response that says everything is "OK".

Step 11) Follow the same directions in steps 6-10 except, you'll need to select "ATMega328" on the Main tab (not ATMega168) and you'll need to use the file in your arduino environment at arduino-0018\hardware\arduino\bootloaders\atmega called "ATmegaBOOT_168_diecimila.hex". You'll also need to move the pins on your ARVISP MKII over to the "1AT168" position.

Optional ISP Frequency setting: On the main tab, click the button labelled "Setting" and select a lower number for ISP Freq. I have had the best luck with 6.478 kHz and 125 kHz. Make sure to click the "Write" button to save the setting and go back to the step you were on.

For more info on how to write the bootloader:
Last edited by HappyKillmore; Apr 15, 2011 at 11:38 PM. Reason: Fixed Typos
Sign up now
to remove ads between posts
Jun 05, 2010, 06:52 PM
Registered User
If anyone needs to buy a programmer, I'd suggest this one.

$20, works fine with WinAVR, has an extra Uart, and some o-scope functions.

Since they are cheap enough, I have several hard mounted to my robots/drones. Never had a problem with any.

Quick Reply
Thread Tools

Similar Threads
Category Thread Thread Starter Forum Replies Last Post
Discussion Any tips on un-warping EPP? Smokescreen38 3D Foamies 20 Jun 21, 2010 03:07 PM
Discussion Anyone use Ardupilot on Mike Power's (designes) airplanes? alanhsu Aerial Photography 0 Jun 01, 2010 07:40 PM
Discussion On Becoming an Un-Hyphenated American MtnGoat Life, The Universe, and Politics 19 May 05, 2010 04:28 PM
Alert proof that the USA is now under UN control "US Troops Wearing UN Colors" treehog Life, The Universe, and Politics 33 Dec 02, 2009 10:27 AM
Discussion ArduPilot on the cover of MAKE Magazine! zlite UAV - Unmanned Aerial Vehicles 0 Aug 05, 2009 10:34 PM