Skip to content

boards/xtensa/esp32s3/esp32s3-xiao: add SD card support over SPI2 - #20004

Merged
xiaoxiang781216 merged 1 commit into
apache:masterfrom
FelipeMdeO:feature/xiao-sdcard-spi
Aug 30, 2026
Merged

boards/xtensa/esp32s3/esp32s3-xiao: add SD card support over SPI2#20004
xiaoxiang781216 merged 1 commit into
apache:masterfrom
FelipeMdeO:feature/xiao-sdcard-spi

Conversation

@FelipeMdeO

@FelipeMdeO FelipeMdeO commented Aug 29, 2026

Copy link
Copy Markdown
Contributor

The XIAO ESP32-S3 Sense's onboard microSD slot (Seeed XIAOML Kit) is wired to SPI2 through the GPIO matrix: SCK=GPIO7, MOSI=GPIO9, MISO=GPIO8 (confirmed against espressif/arduino-esp32's XIAO_ESP32S3/pins_arduino.h) and CS=GPIO21 (confirmed against this project's own working xiaoml_bench_logger.ino, which tries CS candidates {21, 3} in that order -- GPIO3 is a documented fallback, not the real pin; a Seeed wiki page that names GPIO3 as CS turned out to be wrong and was the initial, unsuccessful attempt here).

Wires up board_sdmmc_spi_initialize() (common esp32s3 board code, CONFIG_MMCSD_SPI) into this board's bringup, and adds the esp32s3_spi2_status() callback (SPI_STATUS_PRESENT for SPIDEV_MMCSD(0)) that esp32s3-devkit and other in-tree boards already provide -- the esp32s3-xiao board had no SPI board file at all before this.

Validated on the bench: CMD0/CMD41/CMD58 handshake succeeds, SD ver2 card identified (SanDisk 32GB, 62333952 sectors), mounts as vfat, survives umount+remount with a written file intact.

Needed board defconfig additions (not included in this NuttX-tree commit; see the 61680_FW project repo for the board config that turns this on):

  CONFIG_ESP32S3_SPI2=y
  CONFIG_ESP32S3_SPI2_CSPIN=21
  CONFIG_ESP32S3_SPI2_CLKPIN=7
  CONFIG_ESP32S3_SPI2_MOSIPIN=9
  CONFIG_ESP32S3_SPI2_MISOPIN=8
  CONFIG_MMCSD=y
  CONFIG_NSH_MMCSDSPIPORTNO=2
  CONFIG_FS_FAT=y
  CONFIG_FAT_LFN=y
  CONFIG_FAT_LCNAMES=y
  • Real Testing
nsh> mount -t vfat /dev/mmcsd0 /mnt
fat_checkbootrecord: WARNING: Signature: aa55 FS sectorsize: 0 HW sectorsize: 512
nsh> mount
  /etc type romfs
  /mnt type vfat
  /proc type procfs
nsh> echo "hello sd card MY_FW" > /mnt/test.txt
nsh> ls -l /mnt
/mnt:
 drw-rw-rw-           0 RUN00001/
 drw-rw-rw-           0 RUN00002/
 drw-rw-rw-           0 RUN00003/
 -rw-rw-rw-          23 test.txt
 drw-rw-rw-           0 System Volume Information/
nsh> cat /mnt/test.txt
hello sd card MY_FW
nsh> umount /mnt
nsh> mount -t vfat /dev/mmcsd0 /mnt
fat_checkbootrecord: WARNING: Signature: aa55 FS sectorsize: 0 HW sectorsize: 512
nsh> cat /mnt/test.txt
hello sd card MY_FW

@github-actions github-actions Bot added Size: S The size of the change in this PR is small Board: xtensa labels Aug 29, 2026
@github-actions

github-actions Bot commented Aug 29, 2026

Copy link
Copy Markdown

MemBrowse Memory Report

No memory changes detected for:

Comment thread boards/xtensa/esp32s3/esp32s3-xiao/src/esp32s3_bringup.c
Comment thread boards/xtensa/esp32s3/esp32s3-xiao/src/esp32s3_bringup.c
The XIAO ESP32-S3 Sense's onboard microSD slot (Seeed XIAOML Kit) is
wired to SPI2 through the GPIO matrix: SCK=GPIO7, MOSI=GPIO9,
MISO=GPIO8 (confirmed against espressif/arduino-esp32's
XIAO_ESP32S3/pins_arduino.h) and CS=GPIO21 (confirmed against this
project's own working xiaoml_bench_logger.ino, which tries CS
candidates {21, 3} in that order -- GPIO3 is a documented fallback,
not the real pin; a Seeed wiki page that names GPIO3 as CS turned out
to be wrong and was the initial, unsuccessful attempt here).

Wires up board_sdmmc_spi_initialize() (common esp32s3 board code,
CONFIG_MMCSD_SPI) into this board's bringup, and adds the
esp32s3_spi2_status() callback (SPI_STATUS_PRESENT for SPIDEV_MMCSD(0))
that esp32s3-devkit and other in-tree boards already provide -- the
esp32s3-xiao board had no SPI board file at all before this.

Validated on the bench: CMD0/CMD41/CMD58 handshake succeeds, SD ver2
card identified (SanDisk 32GB, 62333952 sectors), mounts as vfat,
survives umount+remount with a written file intact.

Needed board defconfig additions (not included in this NuttX-tree
commit; see the 61680_FW project repo for the board config that turns
this on):
  CONFIG_ESP32S3_SPI2=y
  CONFIG_ESP32S3_SPI2_CSPIN=21
  CONFIG_ESP32S3_SPI2_CLKPIN=7
  CONFIG_ESP32S3_SPI2_MOSIPIN=9
  CONFIG_ESP32S3_SPI2_MISOPIN=8
  CONFIG_MMCSD=y
  CONFIG_NSH_MMCSDSPIPORTNO=2
  CONFIG_FS_FAT=y
  CONFIG_FAT_LFN=y
  CONFIG_FAT_LCNAMES=y

Assisted-by: Claude <noreply@anthropic.com>
Signed-off-by: Felipe Moura <mouraf@fiteclabs.org.br>
@FelipeMdeO
FelipeMdeO force-pushed the feature/xiao-sdcard-spi branch from eacdcdc to bfae41e Compare August 30, 2026 13:56
@xiaoxiang781216
xiaoxiang781216 merged commit 61c30d8 into apache:master Aug 30, 2026
27 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Board: xtensa Size: S The size of the change in this PR is small

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants