On Linux there is a great Heimdall tool. I used it recently to flash stock ROM and custom recovery (TWRP) to my old Samsung S3 mini. Best to be used from command line.
Heimdall is in Ubuntu repos (or build from source):
sudo apt-get install heimdall-flash
Steps to flash:
- Restart phone in download mode – push all tree button: Vol -, Home, Power
- Connect to USB
-
sudo heimdall detect
Heimdall must always run as root.
If phone is not found try other USB ports ( worked only on one in my notebook). - Get PIT in readable form:
sudo heimdall print-pit >myphone_pit.txt
- Unzip, untar ROM archive
- Match file names to partition names – look into PIT dump:
— Entry #21 —
Binary Type: 0 (AP)
Device Type: 2 (MMC)
Identifier: 20
Attributes: 5 (Read/Write)
Update Attributes: 5 (FOTA)
Partition Block Size/Offset: 524288
Partition Block Count: 2457600
File Offset (Obsolete): 0
File Size (Obsolete): 0
Partition Name: SYSTEM
Flash Filename: system.img
FOTA Filename: - Flash partitions – in case of stock ROM I did not have to flash all (probably because re-flashing same ROM back):
sudo heimdall flash --Kernel boot.img --CACHEFS cache.img --Kernel2 recovery.img --SYSTEM system.img
To flash custom recovery:
sudo heimdall flash --Kernel2 ~/tmp/recovery.img