Debuger for nanoatmega328

I found information on

that " Arduino Nano ATmega328 has on-board debug probe and IS READY for debugging. You don’t need to use/buy external debug probe."

but only Compatible Tools is [simavr] that is a simulator, so it can debug but only on simulated env not actual board. How to debug on real board ? it “IS READY for debugging”

Hi porlock,

atmega328 chip uses AVR’s “debug-wire” technology instead of higher Chip’s JTAG stuff. That’s why, I really think that register-, breakpoint- and GPIO level debugging are only possible when connecting a debug device like the Atmel ICE to the 6-pin header.

I own an Atmel ICE and used it sometimes in the past, but I have switched to using serial output and - more recently - setting up unit tests both locally (to check if outputs are active etc.) and on native for more complex tests, completely abstracting the Hardware, only using the laptop’s compiler and a framework.

If you’re not dependant on e.g. analog in levels of the chip for your special application, it might be a good idea to dive into unit testing with PIO, saving time over fiddling around with registers.

Some additional reference: Debugger for Arduino uno / Mega and ESP8266 - #8 by ivankravets

Atmel ICE is definitely external probe, and documentation clearly says that

“You don’t need to use/buy external debug probe”

you think that someone made that such prime and big mistake and no one noticed it for so long time ?

1 Like

No, sorry, maybe I expressed myself not clearly enough.
I don’t know about the option that there is an Arduino Nano in-built “full” debug option. I didn’t find anything online about it on a quick search either.

It comes a bit down to what you understand by “debugging”. It is a completely different task to look at the stack contents at a given amount of time during execution than to simply print a GPIO value. The latter is possible with libraries, the former will need a dedicated chip that can halt the CPU and access it’s core and periphery.

The only thing I can imagine is that the serial-to-USB connecting chip can be used as a “workaround” debugger like here using serial monitor.

Never used it though, as aforementioned unit testing is a good tool to not having the need to go down that far.

Debugging in my understanding is track the code and ability to mark break points and track variables values. It doesn’t matter it will be realized by special library that will communicate with debugging software by serial, and exchange data thru it or it will be a special probe that will be able to read register values directly from mcu, or run special mcu instructions for memory dumping. End effect should be the same. Ability to mark break points and track variables values.

But i totally don’t understand what platformio creators have in mind putting this statement in documentation:

" Arduino Nano ATmega328 has on-board debug probe and IS READY for debugging. You don’t need to use/buy external debug probe."

It seems that it does not realize basic concept of debugging in anyway.

btw, nano has build in serial to usb chip.

Hi porlock, I did some digging.
Debugging the Nano ATmega328 is possible but likely just via the simulator simavr when you don’t want to spend money on an external probe. Additional References here. Just like you said.

From the statement

only the part about “on-board debug probe” is misleading. @ivankravets, are @porlock and I misinterpreting the documentation or should the “on-board debug probe” bit be changed to “debugging via simulator”? Or is it somehow possible to debug on target through simavr? Thanks :slight_smile:

1 Like

@schallbert, yesterday i opened an issue for platformio docs :slight_smile:

1 Like