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.
ENVIRONMENT: Atmel Studio 7.0.188, Arduino.cc 1.6.9/1.6.13/1.8.0, Arduino Due Libraries 1.6.10, Arduino Zero Libraries 1.6.11, Visual Studio 2015 (14.0.25420.1) on same system with support for C/C++, Windows 10 Anniversary Update.
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.
- Open Atmel Studio
- Select File | New | Project
- Select "Create project from Arduino sketch" ( leaving default location, "create directory for solution" checked)
- In "Create C++ project from Arduino sketch" popup, set Sketch File to "C:\Program Files (x86)\Arduino\examples\01.Basics\Blink\Blink.ino", Arduino IDE Path to "C:\Program Files (x86)\Arduino", Board to "Arduino/Genuino Zero (Programming Port)", and Device to the only option, "ATSAMD21G18A".
- Once Solution is loaded, press F7 to build solution.
- Build fails with error list citing "sam.h: No such file or directory", full output text attached as Arduino Zero Output Failure 1.txt.
- 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!