Can't get MicroSD working on ESP32-P4-Function-EV-Board

johnsondavies
Posts: 6
Joined: Thu Oct 11, 2018 6:10 pm

Can't get MicroSD working on ESP32-P4-Function-EV-Board

Postby johnsondavies » Sun Jun 08, 2025 1:54 pm

I can't get the MicroSD card slot to work on the ESP32-P4-EV board. I've tried:

Code: Select all

SPIClass myspi(HSPI);
SPI.begin(43, 39, 44, 42); // SCK, MISO, MOSI, SS
pinMode(45, OUTPUT);
digitalWrite(45, LOW);     // SD_PWRn for MicroSD power
SD.begin(42, myspi);
but it still won't read an SD card. Any suggestions would be greatly appreciated!

lbernstone
Posts: 1131
Joined: Mon Jul 22, 2019 3:20 pm

Re: Can't get MicroSD working on ESP32-P4-Function-EV-Board

Postby lbernstone » Sun Jun 08, 2025 4:29 pm

I don't have a P4 to test on, but there is no need to create a new SPI object. The example should work fine if you just reassign pins. Are you sure pin 45 is inverted? How are you gating the power? Force it "ON" while testing the driver. I don't have a P4 to test, but the variant file includes this nugget:
// Use GPIOs 36 or lower on the P4 DevKit to avoid LDO power issues with high numbered GPIOs.

Code: Select all

SPI.begin(43, 39, 44, 42); // SCK, MISO, MOSI, SS
SD.begin(42);

chegewara
Posts: 2505
Joined: Wed Jun 14, 2017 9:00 pm

Re: Can't get MicroSD working on ESP32-P4-Function-EV-Board

Postby chegewara » Tue Jun 10, 2025 10:02 am

I can't get the MicroSD card slot to work on the ESP32-P4-EV board. I've tried:

Code: Select all

SPIClass myspi(HSPI);
SPI.begin(43, 39, 44, 42); // SCK, MISO, MOSI, SS
pinMode(45, OUTPUT);
digitalWrite(45, LOW);     // SD_PWRn for MicroSD power
SD.begin(42, myspi);
but it still won't read an SD card. Any suggestions would be greatly appreciated!
Are you trying to use on board SD card slot or connect own?

johnsondavies
Posts: 6
Joined: Thu Oct 11, 2018 6:10 pm

Re: Can't get MicroSD working on ESP32-P4-Function-EV-Board

Postby johnsondavies » Thu Jun 12, 2025 11:25 am

Thank you for the suggestions, but still not working.
there is no need to create a new SPI object.
I've tried:

SPI.begin(43, 39, 44, 42); // SCK, MISO, MOSI, SS
SD.begin(42);

but that doesn't help.
Are you trying to use on board SD card slot or connect own?
I'm trying to use the on-board MicroSD slot.
Are you sure pin 45 is inverted? How are you gating the power?
In the pins_arduino.h file it's defined as:

#define BOARD_SDMMC_POWER_PIN 45
#define BOARD_SDMMC_POWER_ON_LEVEL LOW

I'm doing:

pinMode(45, OUTPUT);
digitalWrite(45, LOW);

Thanks!
David

andromeda92
Posts: 34
Joined: Tue Nov 18, 2025 5:24 pm

Re: Can't get MicroSD working on ESP32-P4-Function-EV-Board

Postby andromeda92 » Thu Nov 27, 2025 12:43 pm

I have the same problem with Waveshare ESP32-P4 dev kit basic

SD_MMC work fine, but not with SD.h (SD_Test.ino)

pins are the same that EV-BOARD.

Any solution ?

lbernstone
Posts: 1131
Joined: Mon Jul 22, 2019 3:20 pm

Re: Can't get MicroSD working on ESP32-P4-Function-EV-Board

Postby lbernstone » Thu Nov 27, 2025 7:24 pm

Works just fine for me. Remember to flip the switch on. On my board (P4-EYE), the switch is on pin 46, and must be held low to power the sd. I didn't test 4-bit. What's the use case where would you use SD instead of SD_MMC?

andromeda92
Posts: 34
Joined: Tue Nov 18, 2025 5:24 pm

Re: Can't get MicroSD working on ESP32-P4-Function-EV-Board

Postby andromeda92 » Fri Nov 28, 2025 1:01 pm

I wanted to test the functionalities of the Waveshare ESP32-P4 Dev Kit Basic board, and I noticed that the SD_mmc example worked fine, but SD_Test, which uses SD.h and SdFat, doesn't.

Many applications use SD.h or SdFat, such as RunCPM under Arduino, etc., so I'm limited to the level of these applications that don't work.

lbernstone
Posts: 1131
Joined: Mon Jul 22, 2019 3:20 pm

Re: Can't get MicroSD working on ESP32-P4-Function-EV-Board

Postby lbernstone » Sat Nov 29, 2025 3:26 am

Well, the SD_Test sketch does work for me, just by setting the REASSIGN_PINS section. As mentioned above, make sure you turn on the SD switch, which on that board appears to be gpio45, and low is on.

andromeda92
Posts: 34
Joined: Tue Nov 18, 2025 5:24 pm

Re: Can't get MicroSD working on ESP32-P4-Function-EV-Board

Postby andromeda92 » Sat Nov 29, 2025 9:01 am

with this it not work.
i have uncommented #define REASSIGN_PINS

Code: Select all

void setup() {
  Serial.begin(115200);

#ifdef REASSIGN_PINS
  //pinMode(46, OUTPUT);
  //digitalWrite(46, LOW);
  //SPI.begin(sck, miso, mosi);  //, cs);
  pinMode(45, OUTPUT);
  digitalWrite(45, LOW);
  SPI.begin(43, 39, 44,42); // SCK, MISO, MOSI, SS

  if (!SD.begin()) {
#else
  if (!SD.begin()) {
#endif
    Serial.println("Card Mount Failed");
    return;
  }
can you put your code from SD_Test ?

andromeda92
Posts: 34
Joined: Tue Nov 18, 2025 5:24 pm

Re: Can't get MicroSD working on ESP32-P4-Function-EV-Board

Postby andromeda92 » Sat Nov 29, 2025 9:22 am

i have tested with two sdcard, and is the same.

https://imgur.com/a/5khT3wW

Who is online

Users browsing this forum: No registered users and 3 guests