Trouble Setting DWEN for Atmel ICE Debugging

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

I have a custom PCB using an Atmega16U2 and i'm connecting it to my PC directly via USB. When I program the uC I do so via Atmel FLIP over the USB port I designed into my PCB.

 

The problem: I have the below pinout on board for debugging via debugWire.

 

Since I don't have the MOSI, SCK, and MISO pins needed for SPI comms over this interface it seems that my Atmel ICE is unable to program the DWEN fuse to enter debugging mode. I see the following dialogs when I try to Start Debugging and Break from Atmel Studio:

 

 

Is it impossible to debug given my pinout that doesn't have SPI pins? If not, how do I program the DWEN fuse?

This topic has a solution.
Last Edited: Wed. Nov 1, 2017 - 06:17 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Go on. You have been a member for a long time.
You should know that fuses can ONLY be altered with an external programmer.
YOU designed the 3x2 header.
.
If you want to shoot yourself in the foot, make connections to the SPI pins. Program DWEN.
.
Note that most debug software will destroy your Flip bootloader. So you need to restore afterwards.
.
David.

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

Ugh, I appreciate your information but did you have to use such an unnecessarily snarky tone? Length of membership on a forum doesn't automatically make someone an expert at things they're trying for the first time.

 

I attempted to verify beforehand that this pinout would work and because of js' answer on my post here I thought it would. The answer said, literally "That diagram you show is correct for DW". Now I know it isn't, which is frustrating when I tried doing my due diligence to avoid a problem.

 

Last Edited: Wed. Nov 1, 2017 - 07:57 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Yes, I was being snarky. But only because you are NOT a new member.
.
General advice is to use the standard 3x2 ISP header on your pcb.
Let AS7 look after debugWIRE.
Develop your project.
Let AS7 disable debugWIRE and Close.
Restore the DFU bootloader flash, fuses and lock.
.
Use Flip to upload your debugged Application via the DFU bootloader.
.
Yes, it is more fiddly to use debugWIRE vs JTAG e.g. for the 16u4.
But it is essential that you understand the procedure. Even JTAG debug will destroy the bootlader as default.
.
David.

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

Is there a way to toggle fuses over USB? 

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

Yes.   Buy an external programmer.

 

A $3 USBASP will do it.    Likewise a $6 Uno clone.    Or buy a proper $99 ATMEL-ICE.

 

You need a proper ATMEL-ICE to do the debugWIRE debugging anyway.

If you change fuses without a proper ATMEL-ICE,  you make the chip inaccessible.

 

In other words,   it is always wise to book the hospital bed before you shoot your foot.

 

David.

Last Edited: Wed. Nov 1, 2017 - 04:56 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

What? Read my original post, I already have an Atmel ICE. How do I use it to toggle fuses over USB? It only has an ISP6 interface, which I can't use to toggle fuses since my pinout doesn't have the SPI pins. You're talking me in circles here David, talking me in circles...

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

You appear to be missing the point. David is correct to say that the fuses can only be changed by an ISP (or HVPP) interface. You cannot use the USB of the 16U2 to set fuses.

 

So you need to hackyour PCB design to wire the 6 wires to the ISP header that you should have put there in the first place.

 

As it's presumably just a "prototype" at this stage in your final PCB design you can learn from this lesson and connect up all 6 pins.

This reply has been marked as the solution. 
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

The High Septon wrote:
I attempted to verify beforehand that this pinout would work and because of js' answer on my post here I thought it would.

The miscommunication there is this:

 

The three pins in your diagram is enough to actually drive a debugWire session.

 

To get into a debugWire session the DWEN fuse has to be programmed. And to program that fuse, you need ISP (or, as 'clawson' also noted, HVPP).

 

So, summing up: To have a system where you can start, do and stop debug-wire debugging you need a complete ISP connector. Connecting only the three debugWire signals is not enough. If your AVR has the DWEN pre-programmed before going onto the board, and you plan to let it stay in debugWire mode while it sits there then your three wires/signals are enough.

"He used to carry his guitar in a gunny sack, or sit beneath the tree by the railroad track. Oh the engineers would see him sitting in the shade, Strumming with the rhythm that the drivers made. People passing by, they would stop and say, "Oh, my, what that little country boy could play!" [Chuck Berry]

 

"Some questions have no answers."[C Baird] "There comes a point where the spoon-feeding has to stop and the independent thinking has to start." [C Lawson] "There are always ways to disagree, without being disagreeable."[E Weddington] "Words represent concepts. Use the wrong words, communicate the wrong concept." [J Morin] "Persistence only goes so far if you set yourself up for failure." [Kartman]

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

Thanks. For my understanding; what's the point of the fuse.h API if fuses can't be manipulated programatically?

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

The Fuse API allows a user to specify the fuse settings for the specific AVR device they are compiling for. These fuse settings will be placed in a special section in the ELF output file, after linking.

Programming tools can take advantage of the fuse information embedded in the ELF file, by extracting this information and determining if the fuses need to be programmed before programming the Flash and EEPROM memories. This also allows a single ELF file to contain all the information needed to program an AVR.

 

Nothing there about changing fuses programmatically! Only embeds fuse data in the ELF file for tool use!

 

Jim

 

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

Just to note that Jim's text above is a direct quote from the documentation High Septon linked to. So, the point with the functionality in fuse.h is documented right in that link. Granted, it's not always easy to get what documentation says before "you've seen the light" / " experienced the 'aha moment'".

 


 

Apart from that, while not principally impossible, the reasons for fuses not being programmable by firmware might be several, but I can immediately think of at least one: They are an important part of the preconditions of the startup, and other parts of the AVR design might rely on them not changing during execution. Allowing fuse programming from firmware would likely complicate not only the fuse hardware as such but many other parts of the hardware so that it can cope with e.g. a change of clock selection fuses.

 


 

I'm sorry we didn't spot in the other thread what you where aiming at. Had we done that we would have shouted "You need a complete ISP interface on your board!". Looking at it now it's obvious we should have. Communicating is hard sometimes...

 

 

"He used to carry his guitar in a gunny sack, or sit beneath the tree by the railroad track. Oh the engineers would see him sitting in the shade, Strumming with the rhythm that the drivers made. People passing by, they would stop and say, "Oh, my, what that little country boy could play!" [Chuck Berry]

 

"Some questions have no answers."[C Baird] "There comes a point where the spoon-feeding has to stop and the independent thinking has to start." [C Lawson] "There are always ways to disagree, without being disagreeable."[E Weddington] "Words represent concepts. Use the wrong words, communicate the wrong concept." [J Morin] "Persistence only goes so far if you set yourself up for failure." [Kartman]

Last Edited: Wed. Nov 1, 2017 - 07:30 PM