• Introducing XDA Computing: Discussion zones for Hardware, Software, and more!    Check it out!

Development [RECOVERY] [UNOFFICIAL] TeamWin Recovery Project

Search This thread

iooxda

Senior Member
Dec 1, 2019
69
33
Hi Group,

I am trying to automate some common TWRP tasks. I see TWRP has command line support here: https://twrp.me/faq/openrecoveryscript.html.

I would like to launch the TWRP terminal and run a shell script when TWRP starts. If this isn't possible then I would like to just run a twrp command or series of commands when TWRP starts.

Earlier Nebrassy mentioned:

/cache/recovery/command

as either the place to put the script or the twrp command. Does anyone know how this works?

I tried MANY different combinations of the following:
Code:
/cache/recovery/command/test.sh
/cache/recovery/command.sh
/cache/recovery/twrp install
/cache/recovery/command/install
/cache/recovery/install
/cache/recovery/install with the file contents "twrp install *.zip"

I can't get the syntax correct, nothing seems to start when I launch TWPR. Nebrassy or others with experience can you explain a bit more how I can run a script automatically when TWPR starts?

Other than that FAQ page I linked above and two vague references there doesn't seem to be any otherreference to the "Open Recovery Script" system and how it works in TRWP.

Thank you.
 

iooxda

Senior Member
Dec 1, 2019
69
33
Hi,

I have run into some problems with my recovery. I am no longer able to decrypt the data partition. I am seeing several errors:

E: unable to decrypt FBE data.
even though Lineage is installed and there is a valid data partition.

If I try to flash Magisk I get:

Unable to mount storage

...and Magisk does install however when I boot recovery it no longer automatically asks for a password to decrypt the data partition. If I try to use the decrypt data button I get:

Failed to decrypt data.
Unable to decrypt with default password. you may need to perform a Format Data.
I also get this error if I try to wipe the data partition.

I did try to format data several times, wiped data, cache, davilk, install firmware and flash LineageOS. The OS installs properly, I can setup a password which it asks for when booting into the OS but my recovery can no longer decrypt data. It used to prompt for the password automatically.

I am not sure what happened, this phone has been working without problems and I have been able to flash many different ROMs, Magisk, format data several times previously but something happened this last time.
Also, if I try to reboot, even into recovery, I get:
No OS installed! Are you sure you wish to reboot?

Even though Lineage is still installed.

Any ideas on how I can recover from this? If I do this, shouldn't it fix the problem:

Open recovery
Wipe data cache davilk
Flash rom
Format data
Reboot.
What is this default password it it is asking for. Does this default password exist somewhere outside of the data partition? Why can the OS decrypt the data but recovery can't?

How can I get recovery to prompt for a password again automatically when I boot into it?

I am running 3.5.2_11-Nebrassy version.
 
Last edited:

iooxda

Senior Member
Dec 1, 2019
69
33
Okay I have tried many different attempts. Different ROMs, formatting data, wiping cache, data etc. I also tried booting from the two older older Nebrassy TWRP images from fastboot etc. Nothing works, TWRP never prompts to decrypt the data anymore and I can't decrypt it manually either. I see this message as soon as I boot into TWRP so this is the root cause:

E: unable to decrypt FBE device
Failed to decrypt data.
Unable to decrypt data with default password. You may need to perform a Format Data.
From the /tmp/recovery.log there is more detail:

Code:
I:Setting up '/data' as data/media emulated storage.
I:Can't probe device /dev/block/sda34
I:Unable to mount '/data'
I:Actual block device: '/dev/block/sda34', current file system: 'f2fs'
I:Can't probe device /dev/block/sda34
I:Unable to mount '/data'
I:Actual block device: '/dev/block/sda34', current file system: 'f2fs'
I:Settings storage is '/data/media'
I:PrepDecrypt::File Based Encryption (FBE) is present.
I:PrepDecrypt::SETPATCH=false, skip_initramfs flag, or ro.boot.fastboot found.
I:PrepDecrypt::crypto.ready=1
I:PrepDecrypt::Script complete. Device ready for decryption.
Cannot log to file /dev/fscklogs/log
I:Successfully decrypted metadata encrypted data partition with new block device: '/dev/block/dm-5'
I:File Based Encryption is present
fscrypt_initialize_systemwide_keys returned fail
fscrypt_initialize_systemwide_keys returned fail
fscrypt_initialize_systemwide_keys returned fail
E:Unable to decrypt FBE device
E:fde::get_crypt_ftr_and_key::Unexpected value for crypto key location:
E:Error getting crypt footer and keyE:Could not get footerFailed to decrypt data.
Unable to decrypt with default password. You may need to perform a Format Data.

