5

Though an emulator is quite useful for debugging code that has no side effects, most real-world applications include some circuitry besides the Arduino. If a microcontroller on an Arduino had a JTAG interface, it would be pretty straight-forward, but what if it's e.g. an Arduino Uno?

polkovnikov.ph
  • 169
  • 1
  • 7
  • 5
    Could you elaborate on what you are trying to accomplish? Its not clear from the question that what exactly do you want to debug. – asheeshr Feb 27 '14 at 12:24
  • 2
    @AsheeshR The only thing that is possible to debug on Arduino is source code. There's a set of tools called "debuggers", which employ breakpoints, step-by-step evaluation etc. I don't understand your question. – polkovnikov.ph Feb 27 '14 at 15:12
  • 1
    @jippie You're wrong about that. DebugWire yes, but JTAG No. The ATMega168/368 has no JTAG support whatsoever. If you do a quick search of the datasheet you will not find any reference to JTAG – Madivad Feb 27 '14 at 15:15
  • @Madivad Is it possible to make another Arduino into USB to DebugWire connector? – polkovnikov.ph Feb 27 '14 at 15:17
  • @polkovnikov.ph I have never used DebugWire, so I don't know the first thing about it. I just did a quick google search, and there is stuff out there, so have a look at that. I have only ever used the JTAG pre Arduino days (ATMega128). – Madivad Feb 27 '14 at 15:25
  • 1
    DebugWire is an Atmel proprietary protocol, not much information available about it. – jippie Feb 27 '14 at 15:44
  • I would say you don't. The closest to debugging I've seem is having the Arduino listen to serial and perform commands (like e.g. variable dumping) on request. – andig Feb 27 '14 at 17:34
  • 1
    It seems there is possibility for interactive debugging with this tool: http://www.visualmicro.com/post/2012/05/05/Debug-Arduino-Overview.aspx it is not free but it is quite cheap. I haven't used it myself so I don't want to provide an answer for it. – jfpoilpret Feb 27 '14 at 22:47

2 Answers2

6

The Arduino Uno uses the Atmel Atmega328p microcontroller, which only has one debug option, DebugWire. There are a few tools that can work with it, but the least expensive and most commonly available is the AVR Dragon.

You can use AVR Studio 6 for this. You can use the .elf file file produced during the Arduino build process directly, but setting up the debugger is a little easier if you port the Arduino program to the AVR Studio. It's not difficult, but there are a lot of little pieces to deal with. There are guides online to help you through this.

Adam Davis
  • 648
  • 5
  • 7
  • 1
    Is there an AVR Dragon clone with open-source firmware? – polkovnikov.ph Feb 28 '14 at 13:28
  • Any links to those online guides? – polkovnikov.ph Feb 28 '14 at 13:30
  • There are MKII clones which will do debugwire with this chip, but I'm not aware of their open source hardware or software status, and am having trouble finding a good example easily. Here's one guide for using AVR Studio 6 with arduino projects: http://www.engblaze.com/tutorial-using-atmel-studio-6-with-arduino-projects/ – Adam Davis Feb 28 '14 at 15:48
  • 1
    Doesn't this require [removing a capacitor](https://awtfy.com/2010/02/21/modify-an-arduino-for-debugwire/)? – Peter Mortensen Sep 16 '17 at 11:42
  • 1
    @PeterMortensen I don't know, you'd have to examine the arduino uno schematic and the debugwire requirements along with your debugger's documentation. It may be worth asking a new question to get or share details of a specific setup. – Adam Davis Sep 16 '17 at 12:00
1

This might not be right for you, but the Visual Micro plugin for Atmel Studio and Visual Studio has a USB debugger which only uses Arduino code.

In the background the debugger uses Serial which might affect some time-sensitive applications.

Enter image description here

Peter Mortensen
  • 394
  • 2
  • 12
Visual Micro
  • 1,027
  • 6
  • 13