100% found this document useful (1 vote)
897 views11 pages

(DEV) How To Compile TWRP Touch Recovery - Android Development and Hacking

Uploaded by

muji ono
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
100% found this document useful (1 vote)
897 views11 pages

(DEV) How To Compile TWRP Touch Recovery - Android Development and Hacking

Uploaded by

muji ono
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 11

2/26/2020 [DEV]How to compile TWRP touch recovery | Android Development and Hacking

NEWS FORUMS DEVICES TOPICS BEST POSTS

# Honor 9X # Snapdragon # Xiaomi # OnePlus 7T Pro # Honor # Redmi Note 8 Pro # Pixel 4 # Galaxy Note 10 # ZenFone 6 # Samsung # 5G # Galaxy S20 # Android 11

 xda-developers  Android Development and Hacking  Android Software Development  [DEV]How to compile TWRP touch recovery by Dees_Troy

[DEV]How to compile TWRP touch recovery


By Dees_Troy, Senior Recognized Developer on 18th October 2012, 05:29 PM

1,705 posts
  
Thanks:
Thanks: 13,615   Tweet   Like

 Reply

1 2 3 11 51 101  Last  Search Thread FORUMS

All of TWRP 3.x source is public. You can compile it on your own. This guide isn't going to be a step-by-step, word-for- Android Software Development
word type of guide. If you're not familiar with basic Linux commands and/or building in AOSP then you probably won't
Android General
be able to do this.

Android Q&A, Help & Troubleshooting


You can currently use Omni 5.1, Omni 6.0, Omni 7.1, Omni 8.1, CM 12.1, CM 13.0, CM 14.1,
14.1, or CM 15.1 source code.
code. Omni 7.1 is
recommended. You can build in CM but you may run into a few minor issues. If you don't know how to x make le
Android Software and Hacking General
issues, then you should choose to use Omni instead.
[Developers Only]

If you are using CM, you'll need to place TWRP in the CM/bootable/recovery-twrp folder and set RECOVERY_VARIANT
Miscellaneous Android Development
:= twrp in your BoardCon g.mk le.
le. TWRP source code can be found here:
https://github.com/omnirom/android_bootable_recovery [More]
Select the newest branch available. This step is not necessary with Omni because Omni already includes TWRP source
by default, however, if you are using an older version of Omni, you will probably want to pull from the latest branch
(the latest branch will compile successfully in older build trees)

If you are only interested in building TWRP, you may want to try working with a smaller tree. You can try using this
manifest. It should work in most cases but there may be some situations where you will need more repos in your tree
than this manifest provides:
https://github.com/minimal-manifest-twrp

*BEFORE YOU COMPILE*


Note:
Note: If you add or change any ags, you will need to make clean or make clobber before recompiling or your ag
changes will not be picked up.

Now that you have the source code,


code, you'll need to set or change a few build ags for your device(s). Find the
BoardCon g.mk for your device.
device. The BoardCon g.mk is in your devices/manufacturer/codename folder (e.g.
devices/lge/hammerhead/BoardCon g.mk).

Your board con g will need to include architecture and platform settings. Usually these are already included if you're
using device con gs that someone else created, but if you created your own, you may need to add them. Without
them, recovery may seg fault during startup and you'll just see the teamwin curtain ash on the screen over and over.

We usually put all of our ags at the bottom of the BoardCon g.mk under a heading of #twrp For all devices you'll
need to tell TWRP what theme to use. This TW_THEME ag replaces the older DEVICE_RESOLUTION ag. TWRP now
uses scaling to stretch any theme to t the screen resolution. There are currently 5 settings which are: portrait_hdpi,
portrait_mdpi, landscape_hdpi, landscape_mdpi, and watch_mdpi. For portrait, you should probably select the hdpi
theme for resolutions of 720x1280 and higher. For landscape devices,
devices, use the hdpi theme for 1280x720 or higher.
TW_THEME := portrait_hdpi

Note that themes do not rotate 90 degrees and there currently is no option to rotate a theme. If you nd that the

https://forum.xda-developers.com/showthread.php?t=1943625 1/11
2/26/2020 [DEV]How to compile TWRP touch recovery | Android Development and Hacking
touchscreen is rotated relative to the screen,
screen, then you can use some ags (discussed later in this guide) to rotate the
 MOST THANKED
touch input to match the screen's orientation.
ALL-TIME RECENT

In addition to the resolution, we have the following build ags:


