Running Fastboot commands off of SD card so commands can be run on the go?

Jordan5900

New member
Jan 10, 2020
4
0
0
Guelph
So I have the Razer Phone 2, and after many painful and stressful days, I was able to successfully root it, after having to bring it to the closest point of bricking and bringing it back to life. Fastforward about a week and a half to today, the first time the phone decided to eat itself and I had to try to recover it. It shutdown without warning (just went black) and wouldn't respond to any buttons, and finally showed life after I clicked the Power button rapidly about 20 times. After it turned on it died very fast, going from 7% to dead in a matter of a minute or so. When I got home, it got itself stuck in a bootloop, which I could only get into fastboot, not system or TWRP. After some messing around and trying to flash a new boot image and having it still fail and trying to boot straight from the img on my computer and it kicking back with the phone saying that it was an unknown command, I decided to switch the slot from a to b, as I remembered that slot b acted like there was no twrp on it and seemed like a clean slate of the OS. I booted into b and fastboot, recovery and system all worked fine. From there, I just had to reflash TWRP and slot a was working fine again.

Through this I had the thought, if this ever happens again (which I'm sure it will) is there anyway to fix it on the go in fastboot with an on the go USB to micro SD with some sort of an executable or script that would run the "fastboot set_active b" command? I want to be able to try to fix this on the go if it comes up again, and not have to wait until I get back to my computer to run one fastboot command.
(For this I understand that accessing the SD card when its in its slot may be tricky, so if I had an OTG for my micro SD is it possible that it could act like a live drive and just run the command automatically?)

With that, if that's possible, since slot b is like a clean slate and boots into android recovery when requested, can I reflash TWRP from the android recovery menu using another script? To flash it it only works if I flash it as "fastboot flash boot_a "twrp-arter97-kernel.img" ", so if I had the img file and a file that could run that command, would it be possible to execute that through android recovery in the "apply update from SD card" or is there any other way to do that?

To fix my bootloop issue all I need to do is switch slots from a to b, flash twrp onto boot_a, and then reinstall magisk if it deletes itself(it may have only deleted because I flashed a new boot onto it) and I want to be able to do this without having to use my computer.

Late night thoughts... I've been doing some digging and can't really find anything on the subject... Thought it might be a useful tool if this can be done?

Now here for the phone info...
Make: Razer
Model: Phone 2
OS: Razer OS since I can't find any ones to actually work with the RP2
Android Version: 9.0 Pie
Build Number: P-MR2-RC001-RZR-190914.3123
Using Arter97 TWRP and Magisk v20.3
 

mattwheat

Senior Member
Oct 25, 2012
1,139
581
143
BIRMINGHAM
Sounds logical to me not sure if the "flash update form sdcard" can implement a boot.img file even with the commands written out. I think that may be a recovery issue that hinders that. I have a feeling that in the code for recoveries there are only certain commands that can be recognized for certain actions you pick. But definitely sounds like a great idea. I've been wondering ever since pixel phones went to this "boot A" and "boot B" partitions that "multi-boot" could be worked out easier than back in the Nexus and Moto x /x2 days. I used to love how you could partition off the drive and flash multiple boot slots and still save one as the original for that "just in case **** happens" moment when you need to boot back to original. It was very cool. And also equally as cool was the fact that you could have "Pacman" on one boot slot and "dirty unicorns" on another. So you could bounce back and forth between them.