yashsingh1/xdaforums huggingface dataset:
[Galaxy S 4 Mini Original Android Development] ripee:
If you have a stock rom, but you're trying to flash TWRP, you have to very quickly pull the battery right when your phone vibrates after the TWRP is finished flashing, otherwise the stock rom will sneak in and re-flash its own stock recovery before rebooting ;)

Also, this is unrelated to rom flashing, but that stock version you mentioned has an old bootloader and modem. You can flash the one linked in the OP through heimdall as well, it's the latest one for the GT-I9192 taken from another stock version. It's unnecessary for the purpose of TWRP working properly, but if you want to flash a custom rom, it'll work best with the latest bootloader and modem. If you want to stick with stock rom, you don't have to flash any other bootloader or modem than the one that's automatically flashed when you flash the stock rom itself.
[Galaxy S 4 Mini Original Android Development] slouse1:
Thanks, but I'm not sure what you mean by "pull the battery". What I did over and over again is to press the required key combo for recovery during reboot, and it goes into "Recovery Booting" every time, but then gets stuck there. I need to get TWRP working properly to install Lineage. I did install it once it did actually boot into TWRP and it worked whenever I managed to boot into it, but it is not a workable solution if I can boot the device only in 1 out of 10 attempts. I still don't understand why flashing TWRP makes the boot hang both for recovery and for system booting. Anything else I can try?

UPDATE: Just tried using all the files from the OP in one go: heimdall flash --ABOOT aboot.mbn --MODEM NON-HLOS.bin --RECOVERY twrp-3.2.1-1-serranodsdd.img --RPM rpm.mbn --SBL2 sbl2.mbn --SBL3 sbl3.mbn --TZ tz.mbn

Unfortunately, it hangs again on "RECOVERY BOOTING.....".
[Galaxy S 4 Mini Original Android Development] ripee:
Pull the battery means remove it from the phone, so that the phone loses power right after it vibrates. No power, no ability to automatically re-flash stock recovery.

What did you do to get it working? More importantly, what had you done since then? Had you made any changes to the recovery partition? Had you tried any other TWRP versions or flashing methods?

Try this flashing method: https://davideddu.org/blog/posts/how-to-flash-a-recovery-image-using-heimdall/
[Galaxy S 4 Mini Original Android Development] slouse1:
No way, this really worked!! Thanks so much!! So the trick is to remove the battery as soon as the display turns black after flashing. Then I re-inserted the battery after a few minutes while holding the volume up and home key (a third hand would have helped). I did flash using the command I mentioned previously, but it probably would have worked if I just flashed twrp.
[Galaxy S 4 Mini Original Android Development] DxBx:
Hi My inital problem was that my CM browser is unsupported/kept stopping-stauling and I couldn't get into playstore to download anything. Solution seemed to be to upgrade of CM13 to latest Lineage and install a newTWRT within previous TWRT. It didn't work. So I went on to do a flash TWRP with Odin. That seemed to work great. It looked really great and easy to use process-simple instructions. I was when it restarted it had retained all the old stock CM13 stuff incl browser. I'm was thinking about trying to root the phone from scratch and redo the whole TWRP-Odin thing. I powered the phone down and restarted it. The good news is that everything is working great. no need to do anything else. The weird thing is that on the at <settings> under System at <about phone> info displayed is all CM refernces. Even the cyanogenmod browser key actually loads up straight to Google browser. the new TWRP- serranotexx- build doesn't even appear on the specs. Now that the phone works and looks great I'm not game to touch it. I hope this helps with your future development work.
[Galaxy S 4 Mini Original Android Development] slouse1:
Pulling the battery really did the trick for getting TWRP installed persistently, thanks again. However, I still keep getting into boot loops after installing Lineage. If I pull the battery during reboot after flashing of Lineage through TWRP, it gets at least into the Lineage boot screen but gets stuck there. What is it that keeps corrupting the boot sequence and is there a way to get rid of it permanently?
[Galaxy S 4 Mini Original Android Development] bierma32:
The best solution , try the TWRP what arco68 has create for the LOS15.1 , this works perfectly for me with all Roms.
[Galaxy S 4 Mini Original Android Development] ripee:
Why are you pulling the battery after flashing Lineage? You only do it when flashing a custom recovery when you still have stock rom installed.