These two look like the key log entries:

fscrypt_initialize_systemwide_keys returned fail

E:fde::get_crypt_ftr_and_key::Unexpected value for crypto key location:

E:Error getting crypt footer and keyE:Could not get footerFailed to decrypt data.


I can see there are key files mentioned in the metadata partion. If I format data and install a new ROM, I get the same results, always failed to decrypt FBE device. It doesn't matter if the ROM has a password set or not. Any ideas on what has happened or how to recover from this? Nebrassy?
 

Nebrassy

Recognized Developer
Sep 17, 2015
974
1,832
Lattakia
Xiaomi Poco X3 Pro
Okay I have tried many different attempts. Different ROMs, formatting data, wiping cache, data etc. I also tried booting from the two older older Nebrassy TWRP images from fastboot etc. Nothing works, TWRP never prompts to decrypt the data anymore and I can't decrypt it manually either. I see this message as soon as I boot into TWRP so this is the root cause:


From the /tmp/recovery.log there is more detail:

Code:
I:Setting up '/data' as data/media emulated storage.
I:Can't probe device /dev/block/sda34
I:Unable to mount '/data'
I:Actual block device: '/dev/block/sda34', current file system: 'f2fs'
I:Can't probe device /dev/block/sda34
I:Unable to mount '/data'
I:Actual block device: '/dev/block/sda34', current file system: 'f2fs'
I:Settings storage is '/data/media'
I:PrepDecrypt::File Based Encryption (FBE) is present.
I:PrepDecrypt::SETPATCH=false, skip_initramfs flag, or ro.boot.fastboot found.
I:PrepDecrypt::crypto.ready=1
I:PrepDecrypt::Script complete. Device ready for decryption.
Cannot log to file /dev/fscklogs/log
I:Successfully decrypted metadata encrypted data partition with new block device: '/dev/block/dm-5'
I:File Based Encryption is present
fscrypt_initialize_systemwide_keys returned fail
fscrypt_initialize_systemwide_keys returned fail
fscrypt_initialize_systemwide_keys returned fail
E:Unable to decrypt FBE device
E:fde::get_crypt_ftr_and_key::Unexpected value for crypto key location:
E:Error getting crypt footer and keyE:Could not get footerFailed to decrypt data.
Unable to decrypt with default password. You may need to perform a Format Data.

These two look like the key log entries:

fscrypt_initialize_systemwide_keys returned fail

E:fde::get_crypt_ftr_and_key::Unexpected value for crypto key location:

E:Error getting crypt footer and keyE:Could not get footerFailed to decrypt data.


I can see there are key files mentioned in the metadata partion. If I format data and install a new ROM, I get the same results, always failed to decrypt FBE device. It doesn't matter if the ROM has a password set or not. Any ideas on what has happened or how to recover from this? Nebrassy?
Flash stock, lock the bootloader and unlock it again
 

inglar2k

Member
Dec 4, 2019
27
6
Moscow
Redmi Note 10 Pro
@Nebrassy, what does it mean "E: Unable to decrypt FBE device"?
ROM has been installed successfully and working properly, but why this error appears in log?

Install process is standard, format data -> reboot to recovery -> wipes -> reboot to recovery -> install zips
photo_2021-09-30 00.05.53.jpeg
 

rzfndrkt

New member
Oct 19, 2013
4
2
hi. i have stock miui rkfeuxm 12.5.4 global stable and when i install this twrp 3.5.2, after i reboot the phone. the stock recovery overwrite this twrp
 

WhereIsMyROM

Member
Oct 11, 2021
5
1
I am also facing the same issue as @rzfndrkt i.e. TWRP is being overwritten by stock MIUI recovery.

Here is the process that I followed:
1) Unlock bootloader
2) Flash recovery using minimal adb (Command: fastboot flash recovery recovery.img)
3) Boot to TWRP after successfully flashing

But as soon as i try to boot into system and then again to recovery I am welcomed by MIUI recovery instead of TWRP.

I have successfully followed the above steps to flash TWRP in my Redmi Note 4 and Poco F1 without any issues.

