Issue with Mounting SD Card on ESP32 Using SPI Interface - CLR_E_VOLUME_NOT_FOUND #1578
Answered
by
alberk8
sangyuxiaowu
asked this question in
Q&A
-
Hello, I am currently working on a project where I need to mount an SD card on an ESP32 using the SPI interface. However, I am encountering an issue where the SD card fails to mount, and I receive the Setup:
Wiring:
Code: using AudioPlayer;
using nanoFramework.Hardware.Esp32;
using nanoFramework.System.IO;
using nanoFramework.System.IO.FileSystem;
using System;
using System.Diagnostics;
using System.Threading;
/*
* nanoFramework.Hardware.Esp32
* nanoFramework.System.IO.FileSystem
* nanoFramework.System.Device.I2s
* nanoFramework.System.Math
* nanoFramework.System.Threading
* nanoFramework.System.Device.Spi
*/
namespace AudioTest
{
public class Program
{
static SDCard mycard0;
public static void Main()
{
Debug.WriteLine("START");
// 尝试手动挂载SD卡
MountMyCard();
const string audioFile = "D:\\music.wav";
var player = new I2sWavPlayer(I2sWavPlayer.Bus.One, audioFile,9,8);
player.Play();
player.Dispose();
mycard0.Unmount();
mycard0.Dispose();
Thread.Sleep(Timeout.Infinite);
}
static bool MountMyCard()
{
// SD Card:
const uint cs = 4;
Configuration.SetPinFunction(1, DeviceFunction.SPI1_MISO);
Configuration.SetPinFunction(2, DeviceFunction.SPI1_MOSI);
Configuration.SetPinFunction(3, DeviceFunction.SPI1_CLOCK);
Debug.WriteLine("SD card initialized");
// 初始化SD卡,使用SPI1总线
mycard0 = new SDCard(new SDCardSpiParameters { spiBus = 1, chipSelectPin = cs });
// 使用存储事件检测驱动器是否已挂载或卸载
StorageEventManager.RemovableDeviceInserted += StorageEventManager_RemovableDeviceInserted;
StorageEventManager.RemovableDeviceRemoved += StorageEventManager_RemovableDeviceRemoved;
try
{
mycard0.Mount();
Debug.WriteLine("Card Mounted");
return true;
}
catch (Exception ex)
{
Debug.WriteLine($"Card failed to mount: {ex.Message}");
Debug.WriteLine($"IsMounted: {mycard0.IsMounted}");
}
return false;
}
static void StorageEventManager_RemovableDeviceRemoved(object sender, RemovableDriveEventArgs e)
{
Debug.WriteLine($"Card removed - Event: {e.Event} Path: {e.Drive}");
}
static void StorageEventManager_RemovableDeviceInserted(object sender, RemovableDriveEventArgs e)
{
Debug.WriteLine($"Card inserted - Event: {e.Event} Path: {e.Drive}");
}
}
} Observed Output:
Troubleshooting Steps Taken:
Despite these efforts, the issue persists. Any insights or suggestions on how to resolve this issue would be greatly appreciated. Thank you! |
Beta Was this translation helpful? Give feedback.
Answered by
alberk8
Jan 3, 2025
Replies: 1 comment 5 replies
-
Make sure that the VCC is 3.3v otherwise you can kill the IO port of ESP32 |
Beta Was this translation helpful? Give feedback.
5 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Look at ESP32 Docs it says that there must be 10K pullup for CMD/CS and all the data line D0-D3 even if it is not used