Welcome, Guest. Please Login or Register
Arduino IDE for Visual Studio
 
 
When Logging a Support Issue in the Forum, please ensure you have also:-
  • Enabled vMicro > Compiler > Show Build Properties and Verbose
  • Re-Compile your program with these settings enabled
 
Save the new Output to a Text File and....
Support requests without the output above may be impossible to answer, so please help us to help you
 
  HomeSearch Tutorials & Wiki visualmicro.com LoginHelpRegister  
 
Page Index Toggle Pages: 1
Send Topic Print
Arduino DUE and Atmel ICE problems (Read 11651 times)
jnorre
Newbies
*
Offline



Posts: 9
Arduino DUE and Atmel ICE problems
Sep 16th, 2014 at 1:13pm
 
I hope it is OK to create a new topic for this issue (it is very similar to the "Bug: AtmelStudio / VisualMicro does not parse 1.5.x Sketchbook Projects Properly" topic, except for Atmel ICE instead of the SAM-ICE).

Following the work-around for the DUE in the topic above, I created a new project (File, New, Project, C/C++, GCC C++ Executable project) and selected the SAM3X8E as the processor. I then selected "Atmel ICE" and "SWD" in the options. Compiling, uploading and running/debugging this empty project works fine.

I closed the solution and copied the INO file (for this example, I simply used the blink example from arduino), renamed it to the project name (NewBlink.ino), reopened the solution and added the INO file from the solution explorer (Visual Micro kicks in at this moment) and removed the CPP-file. Compiling seams to be fine, but upload fails! I tried out the generated upload command (...\atprogram -d cortex-m3 -v -t atmelice -i ISP program -c -f "...\NewBlink\arduino_due_x_dbg\NewBlink.hex") (long paths removed) and found the following problems:
No "NewBlink.hex" is present in the "...\NewBlink\arduino_due_x_dbg\" folder - there is a BIN and a ELF file (which is obvious from the "arm-none-eabi-objcopy" line in the build process).
"-d cortex-m3" does not seem correct, it should be "-d ATSAM3X8E"
"-i ISP" does not seem to work, "-i SWD" does.

Executing (...\atprogram -d ATSAM3X8E -v -t atmelice -i SWD program -c -f "...\NewBlink\arduino_due_x_dbg\NewBlink.elf") uploads the program and the LED blinks as it should.

After the failed upload (when using F5), the debug process (Atmel ICE) fails with the following lines:
[DEBUG] Starting execution of "program"
[DEBUG] Starting process 'C:\Program Files\Atmel\Atmel Studio 6.2\atbackend\atbackend.exe'
[DEBUG] Connecting to TCP:127.0.0.1:32885
[INFO] Connected to atmelice, fw version: 1.9
[INFO] Firmware check OK
[ERROR] Could not set device properties. Make sure you have selected correct device and interface, and that the hardware connections are correct.

So even with the Arduino DUE work-around, I am unable to use Visual Micro Sad
Back to top
 
 
IP Logged
 
Visual Micro
Administrator
*****
Offline



Posts: 10526
United Kingdom
Re: Arduino DUE and Atmel ICE problems
Reply #1 - Sep 17th, 2014 at 12:45pm
 
Other question is [url=http://www.visualmicro.com/forums/YaBB.pl?num=1410871011/0#0]here[url]
Back to top
« Last Edit: Sep 17th, 2014 at 12:49pm by Visual Micro »  
WWW  
IP Logged
 
Visual Micro
Administrator
*****
Offline



Posts: 10526
United Kingdom
Re: Arduino DUE and Atmel ICE problems
Reply #2 - Sep 17th, 2014 at 12:51pm
 
This is not part of the 1.5x system because arduino does not support this programmer.

Visual Micro extends the config to provide these additional programmers.

the default is an ISP upload. You can add your own commands to try this out then we can include in the next release.

To add your own command see the C:\Program Files (x86)\Visual Micro\Visual Micro for Arduino\Micro Platforms\arduino15x\hardware\sam\programmers.atmel.txt

If you add an entry then click "tools>visual micro>reload toolchains" or restart the ide

Thanks
Back to top
 
WWW  
IP Logged
 
Berni
Newbies
*
Offline



Posts: 9
Re: Arduino DUE and Atmel ICE problems
Reply #3 - Jan 24th, 2015 at 11:21am
 
Hi Tim,

I hope you can help me to get the atmel-ICE running as a programmer with Visual Micro and Arduino DUE.

The Atmel-ICE would be a great advantage for using with the Arduino DUE because the upload speed of the serial interface/SAM bootloader is extremly slow, even with very small sketches (e.g. Blink). And the Atmel-ICE is not so expensive.

I am using SWD because it is the standard for ARM devices, it only needs 5 wires and it is easy to connect on the DUE board.

I have uploaded a large ELF file of a sketch via Atmel Studio Device Programming, setting the atmel-ICE to 2MHz and the upload speed is incredible (factor 10 I would guess).

As jnorre already noted and after some tests it seems that Visual Micro does not use the correct MCU device name for the DUE.

Are there more parameters in atmel.programmers.txt which I could use to specify this?

The correct command line example would be:

atprogram -d ATSAM3X8E -v -t atmelice -i SWD program -c -f Blink.elf

There is also a clock parameter that could be set, e.g. -cl 2mhz. But that is also possible to set and stored in the ICE via the Device Programming dialog in Atmel Studio.

Is there a log file or output flag which allows me to see the command line parameters, that Visual Micro uses?

Maybe we could get this running. Would be great.

At the moment I use the following paramters in atmel.programmers.txt:

Code:
atprogram_atmelice_swd.name=Atmel Studio ATMEL-ICE (SWD)
atprogram_atmelice_swd.program.tool=atprogram
atprogram_atmelice_swd.program.extra_params=-t atmelice -i SWD
atprogram_atmelice_swd.help=Connect the programmer to the SWD port  



The MCU device name seems to be incorrect:

Code:
Error during upload using programmer
[ERROR] Could not set device properties. Make sure you have selected correct device and interface, and that the hardware connections are correct.
 



Thanks.


Back to top
« Last Edit: Jan 24th, 2015 at 11:32am by Berni »  

Best Regards,
Berni
 
IP Logged
 
Berni
Newbies
*
Offline



Posts: 9
Re: Arduino DUE and Atmel ICE problems
Reply #4 - Jan 24th, 2015 at 3:22pm
 
Additional Information, maybe trivial but also interesting:

In Visual Studio 2013 you can use the Atmel-ICE as a programmer e.g. for the Arduino DUE and get extremely fast upload speed.

You would have to install Atmel Studio 6.2 to get the programmer tool "atprogram.exe" which will be used for Atmel-ICE. That is no problem, both IDEs can exist on one system without any flaws or disadvantages.

You would have to uninstall Visual Micro before installing Atmel Studio and then reinstall Visual Micro again. You will not lose any settings of Visual Micro etc. This is necessary if you want to use Atmel Studio with Visual Micro maybe at a later time.

I have added the programmer commands as an External Tool in MS Visual Studio:

TOOLS - Externel Tools ... - Add

Title (whatever you like e.g.): Arduino DUE Program via Atmel-ICE

Command: C:\Program Files (x86)\Atmel\Atmel Studio 6.2\atbackend\atprogram.exe

Arguments: -cl 2mhz -d ATSAM3X8E -v -t atmelice -i SWD program -c -f $(ProjectDir)\Debug\$(TargetName).elf

Initial Directory: (empty)

Turn Checkbox "Use Output Window" ON (if you want to see what's going on during programming).

The build (BUILD, REBUILD, CLEAN - BUILD) procedure creates the "elf" file that has to programmed to the Arduino DUE.

Back to top
« Last Edit: Jan 24th, 2015 at 3:26pm by Berni »  

Best Regards,
Berni
 
IP Logged
 
Visual Micro
Administrator
*****
Offline



Posts: 10526
United Kingdom
Re: Arduino DUE and Atmel ICE problems
Reply #5 - Jan 25th, 2015 at 5:54pm
 
Hi Berni,

Thanks for the info.

note: For visual studio, visual micro creates an environment variable %AVRSTUDIO_EXE_PATH% for the location of atmel studio which you can use to extend the std  programmers.txt but you have a working alternative solution for that so a discussion for another day.

Notice that the programmer definition mentions a standard tool called tool=atprogram. This is not actually atprogram.exe but the name of a section defined in platform.txt in the same folder at the atmel.programmers.txt. It is the atprogram tool definition that is attempting to pass the {build.mcu} property of the arduino board defintion (arduino ide/hardware/platform/boards.txt)

Code:
tools.atprogram.cmd.path=%AVRSTUDIO_EXE_PATH%\atbackend\atprogram
tools.atprogram.cmd.setwinpath=true
tools.atprogram.program.params.verbose=-v
tools.atprogram.program.params.quiet=-q
tools.atprogram.program.pattern="{cmd.path}" -d {build.mcu} {program.verbose} {program.extra_params} program -c -f "{build.path}\{build.project_name}.hex"
 



Unfortunately it is the arduino board definition that has miss-used the mcu property for the SAM boards. You will see it is correct for the avr boards but "cortex-m3" for SAM.

I suggest we make a new tool definition which you can do for test purposes using the atmel programmers.txt

Add the following

Code:
atprogram_atmelice_swd_2.name=Arduino Due ATMEL-ICE (SWD 2mhz)
atprogram_atmelice_swd_2.program.tool=atprogram_ice_swd
atprogram_atmelice_swd_2.program.extra_params=-t atmelice -i SWD
atprogram_atmelice_swd_2.help=Connect the programmer to the SWD port 

tools.atprogram_ice_swd.cmd.path=%AVRSTUDIO_EXE_PATH%\atbackend\atprogram
tools.atprogram_ice_swd.cmd.setwinpath=true
tools.atprogram_ice_swd.program.params.verbose=-v
tools.atprogram_ice_swd.program.params.quiet=-q
tools.atprogram_ice_swd.program.pattern="{cmd.path}" -d ATSAM3X8E   {program.verbose} {program.extra_params} program -c -f "{build.path}\{build.project_name}.elf"
 



You will see why the two definitions are split if you add entries for different speeds. I have changed the name of your example to include the 2mhz speed which should hopefully help all this make sense

When you have a working config we can look at moving things around to avoid the need for the 2nd atprogram tool def which above I have called atprogram_ice_swd
Back to top
« Last Edit: Jan 25th, 2015 at 5:57pm by Visual Micro »  
WWW  
IP Logged
 
Berni
Newbies
*
Offline



Posts: 9
Re: Arduino DUE and Atmel ICE problems
Reply #6 - Jan 25th, 2015 at 7:09pm
 
That's so cool. I thank you very much.

I hope I have understood you correctly.

I added the tools.atprogram.... part to platform.txt and the atprogram_atmelice... part to atmel.programmers.txt.

Additional I added "-cl 2mhz" to the program.pattern:

Code:
tools.atprogram_ice_swd.program.pattern="{cmd.path}" -cl 2mhz -d ATSAM3X8E   {program.verbose} {program.extra_params} program -c -f "{build.path}\{build.project_name}.elf"
 



The upload is now working fine and extremely fast. Very nice, thank you.

To use the Atmel-ICE for "real" debugging would be perfect, but that's another story. Your USB debugger is an incredible clever solution.

Would there be a way to make automatic upload via Atmel-ICE in Visual Studio available? Is there a "visual.programmers.txt" or something like that?
Back to top
« Last Edit: Jan 25th, 2015 at 7:20pm by Berni »  

Best Regards,
Berni
 
IP Logged
 
Visual Micro
Administrator
*****
Offline



Posts: 10526
United Kingdom
Re: Arduino DUE and Atmel ICE problems
Reply #7 - Jan 25th, 2015 at 7:25pm
 
Hi Berni,

Good to hear it works thanks.

I will add it to the next release. After the next update, please let me know if I get it wrong thanks.

You can add a vs.programmers.txt or you can rename atmel.programmers.txt to programmers.txt (which would then serve both Ide's with the same programmers). You can also have all 3 if some programmers are common to both ide's.

In the future there will be somewhere else for you to store your own programmer files. For now you need to backup any changes you make because a visual micro install/update will overwrite these changes.

If you make different speed selections etc then post your entire programmers.txt so i can ensure the future versions cater for them.

Thanks
Back to top
« Last Edit: Jan 25th, 2015 at 7:27pm by Visual Micro »  
WWW  
IP Logged
 
Berni
Newbies
*
Offline



Posts: 9
Re: Arduino DUE and Atmel ICE problems
Reply #8 - Jan 25th, 2015 at 7:40pm
 
Hi Tim,

thanks a lot. Of course it has to be "programmers.vs.txt" (to prevent misunderstanding).

Visual Studio does not know %AVRSTUDIO_EXE_PATH% and I had to change it in platform.txt to the direct path and it works.
Back to top
 

Best Regards,
Berni
 
IP Logged
 
Visual Micro
Administrator
*****
Offline



Posts: 10526
United Kingdom
Re: Arduino DUE and Atmel ICE problems
Reply #9 - Jan 25th, 2015 at 8:13pm
 
Yes you are right thanks programmers.vs.txt

I will look into why the AVRSTUDIO_EXE_PATH isn't saving globally for the pc thanks!
Back to top
 
WWW  
IP Logged
 
TT_ZX
Newbies
*
Offline



Posts: 2
Re: Arduino DUE and Atmel ICE problems
Reply #10 - Jan 29th, 2015 at 4:48am
 
For future reference to get the Atmel-ICE working as a programmer for the Due in Windows 7 64bit you need to change 2 files:

Add the following to C:\Program Files (x86)\Visual Micro\Visual Micro for Arduino\Micro Platforms\arduino15x\hardware\sam\platform.txt
Code:
tools.atprogram_ice_swd.cmd.path=%AVRSTUDIO_EXE_PATH%\atbackend\atprogram
tools.atprogram_ice_swd.cmd.setwinpath=true
tools.atprogram_ice_swd.program.params.verbose=-v
tools.atprogram_ice_swd.program.params.quiet=-q
tools.atprogram_ice_swd.program.pattern="{cmd.path}" -d ATSAM3X8E   {program.verbose} {program.extra_params} program -c -f "{build.path}\{build.project_name}.elf" 



Add the following to C:\Program Files (x86)\Visual Micro\Visual Micro for Arduino\Micro Platforms\arduino15x\hardware\sam\programmers.atmel.txt
Code:
atprogram_atmelice_swd_2.name=Arduino Due ATMEL-ICE (SWD 2mhz)
atprogram_atmelice_swd_2.program.tool=atprogram_ice_swd
atprogram_atmelice_swd_2.program.extra_params=-t atmelice -i SWD
atprogram_atmelice_swd_2.help=Connect the programmer to the SWD port 



This is what worked for me.  I had trouble understanding the previous posts because the platform.txt and programmers(.atmel).txt files are in several different places and it wasn't obvious to me which files I was supposed to be changing.  Thanks goes to Tim and Berni for getting this to work.
Back to top
 
 
IP Logged
 
Visual Micro
Administrator
*****
Offline



Posts: 10526
United Kingdom
Re: Arduino DUE and Atmel ICE problems
Reply #11 - Jan 29th, 2015 at 12:53pm
 
Great,

What you have done is fine.

The 2mhz option would also use the "-cl 2mhz" switch?
Back to top
 
WWW  
IP Logged
 
Berni
Newbies
*
Offline



Posts: 9
Re: Arduino DUE and Atmel ICE problems
Reply #12 - Jan 29th, 2015 at 1:53pm
 
If you want a really speedup you need to use the "-cl 2mhz" switch.

I think TT_ZX did a summary of what we have already discussed.
Back to top
 

Best Regards,
Berni
 
IP Logged
 
Page Index Toggle Pages: 1
Send Topic Print