Atmel ICE and Arduino ATMEGA 2560 Board

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

I have recently been using an Arduino (Sunfounder) ATMEGA 2560 development board with the standard Arduino IDE software.  I switched to Atmel Studio-7 to take advantage of the JTAG debug capabilities of the program.  To do this, I purchased an Atmel ICE - Basic debugger and tried to get it running with no success.

 

When I setup the debugger in Studio-7, I selected Atmel - ICE and "JTAG" for the interface.  If I try to start a debug session, I immediately receive an error that states:  "Failed to launch program.  Error: No JTAG devices detected.  Debugger command Activate physical failed".

 

Has anybody successfully setup an Arduino ATMEGA 2560 board and an Atmel ICE debugger?  If any body has any ideas, it would be greatly appreciated - thanks.

 

Hahnsolo

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

Arduinos have a nasty habit of having their main AVR's _Reset line driven by the DTR signal from the USB-UART chip (so avrdude can force the CPU to reset into its bootloader). As debugging wants to control _Reset this means there's usually a conflict. For this reason most Arduino boards have a solder link that can be broken with a soldering iron to detach DTR from Reset. You probably need to explore what facility your board has to achieve this. While detached it will make uploading code with avrdude and the bootloader more complex as you'll have to manually reset the AVR but when using JTAG you'll be delivering code over JTAG anyway (and in doing so the bootloader gets wiped anyway). 

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

JTAG (real JTAG) doesn't use RESET, does it?  I've used a JTAG ICE3 with an ATmega1284-based boards that had a JTAG connector without having to disable the auto-reset circuitry.  I think.

 

 

How do you have your ICE connected to the Arduino MEGA?  By default, the MEGA does not have a JTAG connector.  (Thus https://oshpark.com/shared_proje... )

If you were trying to connect to the ISP connection, you'd need to select the "debugwire" interface (and then you'd run into the problems clawson describes.)

 

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

The MEGA2560 comes out of the box with JTAG disabled. The Arduino software uses the pins for Analog.

Yes, you can enable with the JTAGEN fuse. Connect the ATMEL-ICE to the JTAG pins.
Then use AS7 for building and debugging projects.

Since JTAG does not need to use the hardware Reset pin, the DTR capacitor is not a problem. If you specifically ask to use the hardware Reset pin, it is wiggled relatively slowly. Capacitance is not critical. Much like Reset wiggling on the ICSP interface.

David.

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

JTAG (real JTAG) doesn't use RESET, does it? 

YES it does, it's the only way to recover JTAG functionality when the firmware disables JTAG.

John Samperi

Ampertronics Pty. Ltd.

www.ampertronics.com.au

* Electronic Design * Custom Products * Contract Assembly

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

No it does not.

JTAG has a software reset command that does not need the Reset pin at all.
You only need to use the Reset pin if you have used JTD.

When the hardware Reset pin is wiggled, it is relatively slow. So even if there is 100nF on the Reset pin, the reset pulse is longer than the RC. I guess that 47uF would not kill the reset pulse. I would not trust a 1F supercap.

David.

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

Ok, so I'm not sure where this leaves me.  

 

There are two AVR microcontrollers on the ATMEGA2560 board.  One is an ATMEGA16U2 that handles the USB interface, and the other is the ATMEGA2560 MCU itself.  Each one has a 6-pin ICSP connector next to it.  

 

*  In which device is the bootloader stored?

 

*  When using the ICE device, which 6-pin ICSP connector should I be using?

 

*  I am still unable to make a connection.  Is there something else I missed?

 

Thanks for the help.

 

Hahnsolo

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

Hahnsolo wrote:
* In which device is the bootloader stored?
The big one.
Hahnsolo wrote:
* When using the ICE device, which 6-pin ICSP connector should I be using?
The one next to the big one.

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

I went into the device programming section of Studio-7 and selected the ISP interface to enable the "JTAGEN" fuse, and disable the "BOOTRST" fuse on the ATMEGA2560 (the "big" one).  I can also read the device signature and have what appears to be a valid connection.  When I switch the interface back to "JTAG" and attempt a debug session, it immediately give me the "No JTAG devices detected" error.  At this point I'm beginning to wonder if I have a bad ICE device.

 

Hahnsolo

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

Enable JTAGEN via ISP.
Then connect via JTAG. i.e. A4, A5, A6, A7 and 5V, 0V.
You can connect the RESET pin if you want. It is only necessary if you use JTD.

David.

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

You only need to use the Reset pin if you have used JTD.

Thanks for agreeing with what I said above. wink Doesn't EVERYBODY do that or they simply waste 4 pins sacrificed to the JTAG god? 

John Samperi

Ampertronics Pty. Ltd.

www.ampertronics.com.au

* Electronic Design * Custom Products * Contract Assembly

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

Ok, I think I've finally got this thing worked out.  There was an incredible amount of confusion on this matter, at least for me (and probably many other users with Arduino development boards).  Here's what I've found:

 

1.  When connecting to the Arduino ATMEGA2560 board, the small 6-pin connector at the end of the ICE cable IS NOT FOR JTAG!  It is for accessing the on-board memory of the 2560 device through SPI.

 

2.  As per above, you DO have to connect the ICE 6-pin connector (tab towards MCU) to the ICSP header in the middle of the board next to the 2560 chip to access its memory.

 

3.  The ICE box DOES NOT power the ATMEGA2560 board like the original USB cable did.  You must plug in an external +9VDC wall wart to provide power, which the ICE box then senses.

 

4.  Once the ICE cable and the external power is connected to the board, you need to open up Atmel Studio-7, click on "Tools", then "Device Programming" to call up the setup dialog box.

 

