[Android Software/Hacking General [Developers Only]] Lanchon:
The Background

During the early crazy days of the brickbug saga, developers such as Entropy512 struggled to understand what was happening and how to put an end to the long line of dead devices that modders were rapidly accruing. All the while Samsung helped with their usual routine, a mixture of silence, denial and deception.

Developers found the problem: certain perfectly legal commands when sent the the eMMC (the solid state drive inside phones) destroyed the eMMC module. The module made by Samsung includes flash memory, a processor and its software (called firmware). The firmware implements an FTL, a flash translation layer, that emulates something akin to a harddrive atop the flash memory. This firmware had a bug that caused corruption on its own data structures when certain commands were executed. When the processor later accessed these corrupt structures (say, to read the bootloader partition on power on) it stopped responding, and as a result the devices never booted again.

<RANT>This buggy firmware is Samsung's trade secret and opaque to independent developers, and developers could not change it. Samsung had tools to upgrade the firmware and eliminate the bug (we know this because Google engineers were given this tool) but chose not to release it. In all probability Samsung could also reset the dead eMMCs with software, but preferred to screw their customers. I imagine Samsung failed to care about field upgrades and did not include a firmware update route in the module that supported encrypted firmware images. Then releasing a firmware upgrade tool to fix their buggy module would expose their precious secret silly little buggy firmware without encryption. And it seems they rather just screw their customers instead.</RANT>

Developers worked around the bug by making sure a whole class of eMMC commands would never be issued and urged everybody to upgrade their 'dangerous' (standard actually) custom roms to 'safe' (read 'crippled') alternatives.

Samsung later released 'safe' Android updates. But their version of 'safe' only excluded a subset of the of commands excluded by independent developers. The general response of developers was distrust of Samsung and the belief that Samsung's fix was not enough and not 'safe'. This based mostly on a very bad track record by Samsung during the brickbug days, involving technical matters, denials and lies.

TRIM

Flash storage in general (including the eMMC) requires that certain commands be ran regularly in order to keep performance high. If not, under normal usage performance will degrade enormously. (This is a result of so called write amplification and other effects.) As users can vouch, devices like the Galaxy S2, the Galaxy Nexus, and the Nexus 7 were snappy and fast when new; then they gradually became abysmally slow after months of use.

These commands are called DISCARD, ERASE, TRIM or fstrim depending on context and software stack level, but mostly refer to the same core function.

The Brickbug Aftermath

And this is the problem: the brickbug fix that independent developers implemented disable these commands. This means that running a custom rom in the affected devices pretty much guarantees that you will end up with a ridiculously sluggish device given enough time. In effect, these devices severely under-perform when running custom roms due to software issues that can possibly be fixed. With the current state of affairs, I would go as far as considering custom roms useless for these devices.

This project aims to provide a safe TRIM solution for these devices when running custom roms.

This project has to be executed carefully. I expect accusations of recklessness to be thrown at me for reintroducing 'unsafe' roms. And maybe a couple of devices of careless people will die.

But many other devices will find new life and become usable again.