NOTE: This repo was just a proof of concept and I currently don't intend to keep it up to date with AOSP and Magisk changes as I don't personally use it.
aosproot is a simple way to apply the Magisk boot image patch as part of the AOSP build. This allows building a rooted custom firmware, while preserving AVB (Android Verified Boot).
For patching existing/prebuilt firmware, see avbroot. However, building open source Android firmware with aosproot included is preferable to using avbroot.
NOTE: This is currently a proof of concept implementation and has not yet been tested on a real device. It should, in theory, be functional. When applied to the GrapheneOS source, a Pixel 7 Pro (cheetah
) build produces a rooted and signed init_boot.img
.
-
Do not ever disable the
OEM unlocking
checkbox when using a locked bootloader with root. This is critically important. With root access, it is possible to corrupt the running system, for example by zeroing out the boot partition. In this scenario, if the checkbox is turned off, both the OS and recovery mode will be made unbootable andfastboot flashing unlock
will not be allowed. This effectively renders the device hard bricked. -
Any operation that causes an unsigned or differently-signed boot image to be flashed will result in the device being unbootable and unrecoverable without unlocking the bootloader again (and thus, triggering a data wipe). This includes:
- The
Direct install
method for updating Magisk. Magisk updates must be done by building a new firmware image and flashing the corresponding OTA.
- The
-
Only the latest version of AOSP is supported (13 at this time). There is no plan to support older AOSP versions.
-
Place
aosproot.xml
in.repo/local_manifests/
at the root of the AOSP source code.mkdir -p .repo/local_manifests curl -L -o .repo/local_manifests/aosproot.xml \ https://github.com/chenxiaolong/aosproot/raw/master/aosproot.xml
-
Sync the repo.
repo sync vendor/aosproot
-
Source the
build/envsetup.sh
as usual for AOSP builds.source build/envsetup.sh
-
Copy the Magisk APK into
vendor/aosproot/magisk.apk
. A symlink also works, though it makes the AOSP build less reproducible.cp /path/to/magisk.apk vendor/aosproot/magisk.apk
-
Build
aosproot
.m aosproot
-
Apply code patches to other repos to allow aosproot to be injected into the AOSP build process. The set of patches can be found in the
patches/
directory. NOTE: This need to be rerun every timerepo sync
is run.aosproot patch_code
-
Build AOSP as normal. The
init_boot
orboot
image will be patched with Magisk automatically during the build process, prior to signing.
aosproot is licensed under GPLv3. Please see LICENSE
for the full license text.