I'd like to build the Arduino core in Atmel Studio.
Is there a tutorial for this? If not, how does development on the core proceed?
I did find this thread: Updated tutorial: Using Atmel Studio 6 with Arduino, but it seems focused on how to import the precompiled libcore.a and build your own C++ app on top of it, rather than working on the core itself.
I'm guessing the build steps look something like this:
Clone git repo
Create new Atmel Studio library project
Select processor
Add source code directories to compiler include path
You might consider the newer and much improved Studio 7. It is supposed to include the Arduino core (I haven't tried it). Also, check the AVRFreaks forum for Studio/Arduino advice.
I usually just edit the core files with my favorite editor, and then recompile a test sketch in the IDE.
Depending on how much and how permanent I want my work to be, I'll add other development tool frills (rcs, tags, mkid, etc)
Clone git repo
If there's a git repository for the core, it's a very new thing. (There is one for ArduinoCore-samd...)
So far, the core is handled substantially differently than other libraries.
Studio 7 ... is supposed to include the Arduino core
Yes, it has a "Create project from Arduino sketch" option, that makes a private copy of ALL of the source files from the Arduino core. (It asks for a pointer to your Arduino install, and sucks in copies the core source from there, apparently understanding both the Arduino directory layout AND the desired AS layout) (This is typical of the sort of "bloat" that AS introduces, but it's not an obviously-wrong thing to do.) This is probably a great way to work on the core, if you're used to AS. Putting modified files BACK for other projects might be a bit messy...
Aha! I successfully imported an Arduino sketch into Atmel Studio 7. And westfw is right...it copies all the core files into the project for your debugging or tinkering pleasure.
To do the import, start Atmel Studio 7. Then choose File --> New --> Project. Select "Create Project from Arduino Sketch," then click "OK." Browse to the sketch file you wish to import (if you want to just tinker with the core, try navigating to the "Bare Minimum" Arduino example). You also have to specify the Arduino IDE's path, but it auto-populates (with the default location?). Then select the board and device from drop-down menus, and click "OK," and the project will be created. It will include all the basics, plus whatever libraries you decide to include (i.e. it won't include the Wire library if you don't have "#include <Wire.h>" in your sketch).
The new Atmel Studio project will not have the same folder structure as the core in the Arduino IDE.
The import process is also described on AVRFreaks.
Unfortunately, the import process doesn't seem to support the ArduinoCore-samd, because the Zero isn't listed in the board drop-down menu. I'll contact Atmel to find out more about that.
westfw:
I usually just edit the core files with my favorite editor, and then recompile a test sketch in the IDE.
So most developers working on the core don't use Atmel Studio? I guess that makes sense, but I didn't expect that. No wonder I didn't find instructions on how to set up a project in Atmel Studio.
westfw:
If there's a git repository for the core, it's a very new thing.
Isn't GitHub - arduino/Arduino: Arduino IDE 1.x the official Arduino repository? I mean, it's got the whole development environment with the AVR core inside it, but isn't that how the core is version controlled and developed on?
Yes, but it doesn't include the core separately, or in a place where it would be immediately usable; rebuilding the IDE each time you make a core change isn't very reasonable.
I'm not really sure how official development of the core happens. Like I said, when I've done it (which is "not much"), I work with an installed IDE (which also has all the source for the core, at least for the AVR), generate diffs and submit them to the official team (or apply to the repository and issue a pull request.)