The Setup

I use a Samsung Galaxy S3 (Ting/Sprint). Though it is now 3 generations removed from Samsung’s flagship Galaxy S model, it still is a great phone. Maybe I’ll switch when it eventually dies. Last week the camera stopped working. It was the dreaded “Camera failed” message. All you can do is press “OK” and hope to find a solution.

A quick google search brought up sites with several potential solutions:

  1. Force stop the camera app. Delete cache and data. Reboot and use camera.
  2. If that doesn’t work delete files from folders buried deep in the file system (rooted users only).
  3. If that doesn’t work perform a factory reset on the phone. This will erase all data, so be careful to have backups.
  4. If that doesn’t work, sorry, your camera is broken. Have it repaired or get a new phone.

In my situation, I can tell you that replacing the camera did not fix the device. Nor did copying the SamsungCamera.apk and SamsungCamera.odex from another phone. This is when I stumbled onto what I am calling the “Heimdall Maneuver”.

Heimdall is a program written for Linux and Mac users to flash firmware to Samsung devices. You can use it via Terminal or use the GUI version. I tried the GUI version for Linux, but it was outrageously complicated and did not use terminology that made sense with my device. My advice is use the command line in Terminal because it’s just easier to use.

Through a series of trials and errors, and googling, I discovered the most efficient way to use the Heimdall Maneuver to reflash my phone’s firmware, and repair the camera at the same time. This is a last ditch effort when nothing else works. Make sure you have saved your data on the phone, because it is going to be wiped out.

The Directions

I’m not giving detailed directions for every scenario because your situation may be different from mine. This guide is for putting your phone back to factory stock from a phone that is already at stock. It won’t repartition the device and may not help if your coming from a non-stock Rom. If that’s your case, you might want to search out other guidelines.

I’m using Xubuntu 14.04.2. However, if you’re using another Linux distribution, you can probably figure it out based on what I have done.

Download proper firmware (see above) for your device. I recommend Samsung Updates or SamMobile. Be very careful to download the firmware for your exact model and carrier. You can get the model number from behind the battery. You should know your carrier, they’re the ones who take your money each month!

This guide is only intended for Samsung Galaxy S3, Sprint version, NJ2 stock firmware.

  1. Unzip the firmware zip file. Then rename the .md5 file to .tar then untar that file. The individual files you now see are the ones you are going to use to fix your phone.
  2. Install heimdall from your distribution’s repositories. For me it was heimdall-flash. You can use Terminal (sudo apt-get install heimdall-flash) or Synaptic.
  3. Enable Developer mode on your phone. Go into settings, about phone, tap on Build number rapidly until developer mode is turned on. Then back out and enter Developer options.
  4. Enable USB debugging.
  5. Enter download mode on your S3. Power off. Then press and hold Volume down – home button – power button. Release when you see the warning screen. Press volume up to enter download mode.
  6. Connect your phone to your computer with a USB cable.
  7. Start Terminal and enter the folder where your downloaded files are located.

The Commands

Now is when all the real fun begins!

The command(s) below will take a few minutes to run. Don’t panic just wait. You can try the long command or do the individual ones based on your needs. Once again, this is for the Samsung Galaxy S3, Sprint version, NJ2 stock firmware.

DISCLAIMER: Use the following commands at your own risk. There’s never a guarantee that things will work the way they are supposed to…

Single command:

heimdall flash --MODEM NON-HLOS.bin --SBL2 sbl2.mbn --SBL3 sbl3.mbn --ABOOT aboot.mbn --RPM rpm.mbn --BOOT boot.img --TZ tz.mbn --SYSTEM system.img.ext4 --CACHE cache.img.ext4 --RECOVERY recovery.img --verbose

The verbose option will let you see what’s going on each step of the way. Your phone should reboot automatically when the flashing is complete. You should be good to go!

Multiple/individual commands (you may need to unplug and replug the USB cable from the computer in between commands):

sudo heimdall flash --MODEM NON-HLOS.bin --no-reboot
sudo heimdall flash --SBL2 sbl2.mbn --no-reboot
sudo heimdall flash --SBL3 sbl3.mbn --no-reboot
sudo heimdall flash --ABOOT aboot.mbn --no-reboot
sudo heimdall flash --RPM rpm.mbn --no-reboot
sudo heimdall flash --BOOT boot.img --no-reboot
sudo heimdall flash --TZ tz.mbn --no-reboot
sudo heimdall flash --SYSTEM system.img.ext4 --no-reboot
sudo heimdall flash --CACHE cache.img.ext4 --no-reboot
sudo heimdall flash --RECOVERY recovery.img --no-reboot

The no-reboot option allows you to perform one or more commands without rebooting in between. When finished flashing, unplug your phone from the USB cable and pull the battery. Re-insert the battery and power up. You should be good to go!

One Final Pointer

This guide can be used to help people with other devices, but you’ll have to adapt the steps above to your device. You must have the partition information from your device to flash your firmware using heimdall. Here’s how you get it:

sudo heimdall print-pit

Then copy the printed information to a text file for reference. Match up the partitions with the files you have downloaded. Not every entry in the PIT file will necessarily have an accompanying file to go with it. If you’re not repartitioning your device you can skip the partitions that don’t have a file match.

Also, be very careful because heimdall is case sensitive. You’ll notice the partitions for the Samsung Galaxy S3 (Sprint, NJ2 firmware) are in capital letters. This may or may not be the case with other devices.