I also tried to follow certain tutorials one of which said to do the following procedure:
1) Unlock bootloader
2) Then use minimal adb to and type fastboot boot recovery.img and then in TWRP->Advanced->Flash current recovery. But this option is simply missing. Maybe the option has been removed (not sure).

Please help @Nebrassy . I really hate MIUI and want to use custom ROMs.

BTW mine is Indian unit of Redmi Note 10 pro (I think its called sweetin).

Also, please let me know if I missed something or if any more info is needed.

Thanks
Ayush
 

Laptapper

Senior Member
Jan 17, 2016
839
317
hi. i have stock miui rkfeuxm 12.5.4 global stable and when i install this twrp 3.5.2, after i reboot the phone. the stock recovery overwrite this twrp

I am also facing the same issue as @rzfndrkt i.e. TWRP is being overwritten by stock MIUI recovery.

Here is the process that I followed:
1) Unlock bootloader
2) Flash recovery using minimal adb (Command: fastboot flash recovery recovery.img)
3) Boot to TWRP after successfully flashing

But as soon as i try to boot into system and then again to recovery I am welcomed by MIUI recovery instead of TWRP.

I have successfully followed the above steps to flash TWRP in my Redmi Note 4 and Poco F1 without any issues.

I also tried to follow certain tutorials one of which said to do the following procedure:
1) Unlock bootloader
2) Then use minimal adb to and type fastboot boot recovery.img and then in TWRP->Advanced->Flash current recovery. But this option is simply missing. Maybe the option has been removed (not sure).

Please help @Nebrassy . I really hate MIUI and want to use custom ROMs.

BTW mine is Indian unit of Redmi Note 10 pro (I think its called sweetin).

Also, please let me know if I missed something or if any more info is needed.

Thanks
Ayush


Please try ro flash twrp via adb (before that: developer settings usb debug on)
After Flashing don't restart via adb, instead use hardware buttons to reboot in recovery
Then afterwards directly format data in twrp with yes, reboot twrp, flashing ROM gapps magisk...
Format data with yes again and reboot, ignore failures, reboot give time
 
I am also facing the same issue as @rzfndrkt i.e. TWRP is being overwritten by stock MIUI recovery.

Here is the process that I followed:
1) Unlock bootloader
2) Flash recovery using minimal adb (Command: fastboot flash recovery recovery.img)
3) Boot to TWRP after successfully flashing

But as soon as i try to boot into system and then again to recovery I am welcomed by MIUI recovery instead of TWRP.

I have successfully followed the above steps to flash TWRP in my Redmi Note 4 and Poco F1 without any issues.

I also tried to follow certain tutorials one of which said to do the following procedure:
1) Unlock bootloader
2) Then use minimal adb to and type fastboot boot recovery.img and then in TWRP->Advanced->Flash current recovery. But this option is simply missing. Maybe the option has been removed (not sure).

Please help @Nebrassy . I really hate MIUI and want to use custom ROMs.

BTW mine is Indian unit of Redmi Note 10 pro (I think its called sweetin).

Also, please let me know if I missed something or if any more info is needed.

Thanks
Ayush
All what you did is right. But once you boot into twrp flash dm verity disabler zip. You won't get any issues like recovery being replaced or phone not booting at all.
 

WhereIsMyROM

Member
Oct 11, 2021
5
1
Thank you @Laptapper and @[email protected] for your prompt responses.

Please try ro flash twrp via adb (before that: developer settings usb debug on)
After Flashing don't restart via adb, instead use hardware buttons to reboot in recovery
Then afterwards directly format data in twrp with yes, reboot twrp, flashing ROM gapps magisk...
Format data with yes again and reboot, ignore failures, reboot give time

I tried the procedure you mentioned but now there is a new problem, after TWRP is flashed (from adb) and I boot into recovery via hardware buttons and format data (with yes), I can no longer see my internal storage on my pc which means i cannot copy ROMs, Gapps etc.

I also tried rebooting to recovery after format data and the result is same, still my internal storage is not detected

I even deleted Dalvik/ART cache, Cache, Data and then again did format data and then rebooted to recovery only to find that nothing changed 🥲

All what you did is right. But once you boot into twrp flash dm verity disabler zip. You won't get any issues like recovery being replaced or phone not booting at all.

Ok I will try that once my internal storage is detected somehow.

A few observations:
  • When I format data, on the terminal the first thing it shows is "E: Unable to decrypt FBE device" (I don't have any pin or password, just our regular swipe to unlock)
  • "Unable to find partition for path '/system_root' " (I get this message only if I format data and reboot to recovery via inbuilt reboot to recovery option)

I honestly can't understand why is this happening.

Thank you
Ayush
 

Laptapper

Senior Member
Jan 17, 2016
839
317
Thank you @Laptapper and @[email protected] for your prompt responses.



I tried the procedure you mentioned but now there is a new problem, after TWRP is flashed (from adb) and I boot into recovery via hardware buttons and format data (with yes), I can no longer see my internal storage on my pc which means i cannot copy ROMs, Gapps etc.

I also tried rebooting to recovery after format data and the result is same, still my internal storage is not detected

I even deleted Dalvik/ART cache, Cache, Data and then again did format data and then rebooted to recovery only to find that nothing changed 🥲



Ok I will try that once my internal storage is detected somehow.

A few observations:
  • When I format data, on the terminal the first thing it shows is "E: Unable to decrypt FBE device" (I don't have any pin or password, just our regular swipe to unlock)
  • "Unable to find partition for path '/system_root' " (I get this message only if I format data and reboot to recovery via inbuilt reboot to recovery option)

I honestly can't understand why is this happening.

Thank you
Ayush
Try to use a sd card for ROM gapp... files
Or usb otg
 
Last edited:

WhereIsMyROM

Member
Oct 11, 2021
5
1
Thanks for the super quick responses @Laptapper

Try to use a sd card for ROM gapp... files
Or usb otg
So I tried flashing ROM from sd card as you suggested and I get an error. I have attached a pic of error.

I am going to try OrangeFox and let you know if that works or not.

Please let me know if you need any more info.

EDIT:
I tried OrangeFox just now and it works without any errors. I successfully flashed crdroid and flamegapps. So I can confirm that nothing is wrong with my device. But I still cannot understand why TWRP doesn't work. It is my favorite recovery and I would really like to use it.

Thank you
Ayush
 

Attachments

  • IMG_20211011_211906.jpg
    IMG_20211011_211906.jpg
    1.1 MB · Views: 22
Last edited:
  • Like
Reactions: RAMBO29

ZainBilq

Senior Member
Nov 29, 2014
1,038
421
Thanks for the super quick responses @Laptapper


So I tried flashing ROM from sd card as you suggested and I get an error. I have attached a pic of error.

I am going to try OrangeFox and let you know if that works or not.

Thank you
Ayush
Super Partition or something is damaged. You need to flash stock or any other MIUI ROM which has fix for not damaging partition.

Cheers!
 

WhereIsMyROM

Member
Oct 11, 2021
5
1
Thank you for your response @ZainBilq
Super Partition or something is damaged. You need to flash stock or any other MIUI ROM which has fix for not damaging partition.

Cheers!
Ok.

But out of curiosity, why doesn't OrangeFox show any errors, tried it just now and successfully flashed CrDroid and FlameGapps. I mean if a partition is damaged or something then shouldn't OrangeFox also throw errors since it uses codebase from TWRP.

Thanks a lot.

Cheers!
 

Laptapper

Senior Member
Jan 17, 2016
839
317
Thanks for the super quick responses @Laptapper


So I tried flashing ROM from sd card as you suggested and I get an error. I have attached a pic of error.

I am going to try OrangeFox and let you know if that works or not.

Please let me know if you need any more info.

EDIT:
I tried OrangeFox just now and it works without any errors. I successfully flashed crdroid and flamegapps. So I can confirm that nothing is wrong with my device. But I still cannot understand why TWRP doesn't work. It is my favorite recovery and I would really like to use it.

Thank you
Ayush

You'll have to reboot twrp after format data
Which twrp version?
 

fmrogonhantu

Member
Apr 15, 2012
10
0
ive got issue when flashing zip file.twrp will restart when im trying to flash any zip file

then it shows internal and sd card 0mb? when trying to boot to system it says no os installed.

it works just fine before.
 

Top Liked Posts

  • There are no posts matching your filters.
  • 2
    Hello,
    I have an issue to report with TWRP 3.5.2 from you, Nebrassy. I don't know if this is a known issue, but when you format data it will change dm-5 to sda34 and thus preventing TWRP to decrypt FBE (File Based Encryption) and so the internal storage. To fix this you have to use ADB Sideload to push a ROM. It'll install normally and revert sda34 back to dm-5.

    Before formating data and also after restarting to OS after ADB Sideload push:
    unknown.png


    After:
    unknown1.png
    1
    Thanks for the super quick responses @Laptapper

    Try to use a sd card for ROM gapp... files
    Or usb otg
    So I tried flashing ROM from sd card as you suggested and I get an error. I have attached a pic of error.

    I am going to try OrangeFox and let you know if that works or not.

    Please let me know if you need any more info.

    EDIT:
    I tried OrangeFox just now and it works without any errors. I successfully flashed crdroid and flamegapps. So I can confirm that nothing is wrong with my device. But I still cannot understand why TWRP doesn't work. It is my favorite recovery and I would really like to use it.

    Thank you
    Ayush
    1
    All what you did is right. But once you boot into twrp flash dm verity disabler zip. You won't get any issues like recovery being replaced or phone not booting at all.
    Thanks. It works for me.
    1) flash image recovery
    2) boot image recovery
    3) flash disable dm verity forceencrypt
    1
    If you flash any android 12 based ROM and boot, then go back to recovery, TWRP doesn't ask for password and doesn't recognize partitions.
    Decrypting 12 isn't supported
    1
    I'm sorry for spamming here.. there was a problem with the downoladed zip archive. I've downloaded a new package an now is flashing via adb sideload correctly.
    Good, I'm glad it's fixed!
  • 40



    Introduction:

    Team Win Recovery Project or TWRP for short, is a custom recovery built with ease of use and customization in mind. We started from the ground up by taking AOSP recovery and loading it with the standard recovery options, then added a lot of our own features. It's a fully touch driven user interface , no more volume rocker or power buttons to mash. The GUI is also fully XML driven and completely theme-able. You can change just about every aspect of the look and feel.

    Key Features:

    Touchscreen driven with real buttons and drag-to-scroll
    XML-based GUI that allows full customization of the layout true theming!
    Settings are saved to the sdcard and persist through reboots
    Ability to choose which partitions to back up and which to restore
    Ability to choose to compress backups now with pigz (multi-core processor support for faster compression times)
    Onscreen keyboard
    Easy selection of internal/external storage

    In addition to the above new features, TWRP features a scripting engine that allows an app to send commands to the recovery for the recovery to perform during startup. We call this scripting engine OpenRecoveryScript. This engine will be put to use immediately in the GooManager app. GooManager will be able to install recoveries automatically for most supported devices. The app will also let you choose to install multiple zips from within Android, wipe, and run a backup.

    We are looking for other talented developers, themers, and device maintainers if they are interested in helping with a free, open source project.

    Source Code:

    GitHub - https://github.com/TeamWin/android_bootable_recovery

    Gerrit Instance - http://gerrit.twrp.me

    If you have made your own TWRP build for an unsupported device, please let us know. We might add your build to the list of unofficial builds. Bear in mind that we are working hard to add more devices and we may add your device to our official build list later.

    Hello, this is TWRP, for Redmi note 10 Pro Global/Indian/Indian Pro Max (sweet/sweetin)

    touch and adb work
    SD card and USB OTG are working
    Decryption is working

    Send me a beer: Crypto(Preferred) | PayPal

    Tree: https://github.com/nebrassy/device_xiaomi_sweet-TWRP

    Telegram group: https://t.me/NSSFB

    Download: https://www.androidfilehost.com/?w=files&flid=324059
    21
    New build is up

    Fixed adb sideload
    Fixed fastbootd
    Fixed vibration
    Fixed decryption on stock while flashed
    13
    New build, decryption now works

    Problems as of now are:
    adb sideload
    fastbootd
    vibration

    6
    New twrp for redmi note 10 pro is OUT now


    I prefer this version than the team win
    that's just mine, renamed and reuploaded...
    4
    Hi folks! First, thanks, Nebrassy for gettin TWRP going on this phone!

    I'm using 3.5.1 10.0 and so far have been unsuccessful at restoring any backups I make. The restore appears to succeed but upon boot I get a boot loop before going back to recovery. Are others having this issue?
    - if you are trying to restore backups of encrypted data, you'll most likely fail with restore
    - the only way how to use restore backup function properly AFAIK is to use decrypted storage/data and before backup remove any lockscreen protection (pin, pattern, password) from android, check this for more hints as what to expect (it is written for other phone, but most of it applied also on sweet)