[sqlite] VFS for an MCU internal flash
Below is a link to files for the Atmel SAM4S processor that implements a simple FAT file system. The Atmel part is an ARM M4 core which I used in a recent design. the link takes you to the C files. YOu can also easily navigate to the various documentation for the code. http://asf.atmel.com/docs/latest/common.services.fs.fatfs.access_example.sam4s_xplained/html/files.html Scott Doctor scott at scottdoctor.com -- On 7/13/2015 12:29 PM, Jim Callahan wrote: > At a minimum SQLite needs a C complier (or cross-compiler) for the CPU. > > The storage device manufacturer usually publishes some specs (and sample > code -- such as assembly language routines callable from C) if a third > party has a primitive file system (a term I prefer to VFS which could refer > to virtualizing a network file system) the device manufacturer should know > about it. > > The problem consists of closing the gap, by building or buying a software > layer (primitive file system?) between the routines or sample code provided > by the storage device manufacturer and the calls made by SQLite. > > Virtual usually refers to a layer up the stack (more abstraction) he is > trying to go a layer down the stack (closer to the hardware) which is more > primitive without all the fancy stuff of the Unix civilization. > > Here is an article (SIGMOD 2013) on trying to get MS SQL Server to run on > an SSD with an ARM chip. > http://pages.cs.wisc.edu/~jignesh/publ/SmartSSD.pdf > > > Here is a discussion of solid state drive (SSD) firmware. > http://www.openssd-project.org/wiki/The_OpenSSD_Project > > As the controller chip on the SDD drive becomes a more powerful ARM chip, > it may be feasible to have SQLite in the SDD itself. > > Here is a discussion from 2008 > http://sqlite.1065341.n5.nabble.com/Porting-into-a-microcontroller-minimum-requirements-td37469.html > > Many handheld consumer devices follow the mobile phone tablet model and > have a Unix or Linux derived operating system iOS (based BSD Unix), Android > (based on Linux) or Windows (based on Windows) or Ubuntu (a Linux > distribution) and most of these already have SQLite. > > Jim > > > > On Mon, Jul 13, 2015 at 11:52 AM, Richard Hipp wrote: > >> On 7/13/15, Jim Callahan wrote: >>> SQLite expects a file system. >>> >> Not necessarily. Out-of-the-box SQLite does need a filesystem, but >> embedded system designers can substitute an alternative VFS >> implementation that writes directly to hardware. This has been done >> before. There are consumer gadgets that you can buy off-the-shelf >> today (in blister packs) that contain an instance of SQLite that talks >> directly to flash memory - essentially using SQLite as the filesystem. >> >> I think Shuhrat is just trying to do this again. >> >> -- >> D. Richard Hipp >> drh at sqlite.org >> ___ >> sqlite-users mailing list >> sqlite-users at mailinglists.sqlite.org >> http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users >> > ___ > sqlite-users mailing list > sqlite-users at mailinglists.sqlite.org > http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users > >
[sqlite] VFS for an MCU internal flash
At a minimum SQLite needs a C complier (or cross-compiler) for the CPU. The storage device manufacturer usually publishes some specs (and sample code -- such as assembly language routines callable from C) if a third party has a primitive file system (a term I prefer to VFS which could refer to virtualizing a network file system) the device manufacturer should know about it. The problem consists of closing the gap, by building or buying a software layer (primitive file system?) between the routines or sample code provided by the storage device manufacturer and the calls made by SQLite. Virtual usually refers to a layer up the stack (more abstraction) he is trying to go a layer down the stack (closer to the hardware) which is more primitive without all the fancy stuff of the Unix civilization. Here is an article (SIGMOD 2013) on trying to get MS SQL Server to run on an SSD with an ARM chip. http://pages.cs.wisc.edu/~jignesh/publ/SmartSSD.pdf Here is a discussion of solid state drive (SSD) firmware. http://www.openssd-project.org/wiki/The_OpenSSD_Project As the controller chip on the SDD drive becomes a more powerful ARM chip, it may be feasible to have SQLite in the SDD itself. Here is a discussion from 2008 http://sqlite.1065341.n5.nabble.com/Porting-into-a-microcontroller-minimum-requirements-td37469.html Many handheld consumer devices follow the mobile phone tablet model and have a Unix or Linux derived operating system iOS (based BSD Unix), Android (based on Linux) or Windows (based on Windows) or Ubuntu (a Linux distribution) and most of these already have SQLite. Jim On Mon, Jul 13, 2015 at 11:52 AM, Richard Hipp wrote: > On 7/13/15, Jim Callahan wrote: > > SQLite expects a file system. > > > > Not necessarily. Out-of-the-box SQLite does need a filesystem, but > embedded system designers can substitute an alternative VFS > implementation that writes directly to hardware. This has been done > before. There are consumer gadgets that you can buy off-the-shelf > today (in blister packs) that contain an instance of SQLite that talks > directly to flash memory - essentially using SQLite as the filesystem. > > I think Shuhrat is just trying to do this again. > > -- > D. Richard Hipp > drh at sqlite.org > ___ > sqlite-users mailing list > sqlite-users at mailinglists.sqlite.org > http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users >
[sqlite] VFS for an MCU internal flash
Hello, I was trying to run SQLite on ARM Cortex M4 CPU. What I need is a minimal SQLite without the most features. I have no file system, so I wanted to save a single file db on the internal MCU flash. I have successfully cross compiled SQLite for ARM Cortex M4. I have set among others compile time options SQLITE_OS_OTHER=1 and SQLITE_THREADSAFE=0. Now I wanted to implement a VFS. I want to save db tables directly in internal flash without a file system. I have difficulties to understand test_onefile.c implementation provided by SQLite. How could I edit that file in order to be able to write file content on the internal MCU flash? Please, could someone explain it to me or give some links where it is explained? Kind Regards
[sqlite] VFS for an MCU internal flash
On 7/13/15, Jim Callahan wrote: > SQLite expects a file system. > Not necessarily. Out-of-the-box SQLite does need a filesystem, but embedded system designers can substitute an alternative VFS implementation that writes directly to hardware. This has been done before. There are consumer gadgets that you can buy off-the-shelf today (in blister packs) that contain an instance of SQLite that talks directly to flash memory - essentially using SQLite as the filesystem. I think Shuhrat is just trying to do this again. -- D. Richard Hipp drh at sqlite.org
[sqlite] VFS for an MCU internal flash
Here is a link to a more recent (2013) discussion with a more recent (3.x.xx vs 2.x.xx) version of SQLite: http://comments.gmane.org/gmane.comp.db.sqlite.general/83038 Jim On Mon, Jul 13, 2015 at 11:22 AM, Jim Callahan < jim.callahan.orlando at gmail.com> wrote: > SQLite expects a file system. > "SQLite reads and writes directly to ordinary disk files." > https://www.sqlite.org/about.html > > You need a minimal file system. > > A file system does not have to be large. > CP/M ran on an 8 bit Z-80 with less than 64k of RAM (but the original > CP/M was written in Z-80 assembly language -- not C). > > Here is an article on a stripped down Linux for M3/M4: uCLinux > > http://electronicdesign.com/embedded/practical-advice-running-uclinux-cortex-m3m4 > > And here is website for SQLite for uClinux. > http://www.menie.org/georges/uClinux/sqlite.html > > > The other option would be to emulate the Linux system file calls. > You could start from scratch or download the Linux source code (assuming > you have installed and know how to use git source code management system): > > # the Linux kernel (approx. 640MB download): > $ git clone git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git > > > > https://www.kernel.org/pub/software/scm/git/docs/user-manual.html#how-to-get-a-git-repository > > Hope this helps. > > Jim Callahan > Orlando, FL > > > > On Mon, Jul 13, 2015 at 5:52 AM, Shuhrat Rahimov > wrote: > >> Hello, >> I was trying to run SQLite on ARM Cortex M4 CPU. What I need is a minimal >> SQLite without the most features. I have no file system, so I wanted to >> save a single file db on the internal MCU flash. I have successfully cross >> compiled SQLite for ARM Cortex M4. I have set among others compile time >> options SQLITE_OS_OTHER=1 and SQLITE_THREADSAFE=0. Now I wanted to >> implement a VFS. I want to save db tables directly in internal flash >> without a file system. I have difficulties to understand test_onefile.c >> implementation provided by SQLite. How could I edit that file in order to >> be able to write file content on the internal MCU flash? Please, could >> someone explain it to me or give some links where it is explained? >> Kind Regards >> ___ >> sqlite-users mailing list >> sqlite-users at mailinglists.sqlite.org >> http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users >> > >
[sqlite] VFS for an MCU internal flash
SQLite expects a file system. "SQLite reads and writes directly to ordinary disk files." https://www.sqlite.org/about.html You need a minimal file system. A file system does not have to be large. CP/M ran on an 8 bit Z-80 with less than 64k of RAM (but the original CP/M was written in Z-80 assembly language -- not C). Here is an article on a stripped down Linux for M3/M4: uCLinux http://electronicdesign.com/embedded/practical-advice-running-uclinux-cortex-m3m4 And here is website for SQLite for uClinux. http://www.menie.org/georges/uClinux/sqlite.html The other option would be to emulate the Linux system file calls. You could start from scratch or download the Linux source code (assuming you have installed and know how to use git source code management system): # the Linux kernel (approx. 640MB download): $ git clone git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git https://www.kernel.org/pub/software/scm/git/docs/user-manual.html#how-to-get-a-git-repository Hope this helps. Jim Callahan Orlando, FL On Mon, Jul 13, 2015 at 5:52 AM, Shuhrat Rahimov wrote: > Hello, > I was trying to run SQLite on ARM Cortex M4 CPU. What I need is a minimal > SQLite without the most features. I have no file system, so I wanted to > save a single file db on the internal MCU flash. I have successfully cross > compiled SQLite for ARM Cortex M4. I have set among others compile time > options SQLITE_OS_OTHER=1 and SQLITE_THREADSAFE=0. Now I wanted to > implement a VFS. I want to save db tables directly in internal flash > without a file system. I have difficulties to understand test_onefile.c > implementation provided by SQLite. How could I edit that file in order to > be able to write file content on the internal MCU flash? Please, could > someone explain it to me or give some links where it is explained? > Kind Regards > ___ > sqlite-users mailing list > sqlite-users at mailinglists.sqlite.org > http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users >