Firmware and Set-Up of SAM

Hi,

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.

Hi @ashnak

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:

C:\Users\Computer\AppData\Local\Arduino15\packages\arduino\hardware\samd\1.8.11

The common SAMD21 core code can be found in the "core" directory.

Individual set-up for each board type is in the "variants" directory, where you'll find the "variant.h" and "variant.cpp" configuration files.

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:

  1. Select File > Preferences from the Arduino IDE's menus.
  2. Check the box next to "Show verbose output during: [] compilation".
  3. Click the OK button.
  4. Select Sketch > Verify/Compile from the Arduino IDE's menus.
  5. Wait for the compilation to finish.
  6. Click on the black console pane at the bottom of the Arduino IDE window.
  7. 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:

  1. Select a board from the hardware package you want to find from the Arduino IDE's Tools > Board menu.
  2. File > Examples > SPI > BarometricPressureSensor (or any other SPI example sketch)
  3. Sketch > Show Sketch Folder
  4. 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!

You can also find it online here:

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.