TWRP back to fastboot-flashable sparesechunk img files possible? - Moto G 5G Questions & Answers

in a guide now removed, whose instructions i will not repeat here, it was documented that a Kiev could be reverted to its stock OS by obtaining img files of recovery, boot, etc. and sparsechunks of the super partition, and then flashing them with fastboot. i really like this approach to wipe and restore the phone to an imaged state.
my question is: would it be possible to convert a TWRP backup of the phone in a custom state to the format used for this? how could i start with this? success here would be for me to create a bash script that converts a TWRP backup folder into a series of fastboot-flashable img files. if i succeed, i wwould be happy to share the results. i just need advice on what would need done to TWRP backups to make them workable with fastboot.
i am about to begin a project involving Kiev, and it would be very useful if i could simply use fastboot to restore my phone to any arbitrary state, as opposed to relying on TWRP.

I guess it'd be possible to create images, format, and extract the backup into them. Save a lot of effort by just dumping the partitions with dd imo.

Related

[Q] how to use dd or nvflash to create backup of recovery?

Recently I got Wind Optimus 2x (p999). Before I change anything, I want to create a full backup in case of warranty. Searching forum and google for couple of days I found several different "stock" recovery images. But all of them have different size/date/etc.. So I want to make my own recovery image.
My idea is make stock recovery image (via dd or nvflash), replace recovery with cwm, make backup, flash custom ROM. If i need to go back - do in reverse order .
1. From what I found, using
dd of=/path_to_store/myimage.img if=/dev/block/mmcblk0p7
should produce required image, but size is about 1.6M, while all other recovery images have size 3-5M
Am I doing something wrong?
2. I cannot find anywhere information about correct use of nvflash utility. Some shell scripts have bunch of parameters to write image into phone, but there is no info about how to read data from phone and create image..
Any help please?
I am sorry if I don't understand your questions but, I will try nonetheless. It seems you do not understand what nv flash or cwm do. Nv flash is how you CORRECTLY install a version of the clockworkmod recovery. Once installed, you choose the back up option to copy your system image. This recovery has the ability to do anything that has to do with rom flashing. Also is does it all simply by choosing what you want to do. There's no ADB or entering commands. Just look for TGA_gunnmans one click nv recovery flasher, this is all the info you will need.
Sent from the fastest g2x in the world
well, not exactly correct. nvflash is "low level" (means it accesses EPROM on hardware level) flash utility. It's designed to write data into EPROM. In most cases such utility can be used to read data as well (for backup purposes). That is why I am trying to find more information about nvflash and how to use it.
dd us *nix utility which works on higher than nvflash level, but lower than cp (copy).
By the time cwr is installed, the phone is different from factory - one of partitions is replaced. I am trying to backup this partition before replacement.
cy_mpak said:
well, not exactly correct. nvflash is "low level" (means it accesses EPROM on hardware level) flash utility. It's designed to write data into EPROM. In most cases such utility can be used to read data as well (for backup purposes). That is why I am trying to find more information about nvflash and how to use it.
dd us *nix utility which works on higher than nvflash level, but lower than cp (copy).
By the time cwr is installed, the phone is different from factory - one of partitions is replaced. I am trying to backup this partition before replacement.
Click to expand...
Click to collapse
There are stock recoveries available! Look in the optional files section.
http://forum.xda-developers.com/showthread.php?t=1054492"
After some more research and experiments I have found that recovery partition on G2x is mmcblk0p5.
Thanks to all who answered my questions directly or indirectly

[Q] Why .img?

