Getting Started with Atmel Studio 7 (AS7) and Atmel ICE

I posted this in another area of the forum before I saw this area, which is probably a more proper location for the post.

I recently purchased 5 Chinese eMakeFun Nano clones with the CH340 USB chip for the purpose of trying to learn how to transition from the Arduino IDE to the AS7 and the Atmel ICE debugger. I tested a few of the clones (on Windows 10) using the Arduino IDE after fussing around and finally setting the IDE to use the "Old Bootloader"for the Nano. Without that, the Nano clone would not program. After that the Nano clone programmed perfectly.

I don't think the bootloader is a factor when programming with Atmel-ICE. I also don't think that the CH340 chip is a factor when programming with Atmel-ICE. After I installed AS7, I tried to program one of the Nano clones using the ISP connector and the debug-Wire mode. The flat ribbon cable with the 10-pin end was connected to the AVR connector on Atmel-ICE, and the 6 pin ISP connector was connected to the ISP connector on the Nano with pin 1 properly connected to pin 1 of the Atmel-ICE connector (the pin 1 location is a little weird on the Nano).

The first thing it told me was that my Atmel-ICE needed a firmware upgrade, which it completed. This confirmed to me that Atmel-ICE was communicating with my computer (i.e., the proper drivers were installed with the AS7 installation).

I then came to realize that the Atmel-ICE apparently also needs the board to be powered externally (from the USB connector, presumably), or the target power LED will not light. I was a little taken aback by this because there is a 5V and ground connection on the ISP. After plugging in the Atmel-ICE to the clone Nano board, I could not get AS7 to read the device ID of the CPU or its fuses. When I tried to do that, I got the message that the Atmel-ICE (or AS7) "could not establish a programming connection to the device". And, of course I could not program the board. I tried to program the board with a minimum program of main and while(1) and debug it. The original blink program still persisted in the Nano.

Then I tried to reset the Nano and to try to program it in the Arduino IDE, and it will not respond. And the blink program is now gone. This leads me to think that there is something I am missing doing when setting up the AS7 for the 328P on the Nano. Perhaps some fuses were also reprogrammed. It did ask to set the fuse for debugging, and I allowed AS7 to do that (but that program and debug action failed with the message that AS7 or Atmel-ICE could not enter the programming mode).

I still have 4 more pristine Nano clones, but I'd like some ideas to try to get Atmel-ICE to read the device ID and the fuses. Or better, a step-by-step procedure to get started programming a clone Nano.
The clones cost me less that $4 each, so I don't worry so much if the Nano cannot be restored to work.

I also don't think that the CH340 chip is a factor when programming with Atmel-ICE.
After I installed AS7, I tried to program one of the Nano clones using the ISP connector and the debug-Wire mode.

The Arduino circuitry does not interfere with device programming via ISP.
However, it DOES interfere with "DebugWire" - DW essentially sends data streams on the RESET pin, and the capacitor to the ch340 from RESET that provides "automatic reset" interferes with the relatively high-frequency signal.
So what has happened (probably) is that you successfully erased the AVR and reprogrammed the fuses for it to use debugwire mode, but debugwire can't talk to it :frowning: The only way to take it out of debugwire mode is ... using debugwire (well, HV Parallel programming MIGHT work.)
The easiest thing to try is removing the capacitor that is causing the problem. (or cut an appropriate trace.)
(Since your board is dead otherwise, you have nothing to lose...)
Unfortunately, there are a wide variety of Nano clones all laid out a bit differently, and seldom actual schematics or PCB layout diagrams, so it's difficult to figure out just where the modification should be made. Do you have a link to the actual nanos that you bought (with an accurate picture that matches your actual boards?)

Thanks for this info.

Here is a picture of the bottom of the Emakefun Nano clone.

https://drive.google.com/open?id=1pp6ReVrMvPw-krzWDx98sHw-FuagHTAz

I’ll have to probe out which of the two big 4.7 caps is the correct cap. One belongs to the USB incoming power supply, and one belongs to the reset circuit from the CH340.

Also attached is the schematic of the Emakefun Nano clone.

I have a couple of questions:

  • Does the removal of the 4.7 uF cap eliminate programming via USB instead of via Atmen-ICE?
  • After I remove the correct cap, will Atmel-ICE be able to see the fuses and the device ID before I start programming and debuging?
  • Doesn’t seem that the Nano is a good candidate for for programming/debugging with AS7 and Atmel-ICE does it?
  • I have some cheap SAMD21 boards coming that I will be programming and debugging with AS7/Atmel-ICE using the SWD connectors. Will I have this same nonsense with those parts?

EmakefuNanoSchematic.pdf (127 KB)

It should be a 0.1uF cap between pin13 of the CH340 and the RESET of the AVR.
Your schematic shows an additional 4.7uF cap from Reset to +5V, and a 1k resistor to GND, both of which are "strange" and shouldn't be there, AFAIK. It also has a common NANO "problem" of having a 1k pullup on RESET instead of 10k, which may also interfere with DW.

After I remove the correct cap, will Atmel-ICE be able to see the fuses and the device ID before I start programming and debuging?[/li][/list]

It should. Assuming that AS7 is set to use debugwire for access...
Maybe more than just the one cap, in this case.

Doesn't seem that the Nano is a good candidate for for programming/debugging with AS7 and Atmel-ICE does it?

All of the AVR Arduinos share similar auto-reset circuitry. The Uno has a trace and set of pads designed specifically for cutting to prevent the auto-reset, and re-soldering to turn it back on.
(Hmm. Actually, you can attach JTAG to a Mega and some ATmega1284 clones, and it won't have the same interference problems.) This particular Nano seems a bit weird.

Does the removal of [autoreset circuitry] eliminate programming via USB instead of via Atmen-ICE?

It should only affect "auto-reset"; if you manually reset the chip at just the right time during an "upload" via USB, it should still work. It's a bit fiddly with the standard bootloader - you have about a 2s window...

I have some cheap SAMD21 boards coming that I will be programming and debugging with AS7/Atmel-ICE using the SWD connectors. Will I have this same nonsense with those parts?

No. It should work OK; the SWD connections aren't shared with other signals, and there's a well-defined way to get the ARM in and out of debug modes.