[RECOVERY][UNOFFICIAL] TWRP HH for Nexus 5 (hammerhead)

z3DD3r

Senior Member
Feb 9, 2016
167
1,027
123
Minsk
TWRP HH for Nexus 5

About:
TWRP is an open source, community project. TWRP development is done by roughly 4 people at this point. We also have a large support community with many people who are willing to answer questions and help people with their devices either through our IRC channel or on forums like xda-developers.

Team Win was originally formed to work on porting WiMAX to CM7 for the HTC EVO 4G. After our work on the EVO 4G we wanted to work on a project that would work on more devices than just the EVO 4G and we settled on working on a recovery. Today TWRP is the leading custom recovery for Android phones.

A custom recovery is used for installing custom software on your device. This custom software can include smaller modifications like rooting your device or even replacing the firmware of the device with a completely custom "ROM" like OmniROM
Disclaimer:
Code:
#include <std_disclaimer.h>

/*
* Your warranty is now void.
*
* We are not responsible for bricked devices, dead SD cards,
* thermonuclear war, or you getting fired because the alarm app failed. Please
* do some research if you have any concerns about features included in this RECOVERY
* before flashing it! YOU are choosing to make these modifications, and if
* you point the finger at us for messing up your device, we will laugh at you.
*
*/
You can find the source code for TWRP on GitHub. If you would like to contribute to TWRP, please visit Gerrit Code Review.

Features:
HH.S version with stock partitions map. S means stock.
HH.R version with repartition support. R means repartition.
Working decryption on custom roms. Tested on LOS 16.0 and LOS 17.1 but should work on all Androids since Nougat.
exFAT and NTFS support (read and write) for USB OTG

Requirements:
You need to have an unlocked bootloader to install and use TWRP!

Known bugs:
Everything looks good so far

Downloads:
https://sourceforge.net/projects/hammerhead-twrp/files/beta/

Credits:
TeamWin
@Clamor
@steadfasterX
And all the contributors out there in the community

Contributors:
@z3DD3r

Source Code:
Device tree: https://github.com/z3DD3r/twrp_android_device_lge_hammerhead

Version Information:
Satus:
Stable
TWRP version: 3.5.0
HH Project versions: HH.S.10 and HH.R.10

Created 2020-02-08
Last Updated 2021-02-05
 
Last edited:

z3DD3r

Senior Member
Feb 9, 2016
167
1,027
123
Minsk
Repartition (HH.R versions)

ALWAYS DO THE BACKUPS!!!
No one is responsible for your actions!
Repartition may potentially brick your device, although risk is reduced to minimum.

Features:
Increases /system partition to ~1444Mb
Decreases /cache partition to ~255Mb
Doesn't provide /vendor partition
Doesn't touch /data partition

Requirements:
Not modified partitions by any other solutions

How to increase /system partition and change partitions map:
- Flash the HH.R version of TWRP and launch it
- Open terminal (TWRP -> Advanced -> Terminal)
- Type hh_repart -m
- Wait until your phone reboots
- Install your rom

How to revert back to stock /system size and stock partitions map:
- Launch HH.R version of TWRP
- Open terminal (TWRP -> Advanced -> Terminal)
- Type hh_repart -r
- Wait until your phone reboots
- Flash official TWRP or HH.S version of TWRP! Don't ignore this step!

How to dump partitions map:
- Launch HH.R version of TWRP
- Open terminal (TWRP -> Advanced -> Terminal)
- Type hh_repart -d
- Wait until process finishes
- Look at /sdcard/partitions.log file
 

z3DD3r

Senior Member
Feb 9, 2016
167
1,027
123
Minsk
Some technical notes about the decryption and Android Q support.

Right now the only possible way to decrypt data on our devices is to use system's vold. This logic was added to TWRP some time ago but one required change wasn't in the tree. This change is here: https://gerrit.twrp.me/c/android_bootable_recovery/+/1919. Without this patch system's vold will fail on hammerhead. I don't know why but services in the sbin can't handle decryption. Also using the system's vold means that ROM should be installed to decrypt data. Without installed ROM decryption is not possible!

