6 ms·
I worked on a project professionally to find out why we were corrupting SD cards. Turned out that the SD card firmware is just garbage in a lot of cases. Ende
by monocasa 9y ago
I worked on a project professionally to find out why we were corrupting SD cards. Turned out that the SD card firmware is just garbage in a lot of cases. Ended up with a test program that could corrupt an SD card from a given manufacturer within a couple hours with slow (80kb/s) continous reads and writes from any hardware running Linux. The manufacturer couldn't have cared less and essientially blew us off despite having a support contract.
Long story, short, buy 'industrial' SD cards if you care about them not getting corrupted.
- Ahmed90 9y agoAre you allowed to share the results of your experiment? i have a similar issue with a very limited market (SD Brands/models), it would be great if you provide more info :)
- monocasa 9y agoI'd be hesitant to name any names due to NDAs and what have you. I'll just say that all consumer level cards pretty much don't really care about your data, even the good brands.
- logicallee 9y agoI think I speak for everyone that we really appreciate what you did share here. For how to use what you've shared if we trust you, can you throw us a bone more than: >buy 'industrial' SD cards For example can you name a specific card? Or give us enough clues that we can do so? I for one take your advice very seriously but I don't know how to use what you've just shared. I've seen ATM-style Pi-based kiosks with corrupted SD cards that wouldn't boot. It looked expensive.
- monocasa 9y agoATP Inc. has treated us very well, both their products and their support. But in general 'industrial' is the keyword to get the good shit from manufacturers who'll treat you like an adult.
- pera 9y agoSearch for SLC type memory cards (in the Technology filter): https://www.digikey.com/products/en/memory-cards-modules/memory-cards/501 https://www.digikey.com/products/en/memory-cards-modules/mem...
- monocasa 9y agoIndustrial is more than that. A big one for me was that the manufacturer will work with you and notify you when they change their BoM, letting you reverify and track internally.
- mrsteveman1 9y agoTake a look at ATP, specifically the AF4GUD3A and AF8GUD3A, for 4GB and 8GB respectively. Digikey[1] and Arrow[2] generally sell the 4GB for $15 and the 8GB for $25. They make larger versions too, if you need them. The 'A' stands for aMLC, they're using normal MLC flash (which most consumer SD cards no longer use, but is generally much more reliable than TLC) but they use it in 1-bit per cell mode like SLC. They make traditional SLC cards as well, but the price skyrockets. The aMLC cards have very good endurance ratings, but they're still cheaper than SLC cards. The firmware and controller are designed to prevent sudden power loss issues, which is apparently the root cause of a lot of SD card corruption on the Pi. They're also supposed to have lifetime (i.e. SMART) monitoring, but it's a vendor specific command set rather than something smartmontools can read. ATP has a tool for it that probably only runs on Windows. I've been using those aMLC cards in a bunch of Pi3 and Pi Zero W devices for months, I've never seen them become corrupted or fail to boot even once, despite being pretty hard on them, compiling stuff, yanking the power, etc. For comparison, a Samsung Ultra+ card became corrupted after a single power loss. The device was running Windows 10 IoT Core at the time, it never booted again and had to be re-flashed. [1] https://www.digikey.com/product-detail/en/atp-electronics-inc/AF4GUD3A-OEM/AF4GUD3A-OEM-ND/5361062 https://www.digikey.com/product-detail/en/atp-electronics-in... [2] https://www.arrow.com/en/products/af4gud3a-waaxx/atp-electronics https://www.arrow.com/en/products/af4gud3a-waaxx/atp-electro...
- sitkack 9y agoCould a lot of this be mitigated by having better file systems?
- mrsteveman1 9y agoA small amount of it, yes, but it's the card itself causing corruption issues most of the time, it happens even on devices where the filesystem is read-only. The controller will write and move things around for maintenance purposes even if the host hasn't issued a write command. The cheap SD cards just aren't designed for anything except being used in consumer devices with batteries, where sudden power loss is rare and losing data isn't going to cause a plane to crash or result in someone not receiving a dose of insulin. So when they suddenly lose power, they aren't always capable of ensuring that whatever task they were carrying out at the time is actually completed and did not accidentally destroy data. And apparently the consumer SD card controllers are really there to manage and remap parts of the flash that were defective before ever leaving the factory. It's probably cheaper to build over-provisioned cards with a simple controller that can deal with manufacturing defects in the field, than to do QA on 200 million thumbnail sized NAND die every month and still try to profit while selling them for a fraction of a penny each.
- pera 9y agoYeah, industrial grade SDs is the way to go. Here is an interesting graphic comparing different types of NAND memories: https://www.cactus-tech.com/resources/blog/details/slc-pslc-mlc-and-tlc-differences-does-your-flash-storage-ssd-make-the-grade https://www.cactus-tech.com/resources/blog/details/slc-pslc-...
- chasil 9y agoI bought a SwissBit card off of Ebay for my Raspberry PI, because I wanted the longevity of SLC media. The prices seem to be trending up for SwissBit.
- 0xcde4c3db 9y agoYou'll pay for it, though. Truly industrial-grade SD cards (i.e. SLC flash, industrial temperature range, specified terabytes written/MTBF) apparently cost over $10/GB unless you're buying in huge quantities. I guess that might be a good motivation to slim down your root filesystem.
- monocasa 9y agoA lot of the newer industrial cards are 'aMLC', which basically means you take an MLC NAND, but only stuff 11 or 00 into a cell and sort of treat it as SLC. You can get for close to $1/GB at sane quantities.
- more-coffee 9y agoBeen in a similar boat. Management said we couldn't afford industrial cards because it would kill the margin on the embedded devices they were used in, so we had to make it work with 3$ p.o.s. cards, which would corrupt after 6-12 months. Ended up mounting /var on a tmpfs - ensuring practically no writes to the card - and fetching the device configuration from a server in the network at boot. PLenty of work, with zero (or negative) profit for the company, but at least I learned a thing or two doing it.
- amag 9y agoYup, been there too, way, way back. We wrote simulation tools for typical access patterns and ran them heavily for testing out new cards, both for performance and failure rate. Luckily there was enough margin on the devices that we (R&D) could select the more expensive industrial graded cards by good manufacturers, but I did get to see some really shitty cards that purchasing preferred (because they had gotten a great price on them). However in our case the corruption was due to a buggy FAT-driver for the obscure RTOS we used. In the end though I learned a lot about FAT which was fun (<sarcasm>and is a highly marketable skill these days</sarcasm>).
- monocasa 9y agoHaha, I ended up tapping all read and writes to the card, intending to catch our crappy FAT driver in the act of corrupting. Turns out the card itself was shit and replaying the trace would just kill arbitrary cards.
- michaelt 9y agoHow does one tap all the reads and writes to a card?
- hazeii 9y agoJust intercept the read and write calls! On linux you can just use 'strace $prog'; try it on a minimsal program that reads and writes a file. For a custom approach, this can be done with a library (using LD_PRELOAD). Plenty of articles about how to do this, e.g. http://www.linuxjournal.com/node/7795 http://www.linuxjournal.com/node/7795 (essentially the same technique on Windows, or other OS with shared libs). Slightly more hardcore is to hook the kernel syscalls; not normally necessary (on linux this is effectively hooking the other side of glibc, where it talks to the kernel) but if all you've got a static binary it's one approach. Note that all these techniques only show you the read and write calls made to the library/OS and - importantly - not what actually happens to the card. To see that, the next level down is to instrument the card driver to track the actual I/O operations (i.e. so you see what the card is really being asked to do, sans all the caching and buffering). Note that's not the end of the story; there's what the hardware controller decides to do and when the hardware actually reads/writes the flash array. That's the level where the quality of the firmware in the controller(s) matters.
- 24gttghh 9y agoWow I had no idea to even look for different NAND geometries for SD cards! More expensive obviously but probably well worth it.
- jpm_sd 9y agoYes, SD cards are garbage. eMMC is far, far superior.
- StavrosK 9y agoWhy not name the manufacturer so we can avoid them?
- monocasa 9y agoNDAs.
- pingec 9y agoAny recommendations?
- rwky 9y agoAny idea where industrial micro SD cards can be purchased in Europe? A casual search didn't yeild much info.