Step one is to make the Oilpan your JTAG cable by coupling the AVR Squid cable with your Oilpan. This post assumes that you have broken your APM1.4 by following the JTAG post for APM1.0. 

photo.JPG?width=400

http://code.google.com/p/ardupilot-mega/wiki/JTAG

http://code.google.com/p/ardupilot-mega/issues/detail?id=424

There is a chicken / egg sort of scenario here. You are likely not reading this unless you have already enabled JTAGEN fuse previously. 

I spoke to SparkFun about my boards that no longer responded to the APM planner and they gave me the following script: 

@echo off
MODE CON:cols=150 lines=80
color F0
TITLE ArduPilotMega v14
CLS

:setcomport
CLS
set /p comport=Please type your FTDI's COM PORT number and press enter:
TITLE ArduPilotMega v14 (COM%comport%)
CLS

set $step1=Fuse bits
set step1="C:\Program Files\Atmel\AVR Tools\STK500\Stk500.exe" -e -dATmega2560 -ms -q -cUSB -I125kHz -s -wt -fD8FF -EFD -FD8FF -GFD

set $step2=Program Bootloader onto ATmega2560
set step2="C:\Program Files\Atmel\AVR Tools\STK500\Stk500.exe" -e -dATmega2560 -q -pf -vf -if"\\ArduPilotMega\ArduPilotMega-v14\stk500boot_v2_mega2560.hex" -ms -cUSB -I1MHz -s -wt -lCF -LCF

set $step3=Serial Upload Testcode onto ATmega2560 via COM%comport%
set step3="\\\arduino\hardware\tools\avr\bin\avrdude.exe" -p atmega2560 -P COM%comport% -c stk500v2 -b 115200 -C "\\\Arduino\arduino-0021\arduino-0021\hardware\tools\avr\etc\avrdude.conf" -V -U flash:w:"\\\ArduPilotMega\ArduPilotMega-v14\APM_selftesting_14.cpp.hex"

set $step4=Program ATmega328
set step4="C:\Program Files\Atmel\AVR Tools\STK500\Stk500.exe" -e -dATmega328p -s -q -pf -vf -if"\\\ArduPilotMega\ArduPilotMega-v14\ap_ppm_encoder_v1.4.hex" -fDFFF -EFE -FDFFF -GFE -ms -cUSB -I125KHz -s -wt -lFF -LFF

(note I removed their internal hostnames so it needs slight fixing) 

 I don't use the same tool kit that they do so I had to use my JTAGICE and the latest Atmel Studio. 

To follow along next you should install the latest version of Atmel Studio 6.0 via as6installer-6.0.*.exe from the Atmel website. 

Make sure that the proper lights are on your JTAGICEmkII the green light indicates that you should be good to go! Obviously check your PATH settings as well. 

at the command prompt type: 

atprogram.exe -t jtagicemkii -i jtag -d atmel2560 program -f stk500boot_v2_mega2560.hex

You can obtain the .hex file in your Arduino install or by mailing SparkFun or simply by hunting on google. 

Next open up the Atmel Studio 6 interface. Go to the Tools menu and click Device Programming. 

photo.JPG?width=400

Next click the Tool menu and be sure to select Tool: JTAGIC mkII and Device: Atmega2560 as well as Interface JTAG. Click Apply. Then next to Device signature, click Read. Your device sig should read 0xsomething and the Target Voltage should also show. 

photo.JPG?width=400

Click on fuses in the left hand tab and set the Fuse Register and Values as follows: EXTENDED - FD, HIGH - D8, LOW - FF. Since there is a possibility that your ISP interface is broken or that you do own an ISP tool you should be mindful to click the JTAGEN box with will modify the above settings to: EXTENDED - FD, HIGH - 98, LOW - FF, Finally click Program. 

photo.JPG?width=400

Last step is remove jtag plug from JTAGICE harness. Unplug the power from the Oilpan (USB) and plug it back in. The device should now be recognizable in the APM planner again. 

From here you should be able to start heading the path of debugging with avr-gdb and avarice as a proxy. 

I hope I didn't leave anything out! That was excruciating to go through. =]

 

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

Join diydrones

Email me when people reply –

Activity