Confusion creating my own samd variants

Hi there. I created a fork of the Arduino-samd so I could create my own SAMD variants and make a few surgical modifications to the ArduinoCore. I put my diretory in my {SKETCH}/hardware directory. However, when I try to compile sketches against my new architecture, I'm told that samd.h is missing. I have no problem compiling SAMD architectures if they are in the Arduino15/hardware/... directories so I know i have samd.h installed properly. (E.g. I can compile for Zero, for Adafruit Feather M0, etc)

My directory looks like this:

jgilbert@jgilbert-mbp ~/Documents/Arduino/hardware % ls -l samd/1.23/
total 176
-rw-r--r--  1 jgilbert  staff   4908 Apr 12 12:52 CHANGELOG
-rw-r--r--  1 jgilbert  staff  37118 Apr 12 12:52 README.md
-rw-r--r--  1 jgilbert  staff  24826 Apr 12 12:56 boards.txt
drwxr-xr-x  3 jgilbert  staff    102 Apr 12 12:52 bootloaders
drwxr-xr-x  4 jgilbert  staff    136 Apr 12 13:29 cores
drwxr-xr-x  4 jgilbert  staff    136 Apr 12 12:52 drivers
drwxr-xr-x  8 jgilbert  staff    272 Apr 12 12:52 extras
drwxr-xr-x  7 jgilbert  staff    238 Apr 12 12:52 libraries
-rw-r--r--  1 jgilbert  staff   7842 Apr 12 12:56 platform.txt
-rw-r--r--  1 jgilbert  staff   1243 Apr 12 12:52 programmers.txt
drwxr-xr-x  5 jgilbert  staff    170 Apr 12 12:52 variants
jgilbert@jgilbert-mbp ~/Documents/Arduino/hardware %

My error message looks like this:

In file included from sketch/jg20170331_qtouch_hack_attempt.ino.cpp:1:0:
/Users/jgilbert/Documents/Arduino/hardware/samd/1.23/cores/arduino/Arduino.h:49:17: fatal error: sam.h: No such file or directory
 #include "sam.h"
                 ^

I can see that the SAMD directory includes are supposed to be populated by a parameter {runtime.tools.CMSIS.path}. Where is this path documented? What populates it?

The narrow question I have: How do I get my new core+variants properly wired in with samd.h?

A broader question: what is the best practice for developing new architecture varients? Where do I put them so that the library manager won't get freaked out? And what rules define how the arduino IDE finds things like BOSSAC or other tools when they aren't in the varient/hardware core directory and multiple other versions of these exist in other trees?

Thanks,

Jeremy

CMSIS is called a tool in the Arduino world. If you use Library Manager to install a hardware package, as you would with Arduino SAMD Boards, it defines the toolsDependencies for the package:
from http://downloads.arduino.cc/packages/package_index.json:

            {
              "packager": "arduino",
              "name": "CMSIS",
              "version": "4.5.0"
            },

and if they are not present installs them. In this case it will be installed to: Arduino15\packages\arduino\tools\CMSIS. The Arduino IDE uses the JSON file for the board to define the tool paths such as {runtime.tools.CMSIS.path}. I haven't found any similar mechanism for manual installations. You can change the platform.txt for your board to work with the tools location for the manual installation. This makes it difficult to create a hardware package that works for both Boards Manager and manual installation. I did figure out a way to do this but it was a bit of a hack. I can explain how if that's your goal. Otherwise it's probably easiest just to create a Boards Manager JSON file for your package. You can find instructions here:

If you don't want to host it online during development there are a couple options for storing it locally. One is to use a file:// type URL, the other is to put it in the Arduino15 folder with a special naming scheme. I remember trying both of these a while back and not being able to get either working but I might have just done something wrong or it might have been fixed since. Unfortunately the developer who added those features was too lazy to document them but I have a link to the discussion stashed somewhere if you want more information on that.

jgilbert20:
Where do I put them so that the library manager won't get freaked out?

Please give more details about what you mean. I wasn't aware of any possible issues with Library Manager. Do you mean Boards Manager? There are 3 possible locations:

  • {sketchbook folder}/hardware is for manual installation.
  • Arduino15/packages is for Boards Manager installation
  • {Arduino IDE installation folder}/hardware is where the bundled version of Arduino AVR Boards is located. You could install 3rd party hardware packages there and some do (mostly out of ignorance) but it's really a bad idea.

jgilbert20:
what rules define how the arduino IDE finds things like BOSSAC or other tools when they aren't in the varient/hardware core directory and multiple other versions of these exist in other trees?

As I said, for Boards Manager installations it's the JSON file. For manual installations it's just however you define the path in platform.txt.

You can find some of the information in:

but unfortunately some of the more complex subjects you're interested in are not well documented, which is pretty sad considering that Arduino is meant to be very friendly to learning. I for one definitely don't want to go diving into the Arduino IDE/arduino-builder source code for this information so I end up figuring it out through many hours of trial and error trying to reverse engineer the system. It would be so easy for the developers to take a few minutes to document the features they wrote the code for an know better than anyone else but it seems to be in the nature of all developers to skip this essential step.