Go Down

Topic: Debugging Arduino Due using SAM-ICE JTAG (an approach) (Read 26682 times) previous topic - next topic


Mar 05, 2013, 05:43 am Last Edit: Mar 05, 2013, 05:49 am by neil12 Reason: 1
Well here is the reference on github.com
It incorporates an Arduino compilable port for Atmel Studio 6.
I've ported through Arduino SAM release 1.5.2 (but not run it) but it doesn't incorporate all Arduino SAM libray files. I did download and run tests on a version that had release 1.5.1 - so not that different.
I've  download the github zip file into a temporary directory, and in n AS6.0.1996 opened the project file  sam3xApp01\sam3xApp01.atsln
and then build the solution.
It compiled and linked OK - but I haven't tested it by downloading it through the JTAG.
AS6.0.1996 is the lowest rev  that supports JTAG/SAM-ICE through ATSAM3X JTAG.
It is "As Is" - a development snapshot for unit testing some of the hardware drivers.
See the "ReadMe-AboutThisBuild-SAM3XAZ.docx" - I intend to label any specific differences between my hw and this build as HWSAM3XAZA but not done yet.
Its also my first time through using github.com - and incredibly impressive as it is a fair number of files.
Last time I did such an impressive remote source control was in 2001 with a commerical system called "Continuus" that operated on a private network between two sites and that ended up supporting 50+ working programmers. The simplicity of GIT so far blows me away (though it took about 4 hours to get all of this uploaded). Thanks to all the people contributed to the gitHub online tutorials as well as the git cmd line utility and Git Gui and SSH to work.
Be interested in what you can share about the project you are working on. :)


Mar 05, 2013, 06:47 pm Last Edit: Mar 05, 2013, 06:53 pm by peteb Reason: 1
Neil, very many thanks for the time and effort to prepare and post this. Much appreciated.  
BTW I'm supporting a number of Arduino development projects being undertaken my electronics students and attempting to get better debug facilities by utilising the SAM-ICE, but keeping the Arduino framework.

I built your project((in Version: 6.0.1996 - Service Pack 2) and got errors in adc.h (Part of the output is shown) - see below.
I can understand that some conditionally included definitions are not actually being included. Does the project build for you? Is there some definition that is missing? Have you had similar issues? I see that you have injected an error into this file previously to test a conditionally compiled macro definition...
clip from adc.c:
//error njh;

      In file included from ../arduino/hardware/arduino/sam/system/libsam/chip.h:44:0,
                       from ../arduino/hardware/arduino/sam/cores/arduino/Arduino.h:34,
                       from ../arduino/hardware/arduino/sam/cores/arduino/cortex_handlers.c:19:
C:\at91sam3xaz01-master\sam3xApp01\arduino\hardware\arduino\sam\system\libsam\include\adc.h(170,48): 'enum adc_resolution_t' declared inside parameter list [enabled by default]
C:\at91sam3xaz01-master\sam3xApp01\arduino\hardware\arduino\sam\system\libsam\include\adc.h(170,48): its scope is only this definition or declaration, which is probably not what you want [enabled by default]

Error   8   use of enum 'adc_channel_num_t' without previous declaration   C:\at91sam3xaz01-master\sam3xApp01\arduino\hardware\arduino\sam\system\libsam\include\adc.h   173   48   sam3xApp01
Error   9   use of enum 'adc_channel_num_t' without previous declaration   C:\at91sam3xaz01-master\sam3xApp01\arduino\hardware\arduino\sam\system\libsam\include\adc.h   174   49   sam3xApp01
Error   10   use of enum 'adc_channel_num_t' without previous declaration   C:\at91sam3xaz01-master\sam3xApp01\arduino\hardware\arduino\sam\system\libsam\include\adc.h   177   62   sam3xApp01
Error   11   use of enum 'adc_channel_num_t' without previous declaration   C:\at91sam3xaz01-master\sam3xApp01\arduino\hardware\arduino\sam\system\libsam\include\adc.h   178   61   sam3xApp01
Error   7   use of enum 'adc_resolution_t' without previous declaration   C:\at91sam3xaz01-master\sam3xApp01\arduino\hardware\arduino\sam\system\libsam\include\adc.h   170   48   sam3xApp01


Mar 06, 2013, 03:06 am Last Edit: Mar 06, 2013, 03:08 am by neil12 Reason: 1
Hmm yes I remember I got that problem as well and here is my correction -
The fix seems to be change AS6 to be the sames as the arduino-1.5.1r2 in
C:\Program Files\Atmel\Atmel Studio 6.0\extensions\Atmel\ARMGCC\\ARMSupportFiles\Device\ATMEL\sam.h
/* Entire SAM3XA series */
#define SAM3XA_SERIES (SAM3X4 || SAM3X8 || SAM3A4 || SAM3A8)
#define SAM3XA_SERIES (SAM3A4 || SAM3A8)

I got it from
\My Documents\Arduino\arduino-1.5.1r2\hardware\arduino\sam\system\CMSIS\Device\ATMEL\sam.h
/* Entire SAM3XA series */
#define SAM3XA_SERIES ( SAM3X4 || SAM3X8 || SAM3A4 || SAM3A8)

Let me know if that works for you.

Background: The fix is in the AS6 toolchain so it makes me nervous.
I did send it through to Eric Weddington Jan 10th,2013 and though he responded, he didn't say if the fix I proposed was good.
I see from
that there is another release
Atmel Studio 6.1 beta (build 2440)
and 6.1 has an upgraded  ARM Toolchain 4.7.2
from AS 6.0  ARM Toolchain - GCC  4.7.0


Thanks again for all your help. Exactly right! I updated as suggested: #define SAM3XA_SERIES (SAM3X4 || SAM3X8 || SAM3A4 || SAM3A8)
The example builds, executes and is debuggable via SAM-ICE. I will now undertake some more testing.

BTW, I did try the Atmel Studio 6.1 beta (build 2440). I set up for ATSAM3X8E. I found that there appeared to be a problem when setting up the toolchain in Project Properties. Just by selecting the toolchain configuration to be "All Configurations" an application error was displayed: "Error occurred computing the All Configuration settings".  I tried uninstalling, re-downloading and re-installing but the problem persisted. So, it seemed to be unusable. I wonder if anybody else has come across this? I then installed the earlier version: 6.0.1996 - Service Pack 2 that I am currently using.



Neil and Pete, you guys are awesome!
I was going through all the same problems.  I had tried the two most recent releases of 6.1, neither of which worked.  Not only was the recommendation for 6.0 excellent, but the sample project posted to github was a game changer.  Thanks guys.
I'm now successfully getting my Due blinky test running while debugging with the SAM-ICE.


Hey glad it was useful. SAM3X has a lot of very nice opportunities with its internal ram and peripherals and low power.
Shame this fix hasn't made it in to the AS.
However it does seem the real productive programming is moving to anenvironment with python in it, and there is another productive OOPs paradigm that I've come across using www.squirrel-lang.org - one programsa 'nut' (ElectricImp.com is using it on WiFi SD card).



          I am working with custom SAM3X8C board using SAM-ICE to program it using Atmel STudio 6. i would like to know if there is a way to reset the microncontroller over SAM-ICE through Atmel Studio 6 with out programming it? I am trying to avoid unplugging the power to the board to do a reset.



For those interested in debugging Arduino Due and saving some money, I recommend to use an Atmel ICE that costs around $25 or a SWD CMSIS-DAP ($20) like the one from adafruit and shown in the following picture, instead of pay over $100 for a SAM-ICE. Of course, the mentioned cheap options have limited features but at least let you to perform debugging functions like stepping, breakpoints, watch points, and firmware downloads.



Go Up

Please enter a valid email to subscribe

Confirm your email address

We need to confirm your email address.
To complete the subscription, please click the link in the email we just sent you.

Thank you for subscribing!

via Egeo 16
Torino, 10131