Live data from Hacker News

A little fail-safe filesystem designed for microcontrollers (2017)

github.com

11–20 of 32 posts

Re: A little fail-safe filesystem designed for microcontrollers (2017)

#11
post #7

Earlier quoted context omitted.

Your criticism seems a bit idiosyncratic, to put it kindly. So it doesn't use the flavor of C++ you prefer? Sure, but there's a lot of room for argument about whether shared_ptr or template-instantiation bloat would be good choices for an IoT-level embedded system. Similarly, the fact that it doesn't use cmake seems like more a matter of preference than of actual suitability. As for being supported by ARM, well hey,…

Dynamic memory allocation on an embedded system is pretty bad. Even in desktop applications you should usually try and avoid that. Over complicating the build system is a reason for dropping almost anything but especially this. The whole point of a framework like that is to make things easier.

> Dynamic memory allocation on an embedded system is pretty bad.

That's the one criticism I found valid. I even called it one of the "Four Horsemen of Poor Performance" in a pretty widely read article I wrote on server performance back in 2002. On the other hand, over-reliance on static allocation means allocating many arrays/pools for the worst case, even when they couldn't possibly all hit worst case at the same time, and that can be a pretty bad choice on a highly memory-constrained device. (Doing it for the sake of real-time predictability is actually a different issue.)

OTOH complaining about not using templates because of performance seems exactly backwards, and complaining that it's not likely the the project sponsor will port already-open-source code to a competing architecture themselves seems a bit too entitled. When I see a list of negatives that are mostly bogus, and no mention of positives at all, it's a strong indicator of NIH syndrome.

Re: A little fail-safe filesystem designed for microcontrollers (2017)

#12

Nice, perhaps a more robust fatfs replacement? If you've used this (or are the author) how is the "storage on disk ... always kept in a valid state" feature implemented? Does it write two copies in case a write's interrupted so one can always roll back to the earlier valid copy?

https://github.com/ARMmbed/littlefs/blob/master/DESIGN.md answers those questions in admirable detail.

Re: A little fail-safe filesystem designed for microcontrollers (2017)

#13

Nice, perhaps a more robust fatfs replacement? If you've used this (or are the author) how is the "storage on disk ... always kept in a valid state" feature implemented? Does it write two copies in case a write's interrupted so one can always roll back to the earlier valid copy?

https://github.com/ARMmbed/littlefs/blob/master/DESIGN.md answers those questions in admirable detail.

Thank you. Makes me wish everything else in the world was so thoughtfully documented.

Re: A little fail-safe filesystem designed for microcontrollers (2017)

#14
i am very impressed that, although it's designed for the mbed ecosystem, this code is obviously written so that it can be used in any embedded project (especially those that use a single, statically-compiled binary for the entire firmware) with virtually no changes. i could have this working on my project's bespoke hardware in a couple hours.

* zero dependencies, no assumptions about libc, doesn't use timers or heap, fully synchronous, and it's passive when you're not interacting with it.

* variables, constants, and functions are well-prefixed (without being too verbose) to avoid collisions.

* BSD license is friendly for single-binary firmwares.

* the Makefile doesn't assume anything, it just outputs a .a file which you can link however you want.

* the Makefile is simple and doesn't require cmake or autotools. it's easy to point it at your cross-compile toolchain.

it has other hallmarks of a well-planned and well-maintained project too:

* the readme shows exactly why i might want this (or might not), and how to use it. the separate design doc shows exactly how it works.

* functionality is cleanly separated by file.

* consistent style (could specify which style guide they're using, though).

* the tests serve their usual purpose but also serve as examples. they're well encapsulated and the code was obviously written to be tested.

these authors have absolutely nailed everything i strive for at my embedded firmware development job.

Re: A little fail-safe filesystem designed for microcontrollers (2017)

#15

i am very impressed that, although it's designed for the mbed ecosystem, this code is obviously written so that it can be used in any embedded project (especially those that use a single, statically-compiled binary for the entire firmware) with virtually no changes. i could have this working on my project's bespoke hardware in a couple hours. * zero dependencies, no assumptions about libc, doesn't use timers or heap,…

I had the same reaction. Really impressive and well documented. I will surely do some tests.

> variables, constants, and functions are well-prefixed (without being too verbose) to avoid collisions.

Unfortunately it has the same name (Little File System, LFS) and the same function prototypes (lfs_*) of a filesystem for NOR/NAND based systems I did like 10 years ago and still in use, so it will be at least confusing.

As a matter of fact, I guess every embedded technology company using NAND/NOR/whatever memories have their own version of a LFS.

Re: A little fail-safe filesystem designed for microcontrollers (2017)

#16

I didn't read all of the design, but it looks like the author had an unusually clear understanding of the tradeoffs involved and how they relate to the specific target environment. There are some clever solutions there, all explained quite well. Definitely worth a look.

I think you can be sure this is not his first attempt at a file system.

Documentation does look really good. I’ll hang in to this.

Re: A little fail-safe filesystem designed for microcontrollers (2017)

#17
post #15

i am very impressed that, although it's designed for the mbed ecosystem, this code is obviously written so that it can be used in any embedded project (especially those that use a single, statically-compiled binary for the entire firmware) with virtually no changes. i could have this working on my project's bespoke hardware in a couple hours. * zero dependencies, no assumptions about libc, doesn't use timers or heap,…

I had the same reaction. Really impressive and well documented. I will surely do some tests. > variables, constants, and functions are well-prefixed (without being too verbose) to avoid collisions. Unfortunately it has the same name (Little File System, LFS) and the same function prototypes (lfs_*) of a filesystem for NOR/NAND based systems I did like 10 years ago and still in use, so it will be at least confusing. A…

You're referring to LFS as in LogFS?

Re: A little fail-safe filesystem designed for microcontrollers (2017)

#19
post #2

I am curious - does anyone have some feedback from using the mbed ecosystem? I have generally shied away from using too much vendor middleware but it does look like there are a lot of useful libraries.

I worked with mbedTLS on a desktop/mobile project a couple of years ago. I'd previously used OpenSSL, and I wasn't very impressed, but mbedTLS seemed OK: easy to get it building with cmake, easy to get it building on Windows/OS X/iOS/Linux, no actual I/O in the library.

I remember finding integration with libuv a mite annoying, as mbedTLS is rather pull-minded, and I didn't find the documentation for the I/O callbacks super-clear. If your I/O callbacks are making blocking calls of a pipe or socket, though, I'm sure it's much simpler.

Would use again.

(Would not use OpenSSL again.)

Re: A little fail-safe filesystem designed for microcontrollers (2017)

#20
One problem I see is when they write the pairs of metadata blocks for redundancy, in many FTL implementations they might fall on the same physical page of flash so there is not much redundancy. When FTL write metadata for their own needs, they are congnizant of the flash layout and make sure to write metadata to separate die/block/page.
Post reply on HN