D. Arduino Issues

Installing Support for Arduino Boards

After the Arduino IDE is installed, support for Arduino SAMD Boards (32-bits ARM Cortex-M0+) and Adafruit SAMD Boards have to be installed in the Boards Manager before the computer could interface with the Adafruit Metro M4 development board.

Figure V.D.1: Arduino Boards Manager

Before the flash memory could be used for data file storage, it must be properly formatted as a file allocation table (FAT). The SdFat_format.ino sketch formats the flash memory. This file can be found in the Examples folder of the Adafruit's SPI Flash code library, which must be included in the source code. A custom-tailored SD Fat code library from Adafruit must also be downloaded to support the SPI Flash package. After an experiment, this flash memory can be accessed using Adafruit's CircuitPython USB Flashing Format file.

Figure V.D.2: Arduino Library Manager

Installing libraries for QSPI Flash support

To install the libraries, follow these steps:

  1. Open the Arduino IDE.
  2. Go to menu item Sketch > Include Library > Manage Libraries.
  3. Find and install the Adafruit SPIFlash library.
  4. Find and install the SdFat – Adafruit Fork library.

Preparing to Upload Sketches

To prepare the Arduino IDE to execute sketches on the Metro M4, follow these instructions.

  1. Go to Tools > Board and select Adafruit Metro M4 (SAMD51).
  2. Plug the Adafruit Metro M4 into any USB port on your computer.
  3. Open the Device Manager in the Control Panel of your Windows operating system. Open Ports (COM & LPT) and note which communications (COM) port the Adafruit Metro M4 is connected to.
  4. In Arduino, go to Tools > Port and select the COM port that the Adafruit Metro M4 is associated with. You are now ready to upload sketches.

Formatting the Metro M4 flash drive

Before we can run the motion control sketch on the Adafruit Metro M4, we need to format the QSPI flash memory chip on the microcontroller board. To do this, we need to upload the sketch SdFat_format.ino to the Metro M4. All files in the website (diskio.h, ff.c, ff.h, ffconf.h) must be downloaded to the same folder the SdFat_format sketch is in.

Figure V.D.3: Close-up of Metro M4’s reset button
Figure V.D.4: Windows Explorer with the METROM4BOOT drive shown.

Figure V.D.5: Drag the USB flashing format file to the METROM4BOOT icon.

  1. Double-click the reset button on the Metro M4 board. Figure V.D.3 shows its location.
  2. A new Explorer window will pop up. A drive designated as METROM4BOOT will appear in this window. This is the Metro M4’s drive.
  3. Download the Circuit Python USB flashing format file [adafruit-circuitpython-metro_m4_express-en_US-4.1.0.uf2].
  4. Using your mouse, drag the .uf2 file to the METROM4BOOT drive icon in Explorer.
  5. A new Explorer window will pop up. The METROM4BOOT drive will be renamed Usb Drive. This will display the flash memory’s contents. Right click on Usb Drive and click Format.
  6. When the dialog box pops up, un-check Quick Format so that a thorough format of the flash memory can be done by Windows. Press OK to format the flash memory.
  7. When the formatting is complete, open the sketch SdFat_format.ino in the Arduino IDE.
  8. Press the reset button on the Metro M4 board.
  9. Click the menu item Sketch > Upload.
  10. Go to Tools -> Serial Monitor to open the serial monitor dialog box. The baud rate should be set to 115200 baud.
  11. You will see this prompt: This sketch will ERASE ALL DATA on the flash chip and format it with a new filesystem!
  12. Type OK (all caps) and press enter.
  13. Wait until the sketch is finished. You will see this prompt when the formatting is complete. Flash chip successfully formatted with new empty filesystem!

More Instructions

Once again, here is a link to the manual for the Adafruit Metro M4, which contains detailed instructions on how to configure your Arduino IDE.

https://cdn-learn.adafruit.com/downloads/pdf/adafruit-metro-m4-express-featuring-atsamd51.pdf