I am using the E-ink display GxEPD2_420_GDEY042T81
and driving it by an ESP32S3-WROOM-1U-8N8R.
Therefore I have 8MB of RAM and 8MB of Flash available.
Everything works as expected - until the moment where I include another library into my code.
See minimum code-example at the very bottom of this entry...
#include "DFRobot_DF2301Q.h" // https://github.com/DFRobot/DFRobot_DF2301Q
As soon as I add the above include-statement, then I get a memory crash errror InstrFetchProhibited
.
Important: As I said, the GxEPD2 code alone works. And also, the DFRobot_DF2301Q example as a standalone-code works fine. ONLY in combination, these two libraries do crash.
Here the error message (i.e. the processor keeps crashing again and again no longer being capable of booting the code properly).
The error log sais:
ELF file SHA256: ed7694204b47b38f
Rebooting...
ESP-ROM:esp32s3-20210327
Build:Mar 27 2021
rst:0xc (RTC_SW_CPU_RST),boot:0x9 (SPI_FAST_FLASH_BOOT)
Saved PC:0x42051082
SPIWP:0xee
mode:DIO, clock div:1
load:0x3fce3808,len:0x44c
load:0x403c9700,len:0xbe4
load:0x403cc700,len:0x2a68
entry 0x403c98d4
Guru Meditation Error: Core 1 panic'ed (InstrFetchProhibited). Exception was unhandled.
Core 1 register dump:
PC : 0xffffff00 PS : 0x00060230 A0 : 0x82005792 A1 : 0x3fcebb10
A2 : 0x3fc96dd2 A3 : 0x3c0603fc A4 : 0x00233bc6 A5 : 0x00000001
A6 : 0x0000012c A7 : 0x00000000 A8 : 0x82005502 A9 : 0x3fcebaf0
A10 : 0xffffffff A11 : 0x00000001 A12 : 0xffffffff A13 : 0x3fcf5520
A14 : 0x00000001 A15 : 0x3fce9dc0 SAR : 0x00000006 EXCCAUSE: 0x00000014
EXCVADDR: 0xffffff00 LBEG : 0x42007a70 LEND : 0x42007ad3 LCOUNT : 0x00000002
Backtrace: 0x7ffffefd:0x3fcebb10 0x4200578f:0x3fcebb30 0x4200588c:0x3fcebb50 0x420059c5:0x3fcebb70 0x42005aea:0x3fcebbc0 0x42002f61:0x3fcebc00 0x4200360d:0x3fcebc30 0x4200877a:0x3fcebc50
Now it is pretty clear that the two libraries (i.e. GxEPD2 and DFRobot_DF2301Q) are spilling memory of the ESP32S3 type at choice.
When I investigate more closely, I get the above crash inside the while loop of my GxEPD2 code:
display.setRotation(0);
display.setFullWindow();
display.firstPage();
do {
display.fillScreen(GxEPD_WHITE);
} while (display.nextPage());
Now my questions:
- Is this a RAM or FLASH issue ?
- could I prevent the error when using the ESP32S3-WROOM-1U N16R8 that has 16MB of Flash and 8MB of PSRAM ? Unfortunately, there are no models having more RAM. Could the double Flash work ?
- What else could I do to prevent the
InstrFetchProhibited
error from happening ?
Thank you for any support on this. I am aware that I could ask this same question also in the DFRobot forum - since it is unclear where the error really originates... So I did: InstrFetchProhibited Error using DFRobot_DF2301Q library · Issue #12 · DFRobot/DFRobot_DF2301Q · GitHub
Here the minimum code-example that reproduces the memory issue nicely:
Pleae note: As soon as I uncomment the do-while loop, then I get the error! The question is WHY ?
#include "DFRobot_DF2301Q.h"
#include <GxEPD2_BW.h>
#define EPD_WIDTH 400
#define EPD_HEIGHT 300
#define EPD_ARRAY EPD_WIDTH*EPD_HEIGHT/8
#define CS_SS_PIN SS // 10 (CS SS)
#define HSPI_COPI MOSI // 11 (MOSI)
#define HSPI_SCLK SCK // 12 (SCK)
#define BUSY_PIN A5 // 6 (BUSY)
#define RST_PIN A6 // 7 (RST RES)
#define DC_PIN A14 // 15 (DC)
#define SDA_PIN GPIO_NUM_14
#define SCL_PIN GPIO_NUM_21
GxEPD2_BW<GxEPD2_420_GDEY042T81, GxEPD2_420_GDEY042T81::HEIGHT> display(GxEPD2_420_GDEY042T81(CS_SS_PIN, DC_PIN, RST_PIN, BUSY_PIN)); // GDEY042T81, 400x300, SSD1683 (no inking)
DFRobot_DF2301Q_I2C asr;
void setup() {
Serial.begin(115200);
delay(2000);
Wire.begin(SDA_PIN, SCL_PIN);
// Init the sensor
while (!(asr.begin())) {
Serial.println("Communication with device failed, please check connection");
delay(3000);
}
asr.setMuteMode(0);
asr.setWakeTime(20);
display.init(115200, false, 10, false);
display.setTextColor(GxEPD_BLACK);
display.setRotation(0);
display.setFullWindow();
display.firstPage();
// ***********************************************************
// UNCOMMENTING THIS DO-WHILE LOOP MAKES THE MEMORY-CRASH !
//
// do {
// display.fillScreen(GxEPD_WHITE);
// } while (display.nextPage());
//
// ***********************************************************
}
void loop() {
uint8_t CMDID = asr.getCMDID();
switch (CMDID) {
default:
if (CMDID != 0) {
Serial.print("CMDID = "); //Printing command ID
Serial.println(CMDID);
}
}
delay(300);
}