Android OS Forum banner

1 - 20 of 40 Posts

·
TeamWin
Joined
·
131 Posts
All of TWRP 2.x source is public. You can compile it on your own. This guide isn't going to be a step-by-step, word-for-word type of guide. If you're not familiar with basic Linux commands then you probably won't be able to do this.

You can currently use either CM7 or CM9 source code. Follow the correct part of the guide because the code base for CM9 is slightly different than for CM7. First you'll need to sync whichever code base you're going to work with and get it all set up to compile. I suggest that you follow one of the guides on the CM website like this one:

http://wiki.cyanogen...ogenMod_(Linux)

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". You must lunch and compile -eng builds. -userdebug will not work with recovery.

After you lunch successfully for your device this is the command used for most devices:
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, then you'll need to
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.

Once you are certain that you can compile a working CWM build, it's time to start pulling in the source code that you'll need to build TWRP.

*FOR CM9*
You'll need to replace CM9/bootable/recovery with this:
https://github.com/T...covery-Project/

Now skip down to the "BEFORE YOU COMPILE" section and continue from there.

Note that if you've used this guide before, as of 5/28/2012 you no longer need a custom busybox setup. The busybox in the CM repo now supports everything that TWRP needs to function properly. If you haven't sync'ed CM recently you may need to resync to get the latest busybox changes.

*FOR CM7*
Bear in mind that pulling in some of this code may break your ability to compile CM7. You'll either need 2 copies of the CM7 source or set up some kind of script to swap the source code in and out automatically. And no I don't have such a script so don't ask


First remove and replace CM7/bootable/recovery with this:
https://github.com/T...covery-Project/

And finally replace the entire CM7/build folder with this:
https://github.com/D...TWRP2-CM7_build

Note that if you've used this guide before, as of 5/28/2012 you no longer need a custom busybox setup. The busybox in the CM repo now supports everything that TWRP needs to function properly. If you haven't sync'ed CM recently you may need to resync to get the latest busybox changes.

*BEFORE YOU COMPILE*
Now that you have the source code, you'll need to set or change a few build flags for your device(s). Find the BoardConfig.mk for your device. The BoardConfig.mk is in your CM/devices/manufacturer/codename folder (e.g. CM/devices/hp/tenderloin/BoardConfig.mk). First, scan the BoardConfig.mk file for
TARGET_RECOVERY_INITRC :=
If your device has this line, it will have a path to a custom, prebuilt init.rc that is used in recovery. Most likely you will need to change the custom init.rc slightly. Find the recovery's init.rc file and open it. Near the top you will see something like this:
Code:
on init<br />
	export PATH /sbin<br />
	export LD_LIBRARY_PATH .:/sbin
Add the last line needed. This line is needed to get the linker running. Unlike ClockworkMod, TWRP is a dynamically linked recovery. Dynamic linking allows us to save a considerable amount of space to help make sure that TWRP recovery images will fit on more devices. It also lets us use dynamically linked touchscreen binaries as seen on the Motorola Photon and Atrix and the HP TouchPad without having to mount /system.

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

You will also need at least one build flag for TWRP. We usually put all of our flags at the bottom of the BoardConfig.mk under a heading of #twrp For all devices you'll need to set a resolution. TWRP needs to know the resolution at compile time so that it knows what stock theme to include. You can only use resolutions that have a theme so if you don't see your resolution, you'll have to pick one that's less than or equal to your resolution. You can find the list of stock themes in bootable/recovery/gui/devices. So if your device has a 540x960 display, you would add this:
DEVICE_RESOLUTION := 540x960