So in looking around I have not found any answer to my question. Why is everything to flash on the shield a .img instead of building zip files you can flash directly from recovery? I have been messing with android for quite a long time and know how to flash .img, fastboot, adb, ect. But dl'd and flashing a zip is far easier.
Any answers?
thanks.
*I think* that base factory images (.img files.) are meant to be flashed via fastboot, since they have a direct relationship with device specific partitions. Imagine a bit to bit flash, like a Ghost/Acronis image?!?
As for .zip files, they are installed via recoveries (CWM, TWRP, etc), because you just want to add/replace files in the / partition.
And with our Shield, until now, all OTAs are full system images, not updates.
I hope that I've explained this properly, if not please someone correct me
http://en.wikipedia.org/wiki/Fastboot#Fastboot
anthonws said:
*I think* that base factory images (.img files.) are meant to be flashed via fastboot, since they have a direct relationship with device specific partitions. Imagine a bit to bit flash, like a Ghost/Acronis image?!?
As for .zip files, they are installed via recoveries (CWM, TWRP, etc), because you just want to add/replace files in the / partition.
And with our Shield, until now, all OTAs are full system images, not updates.
I hope that I've explained this properly, if not please someone correct me
http://en.wikipedia.org/wiki/Fastboot#Fastboot
Click to expand...
Click to collapse
Not all ota are full system images, ota 65 and 67 are simple delta updates.
BTW, the main reason of .img files for images is because this can't depend on the recovery. How do you flash a recovery .zip file without a recovery?
You need to have a .img file that can be flashed via fastboot, it is VERY much "bricked" proff that a flashable zip
Thanks for the explanations. I realize some things need to be done via fastboot like unlocking or flashing a recovery for the first time.
I guess I have become spoiled by xda and the simplicity of modification that is available today. Far cry from hacking htcs back in the day.
thx -jason
Both answers are correct - it all depends on which software (on the device) is used to flash, and what format it accepts.
With Tegra devices you have at least 3 ways to flash stuff, from lowest to highest level:
- nvflash/tegrarcm mode. This is a very small firmware that is burnt in ROM and is thus always available no matter how hard you screw your device. It can run small programs (typically, a flasher) that are sent through USB. Problem is, for Tegra4 it will only accept signed binaries, which makes it useless for modders.
- bootloader/fastboot. The bootloader supports the fastboot protocol, which can flash .img files. The bootloader is written in flash memory so your bootloader partition must be in good shape.
- recovery/zip files. The recovery is a Linux image, so this means it is a full-blown system of its own right. Because of this it can support more format, including .zip archives with a script to describe how the archive should be installed.
So in the boot chain, you have 3 anchors from which you can flash images: boot rom (always available but unusable to us) -> bootloader -> recovery. The fact the boot rom cannot be used without a signed image (which is not available publicly) means that screwing your bootloader is sufficient to permanently brick your device.
Recovery images are more convenient since they are in .zip format and can for some be device-independent (e.g. superSU recovery images are flashed the same on every single device out there), contrary to the bootloader which can be different for every device. But they require a working recovery, which is not always granted - so for actual recovery, fastboot images are also useful.
That's why I love XDA
You're never alone!
Thanks for the additional info to all
Anthonws

[RECOVERY] Henk's TWRP Recovery

