The regular version of Heimdall (1.3.2 as of this writing) doesn't work with the T-Mobile SGSII (also known by the model number SGH-T989), but there is a bug report on the main Heimdall project's GitHub site which points at a forked version that will work if you massage it properly.
Within the forked version is a piece of code that checks a numeric device type ID. A few IDs are already allowed, but the program will bail on you if the device isn't in the list. Well, the SGH-T989 comes up as a number "30", which wasn't on the list. Here's a patch to fix it (assuming Blogger doesn't mangle things):
diff --git a/heimdall/source/BridgeManager.cpp b/heimdall/source/BridgeManager.cpp
index 1faa626..7359a0d 100644
--- a/heimdall/source/BridgeManager.cpp
+++ b/heimdall/source/BridgeManager.cpp
@@ -1621,10 +1621,15 @@ bool BridgeManager::BeginSession(void)
int deviceType = setupSessionResponse.GetUnknown();
- // TODO: Work out what this value is... it has been either 180 or 0 for Galaxy S phones, 3 on the Galaxy Tab, 190 for SHW-M110S.
- if (deviceType != 180 && deviceType != 0 && deviceType != 3 && deviceType != 190)
+ /* TODO: Work out what this value is...
+ * it has been either 180 or 0 for Galaxy S phones,
+ * 3 on the Galaxy Tab,
+ * 30 on T-Mobile Galaxy S II (SGH-T989),
+ * 190 for SHW-M110S. */
+
+ if (deviceType != 180 && deviceType != 0 && deviceType != 3 && deviceType != 30 && deviceType != 190)
{
- Interface::PrintError("Unexpected device info response!\nExpected: 180, 0 or 3\nReceived:%d\n", deviceType);
+ Interface::PrintError("Unexpected device info response!\nExpected: 180, 0, 3, 30, or 190\nReceived:%d\n", deviceType);
return (false);
}
else
You really only need to add "&& deviceType != 30" into the right spot.
So, the basic basics:
- Download the forked version of Heimdall with "git clone git://github.com/marshray/Heimdall.git"
- Compile and install Heimdall:
- Enter the new "Heimdall" directory with "cd Heimdall"
- Read through the various README files, including the "Linux/README" one.
- Change into the "libpit" directory and run "./configure && make", then exit the directory upon success.
- Change into the "heimdall" directory and run "./configure && make". Upon a successful compile, run "sudo make install", then exit the directory.
- Change into the "heimdall-frontend" directory and run "qmake && make". Upon a successful compile, run "sudo make install", then exit the directory.
- Download a ClockWorkMod Touch Recovery image by visiting the ClockWorkMod ROM Manager site and finding the "Samsung T-Mobile Galaxy S2". Click on the download link in the second column ("6.0.1.2" as of this writing). For me, this saved as "recovery-clockwork-touch-6.0.1.2-hercules.img"
- Reboot your phone into Download Mode with the following procedure:
- Plug the USB cable into your phone if it isn't already connected.
- Press and hold down both volume keys, followed by holding down the power button. Keep holding down the power button until the phone reboots (a brief vibration happens)
- Release the power button but keep holding down the volume buttons (it's okay if you accidentally release the volume buttons momentarily)
- The phone will come up, and you can release the buttons.
- There will be a prompt saying you're about to enter Download Mode. Press the Volume Up button once to continue.
- At this point, you should be in "Odin Mode". (Note that there's a big warning not to reboot the phone when it's in this mode -- as far as I know, it's okay to reboot here unless you're actually transferring data. But, the phone will restart itself after a few minutes if it isn't told to do anything.)
- Now, go back to the command line on your Linux box, and run the command "heimdall detect" just to see if the phone is communicating with the computer.
- Note: Ideally, there would be a step here where we would dump the recovery image from the phone to make a backup, but apparently that isn't working. The phone is structured in a way that even a screwed up recovery image shouldn't cause insurmountable problems (it shouldn't affect the Download Mode, for instance), but if you're wary, don't proceed.
- Upload the recovery image by running "heimdall flash --recovery recovery-clockwork-touch-6.0.1.2-hercules.img". It should only take a few seconds, and the phone should reboot.
- To test the recovery image, you can either follow the same steps as outlined in step 4, but with the USB cable removed, or run the command "adb reboot recovery" from the Android SDK with the USB cable plugged in.
Mike, Blogger did mangle your patch a little, but I forked the marshray fork, patched, and sent marshray a pull request (https://github.com/marshray/Heimdall/pull/2).
ReplyDeleteOthers, until marshray accepts my pull request, use this instead of Mike's Step 1, above, and you won't have to bother with anything above "So, the basic basics":
git clone git://github.com/jamiejackson/Heimdall.git
Ubuntu users: I may have had some of the necessary packages already installed, but these were the ones *I* had to install to compile according to Mike's instructions. Consider this an extra step after step 2b-ish:
sudo apt-get install qt4-qmake libqt4-dev libusb-1.0-0-dev
@Jamie: Thanks for sharing your code.
ReplyDeleteIn the Readme at github.com/jamiejackson/, Jamie comments '... probably doesn't even build except on Linux.'
Good news OS X users, Jamie's code builds on OS X Lion without an issue. Works as long as you follow instructions - i.e. all of dependencies needed such as Macports (and Macports dependencies) are present.
If you're running ./configure per instructions without using the sudo command, you will probably need to move the old heimdall/configure.log out of the way ($sudo mv config.log config_downloaded.log).
Jamie's code built easier than the original Heimdall (v1.3.1) code which the missing function clock_gettime on OS X requires a workaround.
Now I will work on the BridgeManager.cpp to recognize my T-mobile S II...
Thanks Mike and Jamie for the info and code.
@skurfer, I'm glad it helped. Credit for the solution should go to Mike and Marsh Ray, though. I just helped make the process more streamlined.
ReplyDelete---------
To bring us up to date: Marsh Ray just accepted my pull request, which means the fork I mentioned in my original comment is now obsolete.
In a nutshell, Mike's patch is no longer necessary, and readers of this blog post should now just skip straight to his Step 1, and follow from there.
@skurfer: BTW, you mentioned that you'll need to "work on the BridgeManager.cpp to recognize my T-mobile S II." However, that recognition is already built-in if you used my Git fork, or if you grab the Marsh Ray fork as of fifteen or so minutes ago.
ReplyDeleteJust a note that this works on the Koodo Samsung Galaxy S IIx (SGH-T989D) with the exception that to get into Download Mode, you need to hold down just the Volume Down (and _not_ both Volume Up and Volume Down).
ReplyDeleteTo boot into recovery, both Volume Up and Volume Down need to be held down.
Thanks for the post!
Hi, I have some problems building both heimdall for OS X
ReplyDeleteI stuck at 2d, where I got this msg:
========================================
Chens-MacBook-Pro:heimdall chenjian$ ./configure
checking for pkg-config... /opt/local/bin/pkg-config
checking pkg-config is at least version 0.9.0... yes
checking for DEPS... no
configure: error: Package requirements (libusb-1.0 >= 1.0.8) were not met:
No package 'libusb-1.0' found
Consider adjusting the PKG_CONFIG_PATH environment variable if you
installed software in a non-standard prefix.
Alternatively, you may set the environment variables DEPS_CFLAGS
and DEPS_LIBS to avoid the need to call pkg-config.
See the pkg-config man page for more details.
================================================
I installed pkgconfig from Macport but I have no prior knowledge with Macport,
so I think something is wrong with the PKG_CONFIG_PATH maybe?
Sorry new to OSX/Unix
Thanks...
Hey this worked to un-brick my Samsung Galaxy S2 t-mobile phone perfectly. It had been bricked for 2 months or so. It did not allow me to enter download mode and appeared to just go back to firmware upgrade encountered an issue screen. If anyone else has this problem, I tried to boot into recovery mode by holding power, vol up and down buttons and thought it just didn't work again, however, when I checked in heimdall it did detect my device. I downloaded the Samsung Galaxy S2 T-Mobile clockwork mod image from the site on here, ran heimdall flash --recovery command with that .img file and it gave me and error:
ReplyDeleteERROR: Partition "recovery" does not exist in the specified PIT.
although it gave me this error, after that it started booting properly.
Thanks for this guide and the composition of links & stuff here, Mike.
ReplyDeleteAwesome just found this guide again after realizing i need to revive my old S2 because it goes wayy slow with all the stock stuff bogging it down, works great.
ReplyDeletethank you mike