JTAGICE MKII and ATMEGA48 DebugWIRE

Go To Last Post
13 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hi,

I am trying to use my MkII with a ATMEGA48. I have searched the forum for JTAG MkII and ATMEGA48 and have not seen one that has helped.

I used the STK500 to set the DWEN fuse.

I then connect the MkII Squid cable to the Green SPROG2 connector.

Then I connect using the MkII and try to read the device signature, I get the following error:

---------------------------
ISP Mode Error
---------------------------
A problem occured when executing the command. See the command output for more info.

Tip: Check that the ISP programming frequency specified on the 'Board' page is well
below 1/4 of the clock frequency of the device. Extra precaution should be made when
using the CKDIV fuse and/or Clock Prescaler Register (CLKPR) on parts supporting
this. If this does not help, check your connections.

See the troubleshooting section in the help system for more information on what may
have caused the problems.
---------------------------
OK Help
---------------------------

The command output is:

Setting device parameters.. OK!
Entering programming mode.. FAILED!
Leaving programming mode.. OK!

I reduced the ISP Freq. to 100 Hz and the message changed to:

Setting device parameters.. OK!
Entering programming mode.. FAILED!
Leaving programming mode.. FAILED!

I have tried other ISP Freq settings from 1 MHz down to 125khz.

I am using the internal oscillator at 1 MHz.

I have used my MkII with a ATMEGA16 but now I need to code a self-programming routine for the ATMEGA48 and therefore would like to use the DebugWIRE.

I have also noticed I do not have 'JTAGICE MkII Options' in my tool menu as described in several other posts.

Has anyone used a MkII w/ATMEGA48 in DebugWIRE mode?

Jeff Dombach, JLD Systems
"We do the stuff behind the buttons!"
Your source for embedded solutions with a 100% Guarantee.
http://www.jldsystems.com
Phone 717.892.1100

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

DebugWire does NOT work using the AVRISP/STK500 programming tool.

You must start a debug session before the JTAGICE MKII Options will show up.

It will ONLY program the ATmega48 when starting a debug session. It will not program the any fuses (except unprogram DWEN when disabling it using Debug->JTAGICE MkII Options->Disable debugWIRE) or lockbits. Reading the signature also is not supported.

Only an STK500/AVRISP or equivalent will program fuses/lock bits and ONLY after the debugWIRE interface has been disabled.

If you cannot enter a debug session and the DWEN fuse has been programmed, use the command line program with the -W option as documented in the AVRStudio JTAGICE mkII User's Guide help file. After running the program, keep power applied and hook-up your STK500/AVRISP. Now you can unprogram the DWEN fuse and be able to read the signature with the STK500/AVRISP.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I think I may have confused you. I used the STK500 to set the DWEN fuse and then connected the JTAG MkII to the processor plugged into the STK500. I then restarted the AVR Studio and selected to use the JTAG MkII. Then I received the error.

All of the start debug options are also disabled.

I have tried it with only the JTAG MkII connected to the PC and I still don't have the menu option and the JTAG cannot read the sig. bytes.

Jeff

Jeff Dombach, JLD Systems
"We do the stuff behind the buttons!"
Your source for embedded solutions with a 100% Guarantee.
http://www.jldsystems.com
Phone 717.892.1100

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

As of right now, the JTAGICE mkII will never read the signature byte on a debugWIRE device. It is only possible to debug your code with debugWIRE. AVRs with the debugWIRE interface are not full JTAG parts and cannot be accessed using the STK500 programming tool.

Have you setup the JTAGICE mkII as the debugger? This is done using the Debug->Select Platform and Device window.

To start a debugging session, click on Debug->Start Debugging or the right pointing blue triangle on toolbar. If the DWEN fuse is not programmed then AVRStudio will prompt you to program it using the squid cable. When that is finished, a debug session will be started and your latest code will be programmed using the debugWIRE interface.

When you change your code, AVRStudio will stop the debug session, rebuild your code and start a new debug session which uploads your latest code.

When you want to leave debugWIRE mode, select Debug->JTAGICE MkII Options and press the Disable debugWIRE button on the Connection tab. This will unprogram the DWEN fuse.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I understand now.

I have the JTAG MkII connected and can step thru the c source and see the changes on the LEDs attached to PB on the STK500.

I also now have the JTAG MkII options.

Thank-you BPar for helping me past my mental block!

Jeff

