Hacker News new | ask | show | jobs
by technion 3448 days ago

    SD card failures
I'd love someone knowledgeable to explain why this happens. According to general opinion on the RPi forums, it's because SD card manufacturers cheap out all the time.

I'd have something like a dozen SD cards running things like cameras over the years, and probably a hundred booting ESXi servers. And I've never seen a failure.

Across three RPis, I've bought about seven SD cards, and from everything RPi users tell me, that's a totally normal failure rate.

Edit: In regards to cheap whiteboxes, no such options allow access to GPIO ports. I've learn plenty of interesting things about soldering circuits by having these, without considering the Pi a PC learning tool.

4 comments

In regards to cheap whiteboxes, no such options allow access to GPIO ports.

The parallel port on older PCs works reasonably well as GPIO; you can get expansion cards for those which don't have one (they seem to have gone up in price now but they used to be extremely cheap.) Since this is an actual external interface it will be more robust than the GPIOs directly connected to the SoC of the RPi, and if you use expansion cards you can just swap them out if they do get damaged.

> Across three RPis, I've bought about seven SD cards, and from everything RPi users tell me, that's a totally normal failure rate.

Sounds about right. I went through maybe 4-6 cards on 2 Raspberry Pis in a year and a half.

> I'd love someone knowledgeable to explain why this happens. According to general opinion on the RPi forums, it's because SD card manufacturers cheap out all the time

SD cards are basically uniquely ill-suited to be used in a Raspberry Pi.

First off, cheap SD cards have no wear levelling. The flash controllers are super primitive. They are designed to be written sequentially until full, and erased, like you would use a camera. A regular Linux operating system is not designed to moderate its writes, it will happily do all kinds of work and logging on /var and other places, doing tons of heavy random writes that put tons of wear on the card (write amplification/etc), and there is no levelling taking place. The flash cells just burn out.

Real mobile OSs are much smarter about what they write to flash, and they have eMMC that usually has at least a slightly smarter controller optimized for more random-ish loads, and/or is totally under the CPU's control with a filesystem designed to work with flash.

Next, flash doesn't like to be powered off during erases or writes. In some cases it can actually corrupt operations that were successfully completed. The flash cells do not get as much charge as they should and can decay prematurely.

