A Temporary Support for XIAO ESP32S3 Board on PlatformIO IDE

Alwin Arrasyid
4 min readApr 21, 2023

--

XIAO ESP32S3 board. The photo is owned by Seeed Studio.

So, the long-awaited XIAO ESP32S3 board is finally released. The variant that caught my eye was the XIAO ESP32S3 Sense which includes an extension for the OV2640 camera, a micro SD card, and a digital microphone, a perfectly tiny board for tinyML solutions.

As an early adopter of technology, I recognize the potential risk of using my preferred IDE, the PlatformIO IDE, without proper support. While Seeed Studio has announced official support for the Arduino IDE, I anticipate PlatformIO IDE will receive support soon. However, I don’t want to wait for that to happen. So, I will document my approach in this post. It’s worth noting that I’m basing my post on the board’s wiki page.

Important Update

The support for the Seeed XIAO ESP32S3 board is available on the latest release (v2.0.8). Also, the board definition for PlatformIO IDE is available but not on the release channel. So, all we need to do now is replace the following line:

platform = espressif32

to

platform = espressif32 @ 6.2.0

I tried running the camera example. But I couldn’t make the PSRAM work for me! I got the following error message:

E (164) psram: PSRAM ID read error: 0x00ffffff

The board definition provided in the platform-espressif32 repository uses qio_qspi PSRAM mode. If we change the mode to qio_opi, the PSRAM works!

"memory_type": "qio_opi"

A pull request is coming, so sit tight and relax. Or you can modify the seeed_xiao_esp32s3.json file directly.

Another update: fortunately, the fix is merged and now you can use espressif32 v6.2.0 on PlatformIO IDE.

Prerequisites

If you choose to use this post as a tutorial, I will assume that you have met the following requirements:

  1. PlatformIO IDE installed
  2. Espressif32 Platform installed
  3. Arduino Framework for ESP32 installed

Backup

To ensure a safe backup in case of any mistakes during my tinkering, I plan to duplicate the espressif32 platform and the Arduino framework. This way, I can experiment with these tools without risking any permanent damage.

I have the following script that will copy the espressif32 platform and Arduino framework package from my PlatformIO IDE installation directory:

#!/bin/bash

backup_dir=$HOME/.platformio-backup

if [ ! -d $backup_dir ]; then
mkdir $backup_dir
fi

backup_platforms_dir=$backup_dir/platforms

if [ ! -d $backup_platforms_dir ]; then
mkdir $backup_platforms_dir
fi

backup_packages_dir=$backup_dir/packages

if [ ! -d $backup_packages_dir ]; then
mkdir $backup_packages_dir
fi

platformio_dir=$HOME/.platformio
platformio_packages_dir=$platformio_dir/packages
platformio_platforms_dir=$platformio_dir/platforms


cp -r $platformio_packages_dir/framework-arduinoespressif32 $backup_packages_dir
cp -r $platformio_platforms_dir/espressif32 $backup_platforms_dir

It’s important to note that this script may not be compatible with Windows by default. If you plan to use it on a Windows machine, you should make necessary adjustments to ensure its compatibility. Unfortunately, I don’t have a Windows computer to make those changes myself.

After running the script, you will have the original Arduino framework directory and the espressif32 platform directory saved inside the $HOME/.platformio-backup directory.

Adding Support for PlatformIO IDE

To add support for a new board, we need to add the board definition for the PlatformIO IDE. Then, we need to modify the board.txt file from the Arduino framework and add a new variant that includes a pin definitions file and other kinds of stuff.

First, we define the board definition in a file named seeed_xiao_esp32s3.json. Here is the content of that file:

{
"build": {
"arduino": {
"ldscript": "esp32s3_out.ld",
"partitions": "default_8MB.csv",
"memory_type": "qio_opi"
},
"core": "esp32",
"extra_flags": [
"-DARDUINO_XIAO_ESP32S3",
"-DBOARD_HAS_PSRAM",
"-DARDUINO_USB_MODE=1",
"-DARDUINO_USB_CDC_ON_BOOT=1"
],
"f_cpu": "240000000L",
"f_flash": "80000000L",
"flash_mode": "dio",
"hwids": [
[
"0x2886",
"0x0056"
]
],
"mcu": "esp32s3",
"variant": "XIAO_ESP32S3"
},
"connectivity": [
"wifi"
],
"debug": {
"openocd_target": "esp32s3.cfg"
},
"frameworks": [
"arduino",
"espidf"
],
"name": "Seeed Studio XIAO ESP32S3",
"upload": {
"flash_size": "8MB",
"maximum_ram_size": 327680,
"maximum_size": 1310720,
"require_upload_port": true,
"speed": 460800
},
"url": "https://wiki.seeedstudio.com/xiao_esp32s3_getting_started/",
"vendor": "Seeed Studio"
}

Then, we need to download the board.txt file and the variant folder provided by Seeed Studio. Use the following script to download it:

#!/bin/bash

filename=XIAO_ESP32S3_Package.zip
url=https://files.seeedstudio.com/wiki/SeeedStudio-XIAO-ESP32S3/img/$filename

if [ ! -d downloads ]; then
mkdir downloads
fi

curl --output downloads/$filename $url
pushd downloads && unzip $filename && popd

Please note that this script assumes you have the curl and unzip program installed on your system. After running the script, you will have the board.txt file and the XIAO_ESP32S3 variant directory under the downloads folder.

Finally, we copy the board definition file to the board’s directory under the espressif32 platform folder. Then, we copy the board.txt file and XIAO_ESP32S3 variant directory to the framework-espressif32 directory.

Run the following script to do those tasks:

#!/bin/bash

platformio_dir=$HOME/.platformio
arduino_esp32_dir=$platformio_dir/packages/framework-arduinoespressif32
esp32_dir=$platformio_dir/platforms/espressif32

cp seeed_xiao_esp32s3.json $esp32_dir/boards
cp -r downloads/boards.txt $arduino_esp32_dir
cp -r downloads/XIAO_ESP32S3 $arduino_esp32_dir/variants

And that’s it! Now we can create projects using the seeed_xiao_esp32s3 board using PlatformIO IDE.

Closing

We’ve added temporary support for the Seeed XIAO ESP32S3 board on the PlatformIO IDE. Any update to the espressif32 platform or the Arduino framework for esp32 will undo our temporary workaround. Until official support becomes available, repeat the steps outlined here each time you update the espressif32 platform or the Arduino framework.

References

--

--

Alwin Arrasyid
Alwin Arrasyid

Written by Alwin Arrasyid

Principal Engineer, working on better IoT solutions and enabling AI on the edge.

No responses yet