Thank you for undermining my effort to maintain official TWRP. arco68 made his from the code integrated into Lineage, which will never be official. I use my own TWRP and it flashes, backs up, and restores Lineage perfectly.
[Galaxy S 4 Mini Original Android Development] bierma32:
I wrote try ARCO s TWRP. That minds if this works so is something wrong in your build.
[Galaxy S 4 Mini Original Android Development] mielletseed:
did you wipe data and cache before or after installing LOS?
[Galaxy S 4 Mini Original Android Development] slouse1:
Before installing. I did a factory reset and advanced-wiped Dalvik, Cache, Data and System. Then installed Lineage 14.1. build 30.03.2018. Then pulled the battery during reboot out of desperation, because it gets stuck on booting afterwards. After pulling the battery it and rebooting it gets one step further on the boot screen up to the Lineage logo. Don't know what else to try. A different build?
[Galaxy S 4 Mini Original Android Development] JimmyRay:
[MENTION=6005084]ripee[/MENTION] , many thanks for your work - it's nice to have an official TWRP build.

I updated from ne0zne's 3.2.0-1 build without any problems.

I don't know if this was eventually fixed by ne0zone, but I noticed that automatic flashing (after updating via LineageOS update) now works correctly, although I had to disable zip verification.

By the way, Is there any possibility of removing/reducing the 30+ wait time while the TRWP splash screen is shown?

Thanks again for your work!
[Galaxy S 4 Mini Original Android Development] slouse1:
Well, I tried using ne0zne's 3.2.0-1 build and now stuffed up my system well and proper. It does not boot into recovery any more and I cannot even flash the stock rom that saved me previously:

Uploading ABOOT

100%

ERROR: Failed to confirm end of file transfer sequence!

ERROR: ABOOT upload failed!
[Galaxy S 4 Mini Original Android Development] ripee:
You could wipe data, which wipes twrp's settings file. It could be an old setting from 3.0.2-1.
[Galaxy S 4 Mini Original Android Development] slouse1:
UPDATE: I was able to get TWRP up and running again using the files in the OP and this command: heimdall flash --ABOOT aboot.mbn --MODEM NON-HLOS.bin --RECOVERY twrp-3.2.1-1-serranodsdd.img --RPM rpm.mbn --SBL2 sbl2.mbn --SBL3 sbl3.mbn --TZ tz.mbn

Then needed to unplug usb cable and pull the battery as soon as heimdall stated "Releasing device interface...". After re-inserting battery, I was able to boot into TWRP recovery. Now trying to install Lineage again. Is it normal that the zip signature verification fails?

---------- Post added at 07:18 PM ---------- Previous post was at 06:28 PM ----------

Yet another update: After flashing LineageOS through TWRP, I could not boot into system nor recovery any more. Now even the below procedure does not lead to a functional recovery any more. I have no idea what is going on. Can anyone help to trouble shoot this? Why is the situation getting progressively worse?
[Galaxy S 4 Mini Original Android Development] ripee:
Perhaps, but wait until it says 1.000000 after flashing. That will indicate that no flashing error occurred. DO NOT PULL THE BATTERY AFTER YOU REBOOT INTO SYSTEM!!!! The first boot into any custom rom takes a while, longer than a regular boot from power off. For serranoltexx at least, it takes around 6-7 minutes to boot into Lineage the first time after flashing.

Please start over. Re-flash any stock rom, regardless of which country or carrier it's from, and then flash twrp again.
[Galaxy S 4 Mini Original Android Development] slouse1:
I re-flashed another stock rom using heimdall and was able to boot into stock without problems. However, after flashing twrp, I still cannot boot into recovery. Tried both the Lineage instructions (heimdall flash --BOOT twrp-3.2.1-1-serranodsdd.img --RECOVERY twrp-3.2.1-1-serranodsdd.img --no-reboot) and using all files in the OP:

heimdall flash --ABOOT aboot.mbn --MODEM NON-HLOS.bin --RECOVERY twrp-3.2.1-1-serranodsdd.img --RPM rpm.mbn --SBL2 sbl2.mbn --SBL3 sbl3.mbn --TZ tz.mbn --no-reboot

Once I just pulled the battery out when it was done and then tried to re-boot into recovery, the second time, I restarted using the power button and then pulled the battery out. After re-inserting the battery and booting into recovery, it hangs on "RECOVERY BOOTING.....". What else can I try? How long should I wait before re-inserting the battery?
[Galaxy S 4 Mini Original Android Development] ripee:
Why did you re-flash stock?

Flash twrp by itself, don't include it in the same flash command as the bootloader and modem:

heimdall flash --RECOVERY twrp-3.2.1-1-serranodsdd.img

