The ESP32 Wi-Fi/BLE MCU series has become a go-to choice for both hobbyists and professional engineers due to its impressive performance, strong community support, and ease of use. Its versatility makes it ideal for a wide range of IoT projects. In this first part of the ESP32 Masterclass series, I will guide you through setting up the ESP-IDF (Espressif IoT Development Framework) for the Seeed XIAO ESP32S3 board and demonstrate how to build the "Hello, World!" project specifically tailored to the XIAO ESP32S3 hardware configuration.
Why Not Arduino?While the ESP32 MCU is widely supported in the Arduino ecosystem and many projects leverage the Arduino framework, it does have some limitations. Arduino, known for its ease of use, doesn’t fully exploit the ESP32’s capabilities. Features like code debugging, utilizing the low-power processor, and building multi-threaded applications are either not supported or require complex workarounds in Arduino.
Espressif’s ESP-IDF provides a robust and comprehensive framework that unlocks the full potential of the ESP32S3, offering professional-grade tools such as testing, command-line interface (CLI) build flows, and more. It’s designed to meet the needs of both professional developers and advanced hobbyists. And just to be clear—this article is not sponsored;
Getting StartedBefore diving into the setup of the ESP-IDF, it’s important to understand the memory configuration of the Seeed XIAO ESP32S3 board. The ESP32S3 MCU is available in various memory configurations, and understanding the specific setup of the XIAO ESP32S3 is crucial—especially when it comes to internal and external memory devices.
The core of the ESP32S3 remains consistent across different models, but you can choose configurations with integrated PSRAM and Flash, which help reduce the bill of materials (BOM) and save space on the PCB. Fortunately, Seeed has made the schematics of the XIAO ESP32S3 board open-source, allowing us to examine the specific components used, including the memory configuration. You can access the schematic here.
According to the schematic, the XIAO ESP32S3 uses the ESP32S3R8 variant, which is connected to an external NOR-Flash memory (GD25Q64ENIGR) from GigaDevice. The detailed configuration for this ESP32 model is available in the datasheet, which should be referenced to ensure correct setup and utilization.
The Seeed XIAO ESP32S3 board features an ESP32S3R8 variant with integrated PSRAM, connected to the CPU via Octal SPI (Serial Peripheral Interface). Octal SPI is an enhanced version of the traditional SPI interface, designed to significantly increase data transfer speed and efficiency between a master device (like a microcontroller) and peripheral devices (such as sensors or memory chips).
In a standard SPI setup, four signal lines are typically used: MISO (Master In, Slave Out), MOSI (Master Out, Slave In), SCLK (Serial Clock), and CS (Chip Select). However, Octal SPI employs eight data lines (IO0 to IO7), enabling 8-bit (1-byte) data transfers per clock cycle. This allows for a much higher data throughput compared to traditional SPI, which usually operates with just one or two data lines.
On the XIAO ESP32S3 board, the same SPI bus (SPI0) is shared by both the in-package PSRAM and the external NOR-Flash memory. While the PSRAM utilizes Octal SPI for faster data transfer, the external NOR-Flash is connected via Quad SPI, using four data lines for communication.
Important Considerations: Memory Voltage Levels and Power SupplyA critical aspect to consider is the SPI0 voltage level for both the in-package PSRAM and the external NOR-Flash. The ESP32S3R8 operates with 3.3V signals on SPI0 and supplies slightly less than 3.3V on the VDD_SPI pin to power both the in-package and external memory devices. You can refer to the ESP32 power scheme for more details.
To clarify how these components are interconnected, I’ve created a block diagram that illustrates the memory connections and the power path for the NOR-Flash:
In this diagram:
- The grey box represents the components housed within the ESP32S3R8 package.
- The internal PSRAM is connected directly to the ESP32-S3 core via the SPI0 bus, and some signals are also routed to the GPIOs (light grey box). For instance, the SPI0 clock signal (CLK) drives both the PSRAM and is available on GPIO 33.
- This setup allows for the simultaneous use of two memory devices on the same SPI bus, with each device having a unique Chip Select (CS) signal.
- To minimize potential interference, Seeed has ensured that the Chip Select for the in-package PSRAM is connected to GPIO 28, which remains unconnected to avoid disturbance.
With this foundational knowledge, we can now proceed to configure the ESP-IDF to support the Seeed XIAO ESP32S3 board, taking into account both the in-package PSRAM and the external NOR-Flash memory.
Installing the ESP-IDFEspressif provides excellent and detailed documentation for installing the ESP-IDF (Espressif IoT Development Framework), so rather than reinvent the wheel, I recommend following their official guide. You can find the step-by-step installation instructions here.
For reference, I’m working on a MacBook Pro with an M3 Pro processor, and the installation process was straightforward. To streamline my workflow, I also set up a Docker container for building ESP-IDF projects directly on my MacBook Pro, which adds flexibility and consistency across different environments.
Running the "Hello, World!" Example with XIAO ESP32S3 SettingsOnce the ESP-IDF is installed, the next step is to prepare your environment to build and run the "Hello, World!" example tailored to the XIAO ESP32S3 board.
Source the Export Script: Before you begin, make sure to source the export script to set up the necessary environment variables. This ensures that all ESP-IDF tools are accessible from your terminal.
Copy the Hello-World Example: Navigate to the ESP-IDF directory and copy the "Hello, World!" example project to a location of your choice. This example will serve as a base to test and verify your setup with the XIAO ESP32S3 hardware configuration.
By following these steps, you'll be ready to build and flash your first ESP-IDF project on the Seeed XIAO ESP32S3 boad
# Copy hello-world example
$ cp -r $IDF_PATH/examples/get-started/hello_world .
# Navigate to the hello-world dir
$ cd hello_world
# Set target device to ESP32S3
$ idf.py set-target esp32s3
# Start Menuconfig, save after modify the config
$ idf.py menuconfig
In general we have to modify a few configs to fit the XIAO ESP32S3 hardware.
Overview:
- Set Flash-Size to 8 MB
- Enable PSRAM and Set Octal SPI and Device Type to ESP-PSRAM64
- Set CPU Frequency to 240MHz
Flash-Size
(Top) → Serial flasher config → Flash size
SPI-PSRAM
(Top) → Component config → ESP PSRAM
(Top) → Component config → ESP PSRAM → Support for external, SPI-connected RAM → SPI RAM config → Mode (QUAD/OCT) of SPI RAM chip in use
(Top) → Component config → ESP PSRAM → Support for external, SPI-connected RAM → SPI RAM config → Type of SPIRAM chip in use
CPU-Frequency
(Top) → Component config → ESP System Settings → CPU frequency
# Build the hello-world project
$ idf.py build
After successfully building the project, you should see an output similar to this:
If the build completes without errors, the next step is to flash the XIAO ESP32S3 board and check the output. To do this, simply connect the XIAO ESP32S3 to your computer and identify the corresponding serial port.
Flashing the XIAO ESP32S3Once the board is connected, you can flash the firmware to the ESP32 using the ESP-IDF tools.
# Flash the XIAO ESP32S3, PORT is in my case /dev/cu.usbmodem101
$ idf.py -p <PORT> flash
Once the board is connected, you can flash the firmware to the ESP32 using the ESP-IDF tools. On a Mac, I recommend using screen to monitor the output from the ESP32 via the serial console.
After flashing the "Hello, World!" program, the ESP32S3 will begin executing it immediately. You should see the following key details in the output:
- The 8MB SPI-Flash is detected and in use.
- The PSRAM is operating in Octal mode.
- The CPU is running at 240 MHz.
With the "Hello, World!" example successfully running on your XIAO ESP32S3, you’re now set up to explore the full capabilities of the ESP32S3 MCU. Whether it's diving into more complex projects, experimenting with the built-in features, or optimizing performance, the possibilities are vast.
What would you like to explore next? Feel free to share your ideas or requests!
Comments
Please log in or sign up to comment.