5.  Once in the dialog box, select "Atmel-ICE" for the tool, "ATmega2560" for the device, "SPI" for the interface, then click "Apply".  This will bring up a menu on the left side.  Select "Fuses", and a list of fuses will appear.

 

6.  Place a check mark in the "OCDEN", "JTAGEN", and "BOOTRST" check boxes, then click "Program" to set the fuses in the 2560 chip.  Close the dialog box.  Unplug power from the board and the USB cable from the ICE box.

 

7.  Unplug the 6-pin connector from the ATMEGA2560 board and the cable from the ICE box.  Peel back a small section of the 5th wire on the ICE box ribbon cable that has been left un-terminated, and solder a 3-4" wire onto it.  Strip the other end and solder a pin to it.

 

8.  Now, use jumper wires and connect between the ICE box 6-pin connector and the ATMEGA2560 board Analog-In pins in the following order:  Pin-1 (TDO) to Analog-In A6,  Pin-3 (TCK) to Analog-In A4,  Pin-4 (TDI) to Analog-in A7, the wire you terminated in step-7 (TMS) to Analog-In A5, Pin-2 (Vsense) to +5VDC on the board, and finally, Pin-6 (GND) to ground on board.  I did not connect the reset line; time will tell if I need it.

 

9.  Next, plug in the USB cable to the ICE box, then the board power plug (in that order).  The left LED on the ICE box should be lit up green, and the middle LED should be lit up red, indicating power is properly applied to the board and the ICE box.

 

10.  Call up the setup dialog box in Studio-7 once again by clicking  on "Tools", then "Device Programming".  This time select "Atmel-ICE" for the tool, "ATmega2560" for the device, "JTAG" for the interface, then click "Apply".

 

11.  If all is well the a menu will once again pop up on the left side.  Select "Fuses" once again.  Check that "JTAGEN" and "BOOTRST" are checked ("OCDEN" may or may not be checked - don't worry about it).  Device Signature and Target voltage will be displayed if you've successfully connected.

 

Hope this helps somebody in some small way.  This was an incredible amount of digging, reading, and experimentation.  I'm not sure why it has to be that way, but I did get it to work.  Thanks to all who contributed to this thread and got me pointed in the right direction.  I don't think I would have been successful otherwise.

 

Hahnsolo

Last Edited: Thu. Feb 25, 2016 - 11:24 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

the small 6-pin connector at the end of the ICE cable IS NOT FOR JTAG!

Who ever said it was? 6 pin for ISP and 10 pin for JTAG (even though some people still use 10 pin for ISP after 15 years+ on not being used by Atmel)

 

... my eyes are getting blurry reading the rest... wink

John Samperi

Ampertronics Pty. Ltd.

www.ampertronics.com.au

* Electronic Design * Custom Products * Contract Assembly

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

hahnsolo - THANK YOU!! THANK YOU!! THANK YOU!! THANK YOU!! THANK YOU!! THANK YOU!! THANK YOU!! 

 

In years past that would have required some typing - now it's just copy and paste, but the sentiment is still the same.

 

I, also a newby, have been struggling with this for a month.  Arduino documentation is the worst I've seen in 50+ years of messing around with computers.  I bet no one else on this thread knows what a Bendix G15 is, let alone have programmed one.  I had most of the solution figured out and suspected there was something about the fuses that needed adjusting - but I didn't know how to adjust them or even how to access them.  

 

THANK YOU!! THANK YOU!! THANK YOU!! (more pastes)

 

I have between 4 and 6 Mega2560 boards to program, depending on the complexity of the code, so I built a patch board to connect the ICE to the mega (see attached photo of the smallest node).  It's just a simple stripboard.  Wiring is underneath along with a filter cap.  It looks to be working OK.  

 

Again thanks a bunch.

Attachment(s): 

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

in 50+ years of messing around with computers.

Oh you young ones...... wink

John Samperi

Ampertronics Pty. Ltd.

www.ampertronics.com.au

* Electronic Design * Custom Products * Contract Assembly

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

Hi hacketet:

 

LOL - well that just made my day!  I guess it wasn't a waste of time to document the process after all.  

 

The guys on this forum got me started in the right direction, but then I just had to hammer through it to figure out the rest.  The real confusion for someone new to Arduino boards and external programmers is understanding the duality of programming through the on-board USB port versus programming via external device through the pins on the analog port.  BTW, if you programmed the 2560 through the external device, you've wiped your bootloader code.  However, if you ever need to restore it, I found a great link that explains how to do it using Atmel Studio 7 and your external device:  http://wspublishing.net/avr-c/re....

 

Glad this helped you out.  Keep us posted on your project results.

 

Hahnsolo

Last Edited: Thu. Apr 7, 2016 - 03:51 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

understanding the duality of programming through the on-board USB port versus programming via external device through the pins on the analog port.

 Triple-nature, not just duality!  You have the bootloader with access via a serial UART and the USB converter, ISP access via the SPI pins and/or the 6-pint header on the board, and JTAG via the pins shared with analog IO.

 

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

Hi westfw:

 

LOL, right after I posted that it occurred to me that there really are three methods to access the device.  It's no wonder that people have trouble with this when they first attempt to interface to the Arduino board.

 

Hahnsolo

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

Thanks Hahnsolo!!

Based on your tutorial I was able to launch an Atmega 1284P project in an hour.

I was struggling for a week to do it before.

 

Thanks again for your energy to write it down!

 

Csaba

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

Hi Csaba:

 

Glad this worked out for you.  Good luck with your project and keep us posted.

 

Hahnsolo

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

Just wanted to let you know that there are some of us hanging on that have programmed the Bendix G-15 with it's drum memory, bell and punched paper tape.

stjoe