Both using gxepd2 and sdcard can not work

my test project like this

#include <GxEPD2_BW.h>
#include <GxEPD2_3C.h>
#include <SD.h>

#define GxEPD2_DISPLAY_CLASS GxEPD2_BW

#define GxEPD2_DRIVER_CLASS GxEPD2_420

#define GxEPD2_BW_IS_GxEPD2_BW true
#define GxEPD2_3C_IS_GxEPD2_3C true
#define GxEPD2_7C_IS_GxEPD2_7C true
#define GxEPD2_1248_IS_GxEPD2_1248 true
#define IS_GxEPD(c, x) (c##x)
#define IS_GxEPD2_BW(x) IS_GxEPD(GxEPD2_BW_IS_, x)
#define IS_GxEPD2_3C(x) IS_GxEPD(GxEPD2_3C_IS_, x)
#define IS_GxEPD2_7C(x) IS_GxEPD(GxEPD2_7C_IS_, x)
#define IS_GxEPD2_1248(x) IS_GxEPD(GxEPD2_1248_IS_, x)

#define MAX_DISPLAY_BUFFER_SIZE 65536ul // e.g.
#if IS_GxEPD2_BW(GxEPD2_DISPLAY_CLASS)
#define MAX_HEIGHT(EPD) (EPD::HEIGHT <= MAX_DISPLAY_BUFFER_SIZE / (EPD::WIDTH / 8) ? EPD::HEIGHT : MAX_DISPLAY_BUFFER_SIZE / (EPD::WIDTH / 8))
#elif IS_GxEPD2_3C(GxEPD2_DISPLAY_CLASS)
#define MAX_HEIGHT(EPD) (EPD::HEIGHT <= (MAX_DISPLAY_BUFFER_SIZE / 2) / (EPD::WIDTH / 8) ? EPD::HEIGHT : (MAX_DISPLAY_BUFFER_SIZE / 2) / (EPD::WIDTH / 8))
#elif IS_GxEPD2_7C(GxEPD2_DISPLAY_CLASS)
#define MAX_HEIGHT(EPD) (EPD::HEIGHT <= (MAX_DISPLAY_BUFFER_SIZE) / (EPD::WIDTH / 2) ? EPD::HEIGHT : (MAX_DISPLAY_BUFFER_SIZE) / (EPD::WIDTH / 2))
#endif
GxEPD2_DISPLAY_CLASS<GxEPD2_DRIVER_CLASS, MAX_HEIGHT(GxEPD2_DRIVER_CLASS)> display(GxEPD2_DRIVER_CLASS(/*CS=*/ 15, /*DC=*/ 4, /*RST=*/ 16, /*BUSY=*/ 17));

#include "bitmaps/Bitmaps400x300.h"

SPISettings spi_settings(4000000, MSBFIRST, SPI_MODE0);
SPIClass hspi(HSPI);
unsigned char buf[32];
#define LENG 16 //0x3c + 0x2 + 15 bytes equal to 17 bytes
const char HelloWorld[] = "Hello World!";

void setup()
{
     hspi.begin(14, 12, 13, 15); // remap hspi for EPD (swap pins)
    display.epd2.selectSPI(hspi, SPISettings(4000000, MSBFIRST, SPI_MODE0));
    display.init(115200);
}

void helloWorld()
{
  //Serial.println("helloWorld");
  display.setRotation(1);
  display.setTextColor(GxEPD_BLACK);
  int16_t tbx, tby; uint16_t tbw, tbh;
  display.getTextBounds(HelloWorld, 0, 0, &tbx, &tby, &tbw, &tbh);
  // center bounding box by transposition of origin:
  uint16_t x = ((display.width() - tbw) / 2) - tbx;
  uint16_t y = ((display.height() - tbh) / 2) - tby;
  display.setFullWindow();
  display.firstPage();
  do
  {
    display.fillScreen(GxEPD_WHITE);
    display.setCursor(x, y);
    display.print(HelloWorld);
  }
  while (display.nextPage());
}

my chip is esp32-wroom32
my spi pin like this

when I restart without sdcard, it works well,but when I put my sdcard in and restart, it will always print like this:

10:01:24.735 -> rst:0x7 (TG0WDT_SYS_RESET),boot:0x37 (SPI_FAST_FLASH_BOOT)
10:01:24.735 -> configsip: 0, SPIWP:0xee
10:01:24.735 -> clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
10:01:24.735 -> mode:DIO, clock div:1
10:01:24.781 -> load:0x3fff0030,len:1344
10:01:24.781 -> load:0x40078000,len:13864
10:01:24.781 -> load:0x40080400,len:3608
10:01:24.781 -> csum err:0xa8!=0x51
10:01:24.781 -> ets_main.c 384 
10:01:25.064 -> ets Jul 29 2019 12:21:46

how I can solve this problem? it hardware problem or software problem ?

GPIO5 is a strapping pin of ESP32. TFT_CS most likely pulls it to the wrong level on boot.
Is there a reason why you use a different wiring than example GxEPD2_SD_Example?

I checked gxepd2_sd_simple, but I didn't realize the seriousness of this problem when I was designing the PCB. At present, it seems that I can only insert the SD card after restarting to temporarily avoid it. Can I solve this problem through the level of TF_CS in SETUP?

Yes, I will take a SWAG as you have given us no real information. Cut a trace and add a jumper wire. Kinar AWG 30 WW wire works great.

No. The issue arises before any code is executed.
Consider your PCB as a first failed prototype.

thank you, i will change it

I cut the tf_cs pin off , but it still not work, should i change all sdcard spi pin to other pin

Minimalistic response for a minimalistic question:
technical-documents
Go have a look for ESP32 strapping pins, most likely in the specs of your board.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.