Before logging an issue, please update to the latest release of Visual Micro from the Downloads Page.

When Logging a Support Issue in the Forum, please ensure you have also:-

  • Enabled vMicro > Compiler > Show Build Properties
  • Re-Compile your program with these settings enabled
 
Save the new Output to a Text File and....
  • Click the Reply button and attach as .txt file OR
  • Click here to Email us with the file attached, and a link to your post
Support requests without the output above may be impossible to answer, so please help us to help you
 
Page Index Toggle Pages: [1] 2  Send TopicPrint
Hot Topic (More than 8 Replies) Using Hardware Debugger with Visual Micro (Read 22278 times)
JohnB
Junior Member
**
Offline


Posts: 14
Joined: Jun 1st, 2013
Using Hardware Debugger with Visual Micro
Jun 5th, 2013 at 6:52pm
Print Post  
I have an Atmel Dragon and I am working with an ATmega32U4.  Is it possible to disable the Visual Micro Debugger and do debug with the Dragon in JTAG mode?

Everything I have tried so far to do this has failed.

I know the debugger hardware is working as I also have Atmel Studio 6.0 installed without Visual Micro and I can JTAG debug on a ATmega32U4 just fine.

John
  
Back to top
 
IP Logged
 
Tim@Visual Micro
Administrator
*****
Offline


Posts: 12191
Location: United Kingdom
Joined: Apr 10th, 2010
Re: Using Hardware Debugger with Visual Micro
Reply #1 - Jun 5th, 2013 at 8:24pm
Print Post  
Hi,

The Visual Micro debugger is a USB software debugger, entirely different to a hardware debugger, which Arduino does not support. 

Obviously you can make your own custom board with an Arduino/AVR cpu that might support hardware debugging but then you won't need the Visual Micro debugger.
  
Back to top
IP Logged
 
JohnB
Junior Member
**
Offline


Posts: 14
Joined: Jun 1st, 2013
Re: Using Hardware Debugger with Visual Micro
Reply #2 - Jun 5th, 2013 at 9:09pm
Print Post  
Tim, thanks for the prompt replies.

I already have the hardware debugger - an Atmel Dragon board.

My question was is there a way to disable the USB debugger but still us Visual Micro to allow building and downloading an Arduino sketch and then use the Dragon in Atmel Studio 6.1 to do the actual hardware debug.

Once I enable the Visual Micro Add-in to Atmel Studio 6.1 and Set Visual Micro Debug to NONE I am still not able to use the Dragon hardware debugger in JTAG mode (required for the ATmega32U4).

Is there some special configuration to allow this or does Visual Micro disable the use of hardware debuggers.

John
  
Back to top
 
IP Logged
 
Tim@Visual Micro
Administrator
*****
Offline


Posts: 12191
Location: United Kingdom
Joined: Apr 10th, 2010
Re: Using Hardware Debugger with Visual Micro
Reply #3 - Jun 5th, 2013 at 9:29pm
Print Post  
Thanks

Currently if Visual Micro is responsible for compile then it will override everything. 

However, I am currently discussing with Atmel how to run the Simulator as an option. I hope to add an extra option to the (Micro Debug) list to include Simulator (None, Full, Simulator). I mention this because it is a similar area and requires similar handling to hardware debug (I think)

I am still learning Atmel Studio, today Atmel showed me how to use "File>Open Object File for Debugging". This allowed me to experiment with the Simulator and a standard Arduino project. It looked great and appeared to work well. I am currently investigating how to feed values via serial from the Arduino into the Sim)

I appreciate the Simulator is not of interest to you but the Simulator seems to me to be just another Atmel debug tool so my question to you is can you use the same system. 

I documented todays Simulator test here 

The document shows how to easily find the location of the .elf that Visual Micro produces which is then passed to Atmel Studios "File>Open Object File for Debugging".

Would you please look at the doc and let me know if you believe the same or similar system will work for hardware debugging. 

Currently I know that starting the Sim is a little clunky but if it works then we will certainly have a way to move forward and for Visual Micro, in a future release, to provide a smooth single click solution.

Look forward to hearing your thoughts and thanks in advance
« Last Edit: Jun 5th, 2013 at 9:30pm by Tim@Visual Micro »  
Back to top
IP Logged
 
JohnB
Junior Member
**
Offline


Posts: 14
Joined: Jun 1st, 2013
Re: Using Hardware Debugger with Visual Micro
Reply #4 - Jun 5th, 2013 at 11:00pm
Print Post  
I just looked at the link provided.  This might hold promise for hardware debug.  I will give it a try tomorrow morning.  

I have one question.  In the new instance of Atmel Studio do you need to disable the Visual Micro add-in?

I have two versions of Atmel Studio installed 6.0 without the Visual Micro Add-in and 6.1 with patch and Visual Micro Add-in.  I can use the 6.0 version if needed.

John
  
Back to top
 
IP Logged
 
Tim@Visual Micro
Administrator
*****
Offline


Posts: 12191
Location: United Kingdom
Joined: Apr 10th, 2010
Re: Using Hardware Debugger with Visual Micro
Reply #5 - Jun 6th, 2013 at 12:29am
Print Post  
Great

No your don't need to disable the addin because, with the elf, Atmel does not need a project with the .pde/.ino. 

Atmel will create a project for you from the .elf but bear in mind that when we compile Arduino all .pde/.ino files are combined into [sketchname].cpp in a temp folder. So the .elf has not knowledge of the .pde/.ino sources.

Whilst this works in our favor from debug perspective it does mean that when you debug you will have to work out which pde/ino the .cpp source relates to.

If required Visual Micro could add some commented section markers to the .cpp informing you which pde/ino the source belongs to.
  
Back to top
IP Logged
 
JohnB
Junior Member
**
Offline


Posts: 14
Joined: Jun 1st, 2013
Re: Using Hardware Debugger with Visual Micro
Reply #6 - Jun 6th, 2013 at 11:38am
Print Post  
I did not have much time to look at this yet, but I will latter this morning.  I just wanted to report what I have found so far.

I let Atmel Studio 6.1 build a debug project.  I pointed at my object file and attempted to start debug selecting the Atmel Dragon as JTAG.

Atmel Studio then gave me a list of about 36 files with paths for all but 12 (the Arduino header files and my source ino files).  I fixed all of the paths and pressed "Start Debug with Break"

Atmel Studio did a new build for some reason and the build was successful.  The problem I am having now is that the ATmega32U4 uses the built-in USB virtual serial port for firmware download, but Atmel Studio is trying to download via the Dragon JTAG debug device and the download fails.

I think the USB Virtual Port must be used for the download (at least that is how it works under Arduino and Visual Micro).

There is a chance all of this will work if I can figure out how to get Atmel Studio to use the USB port for firmware download and the Dragon JTAG for debug.

I will post again if I learn anything new.

John 
  
Back to top
 
IP Logged
 
Tim@Visual Micro
Administrator
*****
Offline


Posts: 12191
Location: United Kingdom
Joined: Apr 10th, 2010
Re: Using Hardware Debugger with Visual Micro
Reply #7 - Jun 6th, 2013 at 11:43am
Print Post  
Hello,

Thanks for the report. I didn't have the include path problem with the Sim but maybe we can fix that with some experimentation.

How about using the Tools>programmer and "Tools>Upload using programmer" to perform the upload. Then serial will not be used. You must also ensure (Micro Debug=None) otherwise we will have Serial port usage.

Sorry this is a guess and I have no evidence this will work  Sad


  
Back to top
IP Logged
 
JohnB
Junior Member
**
Offline


Posts: 14
Joined: Jun 1st, 2013
Re: Using Hardware Debugger with Visual Micro
Reply #8 - Jun 6th, 2013 at 3:03pm
Print Post  
Still no joy.  My guess is that this problem is unique to the ATmega32U4.  I am very new to Atmel Studio so there is a high probability that it is a user error.

I have a PNG showing the error I get trying to download the firmware but I did not see a way to upload it, only the ability to insert an image link.  Send me a PM with an Email address and I will send it to you.  Maybe your Atmel contact might see something wrong in the PNG display.

I decided to see what would happen if I used the Simulator and the ATmega32U4 is not in the list.  If it is there I could not find it.  So this could indeed be a problem unique to the part being used.

Hopefully there is a way to do this.  It would be very nice to do Arduino builds and hardware debug all in a single application.

Thanks for your help.

John

  
Back to top
 
IP Logged
 
Tim@Visual Micro
Administrator
*****
Offline


Posts: 12191
Location: United Kingdom
Joined: Apr 10th, 2010
Re: Using Hardware Debugger with Visual Micro
Reply #9 - Jun 6th, 2013 at 3:17pm
Print Post  
Hi JohnB,

I am sorry but the reason for the USb debug option is that Arduino does not support hardware debug unless you are an experienced user, even then I have never heard of a compatible arduino compile with pde/ino that also uses hardware debug.

It might be possible but I don't have the resource to investigate, I wish I did Smiley

I guess what you are saying is that you need to understand how to build your own avr/arduino projects manually in Atmel Studio without using pde/ino files, just c and cpp.

This is certainly possible, you will find some examples on the internet I am sure.

I am also sure you will find some tutorials that explain which AVR micro-controllers are supported in Atmel and also which programmers/debuggers the micro-controller supports. 

There will also be articles to show you how to configure the various Atmel hardware debug options.

Sorry I can't be more help but will appreciate hearing the results of your investigations.

Thanks very much
  
Back to top
IP Logged
 
JohnB
Junior Member
**
Offline


Posts: 14
Joined: Jun 1st, 2013
Re: Using Hardware Debugger with Visual Micro
Reply #10 - Jun 7th, 2013 at 2:25pm
Print Post  
Partial Success!!!!

I found the problem this morning.  Some fuse bits must be set in the ATMEGA32U4 to allow JTAG debugging.  I had set them in Atmel Studio using the Dragon in ISP mode.  

While I was doing all of the testing something happened to the bootloader in the 32U4, possibly erased by a firmware download via the Dragon in JTAG mode.  

I noticed that the Arduino tools added by VM had an option to restore the bootloader.  However, that option does not work with the Dragon ISP port, it is not in the list of tools.  I had to use a USBasp adapter to do the restore.

I did not notice at the time that the restore also altered my Fuse bits (High Byte bits 6 & 7) which turned off JTAG debugging again.  That is what was causing all of my recent problems trying to use the Dragon in JTAG mode.

Once I set these bits to 0 again (using the Dragon in ISP mode), the Dragon worked in JTAG mode and I could get into full hardware debug mode.

However, I still have a problem.  It seems that when the Dragon JTAG downloads the firmware, it wipes out the bootloader again (that must be how it got damaged the first time).

I might be able to work around this by not using the USB bootloader.  I can try to only build the firmware in VM and then do the download and debug in Visual Studio.

Not as convenient as desired, but might get the job done.

I wonder why there is no simulator for the ATMEGA32U4.

John
  
Back to top
 
IP Logged
 
Tim@Visual Micro
Administrator
*****
Offline


Posts: 12191
Location: United Kingdom
Joined: Apr 10th, 2010
Re: Using Hardware Debugger with Visual Micro
Reply #11 - Jun 7th, 2013 at 2:34pm
Print Post  
You have done well!!

And this is a perfect example why most users can not and should not try hardware debugging with Arduino.

I don't understand why you don't just use a usb cable for both upload and debug? What does the usb debugger not do that you need to do?

Thanks very much for the useful information
  
Back to top
IP Logged
 
JohnB
Junior Member
**
Offline


Posts: 14
Joined: Jun 1st, 2013
Re: Using Hardware Debugger with Visual Micro
Reply #12 - Jun 7th, 2013 at 3:04pm
Print Post  
The USB path is for a virtual serial port.  The port enumerates as a COM port (COM30 on my system) and appears as a standard serial port that can be used for Serial.print output.  

Atmel must also have some undocumented (at least to me) hooks in their device driver for this port.  When you do a firmware download Arduino uses this USB port.  Primary COM port (COM30 disconnects) and a new port appears as COM+1 (COM31 in my case), the firmware is downloaded using that path and then COM+1 disappears and COM reappears and can now be used for Serial.print.

Thus the only debugging available is via Serial.print.  The only way to do hardware debug of an Atmel ATmega32U4 is with an Atmel tool such as a Dragon.

John
  
Back to top
 
IP Logged
 
Tim@Visual Micro
Administrator
*****
Offline


Posts: 12191
Location: United Kingdom
Joined: Apr 10th, 2010
Re: Using Hardware Debugger with Visual Micro
Reply #13 - Jun 7th, 2013 at 3:13pm
Print Post  
Hi John,

I am confused.

By default, the Visual Micro debugger uses serial on the usb cable and can also use other Serial ports such as Serial1 or SoftwareSerial on digitalPins via FTDI or similar.

Have you tried it? Seen the YouTube video on the debugger page (skip first minute or so)?

Thanks
« Last Edit: Jun 7th, 2013 at 3:13pm by Tim@Visual Micro »  
Back to top
IP Logged
 
JohnB
Junior Member
**
Offline


Posts: 14
Joined: Jun 1st, 2013
Re: Using Hardware Debugger with Visual Micro
Reply #14 - Jun 7th, 2013 at 5:07pm
Print Post  
I probably added more confusion in my last post.  

I was trying to say that the only debugging available via the USB serial port is with Serial.print.

I am looking for debug tools that allow me to halt execution of the processor with hardware breakpoints and examine/alter register and memory content without modification of the source code.

This is the way I do debug on SiLabs and Microchip parts.  I have been doing it this way for decades and I would like that ability with the Atmel parts.

Atmel Studio provides that ability, but I have not found an easy way to do that with Arduino source.  The project I am working on was done in Arduino.  

Visual Micro nicely adds the Arduino build function to Atmel Studio as well as software debugging with breakpoints.  If I can get the hardware breakpoint debugging to work, I will have everything I desire.

The Visual Micro debugger is a nice tool, a lot better than Serial.print but I am trying to get to be able to do the full hardware based debugging I have used for years.

You folks have done a fine job with Visual Micro and the debugger, I am just trying to get it to go a little further.

John
  
Back to top
 
IP Logged
 
Tim@Visual Micro
Administrator
*****
Offline


Posts: 12191
Location: United Kingdom
Joined: Apr 10th, 2010
Re: Using Hardware Debugger with Visual Micro
Reply #15 - Jun 7th, 2013 at 5:39pm
Print Post  
Ah, yes that makes sense and thanks for the support. 

Yep software debug is quick and simple, also provides a few nice extras such as updating variables without need for break.

But as you say, if you are used to true low level hardware debug you need something else.

When we do the Sim work it might be that we can make life a bit easier for hardware debug, but I am not sure if it will help you.

  
Back to top
IP Logged
 
JohnB
Junior Member
**
Offline


Posts: 14
Joined: Jun 1st, 2013
Re: Using Hardware Debugger with Visual Micro
Reply #16 - Jun 7th, 2013 at 7:00pm
Print Post  
You might ask Atmel if they have a sim for the ATmega32U4.  I was going to try that sim for you but I could not find that processor in the sim list.

Maybe it is there and I just missed it.

John
  
Back to top
 
IP Logged
 
Tim@Visual Micro
Administrator
*****
Offline


Posts: 12191
Location: United Kingdom
Joined: Apr 10th, 2010
Re: Using Hardware Debugger with Visual Micro
Reply #17 - Jun 7th, 2013 at 7:02pm
Print Post  
Ok, I look and speak to them.
  
Back to top
IP Logged
 
Tim@Visual Micro
Administrator
*****
Offline


Posts: 12191
Location: United Kingdom
Joined: Apr 10th, 2010
Re: Using Hardware Debugger with Visual Micro
Reply #18 - Jun 7th, 2013 at 7:03pm
Print Post  
One thing you could do is to select the correct arduino board and then look at the real "Atmel project properties>device" page

The page shows which debuggers are compatible and if the Simulator is supported
  
Back to top
IP Logged
 
JohnB
Junior Member
**
Offline


Posts: 14
Joined: Jun 1st, 2013
Re: Using Hardware Debugger with Visual Micro
Reply #19 - Jun 7th, 2013 at 9:48pm
Print Post  
Thank you, I did not think about that.  There is a lot about Atmel Studio that I have not learned yet.

I looked at the list and "simulator" is not included like it is for some other boards so I guess it is not supported.

The board I am using is a Leonardo.

John
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: [1] 2 
Send TopicPrint