Posted by Chris Anderson on December 22, 2008 at 11:30am
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).
My ArduPilots are amongst the first batches sent out. I started setting up the board for ArduPilot 2.0 and wanted to reflash the ATTiny. After sodoing the soldering work I connected the GPS and the throttle connection from the ESC. No LEDs lit and I have another ArduPilot which I checked with the same setup. There is power in the pins where the throttle is connected but nothing is happening. I tried it in the same configuration but with the AVRISPII connected and same thing. So seems there is a big problem somewhere!
Thanks, I found this snapshot while I was looking for possible similar problems. I may pester somone to compare another screen for me when I get home. I believe the "Brownout" messages were in another tab within the AVR Studio.
Chris - regarding the DIY boards, I am personally concernd because I'm so new at this that I'll be constantly toasting stuff. I believe I'd like to put together one of the through-hole version that way blown items can be replaced easier. The size for testing is not as much an issue for me as it may be for others. Is the latest board we could build ourselves something that will still work? I remember there was a diod that needed to be left out because it was wrong in the board but other than that is it something that can be used? You have any for sale? (just thought I'd ask, cause it's faster than ordering new ones!)
Brian. I'm not sure what the problem is. If your voltages are right, the only thing I can think of is that you've toasted the attiny somehow or have a short somewhere on the board. The fuses should look like this:
Chris - I would very much appreciate your assistance.
I was attempting to use the setup a simulator that uses ArduPilot and the FMS (flight model simulator) and gps simulator. The goal was to see if the model would take input from the com port (ultimately from my radio) and be able to switch into ap mode and return launch or move around the flying field using waypoints. Either would work for me, but...
After attempting the Ardupilot mux light stays lit and takes no input from the radio toggle. The light dims slightly as you engage/disengage the mux.
I had attempted to load ArduPilot 2.0 but ended up being one of the fools that downloaded it before the final was posted, so I reloaded my previous version and that process is fine, but the mux remains lit even when the esc is the only thing attached. All other lights seem normal.
I attempted to reprogram the ATtiny45 but get errors entering programming mode. I am able to see the device and have tried using 125khz and 250khz and get the same errors.
When I check the settings within AVR Studio I see several settings that say something about "Brownout protection" which I don't recall seeing before. Unfortunately I am at work and do not have access to the board to give a better description.
I have a question about the ATtiny 45 on ArduPilot: does the ATtiny45 have code loaded in its EEPROM? If yes, since I have to replace this uC on my ArduPilot board, could someone (Chris or Jordi maybe) tell me where I could download its hex file. Many thanks.
No need to waste $35 and/or 5 days if you are willing to do some work. With a $2 DB25 connector/cable from $LOCAL_ELECTRONICS_STORE you can use connect the AT45 SPI programming lines directly to a PC parallel port and use "avrdude" to burn the fuse and fail safe program. Wire everything like an stk200 (Google for info, if you can't figure it out it's nature's way of telling you not to do it) and supply 5V to the Ardupilot VCC. Then, in Debian:
1. apt-get install avrdude ncurses-hexedit
2. modprobe ppdev (build it if your kernel doesn't have it. You do know how to build a kernel, right?)
3. avrdude -p t45 -c stk200 -U lfuse:r:lfuse.bin:r
4. Open lfuse.bin in "hexeditor". If it's 0xe2 already, your AT45 is already 8MHz (the end goal), so skip to #6-7. If it's 0x62, edit it to 0xe2 in the hex editor, then run #5-7. If you think I'm trying to brick your AT45, double check the value against the datasheet doc2586.pdf pg 153. We're setting CLKDIV8 to 1, which in Atmel fuse parlance means disabled, so no divider, 8MHz.
5. avrdude -p t45 -c stk200 -U lfuse:w:lfuse.bin:r
6. avrdude -p t45 -c stk200 -U flash:w:Fail_Safe_v15.hex:i
7. Power cycle your board 3 or 4 times, until the AT45 stops running Sparkfun's "backwards diode" mfg test (red/green LED blinking)
Now you're ready to go. Unsolder the rats nest from the AT45 SPI port.
You can use a similar process to restore the ATMega168 bootloader if needed
Alternatively, just physically remove the AT45 and connect the MUX control + CTRL servo input to spare pins on the ATMega168. You will have to modify some code but this may actually be safer (fewer components to buy the farm).
The flashing sequence when you first get the board is just a LED test routine that Sparkfun loads. It is not the ArduPilot software, which you still have to load. The flashing sequence will go away once you do that and you'll just get the yellow LED blinking ocassionally on startup, which is the bootloader. If your MUX is not working rock solid (and I think all the ones arriving around now should be), you should check the Attiny fuse.
Hi Amoisonic
does the MUX Control input turn the MUX LED on and off , if it does you probably need to just load the auto pilot software into the main chip through the FTDI pins that are located on the same edge as the GPS plug
as i understand it , the flashing patern you are seeing shows the bootloader is loaded into the main chip , and it is ready to have the software flashed in through the FTDI pins
[QUOTE]Now it's time to load the software. Download and install Arduino, if you don't already have it. Download the latest ArduPilot code, which can always be found on the ArduPilot home page. Load the ArduPilot "sketchfile" (click on any of the .pde files in the ArduPilot directory).[/QUOTE]
Amoisonic: So the MUX light does not switch with the channel from the Rx? If so most likely you do indeed have the CKDIV8 fuse set. On mine it sets the MUX mode sometimes if I leave it powered on, or turn it off and on a few times.
I've yet to program the ATTiny45 fuse but I assume that is the issue, will report back once I have the AVRISP cable made and tried it.
I have just received the board today and the date of shipment is 11th Feb 2009,but it looks like that the Attiny firmware problem still exists with the new stock.Red LED steady "ON",blue and yellow LEDs are flashing with pattern,but MUX LED is only flashed once when powered up.The MUX Control input has no effect to external PWM input.
Comments
Am I missing something?
Chris - regarding the DIY boards, I am personally concernd because I'm so new at this that I'll be constantly toasting stuff. I believe I'd like to put together one of the through-hole version that way blown items can be replaced easier. The size for testing is not as much an issue for me as it may be for others. Is the latest board we could build ourselves something that will still work? I remember there was a diod that needed to be left out because it was wrong in the board but other than that is it something that can be used? You have any for sale? (just thought I'd ask, cause it's faster than ordering new ones!)
Mahalo -Brian
I was attempting to use the setup a simulator that uses ArduPilot and the FMS (flight model simulator) and gps simulator. The goal was to see if the model would take input from the com port (ultimately from my radio) and be able to switch into ap mode and return launch or move around the flying field using waypoints. Either would work for me, but...
After attempting the Ardupilot mux light stays lit and takes no input from the radio toggle. The light dims slightly as you engage/disengage the mux.
I had attempted to load ArduPilot 2.0 but ended up being one of the fools that downloaded it before the final was posted, so I reloaded my previous version and that process is fine, but the mux remains lit even when the esc is the only thing attached. All other lights seem normal.
I attempted to reprogram the ATtiny45 but get errors entering programming mode. I am able to see the device and have tried using 125khz and 250khz and get the same errors.
When I check the settings within AVR Studio I see several settings that say something about "Brownout protection" which I don't recall seeing before. Unfortunately I am at work and do not have access to the board to give a better description.
Any Ideas where I should go next?
Thanks - Brian
1. apt-get install avrdude ncurses-hexedit
2. modprobe ppdev (build it if your kernel doesn't have it. You do know how to build a kernel, right?)
3. avrdude -p t45 -c stk200 -U lfuse:r:lfuse.bin:r
4. Open lfuse.bin in "hexeditor". If it's 0xe2 already, your AT45 is already 8MHz (the end goal), so skip to #6-7. If it's 0x62, edit it to 0xe2 in the hex editor, then run #5-7. If you think I'm trying to brick your AT45, double check the value against the datasheet doc2586.pdf pg 153. We're setting CLKDIV8 to 1, which in Atmel fuse parlance means disabled, so no divider, 8MHz.
5. avrdude -p t45 -c stk200 -U lfuse:w:lfuse.bin:r
6. avrdude -p t45 -c stk200 -U flash:w:Fail_Safe_v15.hex:i
7. Power cycle your board 3 or 4 times, until the AT45 stops running Sparkfun's "backwards diode" mfg test (red/green LED blinking)
Now you're ready to go. Unsolder the rats nest from the AT45 SPI port.
You can use a similar process to restore the ATMega168 bootloader if needed
Alternatively, just physically remove the AT45 and connect the MUX control + CTRL servo input to spare pins on the ATMega168. You will have to modify some code but this may actually be safer (fewer components to buy the farm).
does the MUX Control input turn the MUX LED on and off , if it does you probably need to just load the auto pilot software into the main chip through the FTDI pins that are located on the same edge as the GPS plug
as i understand it , the flashing patern you are seeing shows the bootloader is loaded into the main chip , and it is ready to have the software flashed in through the FTDI pins
here is a link that covers it
http://diydrones.com/profiles/blogs/ardupilot-assembly
scroll down and you will see this section
[QUOTE]Now it's time to load the software. Download and install Arduino, if you don't already have it. Download the latest ArduPilot code, which can always be found on the ArduPilot home page. Load the ArduPilot "sketchfile" (click on any of the .pde files in the ArduPilot directory).[/QUOTE]
.
I've yet to program the ATTiny45 fuse but I assume that is the issue, will report back once I have the AVRISP cable made and tried it.