DISCLAIMER
Code:
The usual disclaimer with an extra warning, this recovery
WILL automatically modify your phone on first boot.
While this should be an entirely safe modification
it is always possible your phone is in a broken state
either on a software or hardware level causing further problems.
This recovery should under no circumstances be flashed
for the first time on a bricked phone
as the automatic changes might damage it further.
ONLY FLASH THIS ON A PHONE IN GOOD CONDITION!
By flashing this recovery you consent to a vendor partition
being created and to take full personal responsibility of any damage
the usage of this recovery may cause rather than blaming it on me.
ABOUT
This modified TWRP is the recovery image i have been using on my personal OnePlus 3T for the past month, with the increasing popularity of system-as-root roms and the issues this causes for older zip files (Such as Google Apps not flashing with wrong arm version errors) i have decided that it would be worth sharing with the community. This recovery image is a ramdisk modification of the TWRP supplied by the LineageOS Unofficial Treble Port Project (Similar to how SHRP is a ramdisk modification of existing TWRP images). Because this is not a source modification (and neither has TWRP been compiled from source) you can find the original source code in their topic. I hope this recovery will be useful to those who often flash multiple kinds of roms and want one recovery that does it all. It has been tested on the Oxygen OS 4, 5 and 9 firmwares and should have great compatibility with all of them.
Included Features
Automatic Vendor Partition Creation and full Treble support
WARNING: Because this recovery will automatically create the vendor partition it should exclusively be used on devices in good conditions. In the very rare case that bricks occur you can revert the change using the MSMDownloadTool (This can only be used on healthy hardware). If you are unsure about the condition of your device or if your device is currently in a bricked state it is best to use another recovery. I am not responsible for further damage to your phone.
Originally the TWRP image provided by the Treble project needs you to type in the 'treblize' command followed by manual reboots, I have automated this process. From the moment you first boot this recovery the vendor partition will automatically be created and the recovery reboots automatically in a new recovery session (This is not a crash and only happens once). If vendor partition has been detected you will be able to see /treblized as a directory on your phone (This is done in RAM and only visible during your recovery session). The vendor partition does not conflict in any way, you can use and pass safetynet on regular roms at will as it is invisible to a rom using a non treble kernel. Before flashing GSI roms please first flash a proper vendor partiton (This can be done by flashing the LineageOS treble rom the regular way).
/system and /system_root hybrid for maximum compatibility!
This is one of my main reasons for sharing this recovery publicly, i have modified the /etc/fstab file to be able to both mount to /system and to /system_root. This means that older zips that expect /system now work again without breaking compatibility with newer system as root or GSI roms. This is one recovery that can do it all! Inside the root folder you will find a flashable zip called Mount-System.zip. This can be used before incompatible zips to mount the /system partition correctly. This tool will automatically detect system-as-root if present and mount /system to /system_root/system, if not present it mounts /system to /system_root. You should prefer this method over the mounting options found in the menu, these should only be used for unmounting system. Keep in mind that by doing this you are messing around with scenario's the original developers have not foreseen and while flashing these previously broken zips is now possible you cause issues in your ROM. Always flash these previously incompatible zips with care and make a backup first! Do not use this Mount-System.zip to flash new roms, those are best flashed in an unmounted state. The same applies for Magisk and any other system-as-root compatible zips. If you are flashing regular roms my fstab changes will be enough and mount-system will not be needed.
Magisk + Magisk Manager on the ramdisk
In the / directory alongside the other zip files you will find Install-Magisk.zip and Manage-Magisk.zip, these can be used to both install and recovery from Magisk related issues. You no longer need to worry about keeping a copy of Magisk at hand after wiping the data or when you are in need of a downgrade, with this a copy of Magisk and a GUI management tool is always available to you directly from the recovery's root folder.
Persist Backup Tool
It is very important that you keep a spare backup of your persist partition, even the MSMDownloadTool will not be able to repair this as it is unique to your device. In addition devices with persist issues (Sensors, LTE, IMSEI, Wifi, not working / blank) should not use the MSMDownloadTool at all since it can leave you with an unbootable phone. Flash the Backup-Persist.zip file (Found in the recovery's root directory) to automatically create a copy of your persist partition stored on your sdcard so you can easily back this up to a secure location. Persist is even more important than backing up the EFS! An EFS backup alone will NOT recover your phone in the case of persist corruption!
Download
Modified Files
This project contains work from
TWRP Base Image and original Treblize scripts : The Unofficial LineageOS Treble Project
Install-Magisk.zip : Magisk
Manage-Magisk.zip : Magisk Manager Recovery Tool
Known issues
Before uploading i did extensive testing, in some scenario's i managed to cause a hard crash of the recovery image, this is not related to any of the included tweaks but seems to be an issue with flashing a rom when you have just formatted partitions. I advice to always reboot after a partition format or before flashing a system rom to ensure that everything is in a state it can be properly mounted. If you did trigger this white light crash do not fear, your device is not bricked (Unless whatever you flashed bricked it). You should be able to turn it off using the power button after which it will boot up just fine and you can try flashing again.
​
<deleted>
henk717 said:
Before uploading i did extensive testing, in some scenario's i managed to cause a hard crash of the recovery image, this is not related to any of the included tweaks but seems to be an issue with flashing a rom when you have just formatted partitions. I advice to always reboot after a partition format or before flashing a system rom to ensure that everything is in a state it can be properly mounted. If you did trigger this white light crash do not fear, your device is not bricked (Unless whatever you flashed bricked it). You should be able to turn it off using the power button after which it will boot up just fine and you can try flashing again.
Click to expand...
Click to collapse
Might not be restricted to just your recovery.
This happens to me on official TWRP as well, when I restore a system image from a backup. It gets stuck on a white light, and I have to hard reset it. The restore does seem to work though.
I flashed the backup persist but did not found the file it should create. Where is it located? Thanks in advance
It should be located in the main directory of your storage and be called persist.img.
However when i just did another test i noticed the zip gives a 255 error that does not happen on the zip on my gitlab.
I am unsure how this difference happened but generated a new img file where i tested and verified all the zip's manually, if you run into the 255 error please redownload and reflash.

a51 recover data

Hello.
I have a problem: after downgrading my device from Magisk 24.1 back to Magisk 23 I can't unlock my device.
I can only see my wallpaper, but it doesn't respond to touch actions and may reboot.
When I reflash patched boot magisk file it is all the same thing.
Reflashing original boot makes only bootloop or message that data is incompatible.
It is Android 10, AP data file: 'AP_A515FXXU3BTF4_CL18770262_QB31913704_REV00_user_low_ship_meta_OS10'
The question is: how can I pull my /data and /sdcard from my phone?
The recovery is stock version, I've tried to flash TWRP, but TWRP sees only gibberish encrypted file names.
I made a copy of /data/unencrypted folder seems to be containing decryption keys. and entire sda32 containing data partition.
Please help me with ways to restore the system without data wipe or ways how to backup data before reinstalling firmware.
You could try to recover you data with Samsung Smart Switch, when IT doesn't work, there is a way top recover Data from a Phone with ADB tools and a PC.

Any Recovery Editing program?

Is there any program that can edit / modify recoveries?
I have tried to make cwm and twrp for a Panasonic KX-PRX150 by unpacking replacing files and repacking but nothing the phone's screen remains black when booting to recovery mode.
I have also tried to flash the stock recovery and it is not in recovery.img format but in recovery-from-boot.p and a install-recovery.sh flashing it on recovery mode.
Try this guide. I've never tested it.
How to Create and Port TWRP Recovery to any Android Device
In this tutorial, we will show you detailed steps to create and port TWRP Recovery for any Android Device using Android Image Kitchen tool.
www.droidwin.com
Thank you. But I was thinking about Editing my stock recovery.
I'm fond of my own ImgUtil.exe (in the sig) which can modify boot images without taking them all apart and putting them back.
I usually start with stock recovery and replace adbd with a rooted adbd, add a service for it in init.rc (if there is none).
This should all work fine unless you have issues with AVB.

Categories

Resources