SQLite Forum

SQLite, STM32F4 and LittleFS
Login

SQLite, STM32F4 and LittleFS

(1) By Teo Vuckovic (tvuckovic) on 2020-09-27 09:34:14 [source]

Hello I'm trying to install SQLite on the STM32F405 platform using LittleFS as the file system. I would use NOR flash memory to save the data. Creating a database and creating a table work OK. The problem arises when I go to enter data into the database. The software reads 4096 bytes from the database from address 0, and reports a "database disk image is malformed" error. The error occurs in line 67003. The log file is attached. Using the TFTP protocol, I copied the database to a PC and checked it. The database was created correctly and the "Cars" table was created correctly. I compared the 4096 bytes read when trying to write data to the table with the first 4096 bytes from the database. They are the same, no difference. The driver read the data correctly. Line 67003 is located in the SQlite3BTreeCursor function.

SQLITE_PRIVATE int sqlite3BtreeCursor( Btree p, / The btree / int iTable, / Root page of table to open / int wrFlag, / 1 to write. 0 read-only / struct KeyInfo *pKeyInfo, / First arg to xCompare() / BtCursor *pCur / Write new cursor here */ ){ int rc; if( iTable<1 ){ rc = SQLITE_CORRUPT_BKPT; //*********ERROR CODE, value of iTable is 0 }else{ sqlite3BtreeEnter(p); rc = btreeCursor(p, iTable, wrFlag, pKeyInfo, pCur); sqlite3BtreeLeave(p); }

The log file is:

------------------ SQLITE OPEN TESTSQL.DB vfsFullPathName TESTSQL.DB vfsOpen name=TESTSQL.DB flags=262 vfsSectorSize vfsSectorSize vfsRead - iAmt = 100 iOfst = 0 vfsFlushBuffer vfsRead - Short Read Error = 0 File Handle = 2000edac

------------------ PRAGMA journal_mode=OFF vfsAccess - *pResOut=0 vfsFlushBuffer vfsFileSize - filesize=0 journal_mode = off

------------------ CREATE TABLE Cars vfsDirectWrite - iAmt = 4096 iOfst = 0 vfsDirectWrite - iAmt = 4096 iOfst = 4096 vfsFlushBuffer vfsSync - retval=0

------------------ INSERT INTO Cars vfsRead - iAmt = 4096 iOfst = 0 vfsFlushBuffer vfsRead = 0 File Handle = 2000edac !!!!!!!!!!!!!! errorLogCallback funkcija (11) database corruption at line 67003 of [fb90e7189a] !!!!!!!!!!!!!! errorLogCallback funkcija (11) statement aborts at 1: [INSERT INTO Cars VALUES(1, 'Audi', 52642);] database disk image is malformed

Does anyone have any idea where the problem is.

(2.2) By hakemi on 2021-12-25 12:06:01 edited from 2.1 in reply to 1 [link] [source]

Hello,
I am exactly going to do this, I searched a lot and found nothing related to porting sqlite on stm32 or other MCUs.
I am wondering how are you doing this, I worked with FatFS and I know how it's ported on STM32 and I think littleFS is going to be like this.
my major problem is matching sqlite and littleFs together and make a local DB on SD Card Using STM32F429VGT6.
I Would Be really appreciated if you give me a clue.

BEST Regards.

D.H

(3) By Teo Vuckovic (tvuckovic) on 2022-01-07 10:49:51 in reply to 2.2 [link] [source]

Sorry I'm late with the answer. I haven't watched this forum in a long time. I failed to solve the problem. However, if you are interested, we can try to solve it together.