RECOVERY_SDCARD_ON_DATA := true -- this enables proper handling of /data/media on devices that have this folder
119 So, now, hopefully you've compiled TWRP for
your device and …
for storage (most Honeycomb and devices that originally shipped with ICS like Galaxy Nexus)
Nexus) This ag is not required
Dees_Troy OP 2012-Oct-18 11:30
for these types of devices though. If you do not de ne this ag and also do not include any references to /sdcard,
/internal_sd, /internal_sdcard, or /emmc in your fstab,
fstab, then we will automatically assume that the device is using 116 TWRP and A/B devices: From a TWRP
standpoint, A/B devices aren't …
emulated storage.
storage.
BOARD_HAS_NO_REAL_SDCARD := true -- disables things like sdcard partitioning and may save you some space if Dees_Troy OP 2012-Oct-18 11:30

TWRP isn't tting in your recovery patition


TW_NO_BATT_PERCENT := true -- disables the display of the battery percentage for devices that don't support it
19 gdb in TWRP gdb in TWRP To make things
quick and easy, the TLDR …
properly
Dees_Troy OP 2019-Mar-10 22:16
TW_CUSTOM_POWER_BUTTON := 107 -- custom maps the power button for the lockscreen
TW_NO_REBOOT_BOOTLOADER := true -- removes the reboot bootloader button from the reboot menu 17 Old guide which might be useful if someone is

TW_NO_REBOOT_RECOVERY := true -- removes the reboot recovery button from the reboot menu building with an …

RECOVERY_TOUCHSCREEN_SWAP_XY := true -- swaps the mapping of touches between the X and Y axis Dees_Troy OP 2016-Feb-23 13:24

RECOVERY_TOUCHSCREEN_FLIP_Y := true -- ips y axis touchscreen values


RECOVERY_TOUCHSCREEN_FLIP_X := true -- ips x axis touchscreen values 9 I have started compiling a list of all TWRP ags,
will be …

MSF Jarvis 2016-Mar-10 22:13


TWRP_EVENT_LOGGING := true -- enables touch event logging to help debug touchscreen issues (don't leave this on
for a release - it will ll up your log le very quickly) THREAD SEARCH
BOARD_HAS_FLIPPED_SCREEN := true -- ips the screen upside down for screens that were mounted upside-down
Search this thread

There are other build ags which you can locate by scanning the Android.mk les in the recovery source. Most of the
other build ags are not often used and thus I won't document them all here.

*RECOVERY.FSTAB*
TWRP 2.5 and higher supports some new recovery.fstab features that you can use to extend TWRP's backup/restore
capabilities. You do not have to add fstab ags as most partitions are handled automatically.

Note that TWRP only supports v2 fstabs in version 3.2.0 and higher. You will still need to use the "old" format of fstab
for older TWRP (example of that format is below), and even TWRP 3.2.0 still supports the v1 format in addition to the v2
format.
format. To maximize TWRP's compatibility with your build tree, you can create a twrp.fstab and use
PRODUCT_COPY_FILES to place the le in /etc/twrp.fstab When TWRP boots, if it nds a twrp.fstab in the ramdisk it
will rename /etc/recovery.fstab to /etc/recovery.fstab.bak and then rename /etc/twrp.fstab to /etc/recovery.fstab.
E ectively this will "replace" the fstab 2 le that your device les are providing with the TWRP fstab allowing you to
maintain compatibility within your device les and with other recoveries. SUGGESTED APPS
Code:
Code: Official XDA Forum App
The XDA App is the fastest
PRODUCT_COPY_FILES += device/lge/hammerhead/twrp.f
way to access the forums on




mobile.
The fstab in TWRP can contain some " ags" for each partition listed in the fstab.
fstab.
Navigation Gestures
Customizable gesture control
Here's a sample TWRP fstab for the Galaxy S4 that we will use for reference: for any Android device.
Code:
Code: 



/boot emmc /dev/block/platform/msm_sd XDA Labs


/system ext4 /dev/block/platform/msm_sd Labs is an independent app
/data ext4 /dev/block/platform/msm_sd store that gives developers
/cache ext4 /dev/block/platform/msm_sd 



full control over their work.
/recovery emmc /dev/block/platform/msm_sd
/efs ext4 /dev/block/platform/msm_sd Substratum
/external_sd vfat /dev/block/mmcblk1p1 The ultimate, most complete
/usb-otg vfat /dev/block/sda1 theming solution for Android.




/ l d t4 /d /bl k/ l tf / d
XDA Feed
Flags are added to the end of the partition listing in the fstab separated by white space (spaces or tabs are ne). The The best way to get cutting
ags a ect only that partition but not any of the others. Flags are separated by semicolons. If your display name is edge news about your device!




going to have a space, you must surround the display name with quotes.
Code:
Code: TOP FORUM DISCUSSIONS
/external_sd vfat /dev/block/mmcblk1p1 flags=di Developers have exploited the Samsung Galaxy
S9 and Note 9 to get root access on the
Snapdragon models
The ags for this partition give it a display name of "Micro SDcard" which is displayed to the user. wipeingui makes this  January 31, 2020
partition available for wiping in the advanced wipe menu. The removable ag indicates that sometimes this partition
Unofficial LineageOS 17.1 brings Android 10 to
may not be present preventing mounting errors from being displayed during startup. Here is a full list of ags:
the Samsung Galaxy S8 and Note 8
removable -- indicates that the partition may not be present preventing mounting errors from being displayed during
 January 29, 2020
boot
storage -- indicates that the partition can be used as storage which makes the partition available as storage for POCO X2 and Xiaomi Redmi K30 5G forums are
now open
backup,
backup, restore, zip installs, etc.
 January 28, 2020
https://forum.xda-developers.com/showthread.php?t=1943625 2/11
2/26/2020 [DEV]How to compile TWRP touch recovery | Android Development and Hacking
settingsstorage -- only one partition should be set as settings storage,
storage, this partition is used as the location for storing
TWRP's settings le Memorigi is a beautiful to-do list app that helps
you plan and organize your life
canbewiped -- indicates that the partition can be wiped by the back-end system,
system, but may not be listed in the GUI for
 January 25, 2020
wiping by the user
userrmrf -- overrides the normal format type of wiping and only allows the partition to be wiped using the rm -rf TWRP is now officially available for the Xiaomi Mi
command A3 and Redmi Note 8 Pro
backup=
backup= -- must be succeeded by the equals sign, so backup=1 or backup=0, 1 indicates that the partition can be listed  January 24, 2020

in the backup/restore list while 0 ensures that this partition will not show up in the backup list. NFCScreenOff mod enables scanning NFC tags
wipeingui -- makes the partition show up in the GUI to allow the user to select it for wiping in the advanced wipe when your Android phone is locked
menu  January 22, 2020
wipeduringfactoryreset -- the partition will be wiped during a factory reset
1Controller Magisk Module adds PlayStation
ignoreblkid -- blkid is used to determine what le system is in use by TWRP, this ag will cause TWRP to skip/ignore
Dualshock and Xbox game controller support to
the results of blkid and use the le system speci ed in the fstab only rooted Android devices
retainlayoutversion -- causes TWRP to retain the .layoutversion le in /data on devices like Sony Xperia S which sort of  January 22, 2020
uses /data/media but still has a separate /sdcard partition
symlink= -- causes TWRP to run an additional mount command when mounting the partition, generally used with More Forum Links 
/data/media to create /sdcard
display=
display= -- sets a display name for the partition for listing in the GUI
storagename= -- sets a storage name for the partition for listing in the GUI storage list
backupname= -- sets a backup name for the partition for listing in the GUI backup/restore list
length= -- usually used to reserve empty space at the end of the /data partition for storing the decryption key when
Android's full device encryption is present, not setting this may lead to the inability to encrypt the device
canencryptbackup= -- 1 or 0 to enable/disable, makes TWRP encrypt the backup of this partition if the user chooses
encryption (only applies to tar backups, not images)
userdataencryptbackup= -- 1 or 0 to enable/disable, makes TWRP encrypt only the userdata portion of this partition,
certain subfuldes like /data/app would not be encrypted to save time
subpartitionof= -- must be succeeded by the equals sign and the path of the partition it is a subpartition of. A
subpartition is treated as "part" of the main partition so for instance, TWRP automatically makes /datadata a
subpartition of /data. This means that /datadata will not show up in the GUI listings, but /datadata would be wiped,
backed up, restored, mounted, and unmounted anytime those operations are performed on /data. A good example of
the use of subpartitions is the 3x efs partitions on the LG Optimus G:
Code:
Code:
/efs1 emmc /dev/block/mmcblk0p12 flags=b
/efs2 emmc /dev/block/mmcblk0p13 flags=b
/efs3 emmc /dev/block/mmcblk0p14 flags=b

This lumps all 3 partitions into a single "EFS" entry in the TWRP GUI allowing all three to be backed up and restored
together under a single entry.

As of TWRP 3.2.0, TWRP now supports a version 2 fstab like those that have been found in Android devices for years.
Yes, I know we're really slow to adopt this one, but I also saw no major advantage to v2 and the v2 fstab was being
used in regular Android as well as recovery and I didn't want full ROM builds crashing or doing other weird things
because of TWRP ags being present in the fstab.
fstab. Version 2 fstab support is automatic. You don’t need to add any
build ags. The regular version 1 fstab format is also still valid and it’s possible to use both v1 and v2 types in the same
fstab.
fstab. TWRP 3.2.0 also supports using wildcards via the asterisk in v1 format which can be useful for USB OTG and micro
SD cards with multiple partitions. Note also that v2 fstab formats haven’t been extensively tested so developers should
test their v2 fstabs before shipping to users (you should always be testing anyway!).

This is a v1 fstab line with a wildcard intended for a USB OTG drive.
drive. All partitions should show up in the list of available
storage devices when the user plugs in a drive:
drive:

Code:
Code:
/usb-otg vfat /dev/block/sda* flags=removable;

This line is straight from the v2 fstab for the same device and also should work. In this case the kernel will notify us that
new devices have been added or removed via uevents:

Code:
Code:
/devices/soc.0/f9200000.ssusb/f9200000.dwc3/xhci-h

In addition to the v2 fstab,


fstab, you can include /etc/twrp. ags which uses the v1 fstab format. The twrp. ags le can be
used to supplement the v2 fstab with TWRP ags, additional partitions not included in the v2 fstab,
fstab, and to override
settings in the v2 fstab.
fstab. For example, I have a Huawei device with the following stock v2 fstab present as
/etc/recovery.fstab

Code:
Code:
# Android fstab file.
file.
#<src>

https://forum.xda-developers.com/showthread.php?t=1943625 3/11
2/26/2020 [DEV]How to compile TWRP touch recovery | Android Development and Hacking
# The filesystem that contains the filesystem chec
# specify MF_CHECK, and must come before any files
/dev/block/bootdevice/by-name/system /system
/dev/block/bootdevice/by-name/cust /cust ext
/devices/hi_mci.1/mmc_host/mmc1/*
/devices/hisi-usb-otg/usb1/*
/d /bl k/b td i /b / d t /d

In addition I have also included this in /etc/twrp. ags:

Code:
Code:
/boot emmc /dev/block/platform/hi_mc
/recovery emmc /dev/block/platform/hi_mc
/cust ext4 /dev/block/platform/hi_mc
/misc emmc /dev/block/platform/hi_mc
/oeminfo emmc /dev/block/platform/hi_mc
/data f2fs /dev/block/dm 0

The rst 2 lines in twrp. ags adds the boot and recovery partitions which were not present at all in the v2 fstab.
fstab. The
/cust line in the twrp. ags le is added to tell TWRP to allow users to back up the cust partition and to give it a slightly
better display name. The /misc partition is also only present in the twrp. ags le.
le. Much like the /cust partition, the
/oeminfo partition is in the twrp. ags le to tell TWRP to allow users to back it up and give a display name. The /data
line is needed because this Huawei device,
device, like many Huawei devices,
devices, is encrypted but the encryption uses some
special Huawei binaries and is encrypted with some sort of default password that the user cannot change. We use the
Huawei binaries to decrypt the device automatically in recovery. The /data line here tells TWRP to use /dev/block/dm-
0 instead of /dev/block/bootdevice/by-name/userdata which is required for proper mounting, etc. Lastly we have the
/system_image line so that TWRP will add a system image option for backup and restore.

As we add more new devices,


devices, we’ll add more example device trees to https://github.com/TeamWin/ which should
help you nd more ways to use this new fstab support. Please note that using the v2 fstab format at this point is
completely optional, so feel free to continue using v1 if that is what is more comfortable or if you have trouble with
the v2 format support.

If you have questions, feel free to stop by #twrp on Freenode.


Freenode. If you post here I may not see it for a while as I have lots
of threads out there and there's no way for me to keep track of them all. If you successfully port TWRP to a new
device,
device, please let us know! We love to hear success stories!

If you have code changes that you'd like to submit, please submit them through the Omni Gerrit server.
server. Guide is here.
here.

Once you get Omni or CM sync'ed and your TWRP ags set, you should do a source ./build/envsetup.sh We usually
lunch for the device in question, so something like "lunch omni_hammerhead-eng".

After you lunch successfully for your device this is the command used for most devices:
devices:
Code:
Code:
make clean && make -j# recoveryimage

Replace the # with the core count +1, so if you have a dual core it's -j3 and a quad core becomes -j5, etc. If you're
dealing with a "typical" Samsung device,
device, then you'll need to
Code:
Code:
make -j# bootimage

Most Samsung devices have the recovery included as an extra ramdisk in the boot image instead of a separate
recovery partition as found on most other devices.
devices.

Old guide here: http://forum.xda-developers.com/show...postcount=1471

 
The
The Following
Following 402
402 Users
Users Say
Say Thank
Thank You
You to
to Dees_Troy
Dees_Troy For
For This
This Useful
Useful Post:
Post: [[ View
View ]]

 Dees_Troy   
Thanks:
Thanks: 13,615
OP
OP Senior Recognized Developer

18th October 2012, 05:30 PM | #2    

https://forum.xda-developers.com/showthread.php?t=1943625 4/11
2/26/2020 [DEV]How to compile TWRP touch recovery | Android Development and Hacking
So, now, hopefully you've compiled TWRP for your device and gotten it working. Now, you'd like to know how to get
TWRP o cially supported for your device so that it can be installed automatically with the TWRP app.
app. In order for us to
add "o cial support" for your device we'll need the following:
1) Device con guration les to compile TWRP from source for your device.
device. This means that you cannot have repacked a
recovery.img by hand to get it working. We need to be able to compile it from source so that we can easily release
future updates.
2) We'll build a copy of TWRP and send it to you for validation. Once you've validated that we can build a working
image for your device,
device, we'll add it to the o cial TWRP app.
app.

Note that we won't take credit for your port.


port. You'll still get to post it on XDA to collect all the credit that goes with
releasing something new for your device along with having your name listed on our website as the maintainer for the
device.
device. Also note that it's not always possible to provide automated installs for all devices.
devices.

You can now boot TWRP in an emulator. If you're trying to help develop TWRP, this can be a huge help as you don't
have to risk your device and you can do everything directly on your computer.
computer.

Download this set of device con guration les.

Compile a recoveryimage using those device les.


les. In the Android SDK, click on Tools -> Manage AVDs. Click New.
New. Set it
up as the following:
AVD Name: TWRP
Device:
Device: Galaxy Nexus
Target:
Target: ICS or newer though anything will probably work here
CPU: ARM (armeabi-v7a)
Check the box for hardware keyboard (your computer's keyboard will work in TWRP)
Up to you if you want to have the skin with controls present
Front Camera:
Camera: None
Back Camera:
Camera: None
RAM:
RAM: 1024 VM Heap: 64
Internal Storage:
Storage: 200
SD Card:
Card: Size: 500 MiB

Then click OK.

Once you have your AVD and your recoveryimage, you can boot TWRP in the emulator by browsing to your android-
sdk/tools folder and run this command:
./emulator -avd TWRP -ramdisk CMFOLDER/out/target/product/twrp/ramdisk-recovery.img

Note that ADB doesn't work right away. About 10 to 15 seconds after TWRP nishes booting, ADB will come online. We
start ADB via init.rc so even if TWRP fails to boot due to some kind of code error that you may have made, ADB should
still work. Enjoy!

 
The
The Following
Following 119
119 Users
Users Say
Say Thank
Thank You
You to
to Dees_Troy
Dees_Troy For
For This
This Useful
Useful Post:
Post: [[ View
View ]]

 Dees_Troy   
Thanks:
Thanks: 13,615
OP
OP Senior Recognized Developer

18th October 2012, 05:30 PM | #3    


TWRP and A/B devices:
devices:

From a TWRP standpoint, A/B devices aren't a whole lot di erent from regular devices,
devices, but developers seem to be shy
about working on these devices.
devices. I'm going to try to shed some light on this subject and hopefully this will serve as a

https://forum.xda-developers.com/showthread.php?t=1943625 5/11
2/26/2020 [DEV]How to compile TWRP touch recovery | Android Development and Hacking
guide for porting TWRP to A/B devices.
devices.

Firstly, let's understand what is an A/B device and how it's di erent. A/B devices have duplicates of many partitions on
the device.
device. An A/B device has 2x system partitions, 2x boot partitions, 2x vendor partitions, 2x modem / rmware
partitions, etc. Only one slot is in use at a time. During early boot,
boot, the rst stages of the bootloader read some small
amount of data called the BCB or Bootloader Control Block and decide whether to boot the A partitions or the B
partitions. When an OTA update is available, the data from the active slot is copied from the inactive slot and patched
/ updated. For example, if you're currently on slot A, your device would download the update and copy the existing
system partition from slot A and patch / update it with the new updates into slot B. Once the copying and updating is
complete, the BCB is updated and the device reboots using slot B. Next time an update is available, the system
partition in slot B is copied to slot A and updated, the BCB gets updated, and we reboot to slot A. When viewing
partitions on the device,
device, you'll see something like this:

Code:
Code:
/dev/block/bootdevice/by-name/boot_a
/dev/block/bootdevice/by-name/boot_b
/dev/block/bootdevice/by-name/system_a
/dev/block/bootdevice/by-name/system_b
/dev/block/bootdevice/by-name/userdata
/dev/block/bootdevice/by-name/vendor_a

Note the dual boot,


boot, system and vendor partitions in the list above, but only one userdata partition.

While there is technically no requirement that I am aware of, all A/B devices shipped thus far have no separate
recovery partition. Instead, the boot image contains the recovery in its ramdisk.
ramdisk. The important thing is knowing that
the boot image now also contains the recovery. For completeness, the system partition is a full root le system.
system. During
boot,
boot, if the kernel is told to boot to recovery, it will extract the ramdisk in the boot partition. If the kernel is not told by
the bootloader to boot to recovery, then the kernel will mount the appropriate system partition (A or B) because the
system partition is a full root le system.
system. This means that the system partition on these devices is mounted to / instead
of to /system and the system partition contains all of the les that would have normally been in the boot image
ramdisk and a /system subfolder.

From a TWRP standpoint, there are 3 things that you have to do for an A/B device.
device. First, you need to set
Code:
Code:
AB_OTA_UPDATER := true

in your BoardCon g.mk. Secondly, for any partition that has an A/B option, you need to add
Code:
Code:
flags=slotselect

in your fstab so something like this:


Code:
Code:
/boot emmc /dev/block/bootdevice/by-n
/system ext4 /dev/block/bootdevice/by-n
/system_image emmc /dev/block/bootdevice/by-n
/vendor ext4 /dev/block/bootdevice/by-n

Lastly, once you get into TWRP, you will probably want to make sure that bootctl hal-info responds correctly with no
errors. Usually the bootctl binary requires a proprietary library or even a couple of services to work correctly. If bootctl
does not work correctly, then you will not be able to switch slots within TWRP correctly either.

In addition to setting
Code:
Code:
AB_OTA_UPDATER := true

you may also want to set:


Code:
Code:
BOARD_USES_RECOVERY_AS_BOOT := true
BOARD_BUILD_SYSTEM_ROOT_IMAGE := true

If you set
Code:
Code:
BOARD_USES_RECOVERY_AS_BOOT := true

https://forum.xda-developers.com/showthread.php?t=1943625 6/11
2/26/2020 [DEV]How to compile TWRP touch recovery | Android Development and Hacking
then make recoveryimage will no longer work and instead you will have to make bootimage. I don't recommend
setting either of these ags for TWRP-only build trees. These ags will probably be required for developers building full
ROMs for A/B devices.
devices.

Installing / Flashing TWRP on A/B devices:


devices:

Since all known A/B devices do not have a separate recovery partition, you will eventually have to ash TWRP to the
boot partition. On the Pixel 1 and 2, we use fastboot boot to temporarily boot TWRP without ashing TWRP. We are
then supplying a zip to allow users to ash TWRP to both slots. You can download one of these zips from our website
and update the zip as needed to support your devices.
devices. Eventually we will add tools to TWRP to allow users to ash
recoveries on these devices without needing to use zips.

Recently, I worked on the Razer Phone.


Phone. The Razer Phone unfortunately does not support fastboot boot.
boot. Instead, users
have to determine their currently active boot slot using
Code:
Code:
adb shell getprop ro.boot.slot_suffix

then use
Code:
Code:
fastboot --set-active=_a

to switch slots to the inactive slot. From here, the user can
Code:
Code:
fastboot flash boot twrp.img && fastboot reboot

to get into TWRP. Once in TWRP they can then go to the reboot page and change back to their originally active slot,
slot,
make a backup,
backup, then install TWRP. Using the inactive slot allows users to get a good, unmodi ed backup of their device
before installing TWRP.

Hopefully this helps!

Debugging with gdb in TWRP guide can be found here!

 

The
The Following
Following 116
116 Users
Users Say
Say Thank
Thank You
You to
to Dees_Troy
Dees_Troy For
For This
This Useful
Useful Post:
Post: [[ View
View ]]

 ViViDboarder   
Thanks:
Thanks: 632
Inactive Recognized Developer

18th October 2012, 06:09 PM | #4    


Beep boop zee doop

 
The
The Following
Following 99 Users
Users Say
Say Thank
Thank You
You to
to ViViDboarder
ViViDboarder For
For This
This Useful
Useful Post:
Post: [[ View
View ]] Gift
Gift ViViDboarder
ViViDboarder Ad-Free
Ad-Free

 sgt. meow   
Thanks:
Thanks: 3,014
Senior Member

26th October 2012, 12:48 PM | #5    


I know I've PM'ed you but I would like to ask you again. What should I do after compiling the TWRP recovery binary?
What les have to be copied and where? I'm trying to integrate it with an ICS kernel.

https://forum.xda-developers.com/showthread.php?t=1943625 7/11
2/26/2020 [DEV]How to compile TWRP touch recovery | Android Development and Hacking

 

 mfsr98   
Thanks:
Thanks: 290
Senior Member

4th November 2012, 02:14 PM | #6    

Quote:
Originally Posted by Dees_Troy 

Once you get CM sync'ed, I suggest that you go ahead and compile a build of ClockworkMod (ClockworkMod
source is included in the CM repos). We usually lunch for the device in question, so something like "lunch
full_tenderloin-eng".

After you lunch successfully for your device this is the command used for most devices:
devices:

Code:
Code:
make clean && make -j# recoveryimage

I don't get this part. What is lunch supposed to be? is it supposed to be a individual command for a device or can I do
"lunch full_tenderloin-eng" for all devices?
devices? Because I am building for a device that doesn't run Android natively (at least
out of-the-box) so cyanogenmod doesn't support it on any way...
Also, can I use this for resistive screens? Just to make sure.
Thanks for the guide, I have been looking for this for a long time

 

The
The Following
Following 44 Users
Users Say
Say Thank
Thank You
You to
to mfsr98
mfsr98 For
For This
This Useful
Useful Post:
Post: [[ View
View ]] Gift
Gift mfsr98
mfsr98 Ad-Free
Ad-Free

 manuel100   
Thanks:
Thanks: 30
Senior Member

4th November 2012, 07:58 PM | #7    


thanks for the guide, well structured and not so complicated

i have only a question: i'm trying to build it for galaxy 5,


5, the problem is that the resolution is 320x240, so can you tip
me on modify the sources? (i've done this some days ago, but images were too large)

 
The
The Following
Following User
User Says
Says Thank
Thank You
You to
to manuel100
manuel100 For
For This
This Useful
Useful Post:
Post: [[ View
View ]] Gift
Gift manuel100
manuel100 Ad-Free
Ad-Free

 mg2195 Thanks:
  
Thanks: 2,610
Senior Member

4th November 2012, 10:08 PM | #8    


Quote:
Originally Posted by manuel100 

thanks for the guide, well structured and not so complicated

i have only a question: i'm trying to build it for galaxy 5, the problem is that the resolution is 320x240, so can you
tip me on modify the sources? (i've done this some days ago, but images were too large)

https://forum.xda-developers.com/showthread.php?t=1943625 8/11
2/26/2020 [DEV]How to compile TWRP touch recovery | Android Development and Hacking

Set the device resolution to 320x240...I'm pretty sure they have support for that resolution...and if they don't then you
can copy one of there's except resize it all to 320x240

Edit-they only have 320x480 https://github.com/TeamWin/Team-Win-Recovery-Project/

My question: I built twrp from source a while ago using smasher's Samsung inject twrp zip...that
zip...that worked ne for a
while...but recently we switched to mtd format so that inject twrp zip doesn't work...neither does the inhect twrp
button within twrp anymore...I've seen that the galaxy s has the same problem as well...just wondering if you know of a
work around...

Sent from my SGH-I997 using Tapatalk 2

 

 manuel100   
Thanks:
Thanks: 30
Senior Member

5th November 2012, 02:19 PM | #9    


Quote:
Originally Posted by mg2195 

Set the device resolution to 320x240...I'm pretty sure they have support for that resolution...and if they don't
then you can copy one of there's except resize it all to 320x240

Edit-they only have 320x480 https://github.com/TeamWin/Team-Win-Recovery-Project/

My question: I built twrp from source a while ago using smasher's Samsung inject twrp zip...that
zip...that worked ne for
a while...but recently we switched to mtd format so that inject twrp zip doesn't work...neither does the inhect
twrp button within twrp anymore...I've seen that the galaxy s has the same problem as well...just wondering if
you know of a work around...

Sent from my SGH-I997 using Tapatalk 2

thanks for respond, however i've tried resizing images to 320x240 but i don't know what should be the size of bottoms,
because they are alway out-of-screen

what is smasher's Samsung inject twrp zip?


zip? but i think that the recovery doesn't work because you have to built it with
mtd support (for ex. on madteam they are trying to build a mtd kernel, but for install that testing rom they built a
special cwm with mtd support)

 

 mg2195   
Thanks:
Thanks: 2,610
Senior Member

5th November 2012, 03:21 PM | #10    


Quote:
Originally Posted by manuel100 

thanks for respond, however i've tried resizing images to 320x240 but i don't know what should be the size of
bottoms, because they are alway out-of-screen

what is smasher's Samsung inject twrp zip?


zip? but i think that the recovery doesn't work because you have to built
it with mtd support (for ex. on madteam they are trying to build a mtd kernel, but for install that testing rom
they built a special cwm with mtd support)

Smashers inject twrp zip is a tool for Samsung devices that let's you get the recovery without ashing the whole
kernel. You basically put the ramdisk-recovery.img in the zip and then ash.
ash. During the ash process it pulls the
boot.img, replaces the current ramdisk-recovery.img with the new one that contains twrp. It then deletes the old
boot.img and ashes the new one...not a ecting the actual kernel...

The recovery itself has mtd support...I can use it if I ash the whole boot.img, but I don't want to release the recovery
within a whole kernel...because then I have to keep it up to date with both twrp and kernel sources, not to mention the
di erent kernels available for my device....I
device....I can't make a recovery for each kernel...don't have the time for that...that's
where the inject came in handy....the user could use any kernel he wanted while still using twrp

Recovery logs say it fails to nd the ramdisk inside the boot.img and then in parenthesis something about may not be
using gzip compression...which it is....

https://forum.xda-developers.com/showthread.php?t=1943625 9/11
2/26/2020 [DEV]How to compile TWRP touch recovery | Android Development and Hacking
Sent from my SGH-I997 using Tapatalk 2

----------
---------- Post
Post added
added at
at 07:21
07:21 AM
AM ----------
---------- Previous
Previous post
post was
was at
at 07:19
07:19 AM
AM ----------
----------

Deestroy did this same tutorial on rootzwiki...if you look at the second post you'll see info about the smasher inject
twrp I was referring to...http://rootzwiki.com/index.php?/topi...RP-from-Source
to...http://rootzwiki.com/index.php?/topi...RP-from-Source

Sent from my SGH-I997 using Tapatalk 2

 
The
The Following
Following 44 Users
Users Say
Say Thank
Thank You
You to
to mg2195
mg2195 For
For This
This Useful
Useful Post:
Post: [[ View
View ]] Gift
Gift mg2195
mg2195 Ad-Free
Ad-Free

 mfsr98   
Thanks:
Thanks: 290
Senior Member

5th November 2012, 09:27 PM | #11    


Quote:
Originally Posted by mfsr98 

I don't get this part. What is lunch supposed to be? is it supposed to be a individual command for a device or
can I do "lunch full_tenderloin-eng" for all devices?
devices? Because I am building for a device that doesn't run Android
natively (at least out of-the-box) so cyanogenmod doesn't support it on any way...
Also, can I use this for resistive screens? Just to make sure.
Thanks for the guide, I have been looking for this for a long time

can I get help here please?

 

The
The Following
Following User
User Says
Says Thank
Thank You
You to
to mfsr98
mfsr98 For
For This
This Useful
Useful Post:
Post: [[ View
View ]] Gift
Gift mfsr98
mfsr98 Ad-Free
Ad-Free

 Reply  Subscribe to Thread Page 1 of 457 1 2 3 11 51 101  Last 

Guest Quick Reply (no urls or BBcode)

Message:

Post Quick Reply Go Advanced

 Previous Thread Next Thread 

 Top Threads in Android Software Development by ThreadRank

[Mod] [Ainur Audio addon] Ciaomeme Audio+  2019-11-02

 Android Software Development

[ROM][UNOFFICIAL][9.x] Arrow OS [BETA][Redmi Y3/onc]  2019-11-24

 Android Software Development

[CUSTOM][GAPPS] BiTGApps for Android  2019-11-30

 Android Software Development

[APP][5.0] β-Maniac -- Life of a beta tester  26th January 2020

 Android Apps and Games

Bliss OS (x86) for PC's - 12.x Development - Beta Builds  2019-11-16

 Android Software Development

https://forum.xda-developers.com/showthread.php?t=1943625 10/11
2/26/2020 [DEV]How to compile TWRP touch recovery | Android Development and Hacking
[GApps][ARM64] FlameGApps for Android [9.0+10.0]  2019-12-17

 Android Software Development

[APP][MOD] Today Weather - A beautiful weather app with more 10 data sources[P-CODES]  15th September 2019

 Android Apps and Games

[AIO Guide] Realme C2 bootloader unlocking,root,twrp & stock rmware  2019-09-21

 Android Software Development

 xda-developers  Android Development and Hacking  Android Software Development  [DEV]How to compile TWRP touch recovery by Dees_Troy

We're Social

   
XDA Developers was founded by developers, for developers. It is now a
valuable resource for people who want to make the most of their mobile
devices, from customizing the look and feel to adding new functionality.
Are you a developer? | Terms of Service

More info
-- XDA 2015
Contact Advertise Rules Suggest Content Security Privacy Policy XDA App Remove ads on XDA
Root Any Device How To Guides XDA's Best

Devices

Redmi Note 8 Pro

Copyright © xda-developers. Hosted by Leaseweb

https://forum.xda-developers.com/showthread.php?t=1943625 11/11

You might also like