Nor does flash like operating under questionable power conditions either. The flash can think it's successfully completed the operation, the processor will keep on trucking, but if the voltage drooped too much, the write doesn't persist. In some cases, this can cause the flash to get trapped in a "bricked" state that needs a hard reset to clear properly (which can't be done with a SD card).

http://superuser.com/questions/290060/can-flash-memory-be-ph...

The Pi also has no/very little power filtering. Your phone doesn't ever run off the charger. It uses the adapter to charge the battery and/or feed the regulator circuit, the key being there is a regulator circuit here. The Pi does not have one.

In short - the Pi is an absolute worst case in terms of power. Your average camera or phone has a battery, so the power is clean, full-on power faults are quite uncommon, and the device can monitor voltage and stop doing writes before things get critical. Not only is it really, really easy to accidentally or purposefully unplug the Pi, or flip the power strip off, but the shit-tier phone chargers that get used with it have terrible power filtering and tend to have wildly insufficient power delivery capacity. Under load, the voltage droops and the noise on the power line gets pretty intense.

With the first-gen Pis, there was an additional physical issue with the SD cards. The cards are just made of plastic, they are meant to go into a slot in a camera or phone that physically supports them, they are not intended to just hang off into space. The Pi does actually get fairly warm, especially if you have it in a case, and hot plastic warps. The card loses contact half-way through a write and there goes your file system.

http://likemagicappears.com/2014/03/11/sd_card_issues/

https://www.raspberrypi.org/forums/viewtopic.php?t=39843&p=3...

https://bigdanzblog.wordpress.com/2015/01/27/raspberry-pi-fa...

Adding a "UPS" board that can command a soft-poweroff, a decent microSD card (Samsung EVO are reputedly the most reliable on a Pi), and a "low-profile" microSD adapter that doesn't hang off into space quite as much reportedly make a pretty big difference in reliability, as does using a purpose-built adapter from a reputable vendor like Adafruit or something. Not running it in a case probably helps too.

Again though, once you spend the money to fix the flaws, you could just buy something that just includes what you need to boot up right in the box.

I really can't emphasize enough how much all of this is actually the result of poor design. If the Pi Foundation would have chucked a 2 GB eMMC chip on there and added a barrel connector and a decent power supply, these issues would be essentially eliminated. And IMO the issues are pretty much show-stoppers for any chance of reliable operation.

> In regards to cheap whiteboxes, no such options allow access to GPIO ports. I've learn plenty of interesting things about soldering circuits by having these, without considering the Pi a PC learning tool.

That's definitely true, but you can also buy a Bus Pirate that will be capable of adapting most simple embedded units to any PC.

You really only need the Pi's GPIOs when you are doing something that involves really high throughput or really low latency. The examples I've heard are video streams and using a GPS board as a reference for an NTP server - they exist, but for your every day "talk SPI/I2C to a sensor" or "count freqency counts from a sensor" the Bus Pirate does very well.

>it uses the adapter to charge the battery and/or feed the regulator circuit, the key being there is a regulator circuit here. The Pi does not have one.

Wait, what? Of course the RPi has voltage regulators. Do you think the Broadcom chip runs at 5V? There's a LP2980-N and NCP1117 shown in the schematic.

Yeah, and microSD cards run at 3V3. The problem is that a phone usually has better filtering capacitors, which the Pi lacks and thus any noise from the power line directly goes from 5V down to 3V3. Oh, and people usually buy the 2-5$ range of power adaptors from Amazon, I'm amazed that no one has managed to burn down their house with this stuff.
>Yeah, and microSD cards run at 3V3.

Err, yes. Hence the LDO regulators.

>The problem is that a phone usually has better filtering capacitors, which the Pi lacks and thus any noise from the power line directly goes from 5V down to 3V3.

The RPi has filtering capacitors. In general filtering capacitors are regular cheap X5R or X7R caps. They don't need to be anything special. Look at any LDO regulator datasheet.

> Oh, and people usually buy the 2-5$ range of power adaptors from Amazon

What does that have to do with the designers of the RPi? They don't have any control over which power supplies people buy.

> The RPi has filtering capacitors

It's hard to specifically assign blame to noise since it's such a personal and transient problem, but as a general statement power quality is one of the biggest problems with the Raspberry Pi and I strongly suspect that the Pi is not really equipped to tolerate 270mv swings as are seen on cheap USB adapters. Phones deal with this quite fine, but the Pi has less filtering and if anything is doing things that are much more sensitive to noise due to its OS.

http://www.crazy-audio.com/2013/09/raspberry-pi-power-supply...

> What does that have to do with the designers of the RPi? They don't have any control over which power supplies people buy.

You shouldn't have to buy a power supply at all. The norm is that when you buy a piece of hardware it comes with an appropriate power supply. When I buy a $15 gigabit-ethernet switch from D-Link, it comes with a power adapter.

Again, the Pi Foundation wanted to hit their price target so they could put "A computer for $35!!!" in their advertising, so they cheaped out on something that probably costs $2 when you are buying a million of them. At quantity 500, you are already down to $4 when sourcing them from Mouser.

They also pretty much openly encouraged you to use whatever crappy USB charger you had lying around. The reality is most knockoff chargers are total crap, their current ratings are dramatically overinflated, and they certainly won't be delivering clean power anywhere near their current ratings, which again amplifies the problems with the Pi's lack of filtering.

All of this has been well-known for ages. Check out Ken Shirriff's excellent series of teardowns on cheapo USB chargers and his comparison to a genuine Apple charger. This was not news even at the time.

http://www.righto.com/2012/03/inside-cheap-phone-charger-and...

http://www.righto.com/2012/10/a-dozen-usb-chargers-in-lab-ap...

http://www.righto.com/2012/05/apple-iphone-charger-teardown-...

>but as a general statement power quality is one of the biggest problems with the Raspberry Pi and I strongly suspect that the Pi is not really equipped to tolerate 270mv swings as are seen on cheap USB adapters. Phones deal with this quite fine, but the Pi has less filtering

What is your source for all these statements? How do the voltage regulation circuits in phones differ? If anything the phones ought to have more noise, since they're using switching regulators rather than linear regulators.

>Again, the Pi Foundation wanted to hit their price target

Yes, you got it. There's 1001 improvements that could be made to the RPi. If you made all of those improvements, it would not be affordable.

>They also pretty much openly encouraged you to use whatever crappy USB charger you had lying around.

They say to use a charger that's rated for at least 2.5A. That does not include most crappy phone chargers. They also sell an official RPi power supply which anyone is free to buy if they're concerned about this issue.

Yeah… also in particular microSD cards have been used in mobile phones for years and I haven't heard any card corruption stories about phones.
The ESXi servers by default regard your SD card as read only media, so normally they should not fail easily.