Let it reboot, or whatever happens without the "--no-reboot" parameter. If in fact it does reboot if you don't use "--no-reboot", PULL THE BATTERY once heimdall finishes flashing twrp. Then boot into recovery with the button combination. Let me know if you are able to boot into recovery.
[Galaxy S 4 Mini Original Android Development] slouse1:
No success. Here is what I did: re-flashed stock (I9192DDUCOF2_I9192ODDCOF2_I9192DDUCOF2_HOME), booted fine. Rebooted into odin, then ran:

heimdall flash --RECOVERY twrp-3.2.1-1-serranodsdd.img

Watched terminal, until I saw:

Uploading RECOVERY

100%

RECOVERY upload successful

Ending session...

Rebooting device...

Releasing device interface...

Then pulled the usb cable. When the phone display got black and then the phone vibrated, I pulled the battery. Waited for a few seconds, re-inserted battery and tried to boot into recovery. Stuck at "RECOVERY BOOTING....."

Then flashed all the other files in your OP without twrp, so now see "RECOVERY BOOTING...." and "Set Warranty Bit...", but still stuck there. It still boots fine into the stock rom. I don't understand what is going on.
[Galaxy S 4 Mini Original Android Development] ripee:
You just wrote that you rebooted into Odin. If you're using Odin, why would you need to run Heimdall???? I linked both in the OP as alternatives, depending on what operating system you're running on your computer. If you have Windows, use the "AP" button in Odin to flash the twrp-3.2.1-1-serranodsdd.img.tar file, then pull the batter as soon as it vibrates. Boot into recovery with the button combination.
[Galaxy S 4 Mini Original Android Development] slouse1:
Sorry about the confusion. When I reboot using the HOME+VOLUME DOWN keys, the display shows:

ODIN MODE

...

This is why I sad "reboot into Odin". I am running a debian machine, so using heimdall, not Odin for flashing.
[Galaxy S 4 Mini Original Android Development] ripee:
Is your heimdall updated to its latest version? Have you tried its GUI rather than the command line? The GUI will ask you for a PIT file. Try this one taken from stock I9192, courtesy of nasirahmed:

CSB_signed_SERRANODS_ONEPIT_OPEN_130523.rar
[Galaxy S 4 Mini Original Android Development] slouse1:
Thanks for the pit file! I am using Heimdall v1.4.1, but even with heimdall-frontend and the pitfile you provided I am still stuck on the RECOVERY BOOTING screen. Should I try reformatting using the pit file?
[Galaxy S 4 Mini Original Android Development] ripee:
Yes, flash all the partition images from inside my bootloader and modem .tar file, twrp img itself, and the pit file, as per the normal flashing command line parameters.
[Galaxy S 4 Mini Original Android Development] slouse1:
Thanks, but it failed:

ERROR: Failed to confirm end of PIT file transfer!

ERROR: PIT upload failed!

Should I try without reformat?
[Galaxy S 4 Mini Original Android Development] ripee:
Sure.
[Galaxy S 4 Mini Original Android Development] slouse1:
Without reformat, the flash works, but the result is the same: stuck at "RECOVERY BOOTING.... Set Warranty Bit : recovery"

The verbose output of heimdall-frontend shows on each file: "WARNING: Empty bulk transfer after sending packet failed. Continuing anyway..." Does this mean anything?
[Galaxy S 4 Mini Original Android Development] ripee:
According to this, are you running heimdall version 1.4.2? That error means that heimdall is sending the recovery, but your phone isn't accepting it.

