[Captivate General] modest_mandroid:
- Introduction -

This is a primer on why phones get bricked, how to recover from a brick, and how to prevent bricking your expensive hardware. I wrote this because I noticed the same questions popping up over and over, perhaps due to an instant onset of panic, from people that bricked their phones and there doesn't seem to be a single stickied thread that is dedicated to bricks. Sorry for my inability to be brief, but I would still highly recommend that you read this article in its entirety.

- The Android Boot Process -

In order to get a good understanding of why phones brick, we must have a good understanding of the boot process. All android phones have a similar boot process, so most of this information should be applicable to the i897 and any other Android handset.

So, here is what happens when you press the power button on your phone.

1. BOOT ROM - Your phone waits for the power to stabilize, then runs a piece of code that is stored in permanent rom on your cpu called the Boot Rom. The main job of this code is to detect the boot media and load it into memory (in this case, it is the First Stage Bootloader). This code is hard wired and can never be overwritten.

2. First Stage Bootloader - Once the boot rom loads the boot media, it hands control over to the First Stage Bootloader (you may see this in some roms as boot.bin). The job of this bootloader is basically to "find more ram" and load the second stage bootloader into it. When computers first boot up (even PC's), the default memory model usually only allows for very tiny programs to be loaded into memory. For this reason, there is usually two bootloaders, the first of which detects and sets up external ram and loads the second stage bootloader into it. NOTE: The first stage bootloader can be overwritten! If you damage your bootloader, you will have a permanent UNRECOVERABLE brick at this point!

3. Second Stage Bootloader - The first stage bootloader hands off execution to the Second stage bootloader (you may see this in some roms as sbl.bin) once it is loaded into memory. The job of the SBL is to "set everything up" so the main kernel can take over. It is in charge of setting up the file systems, setting up any additional memory, setting up all the hardware, bringing up the modem cpu and setting any sort of low level security that may need to be set. Fun fact: This is where your 3 button combo and "download mode" is handled. Once the hardware is set up, the sbl will look for the kernel. NOTE: The SBL can also be overwritten, meaning if you damage your SBL, you can lose your ability to boot into download mode and thus have a permanent, unrecoverable brick!

4. Kernel - The kernel, if one were to put it simply, is essentially "the os". I know there is far more to it, especially in the case of Android with Dalvik providing most of the things we typically think of as "Android". But for all intents and purposes, the kernel is the core part of the OS that handles all of the hardware interrupts, memory management, memory protection, manages file systems and drivers, threading and access to the processor, and so forth. Once the kernel is loaded into memory, it sets up anything else that needs to be set up, loads Dalvik, and from there the rest of Android is brought up. Fun fact: This is where recovery resides. NOTE: You can still brick your device at this step, though it is only a soft brick and very recoverable - nothing to lose sleep over.

Now that you have a general understanding of how Android boots, let's move on.

- But my phone is bricked -

You probably arrived at this article because it's too late and you've already botched something. You've probably read through the first part and are thinking "Ok professor, that's all good and well, but my phone is dead. Do I have to shoot myself in the head now?" The short answer is "Maybe."

The most important part of analyzing a brick is to figure out what part of the boot procedure it crapped out on. Fortunately, most of the time this is pretty easy to figure out IF YOU REMEMBER WHAT YOU WERE DOING IMMEDIATELY BEFORE THE BAD THINGS HAPPENED. If you look at the previous section, you'll notice a color coding of the various boot steps.

The reason why bad things happen to good telephones is something bad is happening during the boot process, preventing successive stages from completing. If you were flashing a rom (either through CWM or Odin) that included bootloaders and you saw that it died somewhere around the part where it was flashing boot.bin or sbl.bin, you may have a hard brick. If you think about it, it makes sense logically. It's crapping out at the part (or before) where the code that handles the key combos for download mode is being set up. If you've damaged that part of the process, there aren't really any other (easy) alternatives.

Here is a good barometer for checking if you have a hard brick:: Does something show up on your screen when you press power? (This can literally be anything - error messages, boot loops, naked chicks, that infuriating AT&T logo). If it does, congratulations! You're probably in the orange section of the boot process and can recover your phone. If not, and no matter how many times you mash the power button it stays at a black screen, you probably messed it up somewhere in the red part of the boot process and have a hard brick.

- How to recover from a brick -

If you have a hard brick (Black screen, power button isn't doing anything, multiple battery pulls didn't get you anywhere), you're probably out of luck. Sorry, dude. You can still recover it, but it'll require some surgery on your part.. You'll have to order a riff box (http://www.jtagbox.com/), remove the motherboard, and connect it to the riff box and flash your two bootloaders back onto the rom chips directly. Or, you can just do what everyone else here does and mail it back to Samsung or AT&T, with some story about how kies wrecked your junk and you have no idea wtf.

If you have a soft brick (something shows up on your screen), it's just a matter of getting your phone into recovery or download mode. Basically, when dealing with a soft brick, you want to be as unintrusive as possible to NOT MESS IT UP WORSE THAN YOU ALREADY DID. So here are a few basic procedures.

1. Don't panic.

2. Can you get into recovery?

Pull the battery out.

Put the battery back in!

Press and hold Volume Up, Volume Down, and Power, and wait until something shows up on the screen.

Release power! Keep holding Vol up+Vol down.

Did it go into recovery?

If that worked, try flashing a different kernel from recovery. If it still doesn't work, it's probably not the kernel but something else in the rom, so flash a different rom altogether. NOTE: The key combo for recovery is different with the new 2.3 bootloaders! It is now Vol up+power instead of Vol up+Vol down+Power.

3. If not, boot it into download mode.

Pull the battery out and make sure the phone is NOT connected by a usb cable.

Put the battery back in!

Hold vol up+Vol down. DO NOT PRESS POWER.

Plug in the USB cable.

NOTE: The key combo is different with the new 2.3 bootloaders. It is now Vol down+Power. You no longer need to connect the usb cable.

The phone should boot into download mode. If it still does not, you can try using a USB jig. They are very easy to build - it is just a 301k resistance across pins 4 and 5 of the microusb slot. You can find plenty of instructions by searching the General section. You can also find a usb breakout board here: http://www.sparkfun.com/products/10031 and 100k (make sure it's 100k and not 100) resistors at radio shack. To use the jig, simply pull the battery out, put the jig in the microusb slot, DO NOT TOUCH THE JIG WITH YOUR FINGERS AS YOU MAY CHANGE THE RESISTANCE, and put the battery back in. It should kick you into download mode within 3 seconds.

Once you are in download mode, flash back to stock. Refer to the Odin guide at the end of this article for instructions. ***NOTE***: DO NOT FLASH A ROM THAT INCLUDES BOOTLOADERS - THIS INCLUDES THE ODIN ONE CLICK PACKAGE - IT IS AN UNNECESSARY RISK AS YOUR PHONE ALREADY HAS PROPER WORKING BOOTLOADERS

I actually don't like the one-click package very much in general, simply because there seems to be an element of randomness around it. It seems to work with a certain build of phone, and seems to cause problems with newer phones.

- You may have to flash bootloaders -

So you're probably thinking, "What if I don't have a working 3 button combo?" Someone correct me if I'm wrong, but to my understanding a certain batch of phones were shipped out with corrupt sbl's. If you're one of those unlucky folks that has a phone with a busted 3 button combo, you'll have to flash new bootloaders to fix it. There is a bootloader fix package you can flash somewhere in the dev section, and if I'm not mistaken, the Cognition rom also flashes properly working bootloaders.

You will also have to flash new bootloaders if you want to upgrade from 2.1/2.2 to the official Samsung 2.3 roms (or any custom roms based off of the official 2.3's). Don't try to flash these individually if you happen to find them somewhere. The best way to get the new bootloaders is to download the stock JVB rom from www.samfirmware.com and flash it using Odin3.

Be warned - by flashing bootloaders, you may brick your phone permanently. Remember, you're flashing the red part of the boot process at this point. If things go boom, your phone ends up in an unrecoverable state. The chances of it crapping out while flashing the bootloaders may be a million to one, but there's still a chance it might happen and I've seen people brick their phone from this several times.

Be warned #2 - If you've successfully flashed working bootloaders, don't flash other bootloaders for sport. There isn't any point to it and it doesn't give you anything "extra", and even though the chances of things going sour are slim, keep it up and sooner or later you'll end up with an unresponsive device.

Be warned #3 (for 2.3 people only): Do not flash roms or odin packages that include bootloaders. I'm not entirely sure why some phones are bricking when being flashed back to stock, but something tells me that some of the odin packages are only flashing the second stage bootloader instead of both the first stage and second stage. There is probably some major incompatibility between the 2.1/2.2 first stage bootloader and the 2.3 sbl (perhaps the 2.3 sbl has a different entry point?). Either way, I've noticed that some people have perma-bricked their devices trying to flash back to stock using some of the odin packages. Flashing back to stock using a package that contains both the main bootloader and sbl should be fine (in theory), but I have not tried it and don't know how things will end up. If someone has, let me know and I'll ad it to the guide! Also - there isn't much of a point of going back to the old bootloaders once you have the new ones. I tried flashing 2.1 (JH2) and 2.2 (Serendipity 6.3) roms with the new bootloaders and everything works as expected. I didn't experience any problems or instability with either rom, and was able to boot into download mode and recovery with both.

edit: Apparently some people are reporting success with Odin one-click (JF6). Dunno dudes! Flash at your own risk.

edit edit: According to TRusselo, the odin one-click downloader (JF6) flashes both bootloaders, so it should be fine to use it to flash back to stock. Keep in mind that the JF6 one-click downloader does not work with certain handsets, and if yours is build# 1010 or above (you can check your build number by removing your battery, it should be printed on a label in the battery compartment), you should refer to this guide for how to flash back to stock:

http://xdaforums.com/showpost.php?p=10056254&postcount=36

Also, I'm pretty sure the above guide will NOT flash new bootloaders. If for whatever reason you really really need the old bootloaders, I would suggest finding a package on samfirmware.com that flashes BOTH bootloaders.

- How to prevent perma-bricking -

Soft bricking is always going to happen. It's a minor software error that isn't a big deal, and common when we fiddle with our devices in ways the manufacturer never intended. The thing we worry about is hard bricking, which is fortunately for us, is easy to prevent!

Here are a few simple rules to help you avoid disaster:

Don't flash roms that flash bootloaders (sbl.bin)

Don't try to flash bootloaders individually.

If you have working bootloaders and can do the 3 buttom combo, don't use Odin packages that include bootloaders, they are an unnecessary risk.

Don't flash when you know your battery is low! Seriously, I see this happening all the time. We know you're excited about a new rom, but it can wait. Put your phone on the charger and let it sit there for a while until you have >50% charge.

Don't mess with your boot partition. I noticed CWM has an option to format your boot partition; I have no idea why.

- Odin guide -

You can find odin by searching the dev section. I use odin3 1.0 simply because that is what I have. I don't know if other versions are better or more stable, but it kind of doesn't matter if you aren't flashing bootloaders anyway.

There are a few videos in this thread: http://xdaforums.com/showthread.php?t=919816 But I'll try to explain in text anyway.

So the first thing you need to do is DOWNLOAD THE DRIVERS! Odin won't recognize your phone in download mode if you don't have the proper drivers. You can find them here:

Windows 64bit: http://www.mediafire.com/?3dh4d6up72me9re

Windows 32bit: http://www.mediafire.com/?0b45zo7o75rc5d5

The next thing you want to do is find a rom to pop in to odin. There are a few in the dev section. There are also a lot of completely stock roms at www.samfirmware.com (WARNING: most of these include bootloaders). When I need to flash back to stock, I use this one: http://xdaforums.com/showthread.php?t=751518 as it does not include bootloaders.

Open Odin and you'll notice a bunch of options. You can ignore most of them. Here is what you need to do: examine your rom package that you downloaded. If it was from samfirmware.com, just pick the files that correspond to the option name, ie if the file starts with PDA, put it in the pda slot. If it starts with CRC, put it in the CRC slot. If it's a rom you found on here, it should have come with instructions, so refer to those.

Choose a pit file. The rom should have come with a pit file, but if it didn't, you can use any pit file and it should work fine. Seriously dudes, the differences between the different pit files is negligible, there isn't any mysticism around how they work.

Unless otherwise noted, leave F. Reset Time and Auto Reboot checked. There isn't any need for repartitioning unless you are flashing back to stock from Cyanogenmod 7, in which case you NEED to select repartition.

The next thing you need to do is put your phone into download mode. Once it's in download mode and odin is set up properly, connect it to the computer. It should show up in odin under ID:COM. Once it's there, simply hit start and kick back for a while until it's done. It should reboot and you should be in Android 2.1 JH2.

*If you are using the Odin One-click downloader (JF6), the process is greatly simplified. Simply open odin, put your phone into download mode, connect it to the computer via usb, wait for odin to recognize it and hit start. Also, keep in mind that the one click downloader will flash bootloaders.

Edit: I just remembered something important. MAKE SURE YOU PLUG YOUR CABLE INTO A USB PORT THAT IS DIRECTLY CONNECTED TO THE MOTHERBOARD, OR ODIN WILL NOT RECOGNIZE IT. This usually means a usb port on the back of your computer. So, if you've installed the drivers and odin still isn't recognizing your phone, you might want to try different usb ports. If it's still not recognizing your phone, you might have a bad cable.

- Some additional ways to get into download mode or recovery -

Just thought I should point this out - you can get into both download mode and recovery through adb. You can download adb by downloading the android sdk at http://developer.android.com. It is in the 'platform-tools' folder.

To get into recovery, simply connect your phone and type 'adb devices' to make sure it is being detected. If it shows up in the list of devices, type 'adb reboot recovery'.

To get into download mode, do the above, but type 'adb reboot download' instead.

**Belatedly amending this document in lieu of old man Outler's unbrickable mod. Any place you see the word "unbrickable" in the article above, take it to mean "unbrickable (if the mod hasn't been applied)". - Jul 27 2012