-
Notifications
You must be signed in to change notification settings - Fork 1.6k
[OLD] Before you compile
Note: If you add or change any flags, you will need to make clean or make clobber before recompiling or your flag changes will not be picked up.
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 devices/manufacturer/codename folder (e.g. devices/lge/hammerhead/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:
on init
export PATH /sbin
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 may seg fault during startup and you'll just see the teamwin curtain flash on the screen over and over.
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 1 that expects a 800x1280 type of theme.
In addition to the resolution, we have the following build flags:
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)
RECOVERY_GRAPHICS_USE_LINELENGTH := true
-- fixes slanty looking graphics on some devices
BOARD_HAS_NO_REAL_SDCARD := true
-- disables things like sdcard partitioning and may save you some space if TWRP isn't fitting in your recovery patition
TW_INCLUDE_DUMLOCK := true
-- includes HTC Dumlock for devices that need it
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_DEFAULT_EXTERNAL_STORAGE := true
-- defaults to external storage instead of internal on dual storage devices (largely deprecated)
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