Honestly, if at all possible, please try Odin on someone else's Windows computer. This will eliminate the possibility that there's something wrong with the serranodsdd twrp itself.
[Galaxy S 4 Mini Original Android Development] slouse1:
Thanks for chasing this up. I found a similar issue for 1.4rc, which was supposed to be solved with 1.4.1., but perhaps not. I will try to get odin to run. Really annoying, if this is the problem. I will report back if I manage.
[Galaxy S 4 Mini Original Android Development] slouse1:
Thanks again for your help. Unfortunately, I still have the same problem. I installed heimdall 1.4.2 and used it to re-flash twrp. It seemed to work, I could boot into twrp, flashed Lineage and Gapps pico, but then could not boot any more, as previously. Re-flashed stock, got Odin to run in my Virtualbox, re-flashed twrp, and again stuck at RECOVERY BOOTING. Tried both with and without pulling the battery, using Odin. Then tried again re-flashing twrp using heimdall 1.4.2, but can't boot into twrp, while stock booting works. Since I don't have trouble with flashing stock, heimdall is unlikely the culprit, I would say. By the way, even with the heimdall 1.4.2 gui, I cannot re-format using the pit file you provided. The error in Issue #276 only occurs when I use the gui and click on "reformat", so it is quite different to the problem reported in the issue. When I use the command line without re-format, no error is reported.
[Galaxy S 4 Mini Original Android Development] ripee:
When you flashed with heimdall 1.4.2 and managed to boot into twrp, please wipe everything except the sd card. Then reboot into twrp, if it works, you'll have to reset your settings because wiping data will also wipe twrp's settings. Then try rebooting into twrp from its boot menu.
[Galaxy S 4 Mini Original Android Development] slouse1:
Thanks, but I cannot get into twrp any more, whatever I do. I don't get it. Does it make a difference what stock rom I come from? Should I try different ones? Hard to find stock roms for i9291 that can be flashed with heimdall.
[Galaxy S 4 Mini Original Android Development] slouse1:
Weird, it was stuck on boot again, I pulled out the battery over night and this morning it booted into twrp. Tried to wipe everything except for Micro SDcard, but:

"E: Unable to wipe '/usb-otg' -- unknown file system 'auto'

Unable to wipe /usb-otg"

And of course stuck on "RECOVERY BOOTING...." again afterwards.
[Galaxy S 4 Mini Original Android Development] slouse1:
cannot boot into TWRP

After a lot of attempts, trying all the possibilities mentioned in this thread, (different versions of heimdall, odin, TWRP 3.2.1-1 and 3.2.1-0), I still cannot get my I9192 to boot into TWRP consistently. Isn't there a way to trouble-shoot more systematically? I seem to be turning in circles. Any advice welcome!
[Galaxy S 4 Mini Original Android Development] ripee:
You made the fatal mistake of misinterpreting the instructions when you didn't pull the battery after flashing twrp, but you did pull it after flashing lineage. No judgment, I'm just looking at the facts.

Can you get into Download mode? Are you able to flash stock from heimdall? Flash any stock rom build, regardless of country/carrier, and go through its setup wizard. Then start over and follow the instructions! If you aren't sure, ASK FIRST BEFORE DOING ANYTHING!!!!
[Galaxy S 4 Mini Original Android Development] slouse1:
Thanks, but after those mistakes, I have re-flashed stock again several times and did as you suggested, pulling the battery after installing TWRP and not pulling the battery after installing lineage. Just to be sure, does it matter if I pull the battery before or after the phone vibrates when rebooting after flashing?

My other question was whether it matters which stock version I flash before starting over. Could it be that there is something preventing re-flashing parts of the system or boot with anything but stock?? As I said before, getting into Download mode and reflashing stock works, and I can boot from there into stock or recovery, but after flashing TWRP I cannot get into recovery any more. At least not reliably, sometimes it works.
[Galaxy S 4 Mini Original Android Development] ripee:
It matters greatly when you pull it!!!! That's why I wrote to pull it when it vibrates ONLY, which happens AFTER it finishes flashing twrp!!!

It doesn't matter which stock you flash, but for your sake, it would be best to try the latest one that matches your phone's CSC (country/carrier) code. This will ensure that at least your memory is re-partitioned properly for your particular device.

Please follow instructions.
[Galaxy S 4 Mini Original Android Development] slouse1:
OK, I will try again. If you don't mind, could you let me know how to find out my phone's CSC and where to get the latest stock from? I can also search the web again, but I thought you might have the best advice.
[Galaxy S 4 Mini Original Android Development] ripee:
https://samsung-firmware.org/download/GALAXY__S4__mini__/29a3/SER/I9192XXSCQA3/I9192SERCNJ3/

Try this first, forget the CSC for now.
[Galaxy S 4 Mini Original Android Development] slouse1:
Thanks for the link. I extracted the zip, removed the .md5 from the file name, extracted again and flashed using this command in heimdall:

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

After booting into stock to test that it works, I rembooted into download and flashed recovery using this command:

heimdall flash --RECOVERY twrp-3.2.1-0-serranodsdd.img

