Skip to content

fix(m5stack-tab5): power the SD card IO rail through the P4's LDO channel 4 - #797

Merged
finger563 merged 1 commit into
mainfrom
fix/tab5-sd-ldo
Sep 15, 2026
Merged

finger563 merged 1 commit into
mainfrom
fix/tab5-sd-ldo

Conversation

@finger563

Copy link
Copy Markdown
Contributor

Problem

SD card init on the M5Stack Tab5 fails (sdmmc_init_ocr: send_op_cond returned 0x107, or sdmmc_init_sd_ssr ... returned 0xffffffff on the first data transfer) even with the pins verified correct, including in the component's own example.

Cause

On the ESP32-P4 the SD card IO pads (GPIO39-44) are powered by the chip's internal LDO channel 4 (LDO_VO4). The Tab5 BSP never set host.pwr_ctrl_handle, so the SDMMC driver never switched that rail on and the bus floated.

Fix

Create the on-chip LDO power control (sd_pwr_ctrl_new_on_chip_ldo, channel 4) and hand it to the SDMMC host, the same way esp32-p4-function-ev-board, esp32-p4-nano, esp32-p4-eth, esp32-p4-module-dev-kit and esp32-p4-wifi6-dev-kit already do, and the same as M5Stack's own Tab5 BSP. Also pins the host to slot 0 / 4-bit (matching M5Stack) and releases the handle when mounting fails.

The other ESP32-P4 BSPs with SD support were checked and already do this; esp32-p4-wifi6-poe-eth has no SD support.

Testing

  • components/m5stack-tab5/example builds for esp32p4 (IDF v6.1).
  • Verified on a Tab5 through the tab5-emu project pointing at this branch.

🤖 Generated with Claude Code

https://claude.ai/code/session_01BAeyJSuzVyqvSe4mffGUZo

…nnel 4

The SD card's IO pads (GPIO39-44) on the ESP32-P4 are powered by the
internal LDO channel 4 (LDO_VO4). The Tab5 BSP never gave the SDMMC host
a power-control handle, so that rail stayed off, the bus floated and card
init failed (send_op_cond timeouts, or ESP_FAIL on the first data
transfer). Create the on-chip LDO power control like the other ESP32-P4
BSPs (and M5Stack's own Tab5 BSP) do, pin the host to slot 0 and 4-bit
mode, and release the handle if mounting fails.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01BAeyJSuzVyqvSe4mffGUZo
Copilot AI lite review requested due to automatic review settings September 15, 2026 19:13
@github-actions

Copy link
Copy Markdown

✅Static analysis result - no issues found! ✅

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

The reviewed changes address SD power and host configuration with no unresolved issues.

Pull request overview

Fixes M5Stack Tab5 SD card initialization by powering the ESP32-P4 SD I/O rail through LDO channel 4.

Changes:

  • Adds on-chip LDO power control.
  • Configures SDMMC slot 0 in 4-bit mode.
  • Cleans up the power handle when mounting fails.
File summaries
File Description
components/m5stack-tab5/src/sdcard.cpp Configures SD power and SDMMC host settings.
components/m5stack-tab5/include/m5stack-tab5.hpp Defines the LDO channel and stores the power-control handle.
Review details
  • Files reviewed: 2/2 changed files
  • Comments generated: 0
  • Review effort level: Lite

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@finger563
finger563 merged commit d3501be into main Sep 15, 2026
165 checks passed
@finger563
finger563 deleted the fix/tab5-sd-ldo branch September 15, 2026 19:58
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