risc-v/gd32vw55x: add sdcard (SPI/FAT) example to gd32vw553k-start

Add an "sdcard" configuration that mounts an SD card over SPI0 with a FAT
filesystem. The board provides the SPI chip-select glue (gd32_spi0select,
gd32_spi0status and gd32_spi0register in a new gd32_spi.c) and gd32_bringup()
binds the slot with mmcsd_spislotinitialize() and mounts /dev/mmcsd0 on
/mnt/sd.

The card is wired to the J1 header: SCK PA2, MISO PA1, MOSI PA0, and a
software chip select on PA4. CONFIG_MMCSD_MMCSUPPORT is left off (its MMC
CMD1 probe upsets SD cards).

Signed-off-by: Jorge Guzman <jorge.gzm@gmail.com>
This commit is contained in:
Jorge Guzman 2026-07-24 14:14:21 -03:00 committed by CeDeROM
parent e33a1f9943
commit bbc0bdd40c
7 changed files with 273 additions and 5 deletions

View file

@ -256,6 +256,50 @@ duty (100 Hz, 50 % by default)::
duration for a single run. Put an LED (with a series resistor) or a scope on
PA0 to see it.
sdcard
------
NSH plus an SD card on SPI0 with a FAT filesystem. The card is registered as
``/dev/mmcsd0`` and ``gd32_bringup()`` mounts it on ``/mnt/sd``.
Wire the card (or a microSD-over-SPI breakout) to the J1 header:
======== ==========
Signal Pin
======== ==========
SCK PA2
MISO PA1
MOSI PA0
CS PA4
======== ==========
.. note::
Power the breakout from **5 V**, not 3.3 V. These breakouts carry their
own 3.3 V regulator, and the SD card draws current bursts while it powers
up; feeding 3.3 V directly leaves the card stuck in the ACMD41 init loop
(it answers CMD0/CMD8 but never leaves the idle state). A decoupling
capacitor close to the card and short leads help too.
The SPI runs its initialisation at ~625 kHz (PCLK2 / 256), slightly above the
400 kHz of the SD spec, which the vast majority of cards tolerate.
The block device shows up as ``/dev/mmcsd0`` and the bringup already mounts it
on ``/mnt/sd``, so no manual ``mount`` is needed::
nsh> ls /dev/
/dev:
console
mmcsd0
null
ttyS0
zero
nsh> mount
/mnt/sd type vfat
nsh> echo "GD32 on NuttX" > /mnt/sd/hello.txt
nsh> cat /mnt/sd/hello.txt
GD32 on NuttX
nsh> ls -l /mnt/sd
littlefs
--------