[DEV][TEMPLATE] AnyKernel3 - Easily Mod ROM Ramdisk + Pack Image.gz [Flashable Zip]

Search This thread

Pierre2324

Recognized Developer
Oct 25, 2015
2,299
3,084
25
Canada
Moto G
OnePlus 2
That just means it's not using root access to try to look at it, FX Explorer can do it with root. Running su in the script doesn't do anything, you need to open the root shell and run the script within it. Check Kernel Flasher source would be my advice.
Yup I start a process with su then use it to run commands no problem everywhere in the app + for running that script, but fails at the /android/data/data. I'll have look.
 
  • Wow
Reactions: osm0sis

osm0sis

Senior Recognized Developer / Contributor
Mar 14, 2012
15,651
35,393
Halifax
GT-i9250
Google Nexus 4
Yup I start a process with su then use it to run commands no problem everywhere in the app + for running that script, but fails at the /android/data/data. I'll have look.
Does it work if you flash the zip in Kernel Flasher or FKM? That would always be a good way to check your setup as well.
 
  • Like
Reactions: Pierre2324

Pierre2324

Recognized Developer
Oct 25, 2015
2,299
3,084
25
Canada
Moto G
OnePlus 2
Does it work if you flash the zip in Kernel Flasher or FKM? That would always be a good way to check your setup as well.
Yes works in fkm and also works when running the same command that I run in my app from termux or adb shell. I can write to /data/adb/modules no problem from my app, just not access /data/data/android from that script. (I haven't tried just running ls /data/data/android/ tho if this worked from my app) But this is getting out of the scope of the thread so I'll stop spamming here xd
 
  • Like
Reactions: osm0sis

Pierre2324

Recognized Developer
Oct 25, 2015
2,299
3,084
25
Canada
Moto G
OnePlus 2

Oh seems like running su --mount-master makes it go through /data/data/... checks thanks.

It does reach into this block from the ui_prints I added:

Nothing wrong shows up in my logs, it says
"Creating kernel helper systemless module..."
But modules content is not there.

This is when using KernelSU, on Magisk it works fine. Here's my logs @osm0sis (and that's the same running from my app or through adb shell.


EDIT: nevermind all of this, I was used to Magisk, it only required a reboot for the /data/adb/modules changes to take effect when using KSU :oops: 🤦‍♂️
 

Attachments

  • error.txt
    4 KB · Views: 4
Last edited:

osm0sis

Senior Recognized Developer / Contributor
Mar 14, 2012
15,651
35,393
Halifax
GT-i9250
Google Nexus 4
Just got my laptop fixed yet again (another dead SSD... very possibly cursed?), so feels like it's time for an update roll-up post!

Big updates this time around are any partition can be auto-detected now making AK3 more future-proof to Google partition changing shenanigans, vendor security patch level checking support (should help to restrict custom kernels to flash only over specific OEM firmware), per-partition attributes function support, debugging improvements and KernelSU support (see below), as well as some more logical partition support improvements along the way thanks to @capntrips!

We continue to be hampered by magiskboot not supporting unpack/repack of the VNDRBOOT v4 multi-ramdisk; an open PR has existed at Magisk's GitHub since February thanks to @der_akinator, but for some reason Magisk devs have so far left it unmerged.

AK3: partition auto-detect improvements:
https://github.com/osm0sis/AnyKernel3/commit/1fd27023b8c4a1b9bf1268ad8ffd03510cf157e0

README: update for any partition auto-detect:
https://github.com/osm0sis/AnyKernel3/commit/03046c34e36c905acca07b32a1d6d0288c571415

Backend: add useful mount debugging stderr for logs:
https://github.com/osm0sis/AnyKernel3/commit/e4e0c0eecb941581bdbb55423aa2d9c87406c764

AK3: block=auto and flash_generic improvements:
https://github.com/osm0sis/AnyKernel3/commit/aea91db9e771910c14ca450be2d92e0a5de2187a

AK3: flash_* display/output/debug improvements:
https://github.com/osm0sis/AnyKernel3/commit/c2e0bd7c4b5394c1f08ef0b1ccbbae9c60a4552d

Backend: don't unmount any existing apex at start of flash:
https://github.com/osm0sis/AnyKernel3/commit/e49ea0be958d52d1a449dbe089dce9ebcfc6f77b

AK3: also remove leading spaces from cmdline:
https://github.com/osm0sis/AnyKernel3/commit/8077d111357a12cc71a8d1ef7972bda68a24d2ea

AK3: correct cmdline to remove any type of leading whitespace:
https://github.com/osm0sis/AnyKernel3/commit/6ffb765c8c31ec4d6ead77de5cfb3ab8f88cf130

AK3+Backend: support AMLogic devices where A-only sets slot=normal:
https://github.com/osm0sis/AnyKernel3/commit/c2e33f95d10e0788460715f1f146daa969b8c0b6

Backend: correct build.prop locations for getprop replacement:
https://github.com/osm0sis/AnyKernel3/commit/398b9631df31228cb2d2613c9b370767a457b200

Backend: fix ui_printfile on Lineage-based recoveries:
https://github.com/osm0sis/AnyKernel3/commit/7c8c1e7e9bb61826dce658a2a8c193c0a40a9b2c

Backend: fix showing ui_printfile padding char in error when booted:
https://github.com/osm0sis/AnyKernel3/commit/7a3e6df8cacb6a3f17b8c448b7e8dcb2aada6a56

Backend: fix byname finding on modern Android versions for devices without super:
https://github.com/osm0sis/AnyKernel3/commit/8588147d67ffbae4a7fcfe5fac1c1acc17e557e6

tools: update magisk utils to v26.0(26000) beta:
https://github.com/osm0sis/AnyKernel3/commit/9664985a0b3cd4d27628a90486ce082d1e75fd55

AK3: detect flashing to inactive slot during OTA on VAB devices (#77):
https://github.com/osm0sis/AnyKernel3/commit/ddbb40edc8cd7687d266aaf792c4aae9c54c4d70

AK3: update for latest magiskboot, don't un/repack kernel if not patched:
https://github.com/osm0sis/AnyKernel3/commit/d6e040c227466c931f33c7f0084d9a7076b3c526

LICENSE: update for snapshotupdater_static:
https://github.com/osm0sis/AnyKernel3/commit/e46a516d500599434bd05d1c0f33d89382c73516

Backend: support /metadata mount + debugging improvements:
- look for .ak3-debugging file in /tmp /cache /metadata or /persist to allow debugging better on recoveries that only support sideload
- use /tmp for ak3-debug.tgz if sideloading, and fix .tgz compression when apex fails to mount

https://github.com/osm0sis/AnyKernel3/commit/c45a8d52c09f2b614e72c4a9d65130a5036b1714

Backend: refactor mount_all and umount_all:
https://github.com/osm0sis/AnyKernel3/commit/f080b80e30c56b6d310ed1ab53286337377a7d50

AK3: partial revert of d6e040c until issue with kernel_dtb is addressed:
https://github.com/osm0sis/AnyKernel3/commit/b3c769f1dbbe92e442954be664f4a9a4b9a8a1bb

AK3+Backend: use busybox as much as possible + OLD_PATH for exceptions:
https://github.com/osm0sis/AnyKernel3/commit/b3c769f1dbbe92e442954be664f4a9a4b9a8a1bb

Backend: simpify getprop replacement propval return:
https://github.com/osm0sis/AnyKernel3/commit/dee204c1979bafc71bd46432c4ebfe0021ba7ae7

AK3+Backend: pass AKHOME via export:
https://github.com/osm0sis/AnyKernel3/commit/ba82924dab3cc8a97e82ff037a0cb66112752a3d

AK3: clear cow before logical partition replace or resize (#78):
https://github.com/osm0sis/AnyKernel3/commit/68564baf104a9bd134abe781dafacc1b6c76e498

Backend: move busybox bin setup to setup_bb function, add tools to PATH:
https://github.com/osm0sis/AnyKernel3/commit/8055e75b8e81aa6fd1ac78621ff86e66653a872d

tools: update to latest busybox (1.36.1):
https://github.com/osm0sis/AnyKernel3/commit/7ea57acaa62e8880bd2224774eb5509027f264ed

Backend: fixup now that mount_apex direct .img mount works:
https://github.com/osm0sis/AnyKernel3/commit/f4cbd4b68d124133aa4e1816f3bc25e5d246abe2

Backend: abort apex loop mounts early if failing:
https://github.com/osm0sis/AnyKernel3/commit/5c916de64cfdb41b664379b2c7a05305a66af12c

tools: newer busybox (1.36.1) patched to fix loop mounts on kernels <5.x:
https://github.com/osm0sis/AnyKernel3/commit/15b90dc7db0db8c2dc04f16444de67d44e191257

Backend: fix loop mounts on newer Lineage-based recoveries:
https://github.com/osm0sis/AnyKernel3/commit/c878b3e62b0b13a71c526e88c86dbf4864a98af3

README: update for snapshotupdater_static:
https://github.com/osm0sis/AnyKernel3/commit/1a9dea2caf9f12d8518db540616f93612ef64f42

LICENSE: update XDA link:
https://github.com/osm0sis/AnyKernel3/commit/4cd6b57df700133dd78083e6630ed9962a74cc42

AK3: don't attempt to AVBv1 sign if /system/bin/dalvikvm is not present:
https://github.com/osm0sis/AnyKernel3/commit/c91542d29f838a83f6f8e06c2651616155a20547

AK3+Backend: add preliminary KernelSU support:
https://github.com/osm0sis/AnyKernel3/commit/0b37d0bfa4c86511c4eaa2c6d4d5509be16cd370

AK3+Backend: helper module improvements and full KernelSU support:
- only parse kernel strings when both do.modules=1 and do.systemless=1 are set
- support post-fs-data.sh in systemless kernel helper module (gets renamed and sourced from the built-in one)
- show systemless kernel helper module as an update pending reboot in module apps if flashed while booted
- add system_ext support to systemless kernel helper module
- show a warning during flash if systemless kernel helper module is configured but there's no decrypted /data access to be able to install it
- detect the installed KernelSU app as the indicator the user intends to use KernelSU, and install systemless kernel helper module to modules_update.img accordingly
- do KernelSU directory setup and create modules_update.img if this appears to be the initial KernelSU install
- set all systemless kernel helper module files to system_file context, since unlabeled files are not gracefully handled by KernelSU (they trigger a reboot and the module gets rejected)

NOTE: currently it appears KernelSU won't parse the modules_update.img on the first boot where it sets itself up from initial KernelSU install, but it will then do it after the following reboot. Hopefully this can be fixed by a future KernelSU release so that the systemless kernel helper module is active right away as this might be necessary to boot fully on some devices

https://github.com/osm0sis/AnyKernel3/commit/4030d3665598ad8ecc4a07e9a0c0ba914046b644

Backend: work around for chcon on broken recoveries:
https://github.com/osm0sis/AnyKernel3/commit/9ab60a49de635cecb9ddb11222463675313e2a93

Backend: hide shcon workaround stderr on (likely) working recoveries:
https://github.com/osm0sis/AnyKernel3/commit/a5ce1c04d14a835238f01e321bc587c23d93970f

AK3: add per-partition attributes, multi-partition fixes:
- attributes function now runs via core in setup_ak and reset_ak, but only if it exists, allowing more easy removal of it for setups with no ramdisk changes (so all should now remove the awkward `&& attributes` call from anykernel3.sh, see next commit)
- for multi-partition zips with multiple ramdisks requiring different files, multiple attributes functions may now be specified, either redefine attributes() in anykernel.sh for the next partition, or add a different function for each partition, e.g. boot_attributes() and vendor_boot_attributes()
- fix block=auto multi-partition setup creating an "auto-files" directory instead of final found block, e.g. "init_boot-files"

https://github.com/osm0sis/AnyKernel3/commit/32073dff09cb76f4d0a199045cf588a39caf089c

anykernel: remove attributes call (now handled in core):
https://github.com/osm0sis/AnyKernel3/commit/65678647306ebf9402f30b998351376ce984c854

Example: add commented multi-parition attributes functions:
https://github.com/osm0sis/AnyKernel3/commit/e40e655e408ee84ecfa129cbbb4f169f4d15488a

Example: tidy again:
https://github.com/osm0sis/AnyKernel3/commit/d9afe472df5329f1fcbf3e59a7dc7db9b974390e

Example: correct order:
https://github.com/osm0sis/AnyKernel3/commit/86417ffcb300b4b998f817234264a23411c36bed

AK3: add no_magisk_check=1 to skip Magisk detection and repatching:
https://github.com/osm0sis/AnyKernel3/commit/9d09ba3ecd5b9015d4633bf8e355eca2fec44906

README: add no_magisk_check=1:
https://github.com/osm0sis/AnyKernel3/commit/17f728cae067adf6c6d6a97bdfe6e55b45122bf3

Backend: add vendor security patch checking:
https://github.com/osm0sis/AnyKernel3/commit/b9df8b892ffbfa5eee6b5a4c663108366f5b83d7

anykernel: add supported.vendorpatchlevels:
https://github.com/osm0sis/AnyKernel3/commit/b9bdc36b60ec4fe192580ac647be7ecc33d05f6f

README: update for supported.vendorpatchlevels:
https://github.com/osm0sis/AnyKernel3/commit/2680ecb2cd80f572685af41289b2a4b838b3822b

Example: use boot_attributes instead of deprecated attributes:
https://github.com/osm0sis/AnyKernel3/commit/87d6fc95454c2876ceb29921af53418c5a548cea

README: update for KernelSU support:
https://github.com/osm0sis/AnyKernel3/commit/7b28c94d1f91948fa230f4e0ad925963a9564d8f

AK3: fix repack return check with magiskboot:
https://github.com/osm0sis/AnyKernel3/commit/b52433bf129253e3131d7d67bdc28136363d220c

AK3: fix unset PATCHVBMETAFLAG, only read kernel strings once:
https://github.com/osm0sis/AnyKernel3/commit/051f79300fd69d0031eb992aa258aeb2f76629bc

AK3: add overlay.d warning for KernelSU users:
https://github.com/osm0sis/AnyKernel3/commit/df90d744fd113e9c7512a4bb2061e70087dbb2c3

tools: update magisk utils to v26.3(26300) stable:
https://github.com/osm0sis/AnyKernel3/commit/d2f06464d845069c608a8f750b2dd0ae3cf71151

README: deprecate boot_signer now that magiskboot supports AVBv1:
https://github.com/osm0sis/AnyKernel3/commit/b5a74aab24be30978dd2ae4697ff27a7b4b46a0d

Happy hacking!
 
Last edited:

osm0sis

Senior Recognized Developer / Contributor
Mar 14, 2012
15,651
35,393
Halifax
GT-i9250
Google Nexus 4
Last edited:
  • Like
Reactions: acuicultor

JigsawMobile

Senior Member
Jan 28, 2019
237
67
Bosnia and Herzegovina
LG V60 ThinQ
If the recovery allows that. Lineage-based recovery does not allow it for encrypted devices, for example.

ah i can see you have added code for mount /data. In my case, I have an A13 stock ROM and TWRP recovery, I have a decrypted userdata partition, that is, the data in that case I am able to manipulate user data manully.

I guess I should add folders to the root of anykernel like partition names system, vendor, data, and put my files inside them, correct?.
Is it necessary to edit some customizations inside anykerenel.sh or will the folders by partition name be loaded automatically ?

Thanks for your reply and your hard work to help the community.
 
Last edited:

osm0sis

Senior Recognized Developer / Contributor
Mar 14, 2012
15,651
35,393
Halifax
GT-i9250
Google Nexus 4
ah i can see you have added code for mount /data. In my case, I have an A13 stock ROM and TWRP recovery, I have a decrypted userdata partition, that is, the data in that case I am able to manipulate user data manully.

I guess I should add folders to the root of anykernel like partition names system, vendor, data, and put my files inside them, correct?.
Is it necessary to edit some customizations inside anykerenel.sh or will the folders by partition name be loaded automatically ?

Thanks for your reply and your hard work to help the community.
AnyKernel is for kernels. If you want to place files in data while flashing your kernel you can do that yourself by scripting it in anykernel.sh.
 
Last edited:
  • Like
Reactions: acuicultor

osm0sis

Senior Recognized Developer / Contributor
Mar 14, 2012
15,651
35,393
Halifax
GT-i9250
Google Nexus 4
@Pierre2324 https://github.com/tiann/KernelSU/issues/945 🤞

Also https://github.com/topjohnwu/Magisk/issues/7330 should eventually get some attention as well, though I'm basically ready for it already when it does work (see my edited changelog post above).

Edit: Not looking good on the KSU front... 🫤

Ah well, I posted one more question for tiann before closing, but at the very least a nice workaround came out of it all!

 
Last edited:

LowTension

Recognized Developer
Jan 27, 2014
326
689
Narnia
Xiaomi Mi 8
Xiaomi Poco F3
@osm0sis Kernel modules won't install due to cant mount partitions

I have put kernel modules(ak3 folder, according with this post ) to /modules/vendor/lib/modules/
Also I have tried to /modules/vendor_dlkm/lib/modules/
And it's not working.

Apparently can't mount /vendor partition


Device: Redmi K60/Poco F5 Pro
Kernel: 5.10
Android: 13(Out the box)

Below I attached my anykernel.zip with corresponding log

Code:
Pushing modules...
mount: can't find /system in /proc/mounts
cp: can't create '/vendor/lib/modules/msm_sharedmem.ko': Read-only file system
chown: /vendor/lib/modules/msm_sharedmem.ko: Read-only file system
chmod: /vendor/lib/modules/msm_sharedmem.ko: Read-only file system
...

Code:
Pushing modules...
mount: can't find /system in /proc/mounts
cp: can't create '/system/vendor/lib/modules/wcd_core_dlkm.ko': Read-only file system
chown: /system/vendor/lib/modules/wcd_core_dlkm.ko: Read-only file system
chmod: /system/vendor/lib/modules/wcd_core_dlkm.ko: Read-only file system
 

Attachments

  • AnyKernel3.zip
    2.8 MB · Views: 7
  • ak3-log--2023-09-18--20-08.log
    133.5 KB · Views: 3
  • photo_2023-09-18_21-22-54.jpg
    photo_2023-09-18_21-22-54.jpg
    181.4 KB · Views: 9
Last edited:

osm0sis

Senior Recognized Developer / Contributor
Mar 14, 2012
15,651
35,393
Halifax
GT-i9250
Google Nexus 4
vendor_dlkm is its own partition, and you must flash it whole, see the instructions in the OP, and here:

As for your modules... that's an obscene number of modules you're trying to push to /vendor... not sure how successful replacing all of that would be if you could do it, but anyway, seeing that your device is using hdr v4 images suggests it's pretty new, so I'm guessing your device ROM (stock, probably?) is running ext4-dedup or erofs logical partitions in super, and thus cannot be mounted rw as should happen here:

(That reminds me, I think I'll improve the logging for those rw's... 😉)

Your best bet on a ROM with that setup is to use the AK3 systemless modules feature which will create a Magisk/KernelSU helper module with the files you include for vendor. 👍
 
Last edited:

LowTension

Recognized Developer
Jan 27, 2014
326
689
Narnia
Xiaomi Mi 8
Xiaomi Poco F3
vendor_dlkm is its own partition, and you must flash it whole, see the instructions in the OP, and here:

As for your modules... that's an obscene number of modules you're trying to push to /vendor... not sure how successful replacing all of that would be if you could do it, but anyway, seeing that your device is using hdr v4 images suggests it's pretty new, so I'm guessing your device ROM (stock, probably?) is running ext4-dedup or erofs logical partitions in super, and thus cannot be mounted rw as should happen here:

(That reminds me, I think I'll improve the logging for those rw's... 😉)

Your best bet on a ROM with that setup is to use the AK3 systemless modules feature which will create a Magisk/KernelSU helper module with the files you include for vendor. 👍
You are right.

I attached screenshot with partition info, it can be helpfully
 

Attachments

  • IMG_20230919_002800_719.jpg
    IMG_20230919_002800_719.jpg
    102.3 KB · Views: 12
  • IMG_20230919_002800_513.jpg
    IMG_20230919_002800_513.jpg
    98 KB · Views: 12
  • IMG_20230919_002806_069.jpg
    IMG_20230919_002806_069.jpg
    64.3 KB · Views: 12
Last edited:

Pierre2324

Recognized Developer
Oct 25, 2015
2,299
3,084
25
Canada
Moto G
OnePlus 2
  • Like
Reactions: osm0sis

tqmatvey

Member
Sep 9, 2021
43
9
15
Vietnam
Google Nexus 5
Xiaomi Mi 4i
Hello!, according to the docs, vendor_boot is supported, but i dont really understand how to set it up
vendor_boot in my case (Galaxy S21*) after unpacking, has all *.ko modules in root/lib/modules, am i correct that i should put modules into AnyKernel3/modules/lib/modules and the script will patch vendor_boot that i have on device?
eg. i made changes to mali driver, after building and flashing, 0 changes because that driver gets built as module and is supposed to be in vendor_boot.img, i take that mali_kbase.ko and put it in AnyKernel3/modules/lib/modules?

i tried tweaking anykernel3.sh every way i could but i keep rebooting to bootloader and facing [DTH] dt table header check fail: FDT_ERR_BADMAGIC
[UFDT] DTB LOAD FAILED.

i have only pushed 1 module to AnyKernel3/modules/lib/modules and did nothing else so far, any ideas?
 

Top Liked Posts

  • There are no posts matching your filters.
  • 4
    Just got my laptop fixed yet again (another dead SSD... very possibly cursed?), so feels like it's time for an update roll-up post!

    Big updates this time around are any partition can be auto-detected now making AK3 more future-proof to Google partition changing shenanigans, vendor security patch level checking support (should help to restrict custom kernels to flash only over specific OEM firmware), per-partition attributes function support, debugging improvements and KernelSU support (see below), as well as some more logical partition support improvements along the way thanks to @capntrips!

    We continue to be hampered by magiskboot not supporting unpack/repack of the VNDRBOOT v4 multi-ramdisk; an open PR has existed at Magisk's GitHub since February thanks to @der_akinator, but for some reason Magisk devs have so far left it unmerged.

    AK3: partition auto-detect improvements:
    https://github.com/osm0sis/AnyKernel3/commit/1fd27023b8c4a1b9bf1268ad8ffd03510cf157e0

    README: update for any partition auto-detect:
    https://github.com/osm0sis/AnyKernel3/commit/03046c34e36c905acca07b32a1d6d0288c571415

    Backend: add useful mount debugging stderr for logs:
    https://github.com/osm0sis/AnyKernel3/commit/e4e0c0eecb941581bdbb55423aa2d9c87406c764

    AK3: block=auto and flash_generic improvements:
    https://github.com/osm0sis/AnyKernel3/commit/aea91db9e771910c14ca450be2d92e0a5de2187a

    AK3: flash_* display/output/debug improvements:
    https://github.com/osm0sis/AnyKernel3/commit/c2e0bd7c4b5394c1f08ef0b1ccbbae9c60a4552d

    Backend: don't unmount any existing apex at start of flash:
    https://github.com/osm0sis/AnyKernel3/commit/e49ea0be958d52d1a449dbe089dce9ebcfc6f77b

    AK3: also remove leading spaces from cmdline:
    https://github.com/osm0sis/AnyKernel3/commit/8077d111357a12cc71a8d1ef7972bda68a24d2ea

    AK3: correct cmdline to remove any type of leading whitespace:
    https://github.com/osm0sis/AnyKernel3/commit/6ffb765c8c31ec4d6ead77de5cfb3ab8f88cf130

    AK3+Backend: support AMLogic devices where A-only sets slot=normal:
    https://github.com/osm0sis/AnyKernel3/commit/c2e33f95d10e0788460715f1f146daa969b8c0b6

    Backend: correct build.prop locations for getprop replacement:
    https://github.com/osm0sis/AnyKernel3/commit/398b9631df31228cb2d2613c9b370767a457b200

    Backend: fix ui_printfile on Lineage-based recoveries:
    https://github.com/osm0sis/AnyKernel3/commit/7c8c1e7e9bb61826dce658a2a8c193c0a40a9b2c

    Backend: fix showing ui_printfile padding char in error when booted:
    https://github.com/osm0sis/AnyKernel3/commit/7a3e6df8cacb6a3f17b8c448b7e8dcb2aada6a56

    Backend: fix byname finding on modern Android versions for devices without super:
    https://github.com/osm0sis/AnyKernel3/commit/8588147d67ffbae4a7fcfe5fac1c1acc17e557e6

    tools: update magisk utils to v26.0(26000) beta:
    https://github.com/osm0sis/AnyKernel3/commit/9664985a0b3cd4d27628a90486ce082d1e75fd55

    AK3: detect flashing to inactive slot during OTA on VAB devices (#77):
    https://github.com/osm0sis/AnyKernel3/commit/ddbb40edc8cd7687d266aaf792c4aae9c54c4d70

    AK3: update for latest magiskboot, don't un/repack kernel if not patched:
    https://github.com/osm0sis/AnyKernel3/commit/d6e040c227466c931f33c7f0084d9a7076b3c526

    LICENSE: update for snapshotupdater_static:
    https://github.com/osm0sis/AnyKernel3/commit/e46a516d500599434bd05d1c0f33d89382c73516

    Backend: support /metadata mount + debugging improvements:
    - look for .ak3-debugging file in /tmp /cache /metadata or /persist to allow debugging better on recoveries that only support sideload
    - use /tmp for ak3-debug.tgz if sideloading, and fix .tgz compression when apex fails to mount

    https://github.com/osm0sis/AnyKernel3/commit/c45a8d52c09f2b614e72c4a9d65130a5036b1714

    Backend: refactor mount_all and umount_all:
    https://github.com/osm0sis/AnyKernel3/commit/f080b80e30c56b6d310ed1ab53286337377a7d50

    AK3: partial revert of d6e040c until issue with kernel_dtb is addressed:
    https://github.com/osm0sis/AnyKernel3/commit/b3c769f1dbbe92e442954be664f4a9a4b9a8a1bb

    AK3+Backend: use busybox as much as possible + OLD_PATH for exceptions:
    https://github.com/osm0sis/AnyKernel3/commit/b3c769f1dbbe92e442954be664f4a9a4b9a8a1bb

    Backend: simpify getprop replacement propval return:
    https://github.com/osm0sis/AnyKernel3/commit/dee204c1979bafc71bd46432c4ebfe0021ba7ae7

    AK3+Backend: pass AKHOME via export:
    https://github.com/osm0sis/AnyKernel3/commit/ba82924dab3cc8a97e82ff037a0cb66112752a3d

    AK3: clear cow before logical partition replace or resize (#78):
    https://github.com/osm0sis/AnyKernel3/commit/68564baf104a9bd134abe781dafacc1b6c76e498

    Backend: move busybox bin setup to setup_bb function, add tools to PATH:
    https://github.com/osm0sis/AnyKernel3/commit/8055e75b8e81aa6fd1ac78621ff86e66653a872d

    tools: update to latest busybox (1.36.1):
    https://github.com/osm0sis/AnyKernel3/commit/7ea57acaa62e8880bd2224774eb5509027f264ed

    Backend: fixup now that mount_apex direct .img mount works:
    https://github.com/osm0sis/AnyKernel3/commit/f4cbd4b68d124133aa4e1816f3bc25e5d246abe2

    Backend: abort apex loop mounts early if failing:
    https://github.com/osm0sis/AnyKernel3/commit/5c916de64cfdb41b664379b2c7a05305a66af12c

    tools: newer busybox (1.36.1) patched to fix loop mounts on kernels <5.x:
    https://github.com/osm0sis/AnyKernel3/commit/15b90dc7db0db8c2dc04f16444de67d44e191257

    Backend: fix loop mounts on newer Lineage-based recoveries:
    https://github.com/osm0sis/AnyKernel3/commit/c878b3e62b0b13a71c526e88c86dbf4864a98af3

    README: update for snapshotupdater_static:
    https://github.com/osm0sis/AnyKernel3/commit/1a9dea2caf9f12d8518db540616f93612ef64f42

    LICENSE: update XDA link:
    https://github.com/osm0sis/AnyKernel3/commit/4cd6b57df700133dd78083e6630ed9962a74cc42

    AK3: don't attempt to AVBv1 sign if /system/bin/dalvikvm is not present:
    https://github.com/osm0sis/AnyKernel3/commit/c91542d29f838a83f6f8e06c2651616155a20547

    AK3+Backend: add preliminary KernelSU support:
    https://github.com/osm0sis/AnyKernel3/commit/0b37d0bfa4c86511c4eaa2c6d4d5509be16cd370

    AK3+Backend: helper module improvements and full KernelSU support:
    - only parse kernel strings when both do.modules=1 and do.systemless=1 are set
    - support post-fs-data.sh in systemless kernel helper module (gets renamed and sourced from the built-in one)
    - show systemless kernel helper module as an update pending reboot in module apps if flashed while booted
    - add system_ext support to systemless kernel helper module
    - show a warning during flash if systemless kernel helper module is configured but there's no decrypted /data access to be able to install it
    - detect the installed KernelSU app as the indicator the user intends to use KernelSU, and install systemless kernel helper module to modules_update.img accordingly
    - do KernelSU directory setup and create modules_update.img if this appears to be the initial KernelSU install
    - set all systemless kernel helper module files to system_file context, since unlabeled files are not gracefully handled by KernelSU (they trigger a reboot and the module gets rejected)

    NOTE: currently it appears KernelSU won't parse the modules_update.img on the first boot where it sets itself up from initial KernelSU install, but it will then do it after the following reboot. Hopefully this can be fixed by a future KernelSU release so that the systemless kernel helper module is active right away as this might be necessary to boot fully on some devices

    https://github.com/osm0sis/AnyKernel3/commit/4030d3665598ad8ecc4a07e9a0c0ba914046b644

    Backend: work around for chcon on broken recoveries:
    https://github.com/osm0sis/AnyKernel3/commit/9ab60a49de635cecb9ddb11222463675313e2a93

    Backend: hide shcon workaround stderr on (likely) working recoveries:
    https://github.com/osm0sis/AnyKernel3/commit/a5ce1c04d14a835238f01e321bc587c23d93970f

    AK3: add per-partition attributes, multi-partition fixes:
    - attributes function now runs via core in setup_ak and reset_ak, but only if it exists, allowing more easy removal of it for setups with no ramdisk changes (so all should now remove the awkward `&& attributes` call from anykernel3.sh, see next commit)
    - for multi-partition zips with multiple ramdisks requiring different files, multiple attributes functions may now be specified, either redefine attributes() in anykernel.sh for the next partition, or add a different function for each partition, e.g. boot_attributes() and vendor_boot_attributes()
    - fix block=auto multi-partition setup creating an "auto-files" directory instead of final found block, e.g. "init_boot-files"

    https://github.com/osm0sis/AnyKernel3/commit/32073dff09cb76f4d0a199045cf588a39caf089c

    anykernel: remove attributes call (now handled in core):
    https://github.com/osm0sis/AnyKernel3/commit/65678647306ebf9402f30b998351376ce984c854

    Example: add commented multi-parition attributes functions:
    https://github.com/osm0sis/AnyKernel3/commit/e40e655e408ee84ecfa129cbbb4f169f4d15488a

    Example: tidy again:
    https://github.com/osm0sis/AnyKernel3/commit/d9afe472df5329f1fcbf3e59a7dc7db9b974390e

    Example: correct order:
    https://github.com/osm0sis/AnyKernel3/commit/86417ffcb300b4b998f817234264a23411c36bed

    AK3: add no_magisk_check=1 to skip Magisk detection and repatching:
    https://github.com/osm0sis/AnyKernel3/commit/9d09ba3ecd5b9015d4633bf8e355eca2fec44906

    README: add no_magisk_check=1:
    https://github.com/osm0sis/AnyKernel3/commit/17f728cae067adf6c6d6a97bdfe6e55b45122bf3

    Backend: add vendor security patch checking:
    https://github.com/osm0sis/AnyKernel3/commit/b9df8b892ffbfa5eee6b5a4c663108366f5b83d7

    anykernel: add supported.vendorpatchlevels:
    https://github.com/osm0sis/AnyKernel3/commit/b9bdc36b60ec4fe192580ac647be7ecc33d05f6f

    README: update for supported.vendorpatchlevels:
    https://github.com/osm0sis/AnyKernel3/commit/2680ecb2cd80f572685af41289b2a4b838b3822b

    Example: use boot_attributes instead of deprecated attributes:
    https://github.com/osm0sis/AnyKernel3/commit/87d6fc95454c2876ceb29921af53418c5a548cea

    README: update for KernelSU support:
    https://github.com/osm0sis/AnyKernel3/commit/7b28c94d1f91948fa230f4e0ad925963a9564d8f

    AK3: fix repack return check with magiskboot:
    https://github.com/osm0sis/AnyKernel3/commit/b52433bf129253e3131d7d67bdc28136363d220c

    AK3: fix unset PATCHVBMETAFLAG, only read kernel strings once:
    https://github.com/osm0sis/AnyKernel3/commit/051f79300fd69d0031eb992aa258aeb2f76629bc

    AK3: add overlay.d warning for KernelSU users:
    https://github.com/osm0sis/AnyKernel3/commit/df90d744fd113e9c7512a4bb2061e70087dbb2c3

    tools: update magisk utils to v26.3(26300) stable:
    https://github.com/osm0sis/AnyKernel3/commit/d2f06464d845069c608a8f750b2dd0ae3cf71151

    README: deprecate boot_signer now that magiskboot supports AVBv1:
    https://github.com/osm0sis/AnyKernel3/commit/b5a74aab24be30978dd2ae4697ff27a7b4b46a0d

    Happy hacking!
    2
    @Pierre2324 https://github.com/tiann/KernelSU/issues/945 🤞

    Also https://github.com/topjohnwu/Magisk/issues/7330 should eventually get some attention as well, though I'm basically ready for it already when it does work.

    Edit: Not looking good on the KSU front... 🫤
    2
    @Pierre2324 https://github.com/tiann/KernelSU/issues/945 🤞

    Also https://github.com/topjohnwu/Magisk/issues/7330 should eventually get some attention as well, though I'm basically ready for it already when it does work (see my edited changelog post above).

    Edit: Not looking good on the KSU front... 🫤

    Ah well, I posted one more question for tiann before closing, but at the very least a nice workaround came out of it all!

    1
    Do we have the option to load the data partition to allow flashing of certain files in /data for eg. apks and app data ?
    If the recovery allows that. Lineage-based recovery does not allow it for encrypted devices, for example.

    1
    ah i can see you have added code for mount /data. In my case, I have an A13 stock ROM and TWRP recovery, I have a decrypted userdata partition, that is, the data in that case I am able to manipulate user data manully.

    I guess I should add folders to the root of anykernel like partition names system, vendor, data, and put my files inside them, correct?.
    Is it necessary to edit some customizations inside anykerenel.sh or will the folders by partition name be loaded automatically ?

    Thanks for your reply and your hard work to help the community.
    AnyKernel is for kernels. If you want to place files in data while flashing your kernel you can do that yourself by scripting it in anykernel.sh.
  • 324
    *** NOTE: I will not respond to any requests for support that do not include at least an attached full log and the zip in question; full AK3-debugging.zip debug .tgz preferred (instructions below). ***

    AnyKernel3 -- Flashable Zip Template for Kernel Releases with Ramdisk Modifications


    "AnyKernel is a template for an update.zip that can apply any kernel to any ROM, regardless of ramdisk." - Koush

    The concept of AnyKernel has been around for awhile, (originally by Koushik Dutta/ClockworkMod,) which allowed a device-specific kernel zImage to be flashed over device-specific ROM and use the ramdisk that came with the ROM to reduce the chance of any issues arising from the custom kernel pairing.

    The drawback to this was that some kernels require modifications to the ramdisk to enable/set up kernel features, and in the old AnyKernel format there was no way to do this. Enter AnyKernel2.

    AnyKernel2 pushed the format even further by allowing kernel developers to modify the underlying ramdisk for kernel feature support easily using a number of included command methods along with properties and variables to customize the installation experience to their kernel. AnyKernel3 adds the power of topjohnwu's magiskboot for wider format support by default.

    A script based on Galaxy Nexus (tuna) is included for reference. An example of ramdisk-only changes can be seen in my GN Synapse Injector repo. For an example that also modifies ROM and properly injects init.d support using busybox run-parts and sepolicy-inject see CosmicDan's CosmicTweaks project. For a multi-partition example and an example of how to handle a device which only has a ramdisk when rooted see my N5X/6P BLOD Workaround Injector. Other working AK2/3 examples for more recent devices may be found on eng.stk's blu_spark device repos under Releases.

    Please see the linked posts here for instructions on enabling full AVBv1 (Pixel), AVBv1, A/B slot and/or system-as-root (SAR) or 2-stage init (2SI) device support, and further guidelines for system-as-root/2-stage init (/system/system in recovery) modifications in general.

    Please also see the post here for important notes about the current state of AOSP vendor_boot v4 support and AVBv2 flag options.


    Magisk root is automatically detected and retained by patching the new Image.*-dtb as Magisk would!


    My development work on my many projects comes out of my free time, so if you enjoy this project or anything else I've done on xda, please consider sponsoring my ongoing work using my GitHub Sponsors profile. For a one-time donation you can hit the donate link from my profile. Thank you for your support!


    Source:
    https://github.com/osm0sis/AnyKernel3/
    Download: https://github.com/osm0sis/AnyKernel3/archive/master.zip


    Instructions

    1)
    Place final kernel build product, e.g. Image.gz-dtb or zImage to name a couple, in the zip root (any separate dt, dtb, recovery_dtbo, dtbo and/or vendor_dlkm should also go here for devices that require custom ones, each will fallback to the original if not included)
    2) Place any required ramdisk files in /ramdisk (/vendor_ramdisk for simple multi-partition vendor_boot v3 support) and module files in /modules (with the full path like /modules/system/lib/modules)
    3) Place any required patch files (generally partial files which go with AK3 file editing commands) in /patch (/vendor_patch for simple multi-partition vendor_boot v3 support)
    4) Modify the anykernel.sh to add your kernel's name, boot partition location, permissions for any added ramdisk files, and use methods for any required ramdisk modifications (optionally, also place banner and/or version files in the root to have these displayed during flash)
    5) `zip -r9 UPDATE-AnyKernel3.zip * -x .git -x .github README.md *placeholder`

    The LICENSE file must remain in the final zip to comply with licenses for binary redistribution and the license of the AK3 scripts.


    If supporting a recovery that forces zip signature verification (like Cyanogen Recovery) then you will need to also sign your zip using the method I describe here:
    [DEV][TEMPLATE] Complete Shell Script Flashable Zip Replacement + Signing [SCRIPT]

    Not required, but any tweaks you can't hardcode into the source (best practice) should be added with an additional init.tweaks.rc or bootscript.sh to minimize the necessary ramdisk changes. On newer devices Magisk allows these within /overlay.d - see examples.

    It is also extremely important to note that for the broadest AK3 compatibility it is always better to modify a ramdisk file rather than replace it.

    If running into trouble when flashing an AK3 zip, the suffix -debugging may be added to the zip's filename to enable creation of a debug .tgz of /tmp for later examination while booted or on desktop.


    Staying Up-To-Date

    Now that you've got a ready zip for your device, you might be wondering how to keep it up-to-date with the latest AnyKernel commits. AnyKernel2 and AnyKernel3 have been painstakingly developed to allow you to just drop in the latest update-binary and tools directory and have everything "just work" for beginners not overly git or script savvy, but the best practice way is as follows:

    1) Fork my AnyKernel3 repo on GitHub
    2) `git clone https://github.com/<yourname>/AnyKernel3`
    3) `git remote add upstream https://github.com/osm0sis/AnyKernel3`
    4) `git checkout -b <devicename>`
    5) Set it up like your <devicename> zip (i.e. remove any folders you don't use like ramdisk or patch, delete README.md, and add your anykernel.sh and optionally your Image.*-dtb if you want it up there) then commit all those changes
    6) `git push --set-upstream origin <devicename>`
    7) `git checkout master` then repeat steps 4-6 for any other devices you support

    Then you should be able to `git pull upstream master` from your master branch and either merge or cherry-pick the new AK3 commits into your device branches as needed.


    Enjoy!
    Questions, comments and feedback welcome.



    Credits & Thanks: All authors of the included binaries and the tools I used to port them over for their amazing work. koush for the original AnyKernel concept.

    Disclaimer: Naturally, you take all the responsibility for what happens to your device when you start messing around with things.
    132
    Script Commands Reference

    Everything to edit is self-contained in anykernel.sh. A quick-reference for the commands and properties included are as follows.


    Properties / Variables

    These are some values that will be read during the install process, allowing you to customize your installation, e.g. block= is a shell variable to specify the kernel/boot block partition that the dump_boot command method will copy and unpack.

    Code:
    kernel.string=KernelName by YourName @ xda-developers
    do.devicecheck=1
    do.modules=1
    do.systemless=1
    do.cleanup=1
    do.cleanuponabort=0
    device.name1=maguro
    device.name2=toro
    device.name3=toroplus
    device.name4=tuna
    supported.versions=6.0 - 7.1.2
    supported.patchlevels=2019-07 -
    supported.vendorpatchlevels=2013-07
    
    block=/dev/block/platform/omap/omap_hsmmc.0/by-name/boot;
    is_slot_device=0;
    ramdisk_compression=auto;
    patch_vbmeta_flag=auto;

    do.devicecheck=1 specified requires at least device.name1 to be present. This should match ro.product.device, ro.build.product, ro.product.vendor.device or ro.vendor.product.device from the build.prop files for your device. There is support for as many device.name# properties as needed. You may remove any empty ones that aren't being used.

    do.modules=1 will push the .ko contents of the modules directory to the same location relative to root (/) and apply correct permissions. On A/B devices this can only be done to the active slot.

    do.systemless=1 (with do.modules=1) will instead push the full contents of the modules directory to create a simple "ak3-helper" Magisk module, allowing developers to effectively replace system files, including .ko files. If the current kernel is changed then the kernel helper module automatically removes itself to prevent conflicts.

    do.cleanup=0 will keep the zip from removing its working directory in /tmp/anykernel (by default) - this can be useful if trying to debug in adb shell whether the patches worked correctly.

    do.cleanuponabort=0 will keep the zip from removing its working directory in /tmp/anykernel (by default) in case of installation abort.

    supported.versions= will match against ro.build.version.release from the current ROM's build.prop. It can be set to a list or range. As a list of one or more entries, e.g. 7.1.2 or 8.1.0, 9 it will look for exact matches, as a range, e.g. 7.1.2 - 9 it will check to make sure the current version falls within those limits. Whitespace optional, and supplied version values should be in the same number format they are in the build.prop value for that Android version.

    supported.patchlevels= and supported.vendorpatchlevels= will match against ro.build.version.security_patch and ro.vendor.build.security_patch, respectively, from the current system/vendor build.prop. It can be set as a closed or open-ended range of dates in the format YYYY-MM, whitespace optional, e.g. 2019-04 - 2019-06, 2019-04 - or - 2019-06 where the last two examples show setting a minimum and maximum.

    block=auto instead of a direct block filepath enables detection of the device boot partition for use with broad, device non-specific zips. Also accepts any partition filename (from by-name), e.g. boot, recovery, or vendor_boot.

    is_slot_device=1 enables detection of the suffix for the active boot partition on slot-based devices and will add this to the end of the supplied block= path. Also accepts auto for use with broad, device non-specific zips.

    ramdisk_compression=auto allows automatically repacking the ramdisk with the format detected during unpack. Changing auto to gz, lzo, lzma, xz, bz2, lz4, or lz4-l (for lz4 legacy) instead forces the repack as that format, and using cpio or none will (attempt to) force the repack as uncompressed.

    patch_vbmeta_flag=auto allows automatically using the default AVBv2 vbmeta flag on repack, and use the Magisk configuration (Canary 23016+). Set to 0 forces keeping whatever is in the original AVBv2 flags, and set to 1 forces patching the flag (only necessary on few devices).

    customdd="<arguments>" may be added to allow specifying additional dd parameters for devices that need to hack their kernel directly into a large partition like mmcblk0, or force use of dd for flashing.

    slot_select=active|inactive may be added to allow specifying the target slot. If omitted the default remains active.

    no_block_display=1 may be added to disable output of the detected final used partition+slot path for zips which choose to include their own custom output instead.

    no_magisk_check=1 may be added to disable detection of Magisk and related kernel/dtb repatching for special zips which don't require that.


    Command Methods

    Code:
    ui_print "<text>" [...]
    abort ["<text>" [...]]
    contains <string> <substring>
    file_getprop <file> <property>
    
    set_perm <owner> <group> <mode> <file> [<file2> ...]
    set_perm_recursive <owner> <group> <dir_mode> <file_mode> <dir> [<dir2> ...]
    
    dump_boot
    split_boot
    unpack_ramdisk
    
    backup_file <file>
    restore_file <file>
    replace_string <file> <if search string> <original string> <replacement string> <scope>
    replace_section <file> <begin search string> <end search string> <replacement string>
    remove_section <file> <begin search string> <end search string>
    insert_line <file> <if search string> before|after <line match string> <inserted line>
    replace_line <file> <line replace string> <replacement line> <scope>
    remove_line <file> <line match string> <scope>
    prepend_file <file> <if search string> <patch file>
    insert_file <file> <if search string> before|after <line match string> <patch file>
    append_file <file> <if search string> <patch file>
    replace_file <file> <permissions> <patch file>
    patch_fstab <fstab file> <mount match name> <fs match type> block|mount|fstype|options|flags <original string> <replacement string>
    patch_cmdline <cmdline entry name> <replacement string>
    patch_prop <prop file> <prop name> <new prop value>
    patch_ueventd <ueventd file> <device node> <permissions> <chown> <chgrp>
    
    repack_ramdisk
    flash_boot
    flash_generic <partition name>
    write_boot
    
    reset_ak [keep]
    setup_ak

    "if search string" is the string it looks for to decide whether it needs to add the tweak or not, so generally something to indicate the tweak already exists. "cmdline entry name" behaves somewhat like this as a match check for the name of the cmdline entry to be changed/added by the patch_cmdline function, followed by the full entry to replace it. "prop name" also serves as a match check in patch_prop for a property in the given prop file, but is only the prop name as the prop value is specified separately.

    Similarly, "line match string" and "line replace string" are the search strings that locate where the modification needs to be made for those commands, "begin search string" and "end search string" are both required to select the first and last lines of the script block to be replaced for replace_section, and "mount match name" and "fs match type" are both required to narrow the patch_fstab command down to the correct entry.

    "scope" may be specified as "global" to force all instances of the string/line targeted by replace_string, replace_line or remove_line to be replaced/removed accordingly. Omitted or set to anything else and it will perform the default first-match action.

    "before|after" requires you simply specify "before" or "after" for the placement of the inserted line, in relation to "line match string".

    "block|mount|fstype|options|flags" requires you specify which part (listed in order) of the fstab entry you want to check and alter.

    dump_boot and write_boot are the default method of unpacking/repacking, but for more granular control, or omitting ramdisk changes entirely ("OG AK" mode), these can be separated into split_boot; unpack_ramdisk and repack_ramdisk; flash_boot respectively. flash_generic can be used to flash an image to the corresponding partition. It is automatically included for dtbo and vendor_dlkm in write_boot but can be called separately if using "OG AK" mode or creating a simple partition flashing only zip.

    Multi-partition zips can be created by removing the ramdisk and patch folders from the zip and including instead "-files" folders named for the partition (without slot suffix), e.g. boot-files + recovery-files, or kernel-files + ramdisk-files (on some Treble devices). These then contain Image.gz, and ramdisk, patch, etc. subfolders for each partition. To setup for the next partition, simply set block= (without slot suffix) and ramdisk_compression= for the new target partition and use the reset_ak command.

    Similarly, multi-slot zips can be created with the normal zip layout for the active (current) slot, then resetting for the inactive slot by setting block= to the partition (without slot suffix) again, slot_select=inactive and ramdisk_compression= to the desired options for the target slot and using the reset_ak keep command, which will retain the patch and any added ramdisk files for the next slot.

    backup_file may be used for testing to ensure ramdisk changes are made correctly, transparency for the end-user, or in a ramdisk-only "mod" zip. In the latter case restore_file could also be used to create a "restore" zip to undo the changes, but should be used with caution since the underlying patched files could be changed with ROM/kernel updates.

    You may also use ui_print "<text>" to write messages back to the recovery during the modification process, abort "<text>" to abort with optional message, and file_getprop "<file>" "<property>" and contains "<string>" "<substring>" to simplify string testing logic you might want in your script.


    Binary Inclusion

    The AK3 repo includes current ARM builds of magiskboot, magiskpolicy, lptools_static, httools_static, fec, snapshotupdater_static and busybox by default to keep the basic package small. Builds for other architectures and optional binaries (see below) are available from the latest Magisk zip, or my latest AIK-mobile and Flashlt packages, respectively, here:

    https://forum.xda-developers.com/t/...kernel-ramdisk-win-android-linux-mac.2073775/ (Android Image Kitchen thread)
    https://forum.xda-developers.com/t/...-and-ends-multiple-devices-platforms.2239421/ (Odds and Ends thread)

    Optional supported binaries which may be placed in /tools to enable built-in expanded functionality are as follows:

    mkbootfs - for broken recoveries, or, booted flash support for a script/app via bind mount to /tmp (deprecated/use with caution)
    flash_erase, nanddump, nandwrite - MTD block device support for devices where the dd command is not sufficient
    dumpimage, mkimage - DENX U-Boot uImage format support
    mboot - Intel OSIP Android image format support
    unpackelf, mkbootimg - Sony ELF kernel.elf format support, repacking as AOSP standard boot.img for unlocked bootloaders
    elftool (with unpackelf) - Sony ELF kernel.elf format support, repacking as ELF for older Sony devices
    mkmtkhdr (with unpackelf) - MTK device boot image section headers support for Sony devices
    futility + chromeos test keys directory - Google ChromeOS signature support
    boot_signer-dexed.jar (deprecated) + avb keys directory - Google Android Verified Boot 1.0 (AVBv1) custom signature support
    rkcrc - Rockchip KRNL ramdisk image support

    Optionally moving ARM builds to tools/arm and putting x86 builds in tools/x86 will enable architecture detection for use with broad, device non-specific zips.
    48
    AnyKernel3 (AK3) Release

    Welcome to AK3: AnyKernel2 + Magisk = AnyKernel3!:
    - abstract out execution directory as $home to fascilitate testing individual scripts (defaults to /tmp/anykernel)
    - general script clean ups for uniformity, readability, speed and simplicity
    - simplify consecutive `ui_print` commands where possible

    Backend only fixes:
    - use busybox umount and mount whenever possible to avoid linker warnings in stderr during system-as-root setup
    - use `busybox --install -s` for bin/* setup
    - consolidate setup to abort earlier if there are issues
    - add backwards compatible symlinks for those who might not have updated their anykernel.sh with ak3-core.sh (to be renamed in subsequent commit)

    Tools only fixes:
    - add magiskboot to replace separate support for AOSP and PXA-AOSP formats, with MTK headers, BLOB, DHTB, SEAndroid and Nook signing
    - add magiskpolicy to allow for easy sepolicy patching
    - remove xz and lz4 since magiskboot supports these (and all other formats except lzop)
    - magiskboot also resolves long-standing request for built-in Bump support (#18)

    AK3 Core only fixes:
    - use full `ui_print` function implementation like the backend
    - add `abort` function to simplify exit on errors
    - fix $patch directory being excluded from `reset_ak`
    - update $ramdisk_compression handling for magiskboot
    - update Sony ELF and related support for initial repack as AOSP by using mkbootimg as plug-and-play optional add-in binary
    - update Sony ELF MTK header support using mkmtkhdr only when ELF is initially unpacked by unpackelf
    - add support for MTK RECOVERY ramdisk header type with Sony ELF
    - simplify U-Boot dumpimage/mkimage and Sony ELF unpackelf/mkbootimg split_img file handling
    - update patch_cmdline to handle both magiskboot as header prop file, and unpackelf or mboot as cmdline.txt
    - use `cp -fp` for `backup_file` and `restore_file` to hopefully better preserve attributes if used outside of the ramdisk
    - refactor setup into `setup_ak` to simplify `reset_ak` trigger to find slot and block again
    - add fallback to busybox for compression formats (i.e. lzop) which magiskboot cannot handle

    IMPORTANT NOTES:
    1) forcing repack with uncompressed cpio ramdisk is not currently supported by magiskboot
    2) forcing repack with lzop ramdisk when previously another format is not currently supported by magiskboot

    https://github.com/osm0sis/AnyKernel3/commit/698682123053cab9e3277c9c9df783a97b3e8958

    tools: rename ak2-core.sh to ak3-core.sh:
    https://github.com/osm0sis/AnyKernel3/commit/cba94d3103ec92380717052a69bb6e37b15ad853

    anykernel: Update for AK3:
    https://github.com/osm0sis/AnyKernel3/commit/8724d881595abd529376cb6fe2205b69a05021dd

    README: Update for AK3:
    https://github.com/osm0sis/AnyKernel3/commit/a10312941ade81955d2217caa0e90dae553bb697

    AK3: fix elftool repack cmdline handling:
    https://github.com/osm0sis/AnyKernel3/commit/c8d087bbad6442546a3f85610e3eaa2d867de021

    AK3: allow workaround for dtbo devices with cat /dev/zero issues:
    https://github.com/osm0sis/AnyKernel3/commit/24032c07328cd2ed9b7c2e57d63d351d52425cf0

    README: updates and touchups for AK3:
    https://github.com/osm0sis/AnyKernel3/commit/5fdf659d01f0fed87b44c3dbc6103d4146b694d5

    AK3: resolve non-zero return code introduced by `cat <img> /dev/zero > <block>`:
    https://github.com/osm0sis/AnyKernel3/commit/97de781a55f09cca631982511789e1ff95badc8f

    Alright! The big day is here. Huge thanks to @topjohnwu for working with me to add the necessary features to magiskboot so I could keep virtually all feature parity with AnyKernel2. Plus the rewrite to magiskboot allowed me to do a thorough code review and includes more format support by default and ensures much better ongoing format support as magiskboot continues to be developed. I wrote this intentionally so that basically all current AK2 zips should be able to be immediately upgradeable using the initial patch, or even just dropping the updated tools/core and backend in.

    Of course pay close attention to merge conflicts for the main AK3 rewrite commit and the anykernel.sh updates, especially since many have added an older version of magiskboot/magiskpolicy unofficially to their zips for root repatching, but note you will need the current included builds since they are a couple commits ahead of even the current Magisk Canary. Going forward let me keep the included ARM magiskboot/magiskpolicy up to date, since I'll be ensuring they work correctly before updating them.

    Thanks also to @eng.stk and @Freak07 for their help testing during the AK3 BETA .patch phase. I also throughly tested most things throughout the rewrite on my OnePlus 6T so things should definitely be all good for OnePlus devices. :D:highfive:

    Edit: Added a couple more commits today to resolve issues on devices where dtbo partition flashing is required. Thanks @MSF Jarvis for reporting the issue, and help testing to find a solution. :)
    18
    Happy New Year!

    Despite me being away on vacation here's a big update to module handling thanks to @nathanchance. If you are currently pushing modules with AK2 you will need to move the files under "modules/" to reflect their destination subfolder to avoid breakage, e.g. "modules/system/lib/modules/", "modules/system/vendor/lib/modules/" and/or "modules/vendor/lib/modules/"; this will be pretty future proof so was worth the while.

    update-binary: Change how we handle modules:
    https://github.com/osm0sis/AnyKernel2/commit/6b11373d4ae91b10ce4745e380ee3d4b440fbde6

    README: Update documentation for modules:
    https://github.com/osm0sis/AnyKernel2/commit/218b5774d26f1ff1c0acd3bec273153f5b529cb2

    example: Update modules folder for new location handling:
    https://github.com/osm0sis/AnyKernel2/commit/a0b6db2784a3cd121a4af768a68ec88fc97c550a
    15
    Thanks guys!

    I figured it would be nice to get it out there and also have it as a "Help Desk" thread for kernel devs who have questions about implementation, etc. too. Some devices might require switching it from dd to MTD-Utils, so I can help with that. So on and so forth. :)

    Once we get a few devs who know how to use it, it should be pretty easy to help others. I'm looking at you Smitty. ;) No pressure. :p