Jeff Dombach, JLD Systems
"We do the stuff behind the buttons!"
Your source for embedded solutions with a 100% Guarantee.
http://www.jldsystems.com
Phone 717.892.1100

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I am also having trouble using the JTAG ICE MKII with Debug Wire. My processor is an ATmega324P. My debugger is AVR Studio 4. I have the 6 ISP wires connected. AVR Studio can connect and read the signature with no problem. When I first open AVRStudio, "Start Debugging," is dimmed out. So next, I open a .cof file, built with CodeVision. Then, it invites me to select my device and debug platform, which I do. Then, it reports, "Failed to identify target. Would you like to retry with external reset enabled?"
I click, "Yes."
It responds, "Failed to identify target. Would you like to use SPI to enable the JTAG interface fuse? To continue, use the squid cable to attach to the target's SPI pins." (It is already connected.)
I click, "Yes."
Then is says, "JTAG interface has been enabled. Reattach the probe to the JTAG connector to continue."
I don't have a JTAG connector. I have only ISP. I'm trying to use DebugWire. Nonetheless, I click, "OK."
It repeats, "Failed to identify target. Would you like to use SPI to enable the JTAG interface fuse? To continue, use the squid cable to attach to the target's SPI pins."
Thus I am stuck, and would greatly appreciate any advise.

-Josh

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Silly question but what has debugWire got to do with a mega324P? Surely that chip has JTAG not dW and as such the "on/off switch" is simply the JTAGEN fuse which is on by default anyway. Only if you've previously switched it off while reprogramming fuses might you need to use ISP to re-enable the fuse.

Having done that forget the ISP wires and the 6 pin header. JTAG is done with different wires connected to a 10 pin header.

EDIT: just checked datasheet for 324P - my memory was right - it does have JTAG not dW so you cannot use the 6pin ISP header for this. You need the four signals on PC4, PC5, PC6, PC7 together with Vcc, Gnd and _Reset run out to the 10 pin header that JTAG will use.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Uh, oh. My board doesn't have a 10 pin JTAG header. Does that mean it isn't debuggable at all?

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Quote:

Does that mean it isn't debuggable at all?

Probably but maybe you can just put "flying wires" on the relevant signals and bring them up to a 10 pin header.

Is this a board you laid out yourself or a commercial design you bought? It does seem a bit short sighted for any commercial design using 40 pin AVRs to not at least layout some 2x5 pads for a JTAG header to be fitted.

If it's your own board you'll know on the next Rev. to add this.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Thank you, Clawson, very much for the news that the mega324P does not offer debugWire. I had assumed that all the Atmel processors had it. That would explain why I can't debug through my ISP header. I guess I will have to solder wires onto those 4 JTAG nodes of my board.

-Josh

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Nope I don't think there's any AVRs over 28 pin that have dW. It's a bit of a "cut-down" solution to provide some debugging when the device doesn't have enough pins to "spend" 4 of them on JTAG. Almost all 40 pin AVRs (some early 8K models excepted) have JTAG for their On Chip Debug. To be honest it's actually a lot less hassle (IME) than dW.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

BPar wrote:
DebugWire does NOT work using the AVRISP/STK500 programming tool.

You must start a debug session before the JTAGICE MKII Options will show up.

It will ONLY program the ATmega48 when starting a debug session. It will not program the any fuses (except unprogram DWEN when disabling it using Debug->JTAGICE MkII Options->Disable debugWIRE) or lockbits. Reading the signature also is not supported.

Only an STK500/AVRISP or equivalent will program fuses/lock bits and ONLY after the debugWIRE interface has been disabled.

If you cannot enter a debug session and the DWEN fuse has been programmed, use the command line program with the -W option as documented in the AVRStudio JTAGICE mkII User's Guide help file. After running the program, keep power applied and hook-up your STK500/AVRISP. Now you can unprogram the DWEN fuse and be able to read the signature with the STK500/AVRISP.

Thank you guys, this solved my problem.

I disabled DWEN fuse with JtagIce MKII, then I lost all communications with my target board.

I went to "AVR simulation Options" in the debug menu and then entered debug mode and it worked fine.

I guess you have to exit debug mode like you guys said, because JtagIce MKII will disable the DWEN fuse. Only after DWEN is disabled will you be able to use AVRISP or JtagIce MKII in ISP mode.

My atmega328P doesn't seem to have support for a true JTAG, only jtag debug wire, which is not the same, which was also mentioned earlier.

I just got my JtagIce MKII btw. It rocks, i'm using it with AVR Studio 4, waiting for AVR Studio 5 to become more stable.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Quote:

I went to "AVR simulation Options" in the debug menu and then entered debug mode and it worked fine.

But that's just a software simulator - nothing to do with your JTAGICE or debugWire?!?