siara-cc / esp32_arduino_sqlite3_lib

Sqlite3 Arduino library for ESP32

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

LoadProhibited error in sqlite3_open

Emile1154 opened this issue · comments

MCU: ESP32-S3 16MB ROM with PSRAM 8 MB
sqlite3 version 2.4
in sqlite3.c I tryed with PSRAM and INTERNAL RAM this not give result

#define SQLITE_MALLOC(x)             ps_malloc(x)
#define SQLITE_FREE(x)               free(x)
#define SQLITE_REALLOC(x,y)          ps_realloc((x),(y))

Tried it with littlefs, but this problem with FATFS too. I haven't tried the other options as SD_SPI, SD_MMC
platformio-config:

[env:esp32s3box]
platform = espressif32
board_build.mcu = esp32s3
board = esp32s3box
framework = arduino
board_build.filesystem = littlefs
board_build.extra_flags = -DBOARD_HAS_PSRAM
   ;build_flags = -mfix-esp32-psram-cache-issue -mfix-esp32-psram-cache-strategy=memw -w ;-DCORE_DEBUG_LEVEL=0
monitor_filters = esp32_exception_decoder, colorize;-*
board_build.partitions = default_16MB.csv
board_upload.flash_size = 16MB
board_upload.maximum_size = 16777216
board_upload.maximum_ram_size = 8388608
monitor_speed = 115200
lib_deps = siara-cc/Sqlite3Esp32 @ ~2.4
uint8_t db_open(const char * filename, sqlite3 ** database){
    int rc = sqlite3_open_v2(filename, database, SQLITE_OPEN_READWRITE, "ESP32");// or  sqlite3_open(filename, database); 
    if (rc) {
        ESP_LOGE(NULL, "Failed to open database");
        return 1;
    } 
    ESP_LOGE(NULL, "database opened");
    return 0;
}

void setup(){
  Serial0.begin(115200);
  if(!LittleFS.begin(false, "/data")){
    log_e("%s", "LittleFS begin err");
    //return false;
  }
  sqlite3 * database;
  File root = LittleFS.open("/");
   if (!root) {
       Serial0.println("- failed to open directory");
       return;
   }
   if (!root.isDirectory()) {
       Serial0.println(" - not a directory");
       return;
   }
   File file = root.openNextFile();
   while (file) {
       if (file.isDirectory()) {
           Serial0.print("  DIR : ");
           Serial0.println(file.name());
       } else {
           Serial0.print("  FILE: ");
           Serial0.print(file.name());
           Serial0.print("\tSIZE: ");
           Serial0.println(file.size());
       }
       file = root.openNextFile();
   }
  LittleFS.remove("/mdrusb.db");
  sqlite3_initialize();
  db_open("/data/mdrusb.db", &database);
}

out logs:

FILE: OTAform.html    SIZE: 269
FILE: mdrusb.db       SIZE: 0
/data/mdrusb.db //ESP32FullPathname zPath
/data/mdrusb.db //ESP32FullPathname zPathOut
fn: Open
ESP32File success
/data/mdrusb.db
try fopen
fopen success
fn:Open:Success
fn: SectorSize
fn: SectorSize
fn: Read
fn: FlushBuffer
fn:FlushBuffer:Success
fn:Read:ShortRead 
Guru Meditation Error: Core  1 panic'ed (LoadProhibited). Exception was unhandled.  // is problem on Core 0 too
Core  1 register dump:
PC      : 0x4005544b  PS      : 0x00060830  A0      : 0x8208d211  A1      : 0x3fceb890
A2      : 0x00000000  A3      : 0x3c122afd  A4      : 0x3d800910  A5      : 0x00000000  
A6      : 0x00000000  A7      : 0x00000000  A8      : 0x8037fe89  A9      : 0x3fceb8d0  
A10     : 0x00060823  A11     : 0x00000000  A12     : 0x00060820  A13     : 0x00000000
A14     : 0x3d80d6e0  A15     : 0x00003800  SAR     : 0x00000015  EXCCAUSE: 0x0000001c  
EXCVADDR: 0x00000000  LBEG    : 0x40056fc5  LEND    : 0x40056fe7  LCOUNT  : 0xffffffff
Backtrace: 0x40055448:0x3fceb890 |<-CORRUPTED

on decode this not give info #0  0x40055448:0x3fceb890 in ?? ??:0

in with FAT VFS cfg mount_config = {
.format_if_mount_failed = false,
.max_files = 5,
.allocation_unit_size = 16 * 1024,
};
fx:Read give Success, but LoadProhibited the error still occurs.
UPD: How I think it problem with null pointer to some object, I can enable logging in sqlite3.c for getting more info? Or using esp-idf version for this library better?