About SAR and Android Q. Work on SAR support in TWRP is still in progress but some patches are already available on gerrit. These patches are required to properly detect SAR and mount partitions. Also since Android Q one more service should be run before trying to decrypt data. This service is apexd. Android Q runs apexd on early-init stage to provide required runtime libraries. U can see how it launched at https://android.googlesource.com/pl...fs/tags/android-10.0.0_r29/rootdir/init.rc#37. Only after that step all other services like qseecomd, hwservicemanager, servicemanager and keymaster can be run from system or vendor.

The last point is prebuilt vdc. Prebuilt vdc_pie which is shipped with TWRP fails to run because of linker error. I don't remember exactly what was the error but i guess that something is removed in libc. To fix that problem i've built vcd_ten binary with Android Q sources and placed it into device tree for hammerhead as a temporary solution. The source code of that binary is identical to vdc_pie which located at https://github.com/TeamWin/android_...b/android-9.0/crypto/vold_decrypt/vdc_pie.cpp

This is just a quick notes about what was done.
Patched bootable_recovery is located at https://github.com/z3DD3r/twrp_android_bootable_recovery/tree/android-9.0
Device tree for Q located at https://github.com/z3DD3r/twrp_android_device_lge_hammerhead/tree/q-sar

I hope this will be helpful for TWRP Team!
PS: Changes i've made should be improved. Don't treat them as production ready and/or stable!

FYI @Dees_Troy
 
Last edited:

VnnAmed

Senior Member
Sep 23, 2011
773
604
0
Poznań
Hi, thank you very much for this solution.

hh_repart -d - worked but I couldn't read the log file before rebooting, maybe it's obvious
hh_repart -m - worked without any issues

I have also successfully flashed Lineage 17.1 from your other thread, gapps and Magisk.
 
  • Like
Reactions: z3DD3r

dahawthorne

Senior Member
Nov 15, 2014
1,943
1,792
143
Brighton
I have a question, certainly not in any way a complaint.
I have been running HH4 for a few days. Last night I made a TWRP backup of my LineageOS 17.1, which I installed on 20th without Gapps to see how it works without Google - quite well, in fact, with the help of APK Updater.
This morning I stupidly applied the 22nd update with Gapps - I was on autopilot and forgot that this device had no Google.
No problem, I thought, I'll just restore last night's backup. So I did a total wipe and format ("yes"), but no backup will restore. I just get the LOS line-&-circle animation for ages. I've tried earlier backups, and even standard unmodified TWRP, all with the same result. No backup will restore.
It's not a big deal - I can start with a totally new installation - but I'd like to know if anyone has taken a backup and successfully restored it. Or am I just lucky...? :) If I can't restore, then it sort of defeats the point of TWRP, no?
Edit: Seriously, 85 people have downloaded HH4. Has not a single one of you tried a restore of a backup?
Edit: Tumbleweed... :)
Edit: Do I take it that nobody has tried to restore a backup? If you haven't, and my experience is normal, then we're risking a two-hour fresh install in case of update problems rather than a two-minute restore.
 
Last edited:

z3DD3r

Senior Member
Feb 9, 2016
167
1,027
123
Minsk
I have a question, certainly not in any way a complaint.
I have been running HH4 for a few days. Last night I made a TWRP backup of my LineageOS 17.1, which I installed on 20th without Gapps to see how it works without Google - quite well, in fact, with the help of APK Updater.
This morning I stupidly applied the 22nd update with Gapps - I was on autopilot and forgot that this device had no Google.
No problem, I thought, I'll just restore last night's backup. So I did a total wipe and format ("yes"), but no backup will restore. I just get the LOS line-&-circle animation for ages. I've tried earlier backups, and even standard unmodified TWRP, all with the same result. No backup will restore.
It's not a big deal - I can start with a totally new installation - but I'd like to know if anyone has taken a backup and successfully restored it. Or am I just lucky...? :) If I can't restore, then it sort of defeats the point of TWRP, no?
Edit: Seriously, 85 people have downloaded HH4. Has not a single one of you tried a restore of a backup?
Edit: Tumbleweed... :)
Edit: Do I take it that nobody has tried to restore a backup? If you haven't, and my experience is normal, then we're risking a two-hour fresh install in case of update problems rather than a two-minute restore.
Have u tried to restore backup of other ROMS? I guess it is not TWRP's problem...
 
  • Like
Reactions: ze7zez

sant514

Senior Member
Jun 1, 2014
98
49
48
I have a question, certainly not in any way a complaint.
I have been running HH4 for a few days. Last night I made a TWRP backup of my LineageOS 17.1, which I installed on 20th without Gapps to see how it works without Google - quite well, in fact, with the help of APK Updater.
This morning I stupidly applied the 22nd update with Gapps - I was on autopilot and forgot that this device had no Google.
No problem, I thought, I'll just restore last night's backup. So I did a total wipe and format ("yes"), but no backup will restore. I just get the LOS line-&-circle animation for ages. I've tried earlier backups, and even standard unmodified TWRP, all with the same result. No backup will restore.
It's not a big deal - I can start with a totally new installation - but I'd like to know if anyone has taken a backup and successfully restored it. Or am I just lucky...? :) If I can't restore, then it sort of defeats the point of TWRP, no?
Edit: Seriously, 85 people have downloaded HH4. Has not a single one of you tried a restore of a backup?
Edit: Tumbleweed... :)
Edit: Do I take it that nobody has tried to restore a backup? If you haven't, and my experience is normal, then we're risking a two-hour fresh install in case of update problems rather than a two-minute restore.
With TWRP 3.3.1-HH.R.4 nanroid backup and restore in LOS 14.1 with encyption = ok
With TWRP 3.3.1-HH.R.4 nanroid backup and restore in LOS 17.1 with encyption = ok
 

dahawthorne

Senior Member
Nov 15, 2014
1,943
1,792
143
Brighton
Since I was the one to mention my problem with restoring a TWRP image, I think I should report that, as z3DD3r stated above, TWRP HH 4 does indeed work fine in making and restoring backups. I took a backup yesterday and restored it this morning; no wipe, just a straight recovery, and it all went through in less than two minutes.
Thanks for all your work, z3DD3r. It's great to have bleeding-edge software on such an old device.
 
  • Like
Reactions: z3DD3r

TomiLynch

Senior Member
Jan 31, 2017
441
429
63
Hello @z3DD3r , I've been working on a ship for the last couple of months, so missed some things.

I'm using the first original twrp-3.3.1-HH-hammerhead version you shared in the telegram group, but now I found this thread with newer versions.

Just wanted to double check if it's okay to update straight from that original HH version (ALREADY REPARTED) to the lates HH.R.4 without any problems.


How to revert back to stock /system size and stock partitions map:
- Launch HH.R version of TWRP
- Open terminal (TWRP -> Advanced -> Terminal)
- Type hh_repart -r
- Wait until your phone reboots
- Flash official TWRP or HH.S version of TWRP! Don't ignore this step!
And just out of curiosity, cause I'm not planning on reverting to stock partitions. Why is it so important to flash official or HH.S version after reverting?
What is the difference between stock and HH.S.4 then?

Thanks for putting your time and efforts in to keeping this device alive!
 

z3DD3r

Senior Member
Feb 9, 2016
167
1,027
123
Minsk
Hello @z3DD3r , I've been working on a ship for the last couple of months, so missed some things.

I'm using the first original twrp-3.3.1-HH-hammerhead version you shared in the telegram group, but now I found this thread with newer versions.

Just wanted to double check if it's okay to update straight from that original HH version (ALREADY REPARTED) to the lates HH.R.4 without any problems.
twrp-3.3.1-HH-hammerhead and TWRP HH.R uses the same script for repartition. So, yes, it is okay to flash HH.R over the twrp-3.3.1-HH-hammerhead.


And just out of curiosity, cause I'm not planning on reverting to stock partitions. Why is it so important to flash official or HH.S version after reverting?
What is the difference between stock and HH.S.4 then?

Thanks for putting your time and efforts in to keeping this device alive!
Because TWRP includes size of system partition. This size should match the size of system partition on device. Otherwise bad things can happen...