Skip to content

nopnop2002/esp32-idf-sqlite3

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

esp32-idf-sqlite3

sqlite3 for esp-idf.
The original is here.
Although it is a very nice library, it cannot be built with ESP-IDF Ver5.
Therefore, We changed it so that it can also be used with ESP-IDF Ver5.
At the same time, we also changed the sample code so that it can be used with ESP-IDF Ver5.

Software requirements

ESP-IDF V5.0 or later.
ESP-IDF V4.4 release branch reached EOL in July 2024.

Changes from the original

  • Change to local component
  • Component and sample code provided in the same repository
  • Disable compile warnings
  • Supports ESP32C series
  • Supports PSRAM
  • Added fatfs/littlefs example
  • Added tcp/websocket/mqtt/tusb example
  • Added query/redirect/ftp example
  • Moved sqllib.c and sqllib.h to components

If there is a issues in the original, the same issues will be found in this repository.
If you find any issues, we welcome your PR to resolve them.

Installation

git clone https://github.com/nopnop2002/esp32-idf-sqlite3
cd esp32-idf-sqlite3/spiffs
idf.py menuconfig
idf.py flash monitor

Using PSRAM

Enable PARAM using Menuconfig.
psram-esp32

ESP32-S3 can now use two types: Quad Mode PSRAM and Octal Mode PSRAM.
Please check the ESP32-S3 data sheet to determine which type of PSRAM your ESP32S3 has.
psram-esp32s3-Quad psram-esp32s3-Octal

sqlite uses CONFIG_SPIRAM to determine whether PSRAM is enabled or disabled.
If PSRAM is enabled, use ps_malloc()/ps_realloc() instead of malloc()/realloc().

#if CONFIG_SPIRAM
#define SQLITE_MALLOC(x) ps_malloc(x)
#define SQLITE_FREE(x) free(x)
#define SQLITE_REALLOC(x,y) ps_realloc((x),(y))
#else
#define SQLITE_MALLOC(x) malloc (x)
#define SQLITE_FREE(x) free(x)
#define SQLITE_REALLOC(x,y) realloc((x),(y))
#endif

If PSRAM is enabled, it will be automatically mounted at boot time.

  • ESP32-CAM
I (224) esp_psram: Found 8MB PSRAM device
I (224) esp_psram: Speed: 40MHz
I (228) esp_psram: PSRAM initialized, cache is in low/high (2-core) mode.
W (235) esp_psram: Virtual address not enough for PSRAM, map as much as we can. 4MB is mapped
  • ESP32-S3-WROOM-1 N4R2/N8R2/N16R2(Quad Mode)
I (172) esp_psram: Found 2MB PSRAM device
I (172) esp_psram: Speed: 40MHz
  • ESP32-S3-WROOM-1 N4R8/N8R8/N8R8/N16R8(Octal Mode)
I (225) esp_psram: Found 8MB PSRAM device
I (230) esp_psram: Speed: 40MHz

How to use this component in your project

Create idf_component.yml in the same directory as main.c.

YourProject --+-- CMakeLists.txt
              +-- main --+-- main.c
                         +-- CMakeLists.txt
                         +-- idf_component.yml

Contents of idf_component.yml.

dependencies:
  nopnop2002/sqlite3:
    path: components/esp32-idf-sqlite3/
    git: https://github.com/nopnop2002/esp32-idf-sqlite3.git

When you build a projects esp-idf will automaticly fetch repository to managed_components dir and link with your code.

YourProject --+-- CMakeLists.txt
              +-- main --+-- main.c
              |          +-- CMakeLists.txt
              |          +-- idf_component.yml
              +-- managed_components ----- nopnop2002__sqlite3

About

sqlite3 for esp-idf

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages