JTAG Dragon + STK500 --> programming yes, debuging no

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

Hi freaks,

I got a brand new Dragon but unfortunately I can't get it to do JTAG.

The target hardware is a ATmega32-16PU mounted on my precious STK500 which has nothing connected to it besides power. The reset jumper is off. They are connected via the STK500 JTAG adapter and a cable of about 12 cm or 4".

I'm able to read the signature, flash a programm, verify it and even change the fuse bits. But what just doesn't want to grghlng work is JTAG. It stops the connection while writing "Loading event memory ...". All I get is those three errors:

AVR Dragon: Timed out while waiting for response from the emulator. Please check cables and emulator power.
Coordinator: Error when writing memory contents to the debug platform.
Coordinator: Error loading object file.

I can't find an object file in any of my AVR C programs. I use the latest update of AVR Studio and updated the Dragon Firmware several times. I also connected JTAG directly to PortC on the STK500 which lead to the same behavior. I've also tried several internal clock settings (1...8 MHz) Google, forum search and AVR Studio didn't help.

I'm pretty much at the end of my wisdom here. Can anybody help?

PS: I need JTAG to debug my first paid coding project outside university :) [/bragging]

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

Quote:
The target hardware is a ATmega32-16PU mounted
....on the CORRECT socket? Is the JTAG header used the correct one?
Quote:
The reset jumper is off.
Why?
Quote:
I can't find an object file in any of my AVR C programs.
?? Don't you just do "Build and Run"? it will find what it is looking for provided you have correctly compiled code.

John Samperi

Ampertronics Pty. Ltd.

www.ampertronics.com.au

* Electronic Design * Custom Products * Contract Assembly

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

Quote:
....on the CORRECT socket? Is the JTAG header used the correct one?

I'm pretty sure yes but I'll post a photo just in case.

Quote:
The reset jumper is off.

Because the online-help tells me to. It hast no impact on the behavior anyway.

Quote:
?? Don't you just do "Build and Run"? it will find what it is looking for provided you have correctly compiled code.

I've always hit the green arrow. Using "Build and Run" doesn't change anything. I only started searching for the object file because AVR Studio talks about it. I guess the error for loading results from one of the other errors.

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

Your connections look perfectly normal. However you could have taken a photo showing the whole STK500!

I note that you are using the STK500 programmable clock.
I assume that you have this set to a sensible speed.

Your JTAG debug connection will assume that your AVR is running at 1MHz until you tell it any better. Go to Debug->AVR Dragon Options. A virgin mega32 will be running on its internal 1MHz RC clock. If you have set the fuses for ANY external clock mode, the AVR will run on the STK500 clock. (which can be set to very slow frequencies)

So I copied your setup (as far as I could see).
Providing I have the clock set to some speed >= 1MHz then the Dragon works just fine.

What messages do you get when you do a ctrl-F7 (compile and debug)?

David.

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

Here you go:

[img]http://img46.imageshack.us/i/img0073v.jpg/[/img]
[img]http://img641.imageshack.us/i/img0074jd.jpg/[/img]

I programmed the AVR to INT OSC 1 MHz, 2 MHz or 8 Mhz. I did tell a library function (not really a lib) that it was running at a RTC frequency. I'll spot the line soon and change it accordingly.

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

Your photo shows the problem.

You do not have a serial cable connected to the STK500. So you have no idea what the STK clock frequency is.

Mind you, if your fuses are written to set internal RC, then the STK clock does not matter.

You still need the JTAG clock to be set appropriately. Via the Debug menu as I showed earlier.

If you lied about the F_CPU speed to a library function, your F_CPU calculations will all be wrong. (typically Timers, RS232 and delay_us). But the JTAG debugging only depends on the actual F_CPU.

JTAG programming works whatever speed clock you are running.

So read your fuses to check you are on RC clock. Set the JTAG speed in Debug.

David.

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

My "AVR Dragon Options" button is grayed out. Shortcut doesnt work either. Even after I estsblished a connection via the connect dialog and read the signature. When I don't have a Dragon project open the button isnÄt there at all.

Maybe I'll try another computer? Pretty esotheric option though.

[edit]
Putting the mega at "int rc osc - 1MHz" doesn't change anything. I was pretty rough to my STK500 in the past btw ... it survived a bunch of shortings only getting a chip hot and desperatly blinking red-green-red-green. If nothing helps I'll try debugging w/o it.

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

Create a brand new project. Write a blinky or something trivial. Select mega32 + Dragon as platform.

Then Compile and Debug. (ctrl-F7)

You could just 'Start Debugging' from the Debug menu. This should un-grey your Dragon Options.

Your Dragon options should now be available.

David.

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

It seems that while I was sleeping you are moving ahead. :)

I don't remember seeing the RESET jumper needing to be removed for JTAG operation but
there is a lot of things I don't remember lately. :? In fact the JTAG Mk2 shows your exact
setup in "Using the JTAGICE mkII with STK500" with the jumper still in place.

It must of course be removed for DW debugging.

It may be a ggod idea to have a look at the message window as Studio starts up and as you try to connect for debugging, see if anything appears there.

OH I hate big pictures too, I need to scroll about 4 screens to type. :( no picture rescaling in maximised mode.
800 x 600 is a nice size.....

John Samperi

Ampertronics Pty. Ltd.

www.ampertronics.com.au

* Electronic Design * Custom Products * Contract Assembly

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

As I said in my post, the Dragon JTAG works just fine with the RESET jumper removed.

It also works with the RESET jumper in place.

It is only debugWire that needs the RESET jumper to be removed.

A photo only needs to show the Dragon and the STK500. A picture of your PC or wallpaper is not particularly useful.

David.

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

only a short note: if you click on the link and then on the picture you get a big zoom and can read the compiling messages.

At startup AVR Studio says something like "STK500 plugin loaded".

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

Looks like I found the bad guy:

Using a small blinky programm with a brand new m16 worked at the first try. How can a processor be programmable but not able to do jtag, although I've set his clock to "int RC 1 MHz 64ms startup"? JTAG and OCD Fuses are on.

Btw: The Dragon option is still grayed out.

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

Quote:

be programmable but not able to do jtag

Because its JTAGEN fuse has been set to the inactive state.

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

Quote:
JTAG and OCD Fuses are on.

at least that's what AVR Studio tells me, plus I've programmed it again when I set the clock to 1 MHz today

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

Hi,

I had just the exact same problem that was described in the op.

It turned out, that adding or removing some code, or changing the optimization parameter of GCC (from -Os to eg -O3) solves the problem. I suspect this could be some GCC or Studio related bug, but that's just a guess.

Peter

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

Thanks for your comment, I'll definatly try that.

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

omg, a blinky programm works with the m32. It really is my programm or AVR Studio. Unfortunatly I can't post my sourcecode here since it's for a commercial project. I do use Procyon though. Did anyone have issues with this "lib"?

bucienator, what kind of code did you remove or add? Changing optimization didn't help me.

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

I tried to find out witch part of my code causes Dragon to hang, so I commented the chunk I just added, and iteratively uncommented parts of it. It worked, until all of the code was uncommented again. Then I just added a code to increase, then decrease a volatile global variable, and that also fixed the case.

Maybe it was related to the size of the code that was to be uploaded to the device.

(Also note, that my setup is significantly different from yours: I have an ATmega168, on a breadboard, connected by debugWire to the Dragon.)

Peter

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

Quote:

I can't post my sourcecode here since it's for a commercial project. I do use Procyon though.

I'm sorry but that simply does not add up. Procyon avrlib is subject to the GNU Public License. All the source files say:

// This code is distributed under the GNU Public License
//		which can be found at http://www.gnu.org/licenses/gpl.txt

As such, as soon as you use one file from it your entire code becomes subject to the GPL and all source code must be made publically available.

So, yes, you can post your code.

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

The OP appears to be still struggling after 11 days.

10 days ago I tried his exact set-up. And it works just fine.

So I can only suggest that he really checks the actual AVR clocking speed. i.e. connect the STK500 properly with an RS232 cable. Check that the Vtarget alters correctly, check the programmable clock is set to a sensible value. Check that jumpers are set to sensible positions.

Disconnect as STK500 programmer. Re-connect as Dragon JTAG programmer. This should all correspond to the STK500 operations, except of course the programmable clock. The Dragon should read a sensible Vtarget voltage.

Disconnect as a Dragon programmer, and start a regular Debug session. The Dragon options should be un-greyed. If they are not, I would create a brand new project from scratch. If that does not un-grey, re-install Studio, re-install the Dragon.

David.

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

@Clawson: Uh, seems like I have to get into licence stuff (and have a talk with my client)

@david: I'll follow your instructions. I'm not very confident that it will help, though, since a LED-blinky program worked with the exact same setup right from the start.

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

Quote:

@Clawson: Uh, seems like I have to get into licence stuff (and have a talk with my client)

Well you could either use non-GPL code or even consider doing it yourself - there's little of any major complexity in these "libraries" when you study them - all they are doing is giving you some tested code you could have easily written yourself.

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

I don't know if im digging up old dirt here but I too have had the same problem. The debugging all worked fine until a certin size of code, then failed with a debugger time out loading even memory. Commented a bit out and it started working again. Forced my boss to by a AVR JTAGICE today because of it! :-). However i then removed the vaolatile keyword from two variables and now all the code works. I was using them to improve the debugger watch update as it seems to struggle when they are standard chars.
Well thats my 2p's worth, hopefully this may help someone.

Barry

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

Sorry, should have stated they were global volatiles.

Barry

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

The current Dragon firmware will debug any size of program. Originally there was a 32kB limit.

Changing a 'volatile' variable can make a massive difference to an executable program. You must be sure that you have a appropriate modifier.

AFIK, the Dragon should debug no better or worse than a JTAGICE-mkII. However the mkII is probably physically and electrically far more robust.

Regarding access times. Both debuggers need appropriate JTAG speed settings. In the Debug menu goto 'Dragon options'. There is no point in running slower than the Target AVR clock/4.

David.

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

Quote:

Changing a 'volatile' variable can make a massive difference to an executable program. You must be sure that you have a appropriate modifier.

Especially the size of the code image as you are effectively turning the optimiser off as far as those variables are concerned when they are volatile.

Sounds like you had a electrical issue that had a low statistical chance of disrupting the comms during programming - obviously the larger the block of code data being transferred the higher the chance it had of affecting things.

Some people find the power to the Dragon (esp. V1 without the PCB holes) to be "iffy", maybe try with a powered USB hub for a more stable voltage supply. Also try shortening the cables if long as many have found this helps too.

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

hello
can someone tell me the differences between dragon and stk 500?what more have the stk 500 to offer?i already have the dragon ,can i somehow use them together for on-board debugging if the stk 500 doesnt support on-board debugging?
thanks

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

Reading the STK500 manual in Studio or here http://support.atmel.no/knowledg... is not an option?

Stealing Proteus doesn't make you an engineer.

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

STK500 is dev board, LEDs, buttons, ISP programmer, HV programmer, frequency generator, variable level PSU

Dragon is (very!) mini dev board, ISP programmer, HV programmer, JTAG debugger, debugWire debugger

Although there's some overlap there, a combination of BOTH the STK500 and Dragon is a great set of tools to have.