(In other words, how big is SQLite and what are the size restrictions for IoT devices – I haven't built one before)
(In other words, how big is SQLite and what are the size restrictions for IoT devices – I haven't built one before)
For example, https://www.sqlite.org/about.html claims that SQLite can run in "very little heap (100KiB)"; this project targets an Atmel ATmega2560 which has only 8KiB of RAM.
(I doubt "5 times smaller than SQLite" is a useful comparison; the limiting factor is probably RAM consumption, as opposed to executable code which can be stored in cheaper non-volatile memory.)
(Submitted title was "LittleD – SQL database for IoT, 5 times smaller than SQLite").
define a few C structs with standard read() write() function call are most likely be enough and it is easy to design/test/debug.
One has a lot more control on RAM/ROM/Code space with that approach. You can easily find out where/how every single byte/bit of memory is used.
The corresponding paper [1] claims "SQLite requires at least 200 KB of code space and cannot run on popular platforms such as the Arduino." For comparison, Arduinos based on ATmega microcontrollers only offer up to 256 KB of flash memory at maximum.
I have spent a lot of time with it on ARM Cortex-M-class devices on small RTOSes or even bare metal, and you can adapt it to almost anything by plugging in new VFS interfaces (http://www.sqlite.org/vfs.html).
It does require at least 10s of kb of RAM as a heap to do pretty much anything, as others have stated.
It's rather unusual by today's standards. Certainly quite different from an ARM.
But that's not the biggest problem. SQLite, like most programs, relies on having a C library like glibc available. This is pretty much the intermediary person to the operating system - you can ask it for memory, it will allocate memory for you, you can ask it to open a file, it will facilitate that. Most programs assume it's always present and so the dependency isn't properly abstracted. This is a problem when you don't have an operating system.
Notice also that you can't just go and implement or stub everything that glibc does. To do that, you would just end up having to add an operating system.
(This particular rabbit hole goes much deeper. A lot of programs sadly don't depend on a C library, they depend on glibc in particular. This causes massive problems for systems that run Linux yet can't accomodate glibc, like OpenWRT. They use an alternative C library that works fine 99% of the time, and for the remaining 1% it will cause programs to silently misbehave or crash because of an implicit dependency on whatever glibc does. I had this problem with the hwclock utility which started segfaulting when OpenWRT switched to musl libc)
SQLite itself requires at least 100KiB of Heap space, sometimes many times more memory than already available: http://www.sqlite.org/about.html
Granted. That was 10 years ago, but it was also quite a beefy device for its time. So while naturally the devices have become quite more powerful in the last 10 years, current IoT devices are also much more compact than the old ck1.
As such I would say it's conceivable that you don't have the memory to easily run current SQLite on any of these devices.
SQLite is probably on of the most well tested piece of software on this globe. I do not know if this space saving is worth it.
EDIT to add two links by Ganssle to explain it better:
http://www.ganssle.com/rants/8bitsisdead.htm
http://www.ganssle.com/articles/8and16bit.htm
I think Microchip's 8-bitters doing $1+ billion in business with better profits and dividends vs troubles of many in 32-64 bit markets says a lot.
http://www.edn.com/electronics-blogs/embedded-insights/44408...
Interesting details on how 8-bit companies are doing that from John Donovan the year before:
https://www.digikey.com/en/articles/techzone/2014/feb/is-the...
We'd need a price list for the other thing. Can you get 32's with decent memory & low watts for a few bucks a CPU in low volume? Aside from that, you still think they're dead and useless with the new articles?
I'll add that many chips from old nodes survived for decades due to stability. The new process nodes have all kinds of issues and break faster. So, there is that to consider if the application is long-term, safety-critical, or security-critical. Many in high assurance design stayed with old stuff (esp on SOI) because manufacturing bugs were less and interference/wear issues are lower.
[1] http://bit.ly/1NbLYov redirects to digikey search.
Also, thanks for the mention of Cortex-R as I hadn't heard of it. A quick glance at their description looks good. About $8 on low end to $50 on high-end. Getting quite cheap indeed for what 8-bits would be required for. Way cheaper than the old champ (RCA 1802 MCU) is today ($150 w/ 1k units).
http://www.intersil.com/content/intersil/en/products/space-a...
Ok. So, I'll probably not have to go to 8-bit or drop large $$$ if I take-on certain projects. Good to know. Dirt cheap chips with large ecosystem, lock-step, real-time, and MPU's... it's like the golden era in tech for embedded start-ups, eh? :)
My argument is that the economic cost of production between 8 and 32 bit MCUs is negligible. There is a _need_ for market segmentation, etc. But the cost of the package makes up for the cost in gates. It really is a wash. Much of what we still see in 8 bit designs is because of (no insult intended) 8 bit designers. I love me some 8 bit RISC, but AVR is having to fully embrace ARM even when it has its own AVR32 ISA.
I don't think they are dead and useless, but they are definitely on the out for most designs. Totally agree on old stable designs. Engineering tolerances are "better" now. Something to be said for the Brooklyn Bridge and DC3s.
Cheap and low volume? Yes.
http://www.mouser.com/Semiconductors/Embedded-Processors-Con...
I saw that. They still had almost 10% of a huge market, though. My point was Ganssle's points of them not gone for most cost-sensitive markets seemed still accurate.
"My argument is that the economic cost of production between 8 and 32 bit MCUs is negligible. There is a _need_ for market segmentation, etc. But the cost of the package makes up for the cost in gates."
That does seem to be true. Especially package vs gates.
"I don't think they are dead and useless, but they are definitely on the out for most designs."
I won't argue there. 32-bit space has improved significantly on cost and efficiency. Dropping down process nodes helped a lot, there. ;)
http://www.embeddedinsights.com/channels/2010/12/10/consider...
Bet you didn't know they were even still around, eh? Get's better:
http://www.electro-tech-online.com/threads/mc14500b-a-1-bit-...
With manuals and Verilog included. :)
The basic computer has so little memory (~3KB total for code/data IIRC) to make anything sophisticated impossible, but there are extensions that keep the thing much smaller than a typical embedded device (like orders of magnitude smaller) but providing enough for there to be interesting work.
My last idea was several hundred 8-bit processors in a multi-core config that could handle many data-processing problems. Turns out it wasn't entirely original:
https://en.wikipedia.org/wiki/Kilocore
Doubted about its marketability but supports my assertion these little CPU's & such can go much further on modern nodes. Just gotta experiment. Your work is another example.