Skip to content

stm32h5/qspi, drivers/mtd/gd25: add QSPIMEM_QUADDATA flag and GD25 QSPI support#19177

Open
sammytranGeo wants to merge 2 commits into
apache:masterfrom
sammytranGeo:stm32h5/qspi-quaddata-gd25
Open

stm32h5/qspi, drivers/mtd/gd25: add QSPIMEM_QUADDATA flag and GD25 QSPI support#19177
sammytranGeo wants to merge 2 commits into
apache:masterfrom
sammytranGeo:stm32h5/qspi-quaddata-gd25

Conversation

@sammytranGeo

Copy link
Copy Markdown
Contributor

Summary

include/nuttx/spi/qspi.h currently has QSPIMEM_QUADIO for 1-4-4 transfers (address and data both on quad lines) but no way to express 1-1-4 (single-line address, quad-width data only). Several NOR flash devices use this mode for page program commands.

This adds QSPIMEM_QUADDATA (bit 1) and QSPIMEM_ISQUADDATA() to fill that gap, and extends the STM32H5 QSPI driver to set CCR_DMODE_QUAD when either QUADIO or QUADDATA is set. The address-mode selection block is unchanged, so QUADDATA keeps addrmode at single-line.

The GD25 MTD driver is updated as the first user, gaining a CONFIG_GD25_QSPI build option that switches it from SPI to QuadSPI. When enabled, gd25_initialize() accepts a qspi_dev_s pointer and a bool unprotect. Both 3- and 4-byte address modes are supported, and the existing SPI path is fully preserved when CONFIG_GD25_QSPI=n.

Impact

  • qspi.h: additive change only — new flag and macro, no existing behaviour changed.
  • stm32h5/stm32_qspi.c: the else if (QSPIMEM_ISQUADIO(...)) branch gains an || QSPIMEM_ISQUADDATA(...) condition. No impact on existing QUADIO users.
  • drivers/mtd/gd25.c: new CONFIG_GD25_QSPI Kconfig option, off by default. Existing SPI users are unaffected.

Testing

Host: Linux x86_64, arm-none-eabi-gcc 13.2
Board: Custom STM32H563ZI board with GD25Q256 NOR flash on OCTOSPI1
Config: Custom board NSH config with CONFIG_STM32_QSPI1=y, CONFIG_MTD_GD25=y, CONFIG_GD25_QSPI=y, CONFIG_GD25_QSPIFREQUENCY=40000000, CONFIG_FS_LITTLEFS=y

LittleFS was mounted on /dev/mtd0 and a file written and read back to exercise both transfer modes end-to-end:

nsh> mount -t littlefs -o forceformat /dev/mtd0 /mnt
nsh> echo "hello qspi" > /mnt/test.txt
nsh> cat /mnt/test.txt
hello qspi

@github-actions github-actions Bot added Arch: arm Issues related to ARM (32-bit) architecture Area: Drivers Drivers issues Size: M The size of the change in this PR is medium labels Jun 19, 2026
@github-actions

Copy link
Copy Markdown

MemBrowse Memory Report

No memory changes detected for:

@acassis

acassis commented Jun 20, 2026

Copy link
Copy Markdown
Contributor

@sammytranGeo please fix the CI error (long line and wrong block comment found)

You can use the tools/checkpatch.sh to find coding style issues in the source code before creating the commit

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Arch: arm Issues related to ARM (32-bit) architecture Area: Drivers Drivers issues Size: M The size of the change in this PR is medium

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants