Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Question on SD_MMC for ESP32 #4

Open
jameszah opened this issue Dec 18, 2021 · 16 comments
Open

Question on SD_MMC for ESP32 #4

jameszah opened this issue Dec 18, 2021 · 16 comments
Labels
enhancement New feature or request marvelous

Comments

@jameszah
Copy link

Are you aware if anyone has modified this for SD card access?

I think it would be fairly straightforward. Do you think there would be roadblocks?

Maybe add both LittleFS and SD? I'll start with just SD.

@holgerlembke
Copy link
Owner

No, not heard anything.

I'm more or less active with a version that has a flexible storage device interface.

It will have two functions (findfirst/findnext) that will be called to collect data.

But I have no real need for that, so my commitment is low.

@holgerlembke holgerlembke added the enhancement New feature or request label Dec 18, 2021
@jameszah
Copy link
Author

It was pretty easy.
Issues so far:

  1. The directory files need to be excluded from download and download zip.
  2. Download zip fails with zero size files, so exclude them too. (that was a little time-consuming)
  3. Switching to sub-directories I think is do-able by passing a subdir back and forth from the c++ to javascipt as a parameter to /i command-- have not done that yet

I'll put the modified files into my fork as a esp32-sd file manager test program - with all necessary files.

@holgerlembke
Copy link
Owner

Nice. I'll keep that open as a pointer for others.

@jameszah
Copy link
Author

https://github.com/jameszah/ESPxWebFlMgr/tree/master/esp32_sd_file_manager

Use all the files in that folder for test program, and then delete the .ino and replace with your own project to add the sd file manager to your own projects.

The subfolders implementation turned a little kludgy in the end - most changes marked with //jz

See here for implementation with my esp32 video recorder project (replacing ftp).
https://github.com/jameszah/ESP32-CAM-Video-Recorder-junior

@jameszah
Copy link
Author

hi Holger, obscure followup question:

I've started running these mods in host mode on esp32 rather than in normal station mode, and using a chrome browser on a android phone rather than chrome on windows going through a router.

Two strange events:

First, the files download correctly by always with a ".phps" file type ??? So both config.txt, and abc.avi binary files end up as "config.txt.phps" etc. on android. I cannot understand who is using php in this scenario.

Second, small files (< 1 megabyte) transfer fine, but larger files will stall, and then restart, and sometimes fail, and restart???

It seems to be here in the code on ESPxWebFlMge.cpp (line 856 in my slightly modified version).

I understand you cannot you cannot change the mime bindings of android chrome, but I can just rename the files, and the "stall" or "fail" would be entirely within that line streamFile below.

Any advice before I dig into that?