As soon as heimdall returned back to the command prompt, I pulled the usb cable, waited until the phone vibrated and then pulled the battery. Waited for a minute or so, then re-inserted the battery and booted into TWRP. Hooray! However after flashing Lineage through TWRP, I was not able to boot any more, neither into TWRP nor into Lineage. When trying to boot into download again, I did not keep the key combo pressed for long enough, so instead of booting into download, it booted into - Lineage! Unfortunately, it hang again on reboot, so I tried to repeat the whole process to check whether I can at least boot into TWRP consistently before installing Lineage again. Unfortunately, on this second attempt of flashing TWRP after stock, my phone is stuck again on the boot screen. Feels like groundhog day! Maybe I pulled the batter too early or too late this time? Do I have to re-flash stock again before re-trying?
[Galaxy S 4 Mini Original Android Development] ripee:
Why did you re-do the whole process again?! If Lineage doesn't boot properly, that's beyond my scope of expertise, please ask arco. He may tell you to use his twrp, but I used his code to build mine so it shouldn't make a difference. Anyway, you keep doing things that I never advised you to do. First, start from scratch again and make sure you can reboot back into twrp from twrp and from being powered off with the button combination. Only when you have established that twrp works that way, only then attempt to flash anything in twrp.

I cannot help you if you do things that I don't advise you to do.
[Galaxy S 4 Mini Original Android Development] slouse1:
I re-did the whole process again because my sole purpose of installing TWRP is to flash Lineage. And I did follow your instructions, over and over again. Flash stock, flash twrp, pull battery and reboot into TWRP.

SOMETIMES it works, MOSTLY not. Surely, there must be a more systematic approach to figuring out what is happening.
[Galaxy S 4 Mini Original Android Development] bierma32:
[MENTION=9060853]slouse1[/MENTION]

After you success fully flashed the TWRP.

How you are installed the lineage Is ?

Have you wiped and formatted system ,cache,data and internalSdcard ?

After the flashing you wiped cache and dalvik ?
[Galaxy S 4 Mini Original Android Development] utfluc:
Just an alternative thought, are your volume buttons working properly? Perhaps they are interfering during the boot process, wether it's automatic or user triggered. These switches are prone to fail in time, and can cause erratic behaviors. I have never read a recurring problem like yours...
[Galaxy S 4 Mini Original Android Development] slouse1:
I followed these instructions: https://wiki.lineageos.org/devices/serranodsdd/install

I.e., I only wiped system, cache and data before flashing LineageOS and did not wipe anything afterwards. I could try what you said if I was able to boot into TWRP again...

But it would help to know why certain partitions have to be wiped and when, and why others should not.

---------- Post added at 10:55 PM ---------- Previous post was at 10:02 PM ----------

Thanks for the thought, but I haven't experienced any problems with the volume buttons with the stock rom, so I don't think this is the problem. I am rather thinking about some deeply engrained "protection" against non-stock roms. My device has 24 partitions, only 12 of which are being flashed when flashing a stock rom. Is there a way to reset the system to an entirely known initial condition, i.e. repartition the whole memory and start from scratch?
[Galaxy S 4 Mini Original Android Development] bierma32:
[MENTION=9060853]slouse1[/MENTION]

Post a list of your 24 Portion, so we can see what is wrong.
[Galaxy S 4 Mini Original Android Development] bierma32:
[MENTION=9060853]slouse1[/MENTION]

here you find in this zip your PIT.file.

So far i checked yours and the file looks the same.
[Galaxy S 4 Mini Original Android Development] slouse1:
Thanks! How do you manage to view the .pit files? They don't seem to be text files. Should I try re-paritioning nevertheless? I wonder what all those partitions contain if they are not part of a stock rom.

Actually, I haven't been able to re-partition using heimdall: https://xdaforums.com/showpost.php?p=76159303&postcount=53

---------- Post added at 10:34 PM ---------- Previous post was at 10:13 PM ----------

@ripee, I tried re-doing the process up to flashing TWRP only, i.e. flashed the stock rom you privided, then TWRP and got stuck at booting into TWRP again. Tried a second time and noticed that re-flashing the stock rom did not actually eliminate the settings I made within the stock rom (language settings, developer options). Is this normal? Or does this indicate that heimdall is not doing something correctly? By the way, I just noticed that after flashing stock, my phone boots into stock recovery first and only then into the system. Is this normal? Really grasping for straws.

UPDATE: using stock recovery to reset data and cache before flashing TWRP also did not help: still stuck at Recovery Booting. Booting into TWRP seems to work excactly once with any new stock rom!
[Galaxy S 4 Mini Original Android Development] ripee:
Yes, this is normal. It means that you didn't factory reset in TWRP before rebooting back into stock system.

It boots back into stock recovery to set itself up on first boot.

Like I said, first establish whether or not you can reboot back into TWRP from (1) TWRP itself and (2) from power off with the button combination.