A very informative response to my first post about the Seeeduino XIAO came in three days ago from D. J. Park in Malaysia. The long email contained many comments, corrections and suggestions which I have yet to digest, but I already know that they will help me improve that overview of the XIAO. However, the purpose of this post is to make available the last part of the message which contained instructions on how to add the XIAO to the list of SAM D21 boards in PlatformIO.
It will be assumed that PlatformIO (PIO for short) is installed and working properly in the Visual Studio Code editor (or another supported editor) on the desktop, but if not, here are the installation instructions. It will also be assumed that the XIAO board has been installed in the Arduino IDE although, strictly speaking, that is not mandatory. In essence adding the XIAO to the environment is a two-step operation.
Copy the XIAO_m0
variants directory from Arduino to PlatformIO
You will need to locate the pertinent "variants" directories of each platform.
- The Seeeduino SAMD variants directory in the Arduino IDE.
On my system this is its absolute path.
/home/michel/ED/arduino-1.8.10/portable/packages/Seeeduino/hardware/samd/1.7.2/variants/It contains 6 subdirectories,
michel@hp:~$ ls ED/arduino-1.8.10/portable/packages/Seeeduino/hardware/samd/1.7.2/variants/ arduino_zero femto_m0 grove_ui_wireless wio_terminal XIAO_m0 zero_radioincluding the one that is needed:
XIAO_m0
. Note that I chose the "portable" configuration for the Arduino IDE which was installed inside a directory calledED
in my home directory. Had I chosen the standard configuration, the wanted directory would be somewhere else such as/home/michel/.arduino15/packages/Seeeduino/hardware/samd/1.7.2/variants/ - The PlatformIO variants directory for SAMD devices.
On my system this is its absolute path.
/home/michel/.platformio/packages/framework-arduino-samd/variants/At the time of writing this, the folder contained 13 subdirectories.
michel@hp:~$ ls /home/michel/.platformio/packages/framework-arduino-samd/variants/ arduino_mzero circuitplay mkrfox1200 mkrnb1500 mkrwan1300 mkrzero w25_xplained_pro arduino_zero mkr1000 mkrgsm1400 mkrvidor4000 mkrwifi1010 nano_33_iotNote the absence of the
XIAO_m0
variants directory. If it is there, then the XIAO has been added to PlatformIO, stop reading this!
Now, it's just a matter of copying the directory.
The copy command was split over two lines because it is so long. I was just showing off, it was simpler to use Double Commander
to copy the directory.
If the XIAO board is not installed in the Arduino IDE, the variant directory could be pulled from the Seeed-Studio SAMD Arduino Core fork. In the end you should end up with the following directories and files in the <.../.platformio>/packages/framework-arduino-samd/variants/
directory.
Add the XIAO board definition
Thankfully, D. J. Park provided the board definition.
All that we have to do is copy it to the correct directory.
The file can be downloaded by clicking on this link: seeeduino_xiao.json. Clicking with the right mouse button might be preferable here.
When a new project is started in PlatformIO, it will be possible to use the Seeeduino XIAO board definition from now on. I use the following platformio.ini
configuration file with new projects.
Bonus: printf
The Print
library in the SAMD Arduino core of PlatformIO does not support the printf
method. Mr Park noted that I liked to use that function so he provided instructions on how to replace that library with the Arduino version which does support printf
. All that needed to be done was to copy Print.h
and Print.cpp
from /home/michel/ED/arduino-1.8.10/portable/packages/Seeeduino/hardware/samd/1.7.2/cores/arduino/
to /home/michel/.platformio/packages/framework-arduino-samd/cores/arduino/
. You should probably back up the original PlatformIO Print.h
and Print.cpp
files before overwriting them.
Thank you
Heartfelt thanks to D. J. Park for this very useful information.