Thanks, James

      if (f) {
        //Serial.println("got it open");
        fileManager->sendHeader(F("Content-Type"), F("text/text"));
        fileManager->sendHeader(F("Connection"), F("close"));
        //Serial.print(">");Serial.print(fn);Serial.println("<");
        //Serial.println(fn.indexOf("/"));
        if (fn.indexOf("/") == 0) {
          fileManager->sendHeader(F("Content-Disposition"), "attachment; filename=" + fn.substring(1));
        } else {
          fileManager->sendHeader(F("Content-Disposition"), "attachment; filename=" + fn);
        }
        fileManager->sendHeader(F("Content-Transfer-Encoding"), F("binary"));
        if (fileManager->streamFile(f, "application/octet-stream") != f.size()) {
          Serial.println(F("Sent less data than expected!"));
        }
        f.close();

@jameszah
Copy link
Author

It looks like it is a cell-phone hardware/software issue. I tried the esp32 AP mode (host mode) from the esp32 to a WiFi on a Windows PC, and it was perfect - download a 200 megabyte binary file at exactly 4 mega-bit-per-second, without any stalls or problems -- so it must just be a samsumg-android-phone issue that gets confused at the 4 mega-byte mark. ???

I think I can live with that. Short videos or configuration only to a phone. 😄

@holgerlembke
Copy link
Owner

That would have been my first suggestion: odd android or odd ported android. older android versions had very weird implementations of any stuff you stumble over. Each version solves a lot of things internally, better design, better concept, better working.

And there is this https://github.com/holgerlembke/ESPxWebFlMgr/tree/master/chrome%20browser%20problem thing...

@jameszah
Copy link
Author

Interesting. I was sending some streaming mjpeg video from esp to android chrome today, and it was equally weak. Things that work on a 10 year old laptop with windows 10 and chrome were stalling on a 3 month old android phone -- just display jpeg's ???

@DJprasenjit
Copy link

https://github.com/jameszah/ESPxWebFlMgr/tree/master/esp32_sd_file_manager

Use all the files in that folder for test program, and then delete the .ino and replace with your own project to add the sd file manager to your own projects.

The subfolders implementation turned a little kludgy in the end - most changes marked with //jz

See here for implementation with my esp32 video recorder project (replacing ftp). https://github.com/jameszah/ESP32-CAM-Video-Recorder-junior

please share me the pins and connection diagram

@jameszah
Copy link
Author

jameszah commented Sep 8, 2023

https://randomnerdtutorials.com/esp32-cam-ai-thinker-pinout/

I'm using a standard esp32-cam module with sd card.
The data1, data2, and data3 are not used in 1-bit mode, so don't need to be there on another configuration.

@DJprasenjit
Copy link

https://github.com/jameszah/ESPxWebFlMgr/tree/master/esp32_sd_file_manager

Use all the files in that folder for test program, and then delete the .ino and replace with your own project to add the sd file manager to your own projects.

The subfolders implementation turned a little kludgy in the end - most changes marked with //jz

See here for implementation with my esp32 video recorder project (replacing ftp). https://github.com/jameszah/ESP32-CAM-Video-Recorder-junior

esp32_sd_file_manager
E (26) sdmmc_io: sdmmc_io_reset: unexpected return: 0x108
E (27) vfs_fat_sdmmc: sdmmc_card_init failed (0x108).
SD_MMC Mount Failed

@DJprasenjit
Copy link

https://randomnerdtutorials.com/esp32-cam-ai-thinker-pinout/

I'm using a standard esp32-cam module with sd card. The data1, data2, and data3 are not used in 1-bit mode, so don't need to be there on another configuration.

i am using the same pin out like esp32 cam module. i interfaced a sd card with esp32 board.
data0 io2
data1 io4
clk io14
cmd io15
data1 io13
data2 io12

after upload this problem coming

esp32_sd_file_manager
E (26) sdmmc_io: sdmmc_io_reset: unexpected return: 0x108
E (27) vfs_fat_sdmmc: sdmmc_card_init failed (0x108).
SD_MMC Mount Failed

do i need to add those 47K pullup registers?

i just changed the ssid and password and upload to esp32 dev module. do i need to select any other option on board manager??

@DJprasenjit
Copy link

https://randomnerdtutorials.com/esp32-cam-ai-thinker-pinout/

I'm using a standard esp32-cam module with sd card. The data1, data2, and data3 are not used in 1-bit mode, so don't need to be there on another configuration.

sir i think i found the problem . is this esp32 sd file manager required psram?
because i am not using it. i m interfacing with normal esp32 nodemcu board.

but there is not instruction about this,
is there any video instruction?

@holgerlembke
Copy link
Owner

There is this page: https://github.com/espressif/arduino-esp32/tree/master/libraries/SD_MMC

and as far as I see, there is no limitation with psram.

I have a wemos form factored esp32-wroom-32 pcb

image

in my mail/production/pipeline, might take 2 to 3 weeks. But as usual, I'm clueless and do not know what I'm doing. So no idea where it will end.

@jameszah
Copy link
Author

jameszah commented Sep 9, 2023

Try getting the test program working first.

You need good power, nothing pulling the lines up or down (the 47k pull up might help), sd card with fat32, not write protected (test that first). You could check voltages just with a volt meter to see that nothing is using those gpios.

I don't think the psram is an issue for the sd_mmc.

https://github.com/espressif/arduino-esp32/blob/master/libraries/SD_MMC/examples/SDMMC_Test/SDMMC_Test.ino

@DJprasenjit
Copy link

Try getting the test program working first.

You need good power, nothing pulling the lines up or down (the 47k pull up might help), sd card with fat32, not write protected (test that first). You could check voltages just with a volt meter to see that nothing is using those gpios.

I don't think the psram is an issue for the sd_mmc.

https://github.com/espressif/arduino-esp32/blob/master/libraries/SD_MMC/examples/SDMMC_Test/SDMMC_Test.ino

many thanks. problem solved. i did wrong connection of sd card, now its works fine, i did not add any pullup registers, just in setup i added input pullup lines for these pins and its works good.
thanks a lot

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request marvelous
Projects
None yet
Development

No branches or pull requests

3 participants