Hello everyone, i keep getting guru mediation error when trying to access SPIFFS data, i dont know why, sometimes if i wait enough it will work all of the sudden then crash again if i reboot the module. its pretty random. here is the error i get:
12:28:47.010 ->
12:28:47.010 -> Core 1 register dump:
12:28:47.010 -> PC : 0x4206e5a3 PS : 0x00060930 A0 : 0x8200a759 A1 : 0x3fcbb350
12:28:47.010 -> A2 : 0x00000000 A3 : 0x4200a558 A4 : 0x00000001 A5 : 0x3fca02dc
12:28:47.010 -> A6 : 0x00000000 A7 : 0x3c08c240 A8 : 0x820206eb A9 : 0x3fcbb330
12:28:47.010 -> A10 : 0x00000000 A11 : 0x3fca2148 A12 : 0x3c08c240 A13 : 0x00000008
12:28:47.010 -> A14 : 0x3fca32bc A15 : 0xe0000065 SAR : 0x00000020 EXCCAUSE: 0x0000001c
12:28:47.010 -> EXCVADDR: 0x00000008 LBEG : 0x400570e8 LEND : 0x400570f3 LCOUNT : 0x00000000
12:28:47.010 ->
12:28:47.010 ->
12:28:47.010 -> Backtrace: 0x4206e5a0:0x3fcbb350 0x4200a756:0x3fcbb370 0x42001f9a:0x3fcbb390 0x420037dc:0x3fcbb3b0 0x4200474b:0x3fcbb420 0x42001302:0x3fcbb460 0x4203b098:0x3fcbb480 0x4037d3da:0x3fcbb4a0
12:28:47.010 ->
12:28:47.010 ->
12:28:47.010 ->
12:28:47.010 ->
12:28:47.010 -> ELF file SHA256: 46861a273
12:28:47.010 ->
12:28:47.010 -> Rebooting...
12:28:47.010 -> ESP-ROM:esp32s3-20210327
12:28:47.010 -> Build:Mar 27 2021
12:28:47.010 -> rst:0xc (RTC_SW_CPU_RST),boot:0x8 (SPI_FAST_FLASH_BOOT)
12:28:47.010 -> Saved PC:0x40379d32
12:28:47.010 -> SPIWP:0xee
12:28:47.010 -> mode:DIO, clock div:1
12:28:47.010 -> load:0x3fce2820,len:0x1188
12:28:47.010 -> load:0x403c8700,len:0x4
12:28:47.010 -> load:0x403c8704,len:0xbf0
12:28:47.010 -> load:0x403cb700,len:0x30e4
12:28:47.010 -> entry 0x403c88ac
12:28:47.142 -> E (152) quad_psram: PSRAM ID read error: 0x00ffffff, PSRAM chip not found or not supported, or wrong PSRAM line mode
and here is the part of the code thats causing an issue
std::vector<String> get_all_messages() {
std::vector<String> messages;
// Open the JSON file
File file = SPIFFS.open("/messages.json", FILE_READ);
if (!file) {
Serial.println("Failed to open JSON file.");
return messages;
}
StaticJsonDocument<1024> doc;
DeserializationError error = deserializeJson(doc, file);
file.close();
// Check if there was an error deserializing the JSON
if (error) {
Serial.println("Failed to parse JSON.");
Serial.println(error.f_str()); // Print the error message
return messages;
}
// Ensure the JSON structure is an array
if (!doc.is<JsonArray>()) {
Serial.println("Expected JSON array.");
return messages;
}
// Iterate through the JSON array and extract messages
for (JsonObject msg : doc.as<JsonArray>()) {
if (msg.containsKey("message")) {
String message = msg["message"].as<String>();
if (!message.isEmpty()) {
messages.push_back(message);
} else {
Serial.println("Found empty message, skipping.");
}
} else {
Serial.println("Missing 'message' key, skipping entry.");
}
}
return messages;
}
and here is the loop/setup
#include <TFT_eSPI.h>
#include "main_screen.h"
#include "console_screen.h"
#include "PCF8574.h"
#include <HardwareSerial.h>
#include "received_sms_screen.h"
#include "SPIFFS.h"
#include <ArduinoJson.h>
#include <FS.h>
#define TFT_HOR_RES 320
#define TFT_VER_RES 480
#define TFT_ROTATION LV_DISPLAY_ROTATION_90
#define DRAW_BUF_SIZE (TFT_HOR_RES * TFT_VER_RES / 10 * (LV_COLOR_DEPTH / 12))
bool network_locked = false;
uint32_t draw_buf[DRAW_BUF_SIZE / 2];
TFT_eSPI tft = TFT_eSPI();
PCF8574 pcf8574(0x38, 7, 6); // Fixed this line
void my_disp_flush(lv_display_t *disp, const lv_area_t *area, uint8_t *px_map) {}
void my_touchpad_read(lv_indev_t *indev, lv_indev_data_t *data) {
uint16_t x, y;
bool touched = tft.getTouch(&x, &y, 600);
if (!touched) {
data->state = LV_INDEV_STATE_RELEASED;
}
else {
data->state = LV_INDEV_STATE_PRESSED;
data->point.x = y;
data->point.y = TFT_VER_RES - x;
}
}
static uint32_t my_tick(void) { return millis(); }
void setup() {
mySerial.begin(115200, SERIAL_8N1, 17, 16);
Wire.begin(7, 6);
pinMode(4, INPUT);
pcf8574.pinMode(P2, OUTPUT);
pcf8574.pinMode(P5, OUTPUT);
pcf8574.digitalWrite(P5, LOW);
pcf8574.digitalWrite(P2, HIGH);
Serial.begin(115200);
analogSetAttenuation(ADC_11db);
if (!SPIFFS.begin(true)) {
Serial.println("SPIFFS Mount Failed");
return;
}
Serial.println("SPIFFS initialized.");
lv_init();
lv_tick_set_cb(my_tick);
lv_display_t *disp;
#if LV_USE_TFT_ESPI
disp = lv_tft_espi_create(TFT_HOR_RES, TFT_VER_RES, draw_buf, sizeof(draw_buf));
lv_display_set_rotation(disp, TFT_ROTATION);
tft.begin();
tft.setRotation(3);
#else
disp = lv_display_create(TFT_HOR_RES, TFT_VER_RES);
lv_display_set_flush_cb(disp, my_disp_flush);
lv_display_set_buffers(disp, draw_buf, NULL, sizeof(draw_buf), LV_DISPLAY_RENDER_MODE_PARTIAL);
#endif
lv_indev_t *indev = lv_indev_create();
lv_indev_set_type(indev, LV_INDEV_TYPE_POINTER);
lv_indev_set_read_cb(indev, my_touchpad_read);
initialize_main_screen();
write_serial("AT+CMGF=1"); // Send AT+CPMS? to check message count
}
unsigned long lastRefreshTime = 0;
const unsigned long refreshInterval = 10000; // 10 seconds
bool turn_off_status = false;
void loop() {
// Refresh Display if SMS screen is active
if (is_received_sms_screen_active) {
unsigned long currentMillis = millis();
if (currentMillis - lastRefreshTime >= refreshInterval) {
update_sms_display();
lastRefreshTime = currentMillis;
}
}
if(main_opened == true && turn_off_status == false) {
fetch_network_info();
update_battery_level();
}
if(network_locked == false ) {
wait_for_network_lock();
}
lv_timer_handler();
process_serial();
process_serial_monitor();
delay(5);
}