Hacker Newsnew | past | comments | ask | show | jobs | submitlogin
On Hacking MicroSD Cards (2013) (bunniestudios.com)
79 points by peter_d_sherman on Sept 10, 2020 | hide | past | favorite | 18 comments




>"Flash memory is really cheap. So cheap, in fact, that it’s too good to be true. In reality, all flash memory is riddled with defects — without exception. The illusion of a contiguous, reliable storage media is crafted through sophisticated error correction and bad block management functions. This is the result of a constant arms race between the engineers and mother nature; with every fabrication process shrink, memory becomes cheaper but more unreliable. Likewise, with every generation, the engineers come up with more sophisticated and complicated algorithms to compensate for mother nature’s propensity for entropy and randomness at the atomic scale.

These algorithms are too complicated and too device-specific to be run at the application or OS level, and so it turns out that every flash memory disk ships with a reasonably powerful microcontroller to run a custom set of disk abstraction algorithms. Even the diminutive microSD card contains not one, but at least two chips — a controller, and at least one flash chip (high density cards will stack multiple flash die)."

[...]

>"The embedded microcontroller is typically a heavily modified 8051 or ARM CPU. In modern implementations, the microcontroller will approach 100 MHz performance levels, and also have several hardware accelerators on-die.

Amazingly, the cost of adding these controllers to the device is probably on the order of $0.15-$0.30,

particularly for companies that can fab both the flash memory and the controllers within the same business unit. It’s probably cheaper to add these microcontrollers than to thoroughly test and characterize each flash memory chip, which explains why managed flash devices can be cheaper per bit than raw flash chips, despite the inclusion of a microcontroller.

The downside of all this complexity is that there can be bugs in the hardware abstraction layer, especially since every flash implementation has unique algorithmic requirements, leading to an explosion in the number of hardware abstraction layers that a microcontroller has to potentially handle. The inevitable firmware bugs are now a reality of the flash memory business, and as a result it’s not feasible, particularly for third party controllers, to indelibly burn a static body of code into on-chip ROM."

[...]

>"From the DIY and hacker perspective, our findings indicate a

potentially interesting source of cheap and powerful microcontrollers for use in simple projects.

An Arduino, with its 8-bit 16 MHz microcontroller, will set you back around $20.

A microSD card with several gigabytes of memory and a microcontroller with several times the performance could be purchased for a fraction of the price.

While SD cards are admittedly I/O-limited, some clever hacking of the microcontroller in an SD card could make for a very economical and compact data logging solution for I2C or SPI-based sensors."


Aren't Arduino's more expensive because they're built specifically for the hobbyist market? I'm sure you can buy similar microcontrollers to those found in SD cards cheaper than an Arduino - you just have to deal with the baggage that that comes with (less tutorials, tooling etc)


This is very much the case. Arduino gives you a nice board with a decent power circuit, clock circuit with crystal oscillator, strips of headers to plug wires into, a USB connector, UART to USB adapter, and often other goodies. The exact same MCU, the ATMega328P can be had for $2.08 each[0], or less if you buy in bulk.

For your $2, you get:

* An internal oscillator which lets you run without an external clock circuit (typically limited to around 8MHz, and can cause clock drift, so not good of accurate timing is important).

* Hardware UART interfacing logic

* Hardware SPI interfacing logic

* Hardware I2C interfacing logic

* Several ADCs

* 23 GPIOs

* 2kB data memory

* 1kB EEPROM

* 32kb flash memroy

There are other microcontrollers out there, each with their own trade-offs. I personally like AVRs, as they have good quality open source compilers, you can mooch off the Arduino community for libraries[3], and in-circuit programmers can be had for cheap[1].

If you want to learn more, I suggest this article[2].

0 - https://www.mouser.com/ProductDetail/Microchip-Technology-At...

1 - https://www.adafruit.com/product/46

2 - https://www.evilmadscientist.com/2007/using-avr-microcontrol...

3 - https://github.com/oshlab/Breadboard-Arduino


Or you could buy a 32-bit ARM Cortex-M0 for 50¢ (STM32F0 series)


This. AVR chips are not a great cost comparison point anymore, they're very expensive, especially for the speed you get.


I'm sure you're already aware, but being bigger is actually a benefit for the beginner hobbyist market.

There is a DIP ATMega328P version and in fact it's the one used on the Arduino UNO. It's also socketed! You can program it on the UNO, take it off, and it's good to go to be plugged into a breadboard, soldered standalone on perfboard, etc. and replaced with a new one.


Indeed, for educational use cases and hobbyists, there are tons of resources available for the AVR. Being able to buy it in a DIP package is ideal, since it really lowers the barrier of entry in terms of skills and tools required. There are also tons of libraries and code examples both for AVR itself and for the Arduino platform.


True, but I think that there's a bit of an unreasonable fear of SMD among hobbyists. Large SMD components can actually be easier to solder than through-hole (and there's no shortage of break-out boards for breadboard prototyping).


Arduinos (genuine Arduinos) are priced where they are because people will pay that amount. You can buy Arduino clones for $3-4 delivered. The actual micro is obviously just a fraction of that.


does this explain why newer/faster SD cards get so hot when doing things like recording 4K+ video streams? i never thought about the inner workings of a memory card to even consider having a CPU in it. the temps make sense now.


microSD cards are part of the reason why I always amazed at how much stuff we can fit into such a small package.


The microfilm.

But yeah, 64gb in basically half a fingernail is unbelievable


64GB? I'm looking at 256GB cards right now. It's crazy.


What I find even crazier is that the 1TB cards are not a scam anymore. https://shop.westerndigital.com/products/memory-cards/sandis...


Plummeting microSD card prices are astounding, and also exciting since I have some devices that can only use microSD for storage. For instance, I'm really hoping we get 1TB cards close to the $150 price point this Black Friday/Cyber Monday so I can stop running out of space on my Nintendo Switch's current 200GB microSD.


(2013)




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: