-
Notifications
You must be signed in to change notification settings - Fork 8
EXTENDROM_PREROOT_BOOT (legacy)
This method is deprecated as of now and replaced by this
State | Branch | Supported Android version(s) | Tested on | Howto Guide |
---|---|---|---|---|
DEPRECATED |
any magisk_xx
|
A9, A10, A11, A12, A13 |
A9, A10, A11, A12, A13 |
see here |
flag | values | meaning | where to configure |
---|---|---|---|
EXTENDROM_PREROOT_BOOT | can be unset or true
|
must be true to activate patching a boot.img with MAGISK |
device/<vendor>/<model>/vendorsetup.sh or device/<vendor>/<model>/<any>.mk
|
Pre-rooting with MAGISK seemingless within the AOSP build process while keeping AVB / DM-VERITY intact !
Important: This has been tested on the A/B device OnePlus 7T pro (hotdog) only! No idea what happens on devices without a dedicated recovery partition / boot image without ramdisk. I guess it just means adding INSTALLED_RECOVERYIMAGE_TARGET to mkbootimg.mk as it all uses the internal magisk functions for patching.
- when executing
vendor/extendrom/er.sh
the specified Magisk version will be downloaded, extracted and all necessary components moved to a temporary patch dir (out/.magisk) - When building your ROM a completely unmodified magisk boot_patch.sh will be executed (also a completely unmodified utils_functions.sh gets included) which actually does the patching of your boot.img like the Magisk App would do.
You might noticed that extendrom has several branches:
-
main
-> usually the greatest and latest but sometimes Magisk had caused issues in the past on new releases -
magisk_vXX
-> always kept up2date withmain
with the only diff of the given specific Magisk (Major) release
so choose e.g. magisk_v24
to get the latest v24 magisk release or magisk_v20
for the latest v20 etc.
EXTENDROM_PREROOT_BOOT = true
EXTENDROM_PACKAGES = Magisk | SignMagisk
-
MAGISK_TARGET_ARCH=arm
-> OPTIONAL: when using 32bit devices (ONLY then)*
(*)note: MAGISK_TARGET_ARCH
will be parsed when set in your vendorsetup.sh
or specified as env variable.
It can be arm
or arm64
which will copy the correct libs according to whats specified.
If unset the default is expecting arm64
- so ensure you set it for 32bit devices (see above)!
When you enable this flag you HAVE to use a custom mkbootimg.mk in order to make use of it. That means you have to set this in your BoardConfig.mk
:
BOARD_CUSTOM_BOOTIMG_MK := $(DEVICE_PATH)/mkbootimg.mk
A fully working example configuration for a mkbootimg.mk can be found here. Note: that can differ from what you need, especially Samsung devices are different / having often one which need to be adapted accordingly.
not all devices can / will use the same mkbootimg.mk
. You need to check build/core/Makefile
-> $(INSTALLED_BOOTIMAGE_TARGET):
to identify if you need to adapt this or not. Here are the most important things you need to do:
- add:
ROOTBOOT := $(shell echo $$EXTENDROM_PREROOT_BOOT)
at the top / first line - add:
ROOT_BOOT_BIN := $(OUT_DIR)/.magisk/boot_patch.sh
at the top / second line - copy the whole (matching to your device..)
$(INSTALLED_BOOTIMAGE_TARGET):
block frombuild/core/Makefile
- add:
@/bin/bash $(ROOT_BOOT_BIN) $$PWD/$@
in the block of$(INSTALLED_BOOTIMAGE_TARGET):
, AFTER theMKBOOTIMG
line and BEFORE any AVB line - add:
@cp -v $(OUT_DIR)/.magisk/new-boot.img $(PRODUCT_OUT)/boot.img
after that
some notes:
-
ROOT_BOOT_BIN
is the script coming with vendor/extendrom which does the pre-rooting and$$PWD
is needed as it expects an absolute path - Notice: When using AVB / dm-verity this path
--image $(OUT_DIR)/.magisk/IMAGES/boot.img
is important exactly like that as well - Even though you might not want to use the recovery coming with the ROM you are building -> when specifying a custom mkbootimg.mk you also might have to set
INSTALLED_RECOVERYIMAGE_TARGET
here as well! - When it comes to AVB / dm-verity it is important to set the pre-root script BEFORE adding the hash footer (obviously). The result is a boot image accepted by a locked bootloader (when your bootloader supports custom ROMs / keys) which means you can use a custom ROM + MAGISK and all that on a fully locked device..
- The given mkbookimg.mk example also contains a block for using a prebuilt recovery which is not in scope of this documentation so you likely need to change that block completely (check your
build/core/Makefile
again) - last but not least the example file handles rooting or not rooting automatically depending if the flag
EXTENDROM_PREROOT_BOOT = true
has been set or not. If you always wanna root you can leave out that part ofc (but the flag needs to be set always).