Note that themes do not rotate, so the 1280x800 theme is intended for tablets and would not work on the Samsung Galaxy Note that expects a 800x1280 type of theme (which doesn't exist yet).

In addition to the resolution, we have the following build flags:
RECOVERY_GRAPHICS_USE_LINELENGTH := true -- fixes ****** looking graphics on some devices

The below is how you can add custom / special partitions to the list of partitions available for backup. The SP1_NAME must match the name of a partition defined in recovery.fstab. The SP1_DISPLAY_NAME is the name displayed on the backup page if it needs to be different than SP1_NAME. SP1_BACKUP_METHOD defines how the partition should be backed up (files or image). And SP1_MOUNTABLE determines if the partition can be mounted.
SP1_NAME := "pds"
SP1_BACKUP_METHOD := files
SP1_MOUNTABLE := 1
SP2_NAME := "osh"
SP2_DISPLAY_NAME := "Webtop"
SP2_BACKUP_METHOD := files
SP2_MOUNTABLE := 1
SP3_NAME := "preinstall"
SP3_BACKUP_METHOD := image
SP3_MOUNTABLE := 0
RECOVERY_SDCARD_ON_DATA := true -- this enables proper handling of /data/media on devices that have this folder for storage (most Honeycomb and devices that originally shipped with ICS like Galaxy Nexus)
BOARD_HAS_NO_REAL_SDCARD := true -- disables things like sdcard partitioning
TW_INCLUDE_DUMLOCK := true -- includes HTC Dumlock for devices that need it

This is how you would define dual storage for devices that have dual storage devices. For devices that have internal storage we usually define that as /emmc. Note that the mount point must match something in the recovery.fstab
TW_INTERNAL_STORAGE_PATH := "/data/media"
TW_INTERNAL_STORAGE_MOUNT_POINT := "data"
TW_EXTERNAL_STORAGE_PATH := "/sdcard"
TW_EXTERNAL_STORAGE_MOUNT_POINT := "sdcard"

TW_NO_BATT_PERCENT := true -- disables the display of the battery percentage for devices that don't support it properly
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
TW_NO_REBOOT_RECOVERY := true -- removes the reboot recovery button from the reboot menu
TW_NO_USB_STORAGE := true -- removes the USB storage button on devices that don't support USB storage
RECOVERY_TOUCHSCREEN_SWAP_XY := true -- swaps the mapping of touches between the X and Y axis
RECOVERY_TOUCHSCREEN_FLIP_Y := true -- flips y axis touchscreen values
RECOVERY_TOUCHSCREEN_FLIP_X := true -- flips x axis touchscreen values
TW_ALWAYS_RMRF := true -- forces the rm -rf option to always be on (needed for some Motorola devices)
TW_NEVER_UNMOUNT_SYSTEM := true -- never unmount system (needed for some Motorola devices)
TW_INCLUDE_INJECTTWRP := true -- adds ability to inject TWRP into some Samsung boot images for Samsung devices that have recovery as a second ramdisk in the boot image
TW_INCLUDE_BLOBPACK := true -- uses blobpack to restore boot images on Asus Transformer devices
TW_DEFAULT_EXTERNAL_STORAGE := true -- defaults to external storage instead of internal on dual storage devices
TW_FLASH_FROM_STORAGE := true -- flashes zips from their current location instead of copying them to /tmp for ROMs that are too large to fit in RAM. (We're considering making this the default behavior).
TWRP_EVENT_LOGGING := true -- enables touch event logging to help debug touchscreen issues (don't leave this on for a release - it will fill up your logfile very quickly)

Here's some flags that may help you, but are not specific to TWRP (works in CWM too):
This flag has multiple options, but can be used to set different graphics modes that may be need to correct color space issues on some devices:
TARGET_RECOVERY_PIXEL_FORMAT := "BGRA_8888"
TARGET_RECOVERY_PIXEL_FORMAT := "RGBX_8888"
TARGET_RECOVERY_PIXEL_FORMAT := "RGB_565"

BOARD_HAS_FLIPPED_SCREEN := true -- flips the screen upside down for screens that were mounted upside-down
TARGET_PREBUILT_RECOVERY_KERNEL := path/to/kernel -- use to specify a kernel specifically for building recovery

If you have questions, feel free to stop by #twrp on 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, 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 our Gerrit server. Guide is here.
 

·
that dude
Joined
·
283 Posts
Don't know what's going wrong...
Code:
<br />
<br />
[email protected]:~/android/system$ repo sync -j3<br />
Fetching projects: 100% (313/313), done.  <br />
fatal: Unable to create '/home/luke/android/.git/index.lock': Permission denied<br />
Checking out files: 100% (413/413), done.ng out files:   2% (9/413)   <br />
Checking out files: 100% (5192/5192), done. out files:   0% (35/5192)   <br />
Checking out files: 100% (618/618), done.ng out files:   2% (18/618)   <br />
Checking out files: 100% (136/136), done.ng out files:  29% (40/136)   <br />
Syncing work tree:  87% (273/313)  fatal: cannot create directory at 'src/com/android/settings/deviceinfo': No space left on device<br />
Traceback (most recent call last):<br />
  File "/home/luke/.repo/repo/main.py", line 385, in <module><br />
    _Main(sys.argv[1:])<br />
  File "/home/luke/.repo/repo/main.py", line 365, in _Main<br />
    result = repo._Run(argv) or 0<br />
  File "/home/luke/.repo/repo/main.py", line 137, in _Run<br />
    result = cmd.Execute(copts, cargs)<br />
  File "/home/luke/.repo/repo/subcmds/sync.py", line 467, in Execute<br />
    project.Sync_LocalHalf(syncbuf)<br />
  File "/home/luke/.repo/repo/project.py", line 1027, in Sync_LocalHalf<br />
    self._InitWorkTree()<br />
  File "/home/luke/.repo/repo/project.py", line 1814, in _InitWorkTree<br />
    raise GitError("cannot initialize work tree")<br />
error.GitError: cannot initialize work tree<br />
[email protected]:~/android/system$ <br />
 

·
that dude
Joined
·
283 Posts
I did repo sync -j3.
I had already synced one (took forever) got those errors at the end, so decided to try again.

Sent from my ADR6400L using RootzWiki
 

·
Android Beginner
Joined
·
24 Posts
The github link for the cm9 sources (the 1st one) is down. I looked thru the other folders not really sure which one to use.
 

·
Registered
Joined
·
2 Posts
is there any way to compile this without actually compiling CM9? im asking this because i cant really download 6GB using my crappy modem. so please help me out.
 

·
that dude
Joined
·
283 Posts
Well I will try this again soon enough, my linux partition is full thus I can't sync.

repo sync -j16
Code:
<br />
<br />
Fetching projects: 100% (313/313), done.  <br />
Checking out files: 100% (90/90), done.<br />
Checking out files: 100% (63/63), done.ing out files:  33% (21/63)   <br />
Checking out files: 100% (79/79), done.ing out files:  15% (12/79)   <br />
Checking out files: 100% (55/55), done.ing out files:  38% (21/55)   <br />
Checking out files: 100% (83/83), done.ing out files:  36% (30/83)   <br />
Checking out files: 100% (286/286), done.g out files:  37% (106/286)   <br />
Checking out files: 100% (93/93), done.ing out files:  15% (14/93)   <br />
Checking out files: 100% (92/92), done.ing out files:  20% (19/92)   <br />
Checking out files: 100% (8/8), done.cking out files:  25% (2/8)   <br />
Checking out files: 100% (49/49), done.ing out files:  20% (10/49)   <br />
Checking out files: 100% (30/30), done.king out files:  33% (10/30)   <br />
Checking out files: 100% (340/340), done.ng out files:  11% (38/340)   <br />
Checking out files: 100% (1874/1874), done. out files:  31% (589/1874)   <br />
Checking out files: 100% (4679/4679), done.<br />
Checking out files: 100% (324/324), done.ng out files:   0% (2/324)   <br />
Checking out files: 100% (787/787), done.ng out files:  39% (314/787)   <br />
Checking out files: 100% (25/25), done.king out files:  20% (5/25)   <br />
Checking out files: 100% (30/30), done.king out files:   6% (2/30)   <br />
fatal: cannot create directory at 'test/testmap': No space left on device<br />
Traceback (most recent call last):<br />
  File "/home/luke/.repo/repo/main.py", line 385, in <module><br />
    _Main(sys.argv[1:])<br />
  File "/home/luke/.repo/repo/main.py", line 365, in _Main<br />
    result = repo._Run(argv) or 0<br />
  File "/home/luke/.repo/repo/main.py", line 137, in _Run<br />
    result = cmd.Execute(copts, cargs)<br />
  File "/home/luke/.repo/repo/subcmds/sync.py", line 467, in Execute<br />
    project.Sync_LocalHalf(syncbuf)<br />
  File "/home/luke/.repo/repo/project.py", line 1026, in Sync_LocalHalf<br />
    self._InitWorkTree()<br />
  File "/home/luke/.repo/repo/project.py", line 1840, in _InitWorkTree<br />
    raise GitError("cannot initialize work tree")<br />
df -hal
Code:
<br />
<br />
Filesystem        Size  Used Avail Use% Mounted on<br />
/dev/loop0         17G   17G  270M  99% /<br />
proc                 0     0     0    - /proc<br />
sysfs                0     0     0    - /sys<br />
none                 0     0     0    - /sys/fs/fuse/connections<br />
none                 0     0     0    - /sys/kernel/debug<br />
none                 0     0     0    - /sys/kernel/security<br />
udev              1.5G  4.0K  1.5G   1% /dev<br />
devpts               0     0     0    - /dev/pts<br />
tmpfs             589M  876K  588M   1% /run<br />
none              5.0M     0  5.0M   0% /run/lock<br />
none              1.5G  348K  1.5G   1% /run/shm<br />
/dev/sda2         284G  267G   18G  94% /host<br />
gvfs-fuse-daemon     0     0     0    - /home/luke/.gvfs<br />
 

·
Registered
Joined
·
1,298 Posts
dont know if this is watched often, but i get this error, i have tested and to build cwm works perfectly and build a working .img
once i make my /recovery now twrp /recvoery i get this error,
Code:
<br />
make: *** No rule to make target `out/target/product/wingray/obj/STATIC_LIBRARIES/librecovery_ui_stingray_intermediates/librecovery_ui_stingray.a', needed by `out/target/product/wingray/obj/EXECUTABLES/recovery_intermediates/LINKED/recovery'.  Stop.<br />
make: *** Waiting for unfinished jobs....<br />
target PrefixSymbols: linker (out/target/product/wingray/obj/EXECUTABLES/linker_intermediates/LINKED/linker)<br />
[email protected]:~/cm9$<br />
 

·
TeamWin
Joined
·
131 Posts
Discussion Starter · #15 ·
dont know if this is watched often, but i get this error, i have tested and to build cwm works perfectly and build a working .img
once i make my /recovery now twrp /recvoery i get this error,
Code:
<br />
make: *** No rule to make target `out/target/product/wingray/obj/STATIC_LIBRARIES/librecovery_ui_stingray_intermediates/librecovery_ui_stingray.a', needed by `out/target/product/wingray/obj/EXECUTABLES/recovery_intermediates/LINKED/recovery'.  Stop.<br />
make: *** Waiting for unfinished jobs....<br />
target PrefixSymbols: linker (out/target/product/wingray/obj/EXECUTABLES/linker_intermediates/LINKED/linker)<br />
[email protected]:~/cm9$<br />
Look for a reference to librecovery_ui_stingray in your BoardConfig.mk or one of the other mk files and comment it out with a # sign. It won't be needed for building TWRP.
 

·
Registered
Joined
·
1,298 Posts
Look for a reference to librecovery_ui_stingray in your BoardConfig.mk or one of the other mk files and comment it out with a # sign. It won't be needed for building TWRP.
sweet looks like that worked, just finishing up on ensuring everything works.
Thanks again man
 

·
Registered
Joined
·
2 Posts
Thanks very much for this guide. Using the ics branch I managed to get a recovery.img built for the HTC Flyer. The only problem I'm having is that the touch interface is not responding at all. Is this dependent on having an ICS kernel as the Flyer only has official Gingerbread and Honeycomb kernels. Thanks in advance for any help you can offer.
 

·
Registered
Joined
·
3 Posts
hi thanks for the ho to but i'm getting this error if i start to compile the image:

Code:
<br />
[email protected]:~/android/system$ make -j3 recoveryimage<br />
============================================<br />
PLATFORM_VERSION_CODENAME=REL<br />
PLATFORM_VERSION=2.3.5<br />
TARGET_PRODUCT=cyanogen_p920<br />
TARGET_BUILD_VARIANT=eng<br />
TARGET_SIMULATOR=false<br />
TARGET_BUILD_TYPE=release<br />
TARGET_BUILD_APPS=<br />
TARGET_ARCH=arm<br />
HOST_ARCH=x86<br />
HOST_OS=linux<br />
HOST_BUILD_TYPE=release<br />
BUILD_ID=GINGERBREAD<br />
============================================<br />
No rule to make target `out/host/linux-x86/bin/mkimage', needed by `out/target/product/p920/boot.img'.<br />
hope somebody can help me
 

·
Registered
Joined
·
1,298 Posts
hi thanks for the ho to but i'm getting this error if i start to compile the image:

Code:
<br />
[email protected]:~/android/system$ make -j3 recoveryimage<br />
============================================<br />
PLATFORM_VERSION_CODENAME=REL<br />
PLATFORM_VERSION=2.3.5<br />
TARGET_PRODUCT=cyanogen_p920<br />
TARGET_BUILD_VARIANT=eng<br />
TARGET_SIMULATOR=false<br />
TARGET_BUILD_TYPE=release<br />
TARGET_BUILD_APPS=<br />
TARGET_ARCH=arm<br />
HOST_ARCH=x86<br />
HOST_OS=linux<br />
HOST_BUILD_TYPE=release<br />
BUILD_ID=GINGERBREAD<br />
============================================<br />
No rule to make target `out/host/linux-x86/bin/mkimage', needed by `out/target/product/p920/boot.img'.<br />
hope somebody can help me
As per instructions did you try to compile recovery from cm9/cm7 source before adding/replacing the twrp files into source?

Sent from my Galaxy Nexus using Tapatalk 2
 

·
Registered
Joined
·
3 Posts
I was able to fix that error but i'm getting now that:

Code:
<br />
mkdir -p out/target/product/p920/recovery/root/res/<br />
cp -fr bootable/recovery/gui/devices/common/res/* out/target/product/p920/recovery/root/res/<br />
prebuilt/linux-x86/toolchain/arm-eabi-4.4.3/bin/arm-eabi-gcc -mthumb-interwork -Ibionic/libc/private -DCRT_LEGACY_WORKAROUND -o out/target/product/p920/obj/lib/crtbegin_dynamic.o -c bionic/libc/arch-arm/bionic/crtbegin_dynamic.S<br />
target thumb C: dump_image <= bootable/recovery/flashutils/dump_image.c<br />
cp -fr bootable/recovery/gui/devices/480x800/res/* out/target/product/p920/recovery/root/res/<br />
cc1 error unrecognized command line option -mthumb-interwork<br />
cc1 error unrecognized command line option -mfloat-abi=soft<br />
cc1 error unrecognized command line option -mfpu=vfp<br />
mkdir -p out/target/product/p920/recovery/root/sbin/<br />
bionic/libc/arch-arm/bionic/crtbegin_dynamic.S:1:0: error: unknown ABI (aapcs) for -mabi= switch<br />
bionic/libc/arch-arm/bionic/crtbegin_dynamic.S:1:0: error: wrong value (armv5te) for -march= switch<br />
make: *** [out/target/product/p920/obj/lib/crtbegin_dynamic.o] error 1<br />
ln -sf /sbin/busybox out/target/product/p920/recovery/root/sbin/sh<br />
cc1 error unrecognized command line option -softfp<br />
cc1 error unrecognized command line option -mfpu=neon<br />
cc1 error unrecognized command line option -mthumb-interwork<br />
cc1 error unrecognized command line option -mthumb<br />
bootable/recovery/flashutils/dump_image.c:1:0: error: unknown ABI (aapcs) for -mabi= switch<br />
bootable/recovery/flashutils/dump_image.c:1:0: error: wrong value (armv7-a) for -march= switch<br />
make: *** [out/target/product/p920/obj/RECOVERY_EXECUTABLES/dump_image_intermediates/dump_image.o] error 1<br />
some single words had to be translated cause of they were in german


hope you somebody can helb me
 
1 - 20 of 40 Posts
Top