Close
0%
0%

Arduino support for custom SAMD board

Making tools that allow for effortless creation of bootloaders and Arduino support packages for custom SAMD-based boards

Similar projects worth following
If you have created a custom board using SAMD21 or SAMD51 MCU, building hardware is only half of the story. After that, you need to create and flash a bootloader, and if you want to use the board with arduino, you need to create a board support package.
Doing it requires careful reading of long specification documents and a lot of copy and pasting from existing packages.
But 90% of it can be automated. The goal of this project is to create a solution which would only require you to fill in entires in a simple config file and then run a python script that would do the rest.

Rationale

If you have built a custom SAMD-based board, you need to create and flash a bootloader, then make sure the board is supported in Arduino IDE. Doing it properly takes quite some time (especially if you are doing it first time) - you need to understand config files used to build the bootloader, install gcc toolchain for ARM, read Arduino platform specifications, etc.

If you are making a board just for yourself, you can cheat and reuse bootloader and board support package from another board, e.g. one of Adafruit's SAMD-based boards. But this is inconvenient - what if you want to use different pins for second I2C bus? And having your board show up as FEATHERBOOT doesn't feel right, not to mention that reusing Adafruit's USB Vendor ID is technically speaking illegal. And if you are making a board for sale, e.g. on Tindie, then cheating like this is not an option. 

Solution

Fortunately, most of the process above can be automated. Once you have learned the proper formats and specifications, you can just write a script that takes in a simple, human-friendly conifg file, processes it and does the rest. This project aims to do exactly that. It requires you to provide minimal configuration data, then it will do the rest: build the bootloader, create an Arduino board support package meeting all specifications, and even create the necessary index.json file for you, allowing anyone to install this package. 

Prerequisites

To make it work, you need the following installed on your computer:

  • Arduino IDE (version 1.8.0 or later)
  • Board support package for Adafruit's SAMD based boards installed in arduino IDE 
  • GNU Make 
  • Python3 

You will need to enter basic board info in a plain-text config file and provide variant.h and variant.cpp file for your board. 

You also need to have a place where you can upload the completed package  - github account is probably the easiest option, but you can also use your own website, hackaday, or anything else. 
See Usage Instructions for details

What this tool does (and doesn't) do

This tool  builds  the bootloader (UF2) and creates the Arduino package archive and index file that make it easy to install the board support in arduino. 
It doesn't flash the bootloader to the board. You would need to do it yourself, either using Microchip (formerly Atmel) studio, or by using Adafruit's DAP library

Current status

Basic functionality is all done - what is left is  documentation and testing.

  • 1
    Overview

    To use these tools, you need to:

    • make sure you have the necessary software installed on your system
    • download the code from github 
    • provide basic board information 
    • run the makeboard.py script
    • upload the created package archive and index.json file to a webpage (e.g. you own github repository)

    Additionally, you will also need to flash the bootloader to the board.

  • 2
    Installing required software
    1. Install GNU make (if you do not have it already):
      Windows: install from https://gnuwin32.sourceforge.net/packages/make.htm. Do not worry about adding it to PATH, we will do it later.
      mac OS: install Xcode; it comes with GNU make
      Linux: most likely, make is already installed. If not, run
      • Debian/Ubuntu – sudo apt install make
      • Fedora/RHEL – sudo yum install make
    2. Install Python 3 (if you do not have it already): https://www.python.org/downloads/  
      Alternatively, install Thonny IDE, it comes with Python 3 built into it. 
    3. Make sure you have Arduino IDE (version 1.8.2 or later) installed. 
    4. Install the latest version of Adafruit's SAMD board support package, following instructions here: 
      https://learn.adafruit.com/add-boards-arduino-v164/setup
    5. Download the whole github repository https://github.com/shurik179/SAMD-custom-board. You can do it by either cloning it to your computer, or by downloading the zip file and extracting it.

  • 3
    Providing board configuration

    This is the most important step. 

    In the downloaded SAMD-custom-board repository, find directory board_data. In this directory, you will need to enter info about your board. There are 3 files you need to provide:

    1. board-config.ini. This file is already in the directory; just edit it and enter your info. The file is amply commented. This is where you enter basic info about your board. 
    2. variant.h and variant.cpp files. These files contain descriptions of pins used by Arduino IDE, various interfaces (I2C, UART, I2S...) and more. The easiest way to create such files is copy and paste from one of existing boards, see https://github.com/arduino/ArduinoCore-samd/tree/master/variants or
      https://github.com/adafruit/ArduinoCore-samd/tree/master/variants
      For your convenience, the board_data directory contains variant.h and variant.cpp files for Arduino Zero - you can edit them as you see fit to create your own. Note: the files must be saved with names exactly  variant.h, variant.cpp, no modification allowed!

View all 6 instructions

Enjoy this project?

Share

Discussions

Similar Projects

Does this project spark your interest?

Become a member to follow this project and never miss any updates