Skip to content

ESP32 core 2.0.x: SD read file functions <SD.h> messed up, core 1.06 is fine though #6078

Closed
@dsyleixa

Description

@dsyleixa

Board

Adafruit ESP32 Feather

Device Description

default Adafruit ESP32 Feather

Hardware Configuration

ads1115 by i2c,
Adafruit Featherwing TFT HX3857 with TS

Version

latest master

IDE Name

Arduino IDE 1.8.9

Operating System

Windows 10

Flash frequency

80MHz

PSRAM enabled

no

Upload speed

921600

Description

e.g. I am reading a file array list from my SD, select ist by buttonpad buttons up, down, and right.
When it's a .txt file then I display the content on the screen while blocking parallel running threads:

by 1.0.6 the content is displayed and then return to the calling routine.
By 2.0.2 nothing happens first, by repeated tries the programm completely hangs up and blocks.

BTW,
there is another extra widget which displays ".bmp" picture files on the screen by Adafruit_Imagereader, which also is fine by 1..0.6 and what hangs up the same way like the .txt files by 2.0.6.

Sketch

String filelist[128]; // contents the filenames found on my SD

// list dir

void ls(String *list, int size, int selectnr) {
   Serial.println("print list[]:");
   for (int cnt = 0; cnt < size; cnt++) {
      if (cnt < 100) Serial.print(" ");
      if (cnt < 10)  Serial.print(" ");
      Serial.println((String)cnt+"  "+list[cnt]);

      int COLOR_TEXT;
      if(cnt==selectnr) COLOR_TEXT=LIME;
      else COLOR_TEXT=WHITE;

      display.setTextColor(COLOR_TEXT);
      display.setCursor(20+240*(cnt%2), 0+12*(cnt/2));  // <<<< filepos
      display.print(list[cnt]);
   }
   Serial.println("print list[] done!\n");
}




void ExplorerExecFunc() {
   char filename[80]="";
   strcpy( filename, filelist[selectfilenr].c_str() );
   if(strEndsWith(filename,".txt"))
   {
      THREADSUSPENDED=1;
      msleep(1);
      display_mutex.lock();
      display.setRotation(2);
      display.fillScreen(BLACK);

      File myTxtFile = SD.open(filename);
      if (myTxtFile) {
         //display.setFont(&FreeSans9pt7b);
         display.setTextSize(2);
         display.setTextColor(WHITE);
         display.setCursor(0, 0);
         int c;
         while (myTxtFile.available()) {
            c=myTxtFile.read();
            Serial.write(c);
            display.write(c);
         }
         display.setTextColor(RED);
         display.write(20);  // EOF symbol
         display.setTextColor(WHITE);
         display.setFont();
         display.setTextSize(1);

        delay(2000); // or wait for switch button press

         // close the file:
         myTxtFile.close();
         delay(2);
         display_mutex.unlock();
         THREADSUSPENDED=0;
         display.setRotation(TFT_ROTAT);
         display.fillScreen(BLACK);
         ls(filelist, filecount, selectfilenr);
         markPos(cursorfilenr, cursorfilenr);
      }
      display.setRotation(TFT_ROTAT);
   } // if(strEndsWith(...))

}


### Debug Message

```plain
just first does nothing and later hangs up

Other Steps to Reproduce

complete program:
https://github.com/dsyleixa/Arduino/tree/master/ESP32_GBox/ESP32_Box026e

I have checked existing issues, online documentation and the Troubleshooting Guide

  • I confirm I have checked existing issues, online documentation and Troubleshooting guide.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions