PoempelFox Blog

[..] [RSS Feed]
 

Mon, 17. Oct 2011


Flashing stock firmware with Heimdall Created: 17.10.2011 00:08
Please note: This article simply describes what I did to my Samsung Galaxy S2. It is provided in the hope that it will helpful for others.
Neither will I assist you in doing the same to your phone, nor will I accept responsibility for damages to your phone while doing what I describe here.
This is mainly an continuation of the last article. So, recently the first version of Cyanogen Mod supporting the Galaxy S2 has been released. I naturally had to try it out. Unfortunately, I did not like it at all - the design made me want to puke, and the overall impression was just UGH. After about an hour, I desperately wanted my (rooted but otherwise) stock Samsung firmware back.
That turned out to be a tough task.
In theory, it would be very simple: Put the phone into download mode, which is basically a recovery mode where no real system is running, but it accepts files to flash - which is probably where the name "download mode"" comes from. You could just flash the firmware from that, reboot and be happy with your new firmware. However, the Samsung way of firmware updates does not use that, probably because that would be too simple and way too little error prone.
Instead, firmware updates are done with KIES while the phone is in contact sync mode. KIES is a wonderful piece of bloatware that makes you wonder whether someone stole the SSD out of your computer, because it takes longer to start than Windows Vista on a cheap netbook. Once it started up, it's supposed to do everything, including syncing contact info etc., and also flashing firmware. Unfortunately, its crappy and bugridden. Sometimes it doesn't see the phone when you plugged it in before starting it, sometimes you have to do exactly that to make it work. Even if it does see the phone occasionally, it seems to be pure luck what options it offers to you.
Of course, KIES will not flash the stock firmware back if your phone isn't running the stock firmware. Though that is fine, I'm not sure whether it's on purpose or just out of incompetence. Because even with stock firmware, I've had exactly zero successful flashes with KIES by now. Either the "flash update" button is just missing, or it DOES work and downloads a firmware update for half an hour - only to tell you that it suddenly doesn't recognize the phone (to which it talked for the last half hour, and where it backed up all data from) anymore.
Luckily, Heimdall can not only be used to flash a rooted kernel, but it can also flash a complete stock firmware image - you don't need to rely on strange things like "ODIN" for that. The firmware-packages are usually ZIPped TAR files - unpack them (both the ZIP and the TAR within), and you'll get a directory full of files. Then start looking for corresponding parameters to Heimdall. For example, there might be a file factoryfs.img - the corresponding heimdall parameter is --factoryfs. Most are obvious, some need a bit thought: Sbl.bin usually is the Secondary bootloader, parameter --secondary-boot. The complete commandline for my stock firmware was:

export KR=/tmp/I9100XWKI8_I9100OXXKI2_I9100XXKI4/ heimdall flash --factoryfs $KR/factoryfs.img --cache $KR/cache.img \ --hidden $KR/hidden.img --modem $KR/modem.bin \ --kernel $KR/zImage --param $KR/param.lfs \ --primary-boot $KR/boot.bin --secondary-boot $KR/Sbl.bin

Yes it's long - but other than KIES it worked like a charm. Just put the phone into download-mode and flash away.
One question remains: Where to get the stock firmware images?
That's a question to which I'd love to hear a good answer myself. Unfortunately, Samsung does not seem to provide them for manual download, KIES automatically downloads them from god knows where. So the only way to get them is through the same forums that provide the root-kernels. I'd love to have a more reliable source, so if you know of any - leave a comment.
PS: A little off-topic, but I was thoroughly impressed with Titanium Backup. After going back to stock, it was able to restore everything from the backup I made before. And I mean everything - contacts, call history, received SMS, calendar and alarm clock entries, even Angry Birds and my progress in the game. This is an incredibly useful tool.
1 comment
Thank you so much! Helped me a lot!
luisajeronimo 22.06.2013 18:57

write a new comment:
name or nickname
eMail adress (optional)
Your comment:
calculate: (2 times 10) plus 3
 

EOPage - generated with blosxom