Skip to content

2020-01-30 electronics

Software setup

To get started with the Adafruit ItsyBitsy M4, I installed the Arduino IDE v1.8.11 and followed the guide provided by Adafruit to add board definitions for the ItsyBitsy M4 to the Arduino IDE.

Program flashing

Compiler debugging

I next connected the microcontroller board via USB and attempted to flash the blink example (File->Examples->01.Basics->Blink). Unfortunately this resulted in an error when trying to compile: arm-none-eabi-g++: no such file or directory. A quick search revealed that someone else had encountered the same problem, and mentioned it publicly as GitHub issue arduino/Arduino/#9351. The solution to the missing g++ compiler was to install both the Adafruit SAMD board definitions as well as the Arduino SAMD board definitions. The latter presumably installs the full build toolchain including the g++ compiler.

Adafruit SAMD Arduino SAMD also needed!

Once the compiler issue was resolved, I selected the ItsyBitsy M4 from the Tools->Board menu ("Adafruit ItsyBitsy M4 (SAMD51")

selecting the ItsyBitsy in the arduino IDE

Missing COM device?

A new problem emerged: the ItsyBitsy M4 was not showing up as a COM port on my macOS laptop in the Tools->Port menu, nor at a system level via ls -1 /dev/tty*. Suspecting an issue with either my laptop or the microcontroller board, I tried a new microcontroller board to rule out my computer as a factor. With new ItsyBitsy M4 connected via USB (without any other connections) a new device appeared: /dev/tty.usbmodem14101. With this new microcontroller board connected and selected as in the Arduino IDE, I was able to flash the compiled program to the ItsyBitsy M4. The LED started blinking! Success.

Repeatability

Next I tried to change the blink timing to confirm I could re-flash the board reliably. Unfortunately the second flash failed. Retrying revealed intermittent failures on about 1/20 flashing attempts, with the following output:

Sketch uses 10652 bytes (2%) of program storage space. Maximum is 507904 bytes.
Device       : ATSAMD51x19
Version      : v1.1 [Arduino:XYZ] Nov  2 2018 22:52:55
Address      : 0x0
Pages        : 1024
Page Size    : 512 bytes
Total Size   : 512KB
Planes       : 1
Lock Regions : 32
Locked       : none
Security     : false
BOD          : false
BOR          : true
Write 10908 bytes to flash (22 pages)

[                              ] 0% (0/22 pages)
[==========                    ] 36% (8/22 pages)
SAM-BA operation failed
An error occurred while uploading the sketch

Recovery of boards not showing up as COM ports or failing to flash

While searching for a solution, I found a forum post that sounded relevant to the previous missing COM port issue. Quickly double pressing the reset button can place the ItsyBitsy into a mode where it will try to reacquire a COM port in preparation for accepting new programming. Trying this I was able to rescue the previous ItsyBitsy board. The same procedure was able to allow boards to be flashed successfully after an attempt to flash had failed.

Running CircuitPython

Setting up CircuitPython

The ItsyBitsy M4 also shows up as a drive capable of running CircuitPython.

CircuitPython libraries to import can be found here.

Running a basic example

Trying a simple CircuitPython example, I created a lib/ directory on the ItsyBitsy CIRCUITPY drive, copied in simpleio.mpy, and created a main.py file on the root level of the drive:

import board
import time
import simpleio

led = simpleio.DigitalOut(board.D13)

while True:
    led.value = True
    time.sleep(0.05)
    led.value = False
    time.sleep(0.05)

The LED started blinking immediately, without any reset or flashing procedure!

CircuitPy libs

Changing the sleep times resuled in an immediate change upon save. CircuitPython makes the development iteration cycle much faster. An amazing number of libraries exist for CircuitPython:

CircuitPy libs