Discussion thread for /data EMMC lockup/corruption bug

Search This thread

garwynn

Retired Forum Mod / Inactive Recognized Developer
Jul 30, 2011
5,179
8,589
NE Ohio
www.extra-life.org
Analysis/Opinion

OK, now that you've seen the comments from the Android team, have links to the code and we have confirmed that our devices are affected, let's try and walk this through:

Linux File System Terms:

inode:
Also known as metadata, it's the data about the data. Out of the many articles out there, I thought this might help without going too much into the technical side: http://www.linux-mag.com/id/8658/

Binary Bitmap:
In order to account for the usage of the blocks on the filesystem, the ext2 filesystem consists of a block bitmap. This keeps track of blocks that have been used and those that are free. Each bit in the Block Bitmap denotes an integral number of fragments. So if a bit is allocated to a file and marked as used, then an entire set of fragments are allocated to it.

The Block Bitmap is a clever way to keep track of new empty and old used ones. In order to look for a block, one needs to check the group to which the file belongs. Then the Block Bitmap of the appropriate `Group’ is selected and searched for the required block.

(Source: http://freeos.com/node/41)

Q: Can inserting 32 Kb of zeros corrupt a file system?
Certainly - as mentioned by Mr. Sumrall, it just depends on where the insertion was made.

Q: Can this corruption cause an I/O error?
Again, yes - under the conditions as described by Mr. Sumrall

Q: Can this particular bug be repaired?
Mr. Sumrall says no, and that sounds awfully familiar with our bricks.

Q: Why couldn't JTAG, with its bit blast, at least reset the values and allow it to go ahead?
The answer, as far as I can tell, is simply that the support is not available at a driver and/or eMMC controller level to handle this type of operation. This is either because the embedded controller chip simply cannot do so or the driver has not been designed to use those instructions as of yet. As a result, all it can do is throw an error in frustration. It might be possible down the road but not now. So instead of waiting for this to come Samsung implemented a workaround to the WL logic to avoid it corrupting the filesystem.

I'm still stumped as to why we saw this particularly on the /data portion of the filesystem. It's the most likely to see file changes the most often so perhaps the wear leveling logic kicked in on this partition first. It's also interesting to note that bypassing that block restores the file system to something stable, as tested by drnull. But if this truly is the bug, skipping the bad blocks is not solving the problem; it's only extending the life at the cost of possibly further corrupting the file system. I'm optimistic that it may be possible in the future to save a device even after it's bricked - filesystem corruption is not physical damage so I consider it in the realm of possibility. Whether it is practical or cost-effective is up to Samsung - they may even have a solution already available, just not for end users.

Initial Summary:
Based on available information this is does have significant credibility to be the bug in question and a rather clever attempt to work around the issue short of eMMC replacement. It should be tested for verification by a willing member of the community so long as they can afford to brick and replace the device if necessary. If verified the solution may not save an already bricked device at the moment, but it may avoid future bricks of this nature. It would also mean a high probability that any versions of Android prior to 4.0.4_r1.1 (which is the first standard build with the fix) should be the minimum requirements for any device with this eMMC if it can be supported.

*Disclaimer*
Comments and summary on this post, unless otherwise specified, should not be considered the definitive conclusion for this topic. Instead it is a summary of my observations - as such it should be reviewed and critiqued by others for possible improvement before the community comes to a conclusion.
 
Last edited:

Entropy512

Senior Recognized Developer
Aug 31, 2007
14,088
25,086
Owego, NY
OK, now on to the bug that this fixes. This post will only contain the discussions between myself and Mr. Sumrall of the Android team.

Initial inquiry to Mr. Sumrall:


Initial Response:


We also knew this from the code:
Code:
	 * There is a bug in some Samsung emmc chips where the wear leveling
	 * code can insert 32 Kbytes of zeros into the storage.  We can patch
	 * the firmware in such chips each time they are powered on to prevent
	 * the bug from occurring.
Note: Snipped last part of comment as it is already covered.

OK, so it's putting potentially zeros in the storage; but it doesn't give us any clues as to where the possible storage was or how this could corrupt the filesystem. So I sent some follow-up questions and got the following responses. (Regular is question to Mr. Sumrall, bold is response.



Thanks again to Mr. Sumrall for this information. More soon.
I don't think the question was appropriately phrased to Mr. Sumrall. Filesystem corruption like he describes is one thing - it's easy enough to fix, just reformat.

However, the symptoms we have been seeing are:
1) Parts of the eMMC are becoming inaccessible, to the point where they cannot be written to in any way, shape, or form. This goes way beyond filesystem I/O errors - a reformat would fix those.
2) This includes attempting to rewrite corrupted bootloaders using JTAG recovery methods.

Is there any chance you could send me the contact info for this person, as I've been fairly "down in the dirt" with the hardbricks incurred on other devices.
 
  • Like
Reactions: leaderbuilder

azyouthinkeyeiz

Senior Member
Jan 3, 2010
675
122
1) Parts of the eMMC are becoming inaccessible, to the point where they cannot be written to in any way, shape, or form. This goes way beyond filesystem I/O errors - a reformat would fix those.

Q: Can inserting 32 Kb of zeros corrupt a file system?
Certainly - as mentioned by Mr. Sumrall, it just depends on where the insertion was made.

/*In this case in the low-level bootloader firmware*/

2) This includes attempting to rewrite corrupted bootloaders using JTAG recovery methods.

Q: Why couldn't JTAG, with its bit blast, at least reset the values and allow it to go ahead?
The answer, as far as I can tell, is simply that the support is not available at a driver and/or eMMC controller level to handle this type of operation. This is either because the embedded controller chip simply cannot do so or the driver has not been designed to use those instructions as of yet. As a result, all it can do is throw an error in frustration. It might be possible down the road but not now. So instead of waiting for this to come Samsung implemented a workaround to the WL logic to avoid it corrupting the filesystem.

I don't think the question was appropriately phrased to Mr. Sumrall. Filesystem corruption like he describes is one thing - it's easy enough to fix, just reformat.
That's why he clarified with
The explanation in the bugfix mentions 32 Kb of zeros being added to storage. But I can't see this causing an I/O error unless it was doing this in the storage containing the instruction set. Was this somehow corrupting the I/O instruction set contained within the firmware?*I have spent several weeks defending the opinion that this was not a hardware failure but software-based."
And the answer was- it's corrupting the low-level firmware that handles EMMC, which makes the partition inaccessible.

The intent has not been written at that level to correct that with jTag.

Both of your questions are answered in the two quotes.

Sent from my SPH-D710 using Tapatalk 2
 
Last edited:

sfhub

Senior Member
Oct 23, 2008
5,350
7,231
That's why he clarified with
And the answer was- it's corrupting the low-level firmware that handles EMMC, which makes the partition inaccessible.

The intent has not been written at that level to correct that with jTag.

Both of your questions are answered in the two quotes.
This is the part I don't understand about this answer. If they cannot permanently patch the EMMC firmware (presumably because it is not writable), how is the 32kb of zeros corrupting that same unwritable firmware. If the firmware is kept on EMMC it should be writable though I find it difficult to believe the EMMC firmware (essentially the "OS" handling the blocks on the EMMC is being stored on the regular EMMC itself, subject to wearlevel algorithms)

If that stuff about the firmware was just miscommunication and we are back to talking about filesystem corruption, I can write 32KB of zeros to any of the filesystems just using "dd" and "/dev/zero". These can be repaired by reformating the partition. There is some "special" corruption or damage going on here, IMO.

It may be that the bug they are fixing is causing all this. I just cannot picture the mechanism yet with the descriptions being given.
 

nabbed

Senior Member
Aug 15, 2010
2,382
347
This is the part I don't understand about this answer. If they cannot permanently patch the EMMC firmware (presumably because it is not writable), how is the 32kb of zeros corrupting that same unwritable firmware. If the firmware is kept on EMMC it should be writable though I find it difficult to believe the EMMC firmware (essentially the "OS" handling the blocks on the EMMC is being stored on the regular EMMC itself, subject to wearlevel algorithms)

If that stuff about the firmware was just miscommunication and we are back to talking about filesystem corruption, I can write 32KB of zeros to any of the filesystems just using "dd" and "/dev/zero". These can be repaired by reformating the partition. There is some "special" corruption or damage going on here, IMO.

It may be that the bug they are fixing is causing all this. I just cannot picture the mechanism yet with the descriptions being given.

Dear Mr. sfhub,
There is a new sheriff in town. Or soon will be.
It's going to be either Evo LTE or some kind of a variation.
Can we count you to provide hacking/unlocking support for this puppy?
 

azyouthinkeyeiz

Senior Member
Jan 3, 2010
675
122
This is the part I don't understand about this answer. If they cannot permanently patch the EMMC firmware (presumably because it is not writable), how is the 32kb of zeros corrupting that same unwritable firmware. If the firmware is kept on EMMC it should be writable though I find it difficult to believe the EMMC firmware (essentially the "OS" handling the blocks on the EMMC is being stored on the regular EMMC itself, subject to wearlevel algorithms)

If that stuff about the firmware was just miscommunication and we are back to talking about filesystem corruption, I can write 32KB of zeros to any of the filesystems just using "dd" and "/dev/zero". These can be repaired by reformating the partition. There is some "special" corruption or damage going on here, IMO.

It may be that the bug they are fixing is causing all this. I just cannot picture the mechanism yet with the descriptions being given.

That's what I had started to suppose in the post I removed. It would have to be binary inserts between the software and firmware that corrupted. Otherwise, re-formating would correct it. But, if it went into panic, it could have locked down the partition, and like garwynn suggested the controller hasn't been defined.

Also, there was a certain subset of variables that had to have been met during initial custom development of our device, that would have had the same consequences. We would have had at least one, and I don't think I ever heard of a similar brick before ICS. It could be an issue with this bug and the conversion between two different kernels, which is likely since it is the ICS recovery intents that are borking the partition.

---------- Post added at 07:23 PM ---------- Previous post was at 07:21 PM ----------

I have turtle DNA in my family tree

/Epic
 
Last edited:

sfhub

Senior Member
Oct 23, 2008
5,350
7,231
If I look at this part of code alone:
Code:
cid_rev(0, 0x25, 1997, 1)

...this tells me to look for a definition of cid_rev. So I do and get here:
Code:
#define cid_rev(hwrev, fwrev, year, month)      \
        (((u64) hwrev) << 40 |                  \
         ((u64) fwrev) << 32 |                  \
         ((u64) year) << 16 |                   \
         ((u64) month))
...
Code:
#define _FIXUP_EXT(_name, _manfid, _oemid, _rev_start, _rev_end,        \
                   _cis_vendor, _cis_device,                            \
                   _fixup, _data)                                       \
        {                                                  \
                .name = (_name),                           \
                .manfid = (_manfid),                       \
                .oemid = (_oemid),                         \
                .rev_start = (_rev_start),                 \
                .rev_end = (_rev_end),                     \
                .cis_vendor = (_cis_vendor),               \
                .cis_device = (_cis_device),               \
                .vendor_fixup = (_fixup),                  \
                .data = (_data),                           \
         }

So to properly identify what is affected:

Model Name (.name) -> VYL00M, KYL00M or MAG4FA
Manu. Firwmare ID: --> 0x15
OEM ID: Any ID (easy extrapolation of CID_OEMID_ANY)
Revision Start (Range): The result of cid_rev(0, 0x25, 1997, 1). The date indicates a low limit value.
Revision End (Range: The result of cid_rev(0, 0x25, 2012, 12). The date indicates a high limit value.
Fixup: Function to call to add the fixup - in this case, add_quirk_mmc (data.h linked above)
Data: MMC_QUIRK_SAMSUNG_WL_PATH (Not 100% but looks like a label to me. Can't find a definition in change.)
...
The corrected eMMCs affected involve VYL00M, KYL00M or MAG4FA at Manufacturer Firmware ID 0x15.
...
But even if name, manfid, and oemid match, presumably the reason they give a revision start/end range is because it is actually being used to limit which revisions get the patch. Given that, our fwrev is 0x0 and they provided 0x25. Bitwise shift those over 32 bits and 0x0 still won't be within the range of 0x25.

Am I missing something?

If the wrote range like this, then it would make more sense why it would apply to our phones:
cid_rev(0, 0x0, 1997, 1), cid_rev(0, 0x25, 2012, 12)
instead of this
cid_rev(0, 0x25, 1997, 1), cid_rev(0, 0x25, 2012, 12)
 
Last edited:

azyouthinkeyeiz

Senior Member
Jan 3, 2010
675
122
But even if name, manfid, and oemid match, presumably the reason they give a revision start/end range is because it is actually being used to limit which revisions get the patch. Given that, our fwrev is 0x0 and they provided 0x25. Bitwise shift those over 32 bits and 0x0 still won't be within the range of 0x25.

Am I missing something?

I wonder what the control group and test group in their lab is? You said the scope was incomplete? It could include a higher range?
 

sfhub

Senior Member
Oct 23, 2008
5,350
7,231
So to properly identify what is affected:

Model Name (.name) -> VYL00M, KYL00M or MAG4FA
Manu. Firwmare ID: --> 0x15
OEM ID: Any ID (easy extrapolation of CID_OEMID_ANY)
Revision Start (Range): The result of cid_rev(0, 0x25, 1997, 1). The date indicates a low limit value.
Revision End (Range: The result of cid_rev(0, 0x25, 2012, 12). The date indicates a high limit value.
Fixup: Function to call to add the fixup - in this case, add_quirk_mmc (data.h linked above)
Data: MMC_QUIRK_SAMSUNG_WL_PATH (Not 100% but looks like a label to me. Can't find a definition in change.)
...
The corrected eMMCs affected involve VYL00M, KYL00M or MAG4FA at Manufacturer Firmware ID 0x15.

BTW according to linux kernel documentation, manfid is "Manufacturer ID", not "Manufacturer Firmware ID"

http://www.kernel.org/doc/Documentation/mmc/mmc-dev-attrs.txt

fwrev Firmware/Product Revision (from CID Register) (SD and MMCv1 only)
hwrev Hardware/Product Revision (from CID Register) (SD and MMCv1 only)
manfid Manufacturer ID (from CID Register)

Also they mention a restriction on fwrev and hwrev of "SD and MMCv1 only". Is it possible we don't have MMCv1 and that is affecting what information the kernel is providing for fwrev and hwrev? I'm grasping at straws a little bit here, because based on folks' responses, it still doesn't sound like any of our EMMC falls into the range they are talking about. If the information provided by the kernel is accurate, we all seem to have the same EMMC revs, just with different manufacturing dates.
 

sfhub

Senior Member
Oct 23, 2008
5,350
7,231
I wonder what the control group and test group in their lab is? You said the scope was incomplete? It could include a higher range?
I mentioned that only as a possibility to rationalize the scenario where they put out a fix to address the corruption we are seeing, but for some reason it doesn't seem to be being applied to our EMMC units based on the information provided by our kernels and their table.

I didn't mean I unconditionally knew their scope was incomplete. Another explanation could be that their fix has nothing to do with the /data corruption we are seeing. That is also a reasonable explanation why the fwrevs don't match ours.
 

azyouthinkeyeiz

Senior Member
Jan 3, 2010
675
122
Another explanation could be that their fix has nothing to do with the /data corruption we are seeing. .

I think this is what I'm leaning towards. It just doesn't fit to me.

I wonder if anyone has a bricked device, sitting in a drawer, that we could set up sending it straight to Samsung to research? We've contacted care for warranty replacements and repairs, but I wonder if our issues have been properly notated and reviewed as such?

I can risk bricking it, but I have to have the phone in a matter of days, not weeks.
 

sfhub

Senior Member
Oct 23, 2008
5,350
7,231
So I propose we pursue 2 tracks:
1) continue to analyze and discuss code change
2) in parallel have someone test out the unlocked stock recovery repacked with FE07

If #2 cannot get brick despite trying then that will give us more confidence to expand testing. If #2 bricks, then that is a direct proof that either this fix doesn't fix the /data EMMC corruption issue or if it is meant to, the scope was not made broad enough.

Azrael.arach - I can try to help but not till weekend when my other phone gets here.
pbassjunk - I'll take one for the team if needed. I've been eyeballing the 720p Evo.
azyouthinkeyeiz - I can risk a brick to save future ones. I can help test.
robertm2011 - If need be, will test.

and of course bigpeng from the FE07 OneClick thread.

Let's put together a list of things that should be tested. For example
1) flash FE07 unlocked , then format_all, then flash calk 1.5
2) flash FE07 unlocked, then format_all, then AOKP
...
(removed ROM manager for now)
 
Last edited:

azyouthinkeyeiz

Senior Member
Jan 3, 2010
675
122
1) flash FE07 unlocked , then format_all, then flash calk 1.5
2) flash FE07 unlocked, then format_all, then AOKP
...
5) flash FE07 stock, use ROM manager to temp install CWM Touch, then perform wipe data/factory reset

I am dl'ing 1.5 and performing (1) right now. Will report back asap.

Step 1
Calk's 1.5 and format all flashed just fine from the FE07 repack. Flash seemed to take about a minute to start, but once going worked perfectly.

/*Just flashed FE07 From Rogue Kernel, Booted back into FE07 Unlocked, flashed format all, and reflashed Calk's 1.5, and then flashed FD26 Modem. All flashed perfect.


Step 2
Flashed FE07 unlocked from Rogue> Flashed format all over Calk's 1.5> flashed AOKP 35 Tablet>flashed Format_all over AOKP> re-flashed AOKP. All flashed perfect.

Flashed Format_all over AOKP> Flashed Calk's 1.5> Flashed Format_all> Booted fine> Flashed FE07 Unlocked> Flashed AOKP> Flashed GAPPS20120429(Will not stick)> All Flashed perfect



/*I have tried 6 or 7 different Gapps, each time flashing AOKP from FE07 Unlocked> booting> realizing Gapps did not stick through flash> Odin EL26CWM> Flash FE07 Unlocked> Format_all> Re-flash AOKP> Re-flash Gapps> Boot */


I'm calling it a night, I'll keep messing with Gapps in the morning if someone hasn't already figured it out.
 
Last edited:

Esoteric68

Senior Member
Jun 9, 2011
2,979
1,442
Hellabama
Can I do this on the custom ROM I'm currently on (flashing the unlocked kernel, currently have the plus installed) or should I ODIN the one-click to get me started from a clean slate?
 

azyouthinkeyeiz

Senior Member
Jan 3, 2010
675
122
Can I do this on the custom ROM I'm currently on (flashing the unlocked kernel, currently have the plus installed) or should I ODIN the one-click to get me started from a clean slate?

I'd hold off, if you are just wanting the newest recovery. IF you are wanting to help test, and understand there is a possibility that you will brick, you can try it from the current rom, as I ODIN'ed to EL29 yesterday, and it'd be good to isolate your flash pattern, just make sure to denote all of your steps here in this thread.
 

Esoteric68

Senior Member
Jun 9, 2011
2,979
1,442
Hellabama
I'd hold off, if you are just wanting the newest recovery. IF you are wanting to help test, and understand there is a possibility that you will brick, you can try it from the current rom, as I ODIN'ed to EL29 yesterday, and it'd be good to isolate your flash pattern, just make sure to denote all of your steps here in this thread.
I'd really like to help test. I recognize and accept the risks and am happy to do my part if it further's development on our device.

Okay, gotcha.

AOKP is saying 5 hours to download. Ouch. Can I go with AOSP instead? Nevermind, I have other ICS ROMs already downloaded so I'll try some of them and work my way back around to AOKP tomorrow. lol
 
Last edited:

Esoteric68

Senior Member
Jun 9, 2011
2,979
1,442
Hellabama
One quick question. I flashed clockworkmod touch recovery through ROM manager but uh, now I don't know how to actually access the stupid thing.

FYI, prior to this I've gone through 5 ROM installs using unlocked recovery with no problems. As soon as I've completed the clockworkmod touch recovery step I'll post all my steps/results.
 

azyouthinkeyeiz

Senior Member
Jan 3, 2010
675
122
I think CWM touch should be a very last step. That's almost a sure brick.I'd like to see a couple more get through flawlessly before we say we aren't in the fwrev range. Let's see if we can isolate some more before we go there. We also might try building a cwm touch with the AOSP kernel T.C.P just let out of the bag, before using that one.

Sent from my SPH-D710 using Tapatalk 2
 
Last edited:

Top Liked Posts

  • There are no posts matching your filters.
  • 70
    This post will evolve over time as more info is found:

    Latest Updates
    6/24 Custom PIT repartition workaround posted by Jaymoon.
    You lose 8GB (some of which might be further recoverable with extra work) and restores using the original PIT will lockup your phone again (a scenario that could happen if you brought your phone back to Sprint for some unrelated problem) so if you have the opportunity to get your phone replaced with little to no cost, IMO that should be your primary option.
    http://xdaforums.com/showthread.php?p=27852689#post27852689

    E4GT specific PIT file here (theoretically instead of losing 8GB, you'll only lose 2GB):
    http://xdaforums.com/showpost.php?p=28070569&postcount=654

    6/8 Update for other platforms waiting for fix
    Codeworkx's contact with Samsung got following response [discussion]
    Update 14:56 CEST:
    Patches will be out in form of new official ROMs and also sourcecode releases after testing, which might take some time.

    6/7 Update
    Test plan posted - see bottom of post for results so far (esoteric68, krazy_smokezalot report success)
    BIG THANKS to Esoteric68 (and robertm2011 before her) who took the plunge to benefit everyone else. She has completed the test plan and more. 6 flashes of CM9, 3 flashes of AOKP, 3 wipe data/factory resets, and 3 nandroid restores, 1 stock FF02 flash, all successful. We are ready to have more testers try out the test ROM installs. We are getting more confident the code analysis was correct.

    6/2 Update
    Less technical summary and preparation for new round of testing

    5/31 Lots of discussion on the code path detailing how the problem occurs and where to put the workaround, select posts below
    Call trace for CWM Recovery - wipe data/factory reset
    Call trace for CWM Recovery - restore
    Section of update-binary afflicted by same issue as wipe data/factory reset
    Recap of where workarounds can be placed
    MD5s of various update-binary executables
    Pros/Cons of placing workaround in kernel vs libext4_utils.a
    Are ICS nandroid backup/restores safe?
    Are ICS recoveries safe?
    Why do CM9/AOKP installs often brick in ICS but not in GB?

    5/24 Update pretty much ties up all the loose ends - Thanks Mr. Sumrall, Garwynn, Entropy, and everyone else who pitched in!
    http://xdaforums.com/showthread.php?p=26521643#post26521643

    Potentially very GOOD NEWS
    It appears Sprint/Samsung tested the EMMC brick issue, confirmed the problem, and tested a fix that appears to resolve the problem:
    http://xdaforums.com/showthread.php?p=26465085#post26465085
    To clarify this...in testing done over the weekend, there was a small "subtest" group which consisted of 20 devices. This group was put together STRICTLY for the propose of testing the emmc bug and fix. The devices were all programmed with the data known to have cause bricks when wiping. Of those 20, all but 6 also had the code patch to resolve that issue, so there was a possibility for 6 hard bricks, only 4 actually bricked, therefore, on the build currently being tested, the "emmc break issue" has been deemed "resolved"



    We now have an update on why this bug is happening and which PRV/fwrevs are affected. PRV/fwrev 0x19 are susceptible to the EMMC /data corruption issue (which should now be referred to as EMMC lockup issue). PRV/fwrev 0x25 has the fix for the lockup issue but has a separate 32KB of zeros data corruption issue, which is being patched in the kernel (our kernels don't have that patch). All these problems are in the EMMC firmware. It can potentially be updated, but nothing is publicly available. EMMC lockup issue is triggered on erasing the EMMC. The only piece we have not been able to explain is why GB-based kernels seem immune to the EMMC lockup problem whereas ICS seems more susceptible to the problem. Presumably both are doing ERASE commands, but possibly in slightly different ways. See these posts for more details [#1 / #2]

    To get your PRV/fwrev, you can use this (if you have busybox installed):
    shell@android:/ $ su
    shell@android:/ # cd /sys/class/block/mmcblk0/device

    shell@android:/sys/class/block/mmcblk0/device # cat cid | cut -b 19,20
    19
    If you don't have busybox installed just visually parse the line, match the serial # (0xd3f24fe6 - example only - yours will be different) with the cid, and look at the 2 numbers before the serial #.
    shell@android:/ $ su
    shell@android:/ # cd /sys/class/block/mmcblk0/device

    shell@android:/sys/class/block/mmcblk0/device # cat serial cid
    0xd3f24fe6
    1501004d414734464119d3f24fe68e8b

    It appears after looking at the code more closely and examining the results of the card info dumps, we do not have this fix in our kernel. It isn't clear whether the fix would resolve our /data EMMC brick issues, but the point is moot right now because we don't have the fix.

    Possible BRICK here. Please do NOT do any more testing until further notice. Please do NOT use Wipe Data/Factory Reset. It is the main difference between first and 2nd round of testing and is the current suspect

    FE10 repacks added to Resource section

    Esoteric68, azyouthinkeyeiz, and robertm2011 are testing flashing different ROMs with FE07/FE10 repacked with unlocked recovery. We all owe them our thanks for risking their phones to help the community (taking one for the team) No bricks so far.

    Separately we are still discussing whether the fix Samsung checked in will get applied to our phone. No firm conclusions yet. Even if it doesn't apply, the hope is the data we get from testing will help us produce more flexible "safe" flashing practices.

    Please do NOT test CWM Touch for now. We want to isolate just the FE07 kernel and unlocked stock recovery before introducing new variables.


    Executive Summary
    Garwynn has found a recent checkin from Samsung in the kernel code handling EMMC memory that fixes a data corruption problem. It is possible this might fix the /data EMMC corruption we have been seeing, but we aren't sure if it is fixing the same problem. The first release to include that checked in code is FE07. There has been some communication with the developers in charge of that area to gather further info.

    This thread's purpose is to foster discussion on the issue and to determine if the potential fix actually does fix our issue. Even if the fix doesn't address the issue, it is hoped in the process we are able to gather more info into specific "safe" and "unsafe" scenarios.

    Please do NOT jump ahead and think it is fixed. It is TOO EARLY to make that claim.


    Background
    As many of you are aware since ICS has come out, there has been a nagging issue where in some situations flashing ROMs with an ICS-based kernel and custom recovery has left the phone with EMMC corruption. This EMMC corruption is so far non-recoverable, even with JTAG bit blasting, which should bypass all but hardware issues.

    This problem is NOT limited to the Epic 4G Touch. Other GS2 models as well as Galaxy Note are experiencing the same thing as can be seen by this Public Service Announcement in the Galaxy Note section.

    The problem first cropped up when people used ROM Manager to temporary "fake" flash CWM Touch onto an ICS-based kernel to do their flashing needs. In particular wipe data/factory reset seemed to often trigger the /data EMMC corruption. However later we found it wasn't limited to just CWM Touch and temporary flashing as CWM repacks with the ICS-based kernel also exhibited that behavior, albeit not as often.

    Even more frustrating is that this bug is not always deterministic, in that you could do some operation 3 times and have it work fine, then on the 4th, trigger the /data EMMC corruption.

    Complicating the testing/debugging is the issue that once the problem is triggered, your phone is basically not recoverable. You can try and ODIN a stock ROM on top which will basically work for all the components except the /data partition. Once it reaches the /data partition, ODIN will hang. Similarly if you try and wipe data/factory reset, it will hang or timeout after a while. Attempts to repartition and reformat using ODIN have not changed this behavior. Attempts to edit the partition info manually have not been successful. JTAG bit blasting has not been successful.

    You can read about the past experiences in the Stuck at "Data.img" thru odin thread. By the time you get to ODIN, the damage to /data EMMC is already done. ODIN is NOT causing the damage. ODIN is hanging on data.img because the hardware won't let it write successfully to that area of EMMC.

    This has led to many custom ROMs giving special procedures to go back to a GB-based kernel repacked with CWM recovery to do all your flashing (EL26+CWM). It is also the motivation for the How Not To Brick Your E4GT thread.


    Details
    The code checkin that has piqued our interest is in regards to data corruption caused by problem in the wear-level firmware code of the emmc. This is low-level code that runs on a processor in the emmc module. It basically tries to spread out the data writes so you get an even distribution of writes so as any one section of emmc memory does not get worn out prematurely. This code apparently can corrupt data by writing 32KB of incorrect data under some situations.

    https://bitbucket.org/franciscofranco/android-tuna-omap/changeset/cea631bdac53

    The code appears to restrict the firmware fix to only certain "affected" emmc modules. Also it is not able to persistently/permanently patch the firmware so this code must run at each startup. The following modules were identified in the code:

    Name: VYL00M
    HwRev: 0x0
    FwRev: 0x25

    Name: KYL00M
    HwRev: 0x0
    FwRev: 0x25

    Name: MAG4FA
    HwRev: 0x0
    FwRev: 0x25

    Unfortunately during ad-hoc polling we have found a case of an EMMC /data bricked phone with fwrev 0x0, so either we are not understanding what Samsung's fix is doing or they may not have addressed the full scope of the problem. Do NOT assume if your fwrev is 0x0 you are safe.

    At this point, this does NOT mean the fix is not applicable. We might be looking at the wrong data. The kernel might not be exporting the data to us. The fix might need to be expanded to more modules. The fix could be for something else entirely but we might be able to avoid the bug anyway using stock recovery.

    To determine what version you have (keep in mind we are at the preliminary stage, so this info might not be the right info to collect or could be meaningless for the /data EMMC corruption issue)
    shell@android:/ $ su
    shell@android:/ # cd /sys/class/block/mmcblk0/device

    shell@android:/sys/class/block/mmcblk0/device # cat name hwrev fwrev manfid oemid date type serial cid
    MAG4FA
    0x0
    0x0
    0x000015
    0x0100
    08/2011
    MMC
    0xd3f24fe6
    1501004d414734464119d3f24fe68e8b

    The comments for the code checkin give the following info:
    /*
    * There is a bug in some Samsung emmc chips where the wear leveling
    * code can insert 32 Kbytes of zeros into the storage. We can patch
    * the firmware in such chips each time they are powered on to prevent
    * the bug from occurring. Only apply this patch to a particular
    * revision of the firmware of the specified chips. Date doesn't
    * matter, so include all possible dates in min and max fields.
    */

    The critical piece of code appears to be the following:
    Code:
    	/* set value 0x000000FF : It's hidden data
    	 * When in vendor command mode, the erase command is used to
    	 * patch the firmware in the internal sram.
    	 */
    	err = mmc_movi_erase_cmd(card, 0x0004DD9C, 0x000000FF);
    	if (err) {
    		pr_err("Fail to Set WL value1\n");
    		goto err_set_wl;
    	}
    	/* set value 0xD20228FF : It's hidden data */
    	err = mmc_movi_erase_cmd(card, 0x000379A4, 0xD20228FF);
    	if (err) {
    		pr_err("Fail to Set WL value2\n");
    		goto err_set_wl;
    	}

    Action items
    At this point we would like to

    1) gather more info on which emmc modules folks have and see if we can detect any patterns, so if you could post your EMMC info and optionally include whether you have the ability to do testing (presumably because you have a way to replace your phone if it is damaged)

    2) solicit one volunteer to try different flashing scenarios using the unlocked stock recovery and FE07 kernel repack (bigpeng indicated earlier he would be willing to do this for the community, but that was before the fwrev info, so he might have had a false sense of security, so no pressure on him if he changed his mind)

    If we find that the volunteer does not see any corruption despite trying to do so, then we can expand testing to a few more people and also work on getting CWM repacks.

    If the volunteer hits the bug, then we will know the issue is still there even with stock recovery and FE07 kernel.

    Keep in mind, at some point someone will need to take one for the team or we will be forever in fear of bricking our phones using ICS-based kernels.


    Resources

    1) FE07-based repacks
    Unlocked Recovery Only [update.zip / tar]
    Plus (unlocked recovery, init.d, adb-root) [update.zip / tar]

    2) FE10-based repacks
    Unlocked Recovery Only [update.zip / tar]
    Plus (unlocked recovery, init.d, adb-root) [update.zip / tar]

    3) JEDEC eMMC documentation

    Related threads
    Galaxy Note CID investigation thread
    30
    I posted this less technical writeup on agat63's cwm repacked thread but figured it would be useful to have here also. I am working with CM9/AOKP to have their install scripts replace format("/system") with delete_recursive("/system") After that I think if we still have volunteers, we are ready to do some more testing.

    I'll provide more details when the pieces become available, but if you'd like to take one for the team and help test, please post. If our understanding of the problem is accurate, you should be safe this time around, but there is always the chance we are not understanding the problem completely.

    ====

    I would like to stress that the information I gave agat was based on code tracing and NOT based on real-world testing. You should treat this as a *testing period* to confirm the analysis. You MAY BRICK if the analysis is incorrect.

    The following is all assuming you are repacked with ICS kernel (ie we aren't talking about the GB kernel)...

    Background
    The nature of the problem is a call to the function make_ext4fs(). This function isn't provided by the kernel, rather it is provided as a library (libext4_utils.a) that is used when compiling Recovery and the update installer. It does end up eventually calling kernel mmc driver routines, which then trigger the EMMC firmware lockup/superbrick bug.

    The make_ext4fs() function changed between GB and ICS. In GB the function didn't try to erase the partition before creating the EXT4 fs. In ICS it tries to erase it first. The erase is triggering an EMMC firmware bug that was always there via the kernel MMC driver. GB is also "doubly" safe in that not only do Recovery and update-binary never attempt to do the erase, even if they did, the request to erase is blocked in the GB-kernel and never run.

    The EMMC firmware bug will lockup your phone and corrupt internal EMMC meta-data which cannot be accessed or repaired at this time. It isn't crashing your hard drive per-se, it is crashing your hard drive controller in a way that prevents the hard drive controller from accessing parts of your disk. We don't have any way of updating the EMMC hard drive controller at this time.

    The EMMC firmware lockup/superbrick bug is likely contained in the wear-level firmware code which shifts mmc-internal memory block usage around to prevent any one area from overuse. The bug MIGHT NOT be triggered every time, so you can do the same operation with no issues then on your Nth attempt it bricks.

    Details
    So what does that mean for you? There are 2 executables we are concerned with, Custom Recovery and the update installer (update-binary)

    Custom Recovery is responsible for 2 potential bricking points:
    1) wipe data/factory reset
    2) nandroid backup/restore

    These are both handled by the Recovery itself so if your Recovery is "safe" then these operations should be safe. The nandroid backup is safe regardless. Our concern is only for wipe data/factory reset and nandroid restore. Both of these make the call to make_ext4fs(), so if they are using the GB-based version they are safe. If they are using the ICS version, they are not safe (when used with ICS kernel) Agat has made the effort to make sure the recovery he has provided is compiled against GB CM7 source.

    You may ask what about Installing ROMs, you thought Recovery was responsible for that too?
    This is only partially true. You use the menu option in Recovery to choose to install an update.zip. Recovery is responsible for providing the location of the update.zip and verifying the signature, but when it comes to actually "installing" the update.zip, Recovery uses a "helper app" called update-binary contained in the update.zip.

    This update-binary helper app is responsible for running the Edify install script in the update.zip. It communicates with Recovery just to update the progress bar, output ui messages, and set up the updating of firmware. The rest of the script functions, it handles by itself directly, so Recovery isn't involved.

    update-binary also calls make_ext4fs() so it can also do potentially "unsafe" operations, just like we discussed for Recovery above. If the update-binary, that was included in the update.zip, was compiled using GB-sources, then it is "safe". If it was compiled against ICS sources then there is one function in the Edify script that can potentially cause bricking, format().

    To be clear, Recovery has no control over the update-binary that is included in the update.zip. Whomever built the ROM update.zip package made that decision. So this is why even with a "safe" Recovery, you can brick your phone installing ROMs (with an ICS kernel).

    Even if the Recovery is "safe", if you ask it to use an "unsafe" update-binary to install a ROM AND that ROM install script chose to do a format(), then the EMMC lockup/superbrick bug can be triggered.

    The reason why most stock-based ROMs don't brick in ICS is because
    1) most of them probably include a GB-based update-binary
    2) most of them are not performing a format() within their Edify updater-script

    So a ROM builder has 2 ways to make a ROM update.zip install "safe" to install in ICS. Either package a known GB-based update-binary OR eliminate format(), if present, from the Edify install script.

    So why does Calk's format_all seem to never brick even on ICS? Given the date on the update-binary and when he created the package, it is most likely using a GB-based update-binary

    So why does CM9/AOKP seem to brick more often than stock-based ICS ROM installs? The Edify install script for CM9/AOKP uses new functions that were introduced in the ICS update-binary. This in turn is why they bundle the ICS-based update-binary. They could still potentially be safe, but in the install script a format("/system") is performed. If that format is run under an ICS kernel it will trigger the EMMC firmware lockup/superbrick bug. Under a GB-kernel, the request to erase "/system" is blocked by the GB-kernel.

    What can CM9/AOKP do to make their installs "safe" to install in ICS? All they need to do is replace the format("system") with delete_recursive("/system"). They could also replace the ICS-based update-binary with a GB-based update-binary, but that would require more rewrites to the install script. Replacing the format() call is simpler/easier.

    Why are some superbricks blue-light specials and others only make ODIN hang at data.img? This likely has to do with whether you got your brick from

    1) the format() in the CM9/AOKP install
    2) restoring nandroid backup
    3) doing the wipe data/factory reset in Recovery

    The first two tend to be blue-light specials as they affect /system and/or kernel. The last one tends to affect /data and/or /cache.

    So how do you make sure you are totally safe?
    1) make sure you are using a "safe" recovery repacked with the stock ICS kernel. This is a Recovery that was compiled against GB-based libext4_utils.a (ie GB source) This will assure you that wipe data/factory reset and nandroid restores are safe
    2) whenever you install a ROM for the first time, verify EITHER
    a) the ROM install script is NOT performing any format() calls
    b) the ROM install has bundled a GB-based update-binary

    If neither 2a NOR 2b are true (ie ICS-based update-binary and install performs format) then you DO NOT want to flash that ROM in Recovery while on an ICS kernel. Flash that ROM on a GB-based kernel/recovery.

    Hope that clears things up, and once again, remember, this analysis is only based on tracing code. I may have made a mistake in the analysis or our understanding of the problem could be wrong. We will not be sure if all these statements hold UNTIL WE DO REAL-WORLD TESTING.
    19
    Morning Update

    Well, it's been some time but thankfully Mr. Sumrall from Android did get back to us on our questions. I think the community will find that this was worth the wait.

    Issue: fwrev not set properly.
    As we suspected the bugfix is not in our build. (The patch applies this unconditionally.)
    Ken Sumrall said:
    The patch includes a line in mmc.c setting fwrev to the rights bits from the cid register. Before this patch, the file /sys/class/block/mmcblk0/device/fwrev was not initialized from the CID for emmc devices rev 4 and greater, and thus showed zero.

    (On second inquiry)
    fwrev is zero until the patch is applied.

    Question: Revision didn't match the fix
    (Emphasis mine in red as it discusses the superbrick issue.)
    Ken Sumrall said:
    You probably have the bug, but rev 0x19 was a previous version of the firmware we had in our prototype devices, but we found it had another bug that if you issued an mmc erase command, it could screw up the data structures in the chip and lead to the device locking up until it was powered cycled. We discovered this when many of our developers were doing a fastboot erase userdata while we were developing ICS. So Samsung fixed the problem and moved to firmware revision 0x25. Yes, it is very annoying that 0x19 is decimal 25, and that led to lots of confusion when trying to diagnose emmc firmware issues. I finally learned to _ALWAYS_ refer to emmc version in hexadecimal, and precede the number with 0x just to be unambiguous.

    However, even though 0x19 probably has the bug that can insert 32 Kbytes of zeros into the flash, you can't use this patch on devices with firmware revision 0x19. This patch does a very specific hack to two bytes of code in the revision 0x25 firmware, and the patch most likely will not work on 0x19, and will probably cause the chip to malfunction at best, and lose data at worst. There is a reason the selection criteria are so strict for applying this patch to the emmc firmware.

    I passed on our results a few days later mentioning that the file system didn't corrupt until the wipe. This is a response to that follow-up.

    As I mentioned in the previous post, firmware rev 0x19 has a bug where the emmc chip can lockup after an erase command is given. Not every time, but often enough. Usually, the device can reboot after this, but then lockup during the boot process. Very rarely, it can lockup even before fastboot is loaded. Your tester was unlucky. Since you can't even start fastboot, the device is probably bricked. :-( If he could run fastboot, then the device could probably be recovered with the firmware update code I have, assuming I can share it. I'll ask.

    Question: Why the /data partition?
    Ken Sumrall (Android SE) said:
    Because /data is the place the chip that experiences the most write activity. /system is never written to (except during an system update) and /cache is rarely used (mostly to receiving OTAs).

    Question: Why JTAG won't work?
    Ken Sumrall said:
    As I mention above, the revision 0x19 firmware had a bug that after an emmc erase command, it could leave the internal data structures of the emmc chip in a bad state that cause the chip to lock up when a particular sector was accessed. The only fix was to wipe the chip, and update the firmware. I have code to do that, but I don't know if I can share it. I'll ask.

    Question: Can a corrupted file system be repaired (on the eMMC)?
    Ken Sumrall said:
    e2fsck can repair the filesystem, but often the 32 Kbytes were inserted at the start of a block group, which erased many inodes, and thus running e2fsck would often result in many files getting lost.

    So, while the fix doesn't apply to us at the moment, we've been given a great insight into the superbrick issue as well as information that a fix is already developed (hopefully we'll see it released!). The bug likely applies to us and assuming the fix for the 0x19 firmware is given then it would apply to our devices.

    On a lighter note, I wanted to include his close:
    Ken Sumrall said:
    You are getting a glimpse into the exciting life of an Android kernel developer. :) Turns out the job is mostly fighting with buggy hardware. At least, it seems that way sometimes.
    18
    5/24 Update

    Fresh off the press...

    Q: Do you know the commands to reset the eMMC controller in question?
    Ken Sumrall (Android) said:
    Once the chip has locked up, no command will reset it. It must be power cycled. If instead you are asking how to clear the metadata so the chip works again, the only solution I know is to update the firmware inside the chip, and that also wipes all the data. This probably includes factory calibration data that must be saved before the firmware is updated, and restored after. Also, the boot loader is probably in the chip, and must be restored after the firmware update, or the device will be bricked. This is a dangerous operation, because if something goes wrong, the device will probably be bricked. (emphasis added)

    Q: Is there any documentation available on this issue? If so and it is private is it possible to have it released?
    Ken Sumrall (Android) said:
    It is private, I'm asking if I can release it, along with the code to update the emmc firmware. Don't get your hopes up, my guess is the answer will be no.

    Q: Alternate erase method?
    Ken Sumrall (Android) said:
    If you really want to erase data on a rev 0x19 samsung emmc chip, I suggest you just write zeros to the entire partition.

    Q: Difference between GB/ICS Wipe
    Ken Sumrall (Android) said:
    IIRC, when using recovery to wipe the phone on GB, the make_ext4fs() library would not issue an erase command first, it would just write one a new blank filesystem. This, of course, doesn't really erase all the private data of the user, so we changed make_ext4fs() to first erase the partition, then write out the new filesystem. You can see the code in system/extras/ext4_utils/wipe.c, which didn't exist in gingerbread, but does in honeycomb and later. It is the erase operation on the rev 0x19 firmware that can cause the emmc chip to lockup. (emphasis added)

    Regarding Entropy512's summary of observations:
    Ken Sumrall (Android) said:
    Regarding the notes on MMC_CAP_ERASE, the just lists the cards ability to perform the erase command. In other words, if the mmc_erase() function works. What is more important is if anyone calls the mmc_erase() function. Looking at the mmc driver, in drivers/card/block.c, it is only called when a secure discard or discard request is made. As far as I know, those requests are only sent if the filesystem is mounted with the "discard" option, or if userspace code does an ioctl() to erase a partition, like make_ext4fs does. So check the mount options on the filesystems. *If they don't specify "discard", the erase operations are probably not happening.

    Of course, a simple debugging printk() in the mmc_erase() function will tell you if anyone is calling it.

    Additional info not directly related to questions:
    Ken Sumrall (Android) said:
    The lockup doesn't happen immediately after power-on. The chip doesn't lock up until a sector is referenced that has corrupted wear leveling data inside the chip. Once that sector is referenced, the chip will lockup hard, and the only thing that will get it talking again is to power cycle it. Once it is power cycled, the chip will talk again, until that bogus sector is accessed.
    16
    I was able to confirm with chris41g and T.C.P that the update-binary, included with both the CM9 and AOKP ROM update.zip files, was compiled against ICS source code.

    This means that this update-binary can potentially trigger the EMMC firmware lockup/superbrick bug if "format()" is used in the Edify install script. Both CM9 and AOKP updater-script format("/system") as part of their installs.

    This explains why they brick so often with the bluelight-only style brick, it is because the format("/system") elicits the lockup when make_ext4fs() is called on the /system partition and eventually results in an mmc_erase(). With a boarked /system, you are left with the blue-light special and ODIN will hang on factoryfs.img.

    The other style of brick is the one that hangs on the logo. That one is caused by Wipe Data/Factory Reset from an "unsafe" cWM Recovery. Just as above, the "unsafe" CWM Recovery would have been compiled against the ICS libext4_utils.a and make_ext4fs() would be called on /data and /cache. Eventually that would lead to mmc_erase() being called. With a boarked /data, you are left with a phone that hangs on the log and ODIN will hang on data.img

    As an aside, I now believe the main "unsafe" Recovery we were dealing with was CWM Touch fake-flashed onto the ICS kernel. I don't have the source code for CWM Touch, but I believe it was compiled against the ICS libext4_utils.a. I am not sure if Rogue CWM repacked with an ICS kernel was compiled against ICS sources, but the version that Steady checked into github was not.

    Now previously I recall discussions where it was determined that GB source/kernels also had mmc_erase() and it was an open question why, if both GB and ICS had mmc_erase(), Recovery Wipe Data/Factory Reset would brick one but not the other. Well we finally got the answer to that, the GB version of make_ext4fs() from libext4_utils.a did not perform the ioctl() calls which would eventually lead to mmc_erase() being called, while the ICS version of libext4_utils.a had the ioctl() calls.

    Now if you've been following closely so far, you may be wondering why if the update-binary that is bundled with both CM9 and AOKP ROM update.zip files is using the ICS version of libext4_utils.a (that makes the ioctl() calls which lead to mmc_erase()) it doesn't brick when run under a GB-kernel/CWM. Both ICS and GB have mmc_erase() functionality so it should brick both right?

    Well I wondered the same thing, went digging a little, and believe have found the answer.

    It turns out that even though the GB kernel MMC driver has mmc_erase() the ioctl() calls that would eventually lead to mmc_erase() being called were ifdef'd out. So if you had an "unsafe" update-binary which made the ioctl() calls, they would NOT result in mmc_erase() being called when the ROMs update.zip was run under a GB kernel/recovery.

    Previously the discussion centered around MMC_CAP_ERASE as the explanation, which I believe is a red-herring. This is neither a pre-processor directive nor a direct control mechanism. It is a bit field used to specify whether an MMC device supports the capability of doing erases. It was not ifdef'd out of GB so the functionality was still there.

    The actual conditional compile was on the ioctl() function for mmc cards, which was basically disabled under GB kernels. This is how I came to that conclusion:

    Notice in the kernel config file Samsung provided, both CONFIG_MMC_DISCARD and CONFIG_TARGET_LOCALE_NTT are disabled.

    .config
    Code:
    # CONFIG_MMC_DEBUG is not set
    [B][U]# CONFIG_MMC_DISCARD is not set[/U][/B]
    CONFIG_MMC_UNSAFE_RESUME=y
    # CONFIG_MMC_EMBEDDED_SDIO is not set
    # CONFIG_MMC_PARANOID_SD_INIT is not set
    Code:
    # CONFIG_MACH_C1_NA_SPR_EPIC2_REV00 is not set
    # CONFIG_TARGET_LOCALE_EUR is not set
    # CONFIG_TARGET_LOCALE_KOR is not set
    [B][U]# CONFIG_TARGET_LOCALE_NTT is not set[/U][/B]
    CONFIG_TARGET_LOCALE_NA=y

    Now if you look at the mmc block device driver, due to the kernel config above, the ioctl() function call in the function table is left unpopulated. This basically means ioctl() calls are not supported for the mmc device (based on E4GT GB source, don't know about other platforms).

    drivers/mmc/card/block.c
    Code:
    static const struct block_device_operations mmc_bdops = {
    	.open			= mmc_blk_open,
    	.release		= mmc_blk_release,
    [B][U]#ifdef CONFIG_MMC_DISCARD[/U][/B]
    	.ioctl			= mmc_blk_ioctl,
    [B][U]#endif[/U][/B]
    [B][U]#if defined(CONFIG_TARGET_LOCALE_NTT)[/U][/B]
    #if 0 //def CONFIG_MMC_CPRM
    	.ioctl			= mmc_blk_ioctl,	//int (*ioctl) (struct block_device *, fmode_t, unsigned, unsigned long);  in blkdev.h
    #endif
    [B][U]#endif[/U][/B]

    Now when the "unsafe" update-binary from CM9/AOKP is paired with a GB kernel the wipe.c from libext4_utils.a will try and make these calls:

    system/extras/ext4_utils/wipe.c
    Code:
    int wipe_block_device(int fd, s64 len)
    {
      u64 range[2];
      int ret;
    
      range[0] = 0;
      range[1] = len;
    
      ret = [B][U]ioctl(fd, BLKSECDISCARD, &range);[/U][/B]
    
      if (ret < 0) {
        range[0] = 0;
        range[1] = len;
        ret = [B][U]ioctl(fd, BLKDISCARD, &range);[/U][/B]
      }
      return 0;
    }

    I believe that both those calls have basically been disabled because ioctl() calls are not supported in the mmc block device driver under the GB kernel (for E4GT EL29 GB kernel source).

    So what does that all mean?

    I believe GB systems are doubly "safe". The kernel will not execute mmc_erase() even though the functionality is there because the ioctl() call entry point from user space to kernel space has been disabled and also GB recovery and GB update-binary never even attempt to make the ioctl() calls.

    That explains why, if you pair an "unsafe" update-binary from the CM9/AOKP ROM update.zip with a GB kernel, it is still safe.