MediaTek Software Repairs Training! Join Now

Hovatek Forum DEVELOPMENT Android TWRP recovery image minimization

TWRP recovery image minimization

TWRP recovery image minimization

hipot
hipot
hipot
Enthusiastic Member
7
24-10-2024, 08:52 AM
#1



Hello,

I am experimenting with building TWRP from source myself.
But I am hitting an issue with the image being larger than what I can fit into the recovery partition.
I noticed the Online TWRP Builder has the ability to reduce the size. https://www.hovatek.com/twrpbuilder/

Can I ask how is that done?
I would like to use the same technique on my build.

I have tried using some build flags:
TW_EXTRA_LANGUAGES := false
TW_NO_USB_STORAGE := true
TW_EXCLUDE_MTP := true
TW_NO_EXFAT := true
TW_INCLUDE_FB2PNG := false
TW_EXCLUDE_TZDATA := true
TW_EXCLUDE_NANO := true
TW_INCLUDE_DUMLOCK := false
TW_NO_BATT_PERCENT := true
TW_NO_CPU_TEMP := true
TW_INCLUDE_INJECTTWRP := false
TW_HAS_DOWNLOAD_MODE := false
TW_NO_HAPTICS := true
TW_INCLUDE_NTFS_3G := false
TW_EXCLUDE_TWRPAPP := true
TW_NO_LEGACY_PROPS := true
BOARD_HAS_NO_REAL_SDCARD := true
TW_EXCLUDE_SUPERSU := true
TW_INCLUDE_CRYPTO := false
TWRP_INCLUDE_LOGCAT := false
TW_OEM_BUILD := true

Not only am I not entirely sure what some of these do, but it is removing a lot of functionality.

This got me from about 18MB to 12.8MB.
The compiler still complains though.
recovery.img maxsize=10454400 blocksize=135168 total=13434880 reserve=270336
recovery.img too large (13434880 > [10724736 - 270336])
ninja: build stopped: subcommand failed.

The original revovery.img from the ROM is 9.9MB
I have verified I can flash hovatek's slightly reducer 13.6MB twrp. Though I do not know how is that possible since the partition size appears to be smaller.

18MB is too much though and the the flashing fails.

Are there any other techniques that I can use to compress the recovery without loosing so many features?

Thank you and have a nice day.
hovatek
hovatek
hovatek
Administrator
49,887
24-10-2024, 03:42 PM
#2
(24-10-2024, 08:52 AM)hipot ..
The original revovery.img from the ROM is 9.9MB
I have verified I can flash hovatek's slightly reducer 13.6MB twrp. Though I do not know how is that possible since the partition size appears to be smaller.

18MB is too much though and the the flashing fails.

Are there any other techniques that I can use to compress the recovery without loosing so many features?

Thank you and have a nice day.

You could leverage compression
e.g

LZMA_RAMDISK_TARGETS := boot,recovery
BOARD_RAMDISK_USE_LZ4 := true

or switch to Toolbox
TW_USE_TOOLBOX := true

Note!
We have a reply schedule for Free Support. Please upgrade to Private Support if you can't wait.
hipot
hipot
hipot
Enthusiastic Member
7
24-10-2024, 04:00 PM
#3
Thanks. I will test this out.
LZMA_RAMDISK_TARGETS := boot,recovery
BOARD_RAMDISK_USE_LZ4 := true
These go into BoardConfig.mk?

Is there somewhere a list of all the flags that can be used?
I was not able to find anything.
hipot
hipot
hipot
Enthusiastic Member
7
24-10-2024, 07:34 PM
#4
I have tested it and the image does not want to boot.
Can I somehow check that lzma is supported by the device or use a different compression method?

It does boot if I use just:
TW_USE_TOOLBOX := true
TW_EXTRA_LANGUAGES := false
TW_OEM_BUILD := true
hovatek
hovatek
hovatek
Administrator
49,887
31-10-2024, 12:40 PM
#5



(24-10-2024, 07:34 PM)hipot I have tested it and the image does not want to boot.
Can I somehow check that lzma is supported by the device or use a different compression method?

It does boot if I use just:
TW_USE_TOOLBOX := true
TW_EXTRA_LANGUAGES := false
TW_OEM_BUILD := true

Try

Code:

TW_USE_TOOLBOX := true
TW_EXTRA_LANGUAGES := false
TW_OEM_BUILD := true
LZMA_RAMDISK_TARGETS := boot,recovery

Some flags cause problems when combined and those like BOARD_RAMDISK_USE_LZ4 := true tend to require additional flags
This post was last modified: 31-10-2024, 12:42 PM by hovatek.

