Skip to content

Bus_SPI: detect SCT on ESP-IDF 6.1 - #322

Merged
lovyan03 merged 1 commit into
m5stack:developfrom
ainyan03:spi_sct_idf61
Sep 30, 2026
Merged

lovyan03 merged 1 commit into
m5stack:developfrom
ainyan03:spi_sct_idf61

Conversation

@ainyan03

Copy link
Copy Markdown
Contributor

ESP-IDF 6.1 removed SOC_SPI_SCT_SUPPORTED and SOC_SPI_SCT_SUPPORTED_PERIPH from soc_caps.h; the capability is now SPI_LL_PERIPH_HAS_SCT(host) in hal/spi_ll.h. Bus_SPI found neither macro, so the Segmented-Configure-Transfer path was compiled out on ESP32-S3 / C3 / C6 / C2 / H2 with ESP-IDF 6.1:

  • DMA transfers over 32 KB fell back to restarting every segment from the CPU and waiting for it in between.
  • The SCT-only transfer fixes (AFIFO reset before start, CS setup right after an SCT transfer) were dropped as well.

This PR falls back to hal/spi_ll.h on ESP-IDF 6.1 and later, only when soc_caps.h has no SCT macros. It also uses one LGFX_SPI_SCT_PERIPH(host) for both the compile-time check and the per-host runtime check. Older ESP-IDF keeps using soc_caps.h and does not include the LL header.

Tested:

  • The SCT check result per build: on for ESP32-S3 with ESP-IDF 6.1 (off before this PR), 6.0.2 and 5.5; off for ESP32-P4 and ESP32-C5 with 6.1, which have no SCT
  • Builds across the Arduino and ESP-IDF versions used by the CI (4.4 to 6.1)
  • Hardware, ESP32-S3 with ESP-IDF 6.1, a 150 KB image sent as one DMA transfer (pushImageDMA) and read back from the panel:
Read-back mismatches Time until the call returns Time until the transfer ends
SCT (this PR) 0 0.06 ms 30.8 ms
No SCT (the path used before this PR) 0 24.2 ms 30.8 ms

ESP-IDF 6.1 removed SOC_SPI_SCT_SUPPORTED and
SOC_SPI_SCT_SUPPORTED_PERIPH from soc_caps.h; the capability is now
SPI_LL_PERIPH_HAS_SCT(host) in hal/spi_ll.h. The check saw no macros, so
the Segmented-Configure-Transfer path was compiled out on ESP32-S3 / C3 /
C6 / C2 / H2: DMA transfers over 32 KB fell back to restarting every
segment from the CPU and waiting for it in between, and the SCT-only
transfer fixes (AFIFO reset before start, CS setup after SCT)
were dropped too.

Fall back to hal/spi_ll.h on ESP-IDF 6.1 and later when soc_caps.h has
no SCT macros, and use one LGFX_SPI_SCT_PERIPH(host) for both the
compile-time check and the per-host runtime check. Older ESP-IDF keeps
using soc_caps.h and does not include the LL header.
@lovyan03
lovyan03 merged commit d15bcea into m5stack:develop Sep 30, 2026
28 checks passed
@ainyan03
ainyan03 deleted the spi_sct_idf61 branch September 30, 2026 21:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants