[RECOVERY][UNOFFICIAL_MOD][DECRYPTION][UPDATED-02-01-2019] TWRP 3.2.3-4 for nitrogen

Search This thread


Senior Member
Jan 10, 2010
Huawei Watch
Xiaomi Mi Max 3
TWRP is not outdated for some of us.. absolutely essential for a few of us.
With Orangefox latest stable, I ran into the ongoing Encryption Unsuccessful message when flashing latest customs...

TWRP worked a treat.. an oldie but a goodie.

Top Liked Posts

  • There are no posts matching your filters.
  • 67


    Sharing my unofficial TWRP recovery mod for nitrogen which I have started about 2 years ago for hydrogen/helium. For more details visit https://forum.xda-developers.com/mi-max/development/recovery-twrp-3-0-2-2-hydrogen-helium-t3512981...
    This is and will be work in progress with fixes and reasonable features to be added.

    To install:
    - USB connect device to PC
    - reboot to fastboot
    - open Command prompt/Terminal in the folder with the recovery image and run these commands line by line:
    fastboot flash recovery (XX-XX-XXXX)twrp_v323-X_nitrogen_nijel8-MOD.img
    fastboot boot (XX-XX-XXXX)twrp_v323-X_nitrogen_nijel8-MOD.img
    or just flash the image with TWRP selecting recovery partition
    - reboot from the fresh recovery - it'll take few seconds... let it do its magic to survive MIUI stock recovery replace at system boot. This will happen whenever you install any new ROM.
    Done... This TWRP will not go anywhere, /system is untouched so you can get MIUI OTAs, no need to root if you don't want to, no need to flash anything else, MIUI boots just fine having no idea about the recovery, everybody's happy...;)


    ROM install:
    - skip wiping Data even if switching different ROMs. Do dirty install, see how it runs, if no problems, great... you saved yourself from doing the initial
    setup. If having issues then wipe Data and see how it goes...
    - You do not need to wipe/format/factory reset anything before install(see above), especially System and Vendor.
    - Do not install any patches like lazyflasher, sound or whatever mods, root-on-system etc that are altering System or Vendor partitions on stock MIUI without installing Magisk first or system will not boot!!!

    MIUI OTA Install:
    - Let MIUI download update and press "Reboot" when prompted
    - Device will reboot to TWRP and start installing it.
    - If device reboots to system automatically - all good, update successful
    - If device does not reboot you should see some error in red
    - Just flash the zip package in Internal storage -> downloaded_rom folder and reboot to system
    - Done - you just got your OTA :)

    If MIUI asks for decription password after reboot from TWRP don't panic!
    You will most likely never see this but as anything in this live sh*t happens. I for example have seen this only once in hundreds of TWRP and MIUI flashings and reboots to system and it happen after reboot from MIUI OTA testing. Did I mentioned I never do clean installs? Why bother wiping if no post-install issues, right...
    Anyway... here is how to get back to normal without loosing any data:
    - Reboot back to recovery by pressing and holding POWER + VOLUME UP buttons
    - Run Data backup in TWRP
    - USB connect device to computer and copy all personal data you don't wanna loose from Internal storage to computer
    - Click Wipe -> Format data -> type yes -> [ENTER]
    - Reboot to MIUI and let it encrypt the device. You will see Setup new device wizard when its done
    - Reboot back to recovery by pressing and holding POWER + VOLUME UP buttons
    - Copy back all your personal data including the recent Data backup from computer to Internal storage -> TWRP/BACKUPS/XXXXXX
    - Reboot recovery so TWRP can detect the Data backup you copied
    - Restore Data backup and reboot to MIUI
    - Done - MIUI should boot without complaining and all your data is intact... even your old lockscreen password and fingerprints should work

    - normal backup includes Data only, you can always flash what you are running currently to restore boot, system and vendor
    - if you have modified boot,system or vendor post install you can back them up to keep your changes
    - You do not need to wipe/format/factory reset anything before restore... restore does that for you

    Some observations during my extended decryption testing with China and Global MIUIs 8.1 and 9.0, EU MIUIs, MIUIPro, etc:
    - Downgrading to ROM with lower security patch level brakes encryption in Android but not in TWRP so just boot back to recovery, backup your data to safe location, format data, restore data back and you are good to go...
    - Some times switching back and forth passwords types(pin, pattern etc...) brakes encryption and you loose your data, no way back!!! This is ROM fault and not TWRP. Crypto footer just gets corrupted from Android... I have taken good measures for this not to happen in my TWRP so don't blame recovery if that happens to you...


    - hide navbar during running operarions
    - more userdata decryption reliability improvements
    - Mi bunny is terrified loosing recovery control :D
    - sync with latest Omnirom android-9.0 sources

    - fix decryption with good user password on next retry if wrong password was entered before that
    - improve TWRP persist
    - sync with latest Omnirom android-9.0 sources

    - fix system boot after restoring regular file-for-file backup on ext4 file systems(System and Vendor) - now any backup type works for any partition of any ROM
    - sync with latest Omnirom android-9.0 sources

    - fix installing incremental OTA patching boot - this will start working properly after your first full ROM install with new recovery(boot.img flash)
    - fix loading settings from /persist if decryption fails
    - made sure we always keep current settings copy on /persist
    - remove excessive save settings calls
    - some minor improvements
    - sync with latest Omnirom android-9.0 sources

    - fix incremental OTA update automatic install
    - sync with latest Omnirom android-9.0 sources

    - new much smaller Pie kernel built from source with LineageOS 16.0
    - much smaller recovery image(see above)
    - sync with latest Omnirom android-9.0 sources

    - improved decrypt routine
    - some minor fixes and improvements
    - sync with latest Omnirom android-9.0 sources

    - much improved and reliable decryption routine for preventing crypto footer corruption and loosing all your data - this update is highly recomended
    - fix Android 9.0 userdata decryption with custom user set password, pin or pattern
    - more reliable format data routine for crypto footer support
    - disable useless and sometime buggy reboot check for system size(No OS installed msg)
    - sync with latest Omnirom android-9.0 sources

    - migrate to Android-9.0 for android tree and TWRP sources
    - switch to MIUI Pie prebuilt kernel
    - speed up userdata decryption
    - fix userdata decryption for Android-9.0 with default password only. At this time userdata decryption wit user set password is not supported! Working on it...
    - sync with latest Omnirom android-9.0 sources

    - fix survival routine hang/bootloop after openrecoveryscript execution(OTA)
    - improved decryption handling

    - fix userdata decryption - no more inaccessible userdata in TWRP
    - fix vendor missing from partitions to restore list in some cases
    - fix TWRP bootloop trying to apply survive magic in some cases
    - finaly fix crypto footer for F2FS partition formating(tested and working!!! - you can format userdata in TWRP without any system boot issues now)
    - skip survive magic for good ROMs to speed up reboot
    - translatable and more user friendly survive system boot screen - If you want to help translate and PM me these strings:"
        <!-- Survive system boot strings -->
        <string name="survive_line1">Checking if TWRP will survive system boot!</string>
        <string name="survive_line2">Please, wait...</string>
    - sync with latest Omnirom android-8.1 TWRP sources

    - fix TWRP system boot survive - no need to flash anything to prevent stock recovery reflash at MIUI boot
    - fix crypto footer for F2FS partition format - need no more fastboot format userdata for system boot with forced encription enabled(needs testing)
    - fix error when creating ext2, ext3, or ext4 filesystem in some cases(needs testing)
    - some minor fixes and optimizations
    - kernel compiled from source at build time
    - build with latest Lineage OS 15.1 sources
    - sync with latest Omnirom android-8.1 TWRP sources

    Github sources:
    NITROGEN TWRP device tree
    TWRP Mod repo
    Kernel source

    Thank you:
    TeamWin for the initial device tree!
    Omnirom/TeamWin for the TWRP source code!
    @topjohnwu for the magiskboot source code!
    Updated... Now any backup type works for any partition of any ROM, stock/custom doesn't matter, dm-verity doesn't matter, Magisk doesn't matter.
    Updated... New Pie kernel built from source with LineageOS 16.0!
    Updated... Pie decryption completely fixed among other critical things! Fill very good about this release...
    It's LOS time...

    WoW! Nice work!
    Booted (not flashed permanently). Working. No data encryption issue! I could make a full backup with this version!
    But after backup, system does not reboot, stucked on MI logo.
    It's just an experience, there's no problem.
    But the experience is that this recovery still doesn't work smoothly with the stock MIUI ROM ( I know, you hate this).
    Maybe last TWRP survival script? I do not know...

    I will continue to explore. Now, check if the new recovery works well with TREBLED ROM.

    To be continued...
    Sorry, can't help with that. Done countless backups/restore in my testing and had zero issues...


    Thank you very much.

    I always had problems installing MiuiPro with the previous version.

    The installation was repeated again and again after it was finished, after a restart.

    Something about your script triggered that.
    That was fixed couple of versions back. Also reading about data partition size issues after flashing MIUIPro but I personally never experienced it in my testing.
    But to tell you the true MIUIPro looks kinda fishy in my eyes as a dev, poor porting job IMO. And on top of that with paid OTA updates!? Shame on that guy... Just my 2 cents...
    Posted 12-30-2018 update earlier taken down. What I thought was easy fix for incremental OTA updates proved to be much harder... Fixing it breakes decryption. Fixing decryption breakes incremental OTA.
    So decryption it is for the time being. You can always update with full package ROM.
    If anybody installed 12-30-2018 update, please redownload and install again. Sorry for the inconvenience...