Skip to content

EXTENDROM_PREROOT_BOOT

steadfasterX edited this page Nov 2, 2023 · 18 revisions

EXTENDROM_PREROOT_BOOT

Pre-rooting with MAGISK seemingless within the AOSP build process while keeping AVB / DM-VERITY intact !

Those who are using extendrom since a while might noticed that the process behind this flag has been heavily re-worked several times already. There are several reasons for that but I hope with this complete new approach we become future-proof.

Instead of using custom bootimg makefiles and such we now hook directly into the build process at a stage where all the variable things (avb or not, boot, init_boot, recovery in boot etc etc) are defined by Android and we just make use of it. That way it will be way easier to maintain whatever comes next (fingers crossed).

README

Please read the Magisk specific FAQ

State

State Branch Supported Android version(s) Tested on
STABLE main A9, A10, A11, A12, A13 A9, A13

[1] might work on lower and/or higher Android versions, too but that is untested

WARNING

If you have used this method before commit d9ab7a9 you need to remove any custom bootimg makefile you have added by the legacy guide!

Flags

flag values meaning where to configure
EXTENDROM_PREROOT_BOOT can be unset or true must be true to activate patching a boot.img/init_boot.img with MAGISK device/<vendor>/<model>/vendorsetup.sh
EXTENDROM_PACKAGES one of (mutually exclusive):
Magisk,
SignMagisk,
Magisk_vXX.xx,
SignMagisk_vXX.xx
specify the Magisk type and (optionally) version device/<vendor>/<model>/vendorsetup.sh

Technical background (how does it work)

  1. 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)
  2. extendrom will hook into the build process between the kernel image creation and AVB signing (if set)
  3. that hook will execute a completely unmodified magisk boot_patch.sh (also a completely unmodified utils_functions.sh gets included) which actually does the patching of your boot.img like the Magisk App would do.

Required flags

  • EXTENDROM_PREROOT_BOOT = true
  • EXTENDROM_PACKAGES = Magisk OR SignMagisk OR Magisk_vXX.xx OR SignMagisk_vXX.xx

When choosing just Magisk|SignMagisk (i.e. without a dedicated version) in EXTENDROM_PACKAGES you will always get the latest (supported) Magisk release. If you want a specific version set it accordingly to any of the supported versions in EXTENDROM_PACKAGES.

So when to use "Magisk" and when "SignMagisk" ?
The short answer is: usually you want "Magisk" (i.e. without the "Sign" keyword).

SignMagisk is DEPRECATED as they do not allow to include the Magisk app as a system app anymore and so will work on older Magisk versions only (pre v25 iirc). Using SignMagisk will sign the Magisk package with your own signature and this prevents upgrading even the Magisk app later (as the signatures are different). If you have a device where you are able to re-lock the bootloader this becomes useful though as it adds a (simple) barrier to "prevent" from upgrading Magisk. Upgrading just the Magisk app itself will not break the system but flashing Magisk into the boot image will (verity will reject booting as the checksums are not matching anymore). So this actually does not prevent anything if the user reboots to recovery and flashes Magisk there but at least it was useful for me so I remember not doing nasty things on a locked device.

Examples

device/<vendor>/<model>/vendorsetup.sh

  • EXTENDROM_PACKAGES="Magisk" OR
  • EXTENDROM_PACKAGES="Magisk_v25.2" OR
  • EXTENDROM_PACKAGES="SignMagisk_v23.0"

Note: extendrom supports only v22 and later! This is due to the merge of ZIP (installer) and APK (MagiskManager) introduced with v22.


device/<vendor>/<model>/<any>.mk - (the makefile approach is a DEPRECATED way of using ER)

  • EXTENDROM_PACKAGES := Magisk OR
  • EXTENDROM_PACKAGES := Magisk_v25.2 OR
  • EXTENDROM_PACKAGES := SignMagisk_v23.0

Note: extendrom supports only v22 and later! This is due to the merge of ZIP (installer) and APK (MagiskManager) introduced with v22.

Optional flags

device/<vendor>/<model>/vendorsetup.sh

  • MAGISK_TARGET_ARCH=arm -> OPTIONAL: when using 32-bit 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 32-bit devices (see above)!

This setting does not support device/<vendor>/<model>/<any>.mk so must be set in device/<vendor>/<model>/vendorsetup.sh