Repository navigation
Fix SPI SD card remount zombie state, MISO release clock, and USBSerial vprintf - #3082
Merged
bmorcelli merged 2 commits intoNov 13, 2026
Merged
Conversation
…, fix vprintf Verified build: pio run -e m5stack-sticks3 (exit 0)
This was referenced Nov 14, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes an unrecoverable SPI SD card zombie state after any transient read/command timeout, clocks a trailing
0xFFbyte onCSdeassertion so the SD card releasesMISOon shared SPI buses, and fixesUSBSerial::vprintfprintingva_liststack pointers on CLI commands such asstorage free sd.Hardware Tested
m5stack-sticks3(v1.17/2b6ba4d) with external shared-SPI module (CC1101+NRF24+32GB MicroSDsharingSCK=5, MISO=4, MOSI=6).lib/HAL/sd_cardand USB-serial CLI targets usingUSBSerial.Changes (
fefc13b)src/core/sd_functions.cpp: CallcloseSdCard()anddisplayError("SD Read/Mount Error", true)when the secondfs.exists(rootPath)fails forSD, resetting_pdrvto0xFFso the nextsetupSdCard()performs a real SPI re-initialization (160 SCK + CMD0).lib/HAL/sd_card/sd_diskio.cpp: Clock one trailing0xFFbyte after pullingssPinHIGHinsdDeselectCard()so the card releasesDAT0/MISOto Hi-Z on shared SPI buses.src/core/serial_commands/storage_commands.cpp: Unmount viacloseSdCard()and report an error ifSD.totalBytes() == 0, and guardfreeBytesagainst unsigned underflow.src/core/USBSerial/USBSerial.h: Forwardva_listtoout->vprintf(fmt, args)instead ofout->printf(fmt, args).Verification
pio run -e m5stack-sticks3->SUCCESS.storage free sdaccurately formats 64-bit capacities (31702614016 Byteson 32GB MicroSD), and 10 rounds ofCC1101/NRF24/SD Cardswitching confirm hot-remount recovery withoutESP.restart().