BACKGROUND: While I've found answers on AVR Freaks in the past, I'm having some difficulty with AS7 and some Arduino functions, and its finally driven me over the edge to make my first post here. I have some experience with Microchip's ecosystem (XC8, MPLAB X, PIC enhanced 8-bit micros) but am now evaluating other micros for two projects, one of which is a relatively simple embedded system and the other is an IoT application. I've played with Arduino personally and am interested in learning more about how Atmel's ecosystem works on a professional scale. Documentation indicates that Atmel Studio 7 now supports the direct creation of AS projects based on an Arduino sketch which seems like a reasonable way to get my feet wet as I learn more about AVR and SAM. I am not an experienced EE, but I have done PIC work from whole cloth and have some experience with C, but the majority of my programming has been in Python and C#/.NET.

ISSUE: Creating a project from Arduino sketch fails to build correctly for Arduino Zero and Arduino Due, but succeeds when building for Arduino Uno.

Test Case 1: Importing Blink example sketch for programming to Arduino Zero. This was repeated for Arduino.cc IDE 1.6.9, 1.6.13, and 1.8.0 with the same result. Each Arduino installation was removed between attempts and there has never been a concurrent install of two different versions of Arduino or AS on this machine.

Other forum members indicate that sam.h can be located from Arduino's AppData folder, in my case, "C:\Users\exova\AppData\Local\Arduino15\packages\arduino\hardware\sam\1.6.10\system\CMSIS\Device\ATMEL\sam.h". After finding the file, I expanded ArduinoCore | include | core, right clicked the "core" folder, selected Add | Existing Item, and provided it the sam.h file in AppData. Selecting Build | Rebuild Solution does result in a new Error List and Output file, just not for the better (Arduino Zero Output Failure 2.txt and png).

Another forum suggested removing all included header files and replacing them with the output of the Arduino build. I attempted this but it also did not succeed, I can reattempt if someone needs the information and record it if necessary.

Uninstalled Atmel Studio and reinstalled. No effect.

Uninstalled Arduino IDEs and reinstalled. No effect.

Uninstalled Visual Studio and attempted procedure. No effect.

Formatted computer (just kidding, I upgraded my SSD, but it is a clean Windows 10 install) and attempted procedure with clean installs. Also same behavior.

I want to believe it's something stupid that I'm just not seeing or thinking of, but I've been messing with this for two days now and I can't get it to work. Doing the same steps but targeting an Arduino UNO builds fine. And while I have seen some people state that AS doesn't support this feature on ARM micros, both Adafruit and Atmel themselves have YouTube videos of them using AS 7 to do exactly this on an Arduino Zero (Adafruit: https://www.youtube.com/watch?v=... ; Atmel: https://www.youtube.com/watch?v=...) as well as written documentation from Adafruit explaining this procedure here: https://learn.adafruit.com/prope... . AS7 is able to read information from the Arduino Zero (see screenshot) and if I create a new blank C or C++ executable, I can write it to the device with the expected behavior. Arduino IDE can successfully program the Blink sketch as well as write a new bootloader to the device.

The Due has the same behavior but complains about a different header file. I can write down the specifics, but I get the feeling that if we can solve the Zero, the Due might also be solved, so I'm going to hold off writing unless someone asks. Sorry this came out to be so long, but thanks for reading and any help is greatly, greatly appreciated. Thanks!

so is this an AVR related question or an ARM related question or both?? You have posted in the AVR related Studio forum but we also have an ARM related Studio forum, I know confusing but that's how it is. Trying to keep posts in the correct forum if possible.

I had the same problem. The issue is that the Arduino SAMD core started using the CMSIS-Atmel package as of version 1.6.9. This moved the location of sam.h and all of its dependencies to a different directory and Atmel Studio can't find it using the built-in template for creating projects from Arduino sketches.

I have not been able to find a way to tell Atmel Studio where the new location is, but I worked around this by creating a Windows "junction" link using the old pathname to point to the new pathname:

For any other newbies like me who don't already know how to add an Include path in Atmel Studio 7:

When you created the AS7 project from the Arduino sketch, it creates a Solution with two Projects, one named "ArduinoCore" and one with the name you chose for your Arduino sketch. In order to get AS7 to build correctly with SAMD-based projects (Zero, MKR1000, MKRZero, M0, Tian, etc.) you need to add the path to the Atmel CMSIS library in four places: one for the C compiler and one for the C++ compiler in the ArduinoCore project plus one for the C compiler and one for the C++ compiler in the project associated with your Arduino sketch.

To do this, in the Solution Explorer pane, right click the ArduinoCore project and select Properties. This will open the Properties pane. On the left, select Toolchain. Then under ARM/GNU C Compiler select Directories. Click the Add Item button and then enter the full path to the SAMD CMSIS files. Uncheck the Relative Path box and click on OK. Repeat this for the ARM/GNU C++ Compiler. Then repeat the process again starting with right clicking on the project associated with your Arduino sketch.

The path will look something like this:C:\Users\<myWindowsName>\AppData\Local\Arduino15\packages\arduino\tools\CMSIS-Atmel\1.1.0\CMSIS\Device\ATMEL

These files are installed by the Arduino IDE when you use the board manager to install support for SAMD boards. Note that the path name may change with new releases of the Arduino IDE or board support packages, so verify the location on your system.

all the items jrsmiley mentioned i had checked: (i used the BLINK source)

1. SAMD board support package installed in the Arduino IDE= Done

2. The appropriate SAMD-based board is selected in the Arduino IDE = Done

3. You have saved the Fade demo program as your own sketch in the Arduino IDE (ex: myFade) = Done

4. The sketch compiles and loads correctly in the Arduino IDE= Done and working5. The AS7 project was created from the Arduino sketch (ex: myFade) and not from the Arduino Example library = Done but not working. Same errors you got.