as far as I understand, the Controllers on the Arduino boards come pre-programmed with some kind of Firmware. One Part of this Firmware ist the Bootloader, ok. But here must be something, that pre-configures the Controller for to fit to the special board it comes with. That is, how the SERCOM ist configuret, what function the each pin is assigned to etc. Where is the code that does that? Currently, i design a custom board based on the MKR Zero and have to change the pin assignment so that i can operate it as an SPI-slave. And i need to know how i have to prepare the SAM so that is in the same condition as the ones delivered with the boards.
Yes that's right, the Arduino code code configures and prepares the board during start-up before running the sketch and contains the Arduino specific functions.
The Arduino core code for the Arduino SAMD21 boards (on my old Windows 8.1 machine at least) is located at:
You can find the location of the platforms code that implements the standard Arduino core library API for the currently selected board (note there are different platforms for different boards) by looking at the verbose compilation output:
Select File > Preferences from the Arduino IDE's menus.
Check the box next to "Show verbose output during: [] compilation".
Click the OK button.
Select Sketch > Verify/Compile from the Arduino IDE's menus.
Wait for the compilation to finish.
Click on the black console pane at the bottom of the Arduino IDE window.
Scroll the pane all the way up to the top. There you will find a line that starts with "Using core...", something like this:
Using core 'arduino' from platform in folder:
C:\Users\per\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.3
An alternative technique:
Select a board from the hardware package you want to find from the Arduino IDE's Tools > Board menu.
File > Examples > SPI > BarometricPressureSensor (or any other SPI example sketch)
Sketch > Show Sketch Folder
Move up folder levels until you reach the one that contains boards.txt
Once you are there, check the folders mentioned by MartinL for lots of interesting code!