Skip to main content
Yamir.1
Associate II
August 20, 2021
Solved

Using SQLite in STM32F407

I'm very new to stm32. I want to port SQLite to my STM32F407. I tried adding the SQLite amalgamation libraries to the code file but the code refuses to build due to several issues. I tried to search for a anything that describe how it's done in the internet but couldn't find anything. can someone who knows how it's done help me with this, or at least send me a link that describes how it's done? sorry if this is a dumb question

This topic has been closed for replies.
waclawek.jan
waclawek.janBest answer
Super User
August 21, 2021

As most libraries from the "big computers" world, SQLite expects to run an a full-fledged operation system, which provides file system among other things:

https://www.sqlite.org/selfcontained.html

Default builds of SQLite contain appropriate VFS objects for talking to underlying operating system, and those VFS objects will contain operating system calls such as open(), read(), write(), fsync(), and so forth. All of these interfaces are readily available on most platforms, and custom VFSes can be designed to run SQLite on even the most austere embedded devices.

The STM32 is the case of "most austere embedded device", so you are supposed to "design custom VFS", whatever that may mean (I am not interested in this at all).

JW

5 replies

Pavel A.
August 20, 2021

What issues? If you are new to STM32 (and ARM in general) - expect all kinds of beginner complications.

Start from some simple examples.

If time is critical, find a consultant.

Yamir.1
Yamir.1Author
Associate II
August 21, 2021

I think I accidently responded as an answer rather than a reply. pls check what I posted.

Yamir.1
Yamir.1Author
Associate II
August 21, 2021

Basically what I did is adding the amalgamation code that SQLite provides in its website to the include and src folders in the code folder. I'm not sure if this is the correct way of doing it? when I try to build to see if the code compiled, I get several errors inside the SQLite files (sqlite3.c and shell.c).

For example in the sqlite3.c file in the "#define SQLITE3_MUTEX_INITIALIZER(id) { PTHREAD_MUTEX_INITIALIZER }" line I get "PTHREAD_MUTEX_INITIALIZER undeclared" and for "#include <sys/ioctl.h>" I get "No such file."

in the shell.c I get "unkown type DIR" for "DIR *pDir;" line. and for "if( pEntry->d_name[0]=='.' ){" I get "dereferencing pointer to incomplete type 'struct dirent'" alongside some warnings.

Is it a simple problem that I just dont know how to solve? because I couldnt find anyone asking this question

Thanks for your response btw!

waclawek.jan
waclawek.janBest answer
Super User
August 21, 2021

As most libraries from the "big computers" world, SQLite expects to run an a full-fledged operation system, which provides file system among other things:

https://www.sqlite.org/selfcontained.html

Default builds of SQLite contain appropriate VFS objects for talking to underlying operating system, and those VFS objects will contain operating system calls such as open(), read(), write(), fsync(), and so forth. All of these interfaces are readily available on most platforms, and custom VFSes can be designed to run SQLite on even the most austere embedded devices.

The STM32 is the case of "most austere embedded device", so you are supposed to "design custom VFS", whatever that may mean (I am not interested in this at all).

JW

Yamir.1
Yamir.1Author
Associate II
August 21, 2021

I see. I read about VFS and figured it has something to do with my problem but wasn't sure. I'll try to search on how it's done. thank you