siara-cc / esp32_arduino_sqlite3_lib

Sqlite3 Arduino library for ESP32
Apache License 2.0
350 stars 66 forks source link

usb vfs support? #83

Closed Emile1154 closed 6 months ago

Emile1154 commented 6 months ago

I can reading\writing data with USB device storage. When I make db_open method mcu catch error (LoadProhibited). Exception was unhandled. and rebooting. traceback:

Guru Meditation Error: Core  0 panic'ed (LoadProhibited). Exception was unhandled.
Core  0 register dump:
PC      : 0x4005544b  PS      : 0x00060030  A0      : 0x820d6491  A1      : 0x3fcb6250  
A2      : 0x00000000  A3      : 0x3c1816a5  A4      : 0x3fce7428  A5      : 0x00000001  
A6      : 0x00000046  A7      : 0x00000001  A8      : 0x80380595  A9      : 0x3fcb6290  
A10     : 0x00060023  A11     : 0x00000000  A12     : 0x00060020  A13     : 0x3fce7058  
A14     : 0x0000000e  A15     : 0x00000001  SAR     : 0x00000017  EXCCAUSE: 0x0000001c  
EXCVADDR: 0x00000000  LBEG    : 0x400556d5  LEND    : 0x400556e5  LCOUNT  : 0xfffffffc  
Backtrace: 0x40055448:0x3fcb6250 |<-CORRUPTED
//mount vfs and read descriptors for usb device
log_e("Device address: %d", device_address);
ESP_ERROR_CHECK( msc_host_install_device(device_address, &msc_device) );
ESP_ERROR_CHECK( msc_host_get_device_info(msc_device, &info) );
print_device_info(&info);
ESP_ERROR_CHECK( msc_host_vfs_register(msc_device, "/usb", &mount_config, &vfs_handle) );
msc_host_print_descriptors(msc_device);

vTaskDelay(pdMS_TO_TICKS(250));

sqlite3_initialize();
vTaskDelay(pdMS_TO_TICKS(450));
//open database
db_open("/usb/mdrusb.db"); // error reboot (LoadProhibited). Exception was unhandled.

method db_open:

sqlite3 * database;
uint8_t db_open(const char * filename){
    int rc = sqlite3_open_v2(filename, &database, SQLITE_OPEN_READWRITE, "usb");
    if (rc) {
       ESP_LOGE(NULL, "Failed to open database");
       sqlite3_close(database);
       return 1;
    } 
    ESP_LOGE(NULL, "database opened");
    return 0;
}