Note!
We have a reply schedule for Free Support. Please upgrade to Private Support if you can't wait.
hipot
hipot
hipot
Enthusiastic Member
7
31-10-2024, 02:26 PM
#6
(31-10-2024, 12:40 PM)hovatek Try

Code:

TW_USE_TOOLBOX := true
TW_EXTRA_LANGUAGES := false
TW_OEM_BUILD := true
LZMA_RAMDISK_TARGETS := boot,recovery

Some flags cause problems when combined and those like BOARD_RAMDISK_USE_LZ4 := true tend to require additional flags

Thanks, I will test it.

Is there a list of all possible flags that can be used?
I could not find one.
kelvinchinedu
kelvinchinedu
kelvinchinedu
Contributor
1,649
03-11-2024, 02:03 AM
#7
This flags will help you


# Debug
TWRP_INCLUDE_LOGCAT := true
TARGET_USES_LOGD := true

# Tools / Resetprop and magiskboot
TW_EXCLUDE_BASH := true
TW_EXCLUDE_TZDATA := true
TW_INCLUDE_REPACKTOOLS := false
TW_NO_FASTBOOT_BOOT := true
TW_EXCLUDE_PYTHON := true
TW_EXCLUDE_NANO := true
TW_EXCLUDE_LPTOOLS := true
TW_EXCLUDE_LPDUMP := true
TW_NO_SCREEN_BLANK := true
TARGET_USES_MKE2FS := true
TW_INCLUDE_NTFS_3G := true
TW_INCLUDE_RESETPROP := true
TW_INCLUDE_LIBRESETPROP :=true
TW_INCLUDE_REPACK_TOOL := true

# TWRP-Specific configuration
TW_EXCLUDE_TWRPAPP := true
TW_EXCLUDE_APEX := true

# Density / StatusBar
TW_BRIGHTNESS_PATH := /sys/class/leds/lcd-backlight/brightness
TARGET_RECOVERY_PIXEL_FORMAT := "RGBX_8888"
TW_INPUT_BLACKLIST := "hbtp_vm"
TW_MAX_BRIGHTNESS := 2047
TW_DEFAULT_BRIGHTNESS := 1200
TW_THEME := portrait_hdpi
TARGET_SCREEN_DENSITY := 320

# StatusBar
TW_STATUS_ICONS_ALIGN := center
TW_CUSTOM_CPU_POS := "300"
TW_CUSTOM_CLOCK_POS := "70"
TW_CUSTOM_BATTERY_POS := "790"
hipot
hipot
hipot
Enthusiastic Member
7
24-02-2025, 11:46 PM
#8
(03-11-2024, 02:03 AM)kelvinchinedu This flags will help you


# Debug
TWRP_INCLUDE_LOGCAT := true
TARGET_USES_LOGD := true

# Tools / Resetprop and magiskboot
TW_EXCLUDE_BASH := true
TW_EXCLUDE_TZDATA := true
TW_INCLUDE_REPACKTOOLS := false
TW_NO_FASTBOOT_BOOT := true
TW_EXCLUDE_PYTHON := true
TW_EXCLUDE_NANO := true
TW_EXCLUDE_LPTOOLS := true
TW_EXCLUDE_LPDUMP := true
TW_NO_SCREEN_BLANK := true
TARGET_USES_MKE2FS := true
TW_INCLUDE_NTFS_3G := true
TW_INCLUDE_RESETPROP := true
TW_INCLUDE_LIBRESETPROP :=true
TW_INCLUDE_REPACK_TOOL := true

# TWRP-Specific configuration
TW_EXCLUDE_TWRPAPP := true
TW_EXCLUDE_APEX := true

# Density / StatusBar
TW_BRIGHTNESS_PATH := /sys/class/leds/lcd-backlight/brightness
TARGET_RECOVERY_PIXEL_FORMAT := "RGBX_8888"
TW_INPUT_BLACKLIST := "hbtp_vm"
TW_MAX_BRIGHTNESS := 2047
TW_DEFAULT_BRIGHTNESS := 1200
TW_THEME := portrait_hdpi
TARGET_SCREEN_DENSITY := 320

# StatusBar
TW_STATUS_ICONS_ALIGN := center
TW_CUSTOM_CPU_POS := "300"
TW_CUSTOM_CLOCK_POS := "70"
TW_CUSTOM_BATTERY_POS := "790"

Thanks.
kelvinchinedu
kelvinchinedu
kelvinchinedu
Contributor
1,649
25-02-2025, 07:08 PM
#9
U are welcome
Users browsing this thread:
 1 Guest(s)
Users browsing this thread:
 1 Guest(s)
Join us
WhTlYt