Can't Restore Samsung Galaxy S3 To Factory Firmware


Question

I installed CyanogenMod on my Samsung Galaxy S3 (SGH i747), and now I need to re-install factory firmware to network unlock my phone. Heimdall seems to be able to successfully image the firmware package onto the device, but after imaging, it won't boot. I can still get to recovery mode and download mode, but nothing else. This is the command I'm using to image:



heimdall flash --SYSTEM I747UCDLK3_I747ATTDLK3_I747UCDLK3_HOME.tar.md5 


This is the output:



Heimdall v1.4.1

Copyright (c) 2010-2014 Benjamin Dobell, Glass Echidna
http://www.glassechidna.com.au/

This software is provided free of charge. Copying and redistribution is
encouraged.

If you appreciate this software and you would like to support future
development please consider donating:
http://www.glassechidna.com.au/donate/

Initialising connection...
Detecting device...
Claiming interface...
Setting up interface...

Initialising protocol...
Protocol initialisation successful.

Beginning session...

Some devices may take up to 2 minutes to respond.
Please be patient!

Session begun.

Downloading device's PIT file...
PIT file download successful.

Uploading SYSTEM
100%
SYSTEM upload successful

Ending session...
Rebooting device...
Releasing device interface...


I tried factory resetting before and after imaging the ROM via ClockworkMod, but it didn't help.



How do I fix this?






NOTE: I am using Linux.


Answer

.tar.md5 file is used by Odin (another firmware flashing tool), but AFAIK it cannot be used by Heimdall. Please make a backup of this file.



Remove md5sum



Run md5sum on any file to see what is it's output like. Something similar will be appended to original .tar file. Assuming you can open the .tar.md5 file in a text editor, remove the md5 sum from the end of file (and probably you'll have to remove last new line character). Then rename this file to I747UCDLK3_I747ATTDLK3_I747UCDLK3_HOME.tar.



Extract partitions



You should be able to run tar -xf I747UCDLK3_I747ATTDLK3_I747UCDLK3_HOME.tar. It should create a new directory with similar name and this directory will contain images of boot, cache, fat, hidden, recovery and system partitions (and maybe more):




  • boot.img

  • cache.img.ext4

  • hidden.img.ext4

  • system.img.ext4



Flashing



You should make sure that partitions on your device have the same names as I've written below (APPS, CACHE, HIDDEN, SYSTEM). You can do it be running heimdall download-pit --output <filename> and then heimdall print-pit --file <filename>. Finally, here's the actual flashing (you may want to add --no-reboot to the first command):



# heimdall flash --APPS boot.img --verbose
# heimdall flash --SYSTEM system.img.ext4 --CACHE cache.img.ext4 --HIDDEN hidden.img.ext4 --verbose


Re-flash recovery (added later)



In case your phone boots to recovery instead of system, you should flash your recovery (doesn't have to be stock) image again.


Topics


2D Engines   3D Engines   9-Patch   Action Bars   Activities   ADB   Advertisements   Analytics   Animations   ANR   AOP   API   APK   APT   Architecture   Audio   Autocomplete   Background Processing   Backward Compatibility   Badges   Bar Codes   Benchmarking   Bitmaps   Bluetooth   Blur Effects   Bread Crumbs   BRMS   Browser Extensions   Build Systems   Bundles   Buttons   Caching   Camera   Canvas   Cards   Carousels   Changelog   Checkboxes   Cloud Storages   Color Analysis   Color Pickers   Colors   Comet/Push   Compass Sensors   Conferences   Content Providers   Continuous Integration   Crash Reports   Credit Cards   Credits   CSV   Curl/Flip   Data Binding   Data Generators   Data Structures   Database   Database Browsers   Date &   Debugging   Decompilers   Deep Links   Dependency Injections   Design   Design Patterns   Dex   Dialogs   Distributed Computing   Distribution Platforms   Download Managers   Drawables   Emoji   Emulators   EPUB   Equalizers &   Event Buses   Exception Handling   Face Recognition   Feedback &   File System   File/Directory   Fingerprint   Floating Action   Fonts   Forms   Fragments   FRP   FSM   Functional Programming   Gamepads   Games   Geocaching   Gestures   GIF   Glow Pad   Gradle Plugins   Graphics   Grid Views   Highlighting   HTML   HTTP Mocking   Icons   IDE   IDE Plugins   Image Croppers   Image Loaders   Image Pickers   Image Processing   Image Views   Instrumentation   Intents   Job Schedulers   JSON   Keyboard   Kotlin   Layouts   Library Demos   List View   List Views   Localization   Location   Lock Patterns   Logcat   Logging   Mails   Maps   Markdown   Mathematics   Maven Plugins   MBaaS   Media   Menus   Messaging   MIME   Mobile Web   Native Image   Navigation   NDK   Networking   NFC   NoSQL   Number Pickers   OAuth   Object Mocking   OCR Engines   OpenGL   ORM   Other Pickers   Parallax List   Parcelables   Particle Systems   Password Inputs   PDF   Permissions   Physics Engines   Platforms   Plugin Frameworks   Preferences   Progress Indicators   ProGuard   Properties   Protocol Buffer   Pull To   Purchases   Push/Pull   QR Codes   Quick Return   Radio Buttons   Range Bars   Ratings   Recycler Views   Resources   REST   Ripple Effects   RSS   Screenshots   Scripting   Scroll Views   SDK   Search Inputs   Security   Sensors   Services   Showcase Views   Signatures   Sliding Panels   Snackbars   SOAP   Social Networks   Spannable   Spinners   Splash Screens   SSH   Static Analysis   Status Bars   Styling   SVG   System   Tags   Task Managers   TDD &   Template Engines   Testing   Testing Tools   Text Formatting   Text Views   Text Watchers   Text-to   Toasts   Toolkits For   Tools   Tooltips   Trainings   TV   Twitter   Updaters   USB   User Stories   Utils   Validation   Video   View Adapters   View Pagers   Views   Watch Face   Wearable Data   Wearables   Weather   Web Tools   Web Views   WebRTC   WebSockets   Wheel Widgets   Wi-Fi   Widgets   Windows   Wizards   XML   XMPP   YAML   ZIP Codes