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.
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.
Installing libraries for QSPI Flash support
To install the libraries, follow these steps:
- Open the Arduino IDE.
- Go to menu item Sketch > Include Library > Manage Libraries.
- Find and install the
Adafruit SPIFlash
library. - 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.
- Go to Tools > Board and select Adafruit Metro M4 (SAMD51).
- Plug the Adafruit Metro M4 into any USB port on your computer.
- 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.
- 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.5: Drag the USB flashing format file to the METROM4BOOT icon.
- Double-click the reset button on the Metro M4 board. Figure V.D.3 shows its location.
- A new Explorer window will pop up. A drive designated as
METROM4BOOT
will appear in this window. This is the Metro M4’s drive. - Download the Circuit Python USB flashing format file [
adafruit-circuitpython-metro_m4_express-en_US-4.1.0.uf2
]. - Using your mouse, drag the .uf2 file to the
METROM4BOOT
drive icon in Explorer. - A new Explorer window will pop up. The
METROM4BOOT
drive will be renamedUsb Drive
. This will display the flash memory’s contents. Right click onUsb Drive
and click Format. - 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.
- When the formatting is complete, open the sketch
SdFat_format.ino
in the Arduino IDE. - Press the reset button on the Metro M4 board.
- Click the menu item Sketch > Upload.
- Go to Tools -> Serial Monitor to open the serial monitor dialog box. The baud rate should be set to 115200 baud.
- You will see this prompt: T
his sketch will ERASE ALL DATA on the flash chip and format it with a new filesystem!
- Type OK (all caps) and press enter.
- 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