FORUMS

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

13,967 posts
Thanks Meter: 31,106
 
By osm0sis, Recognized Developer / Recognized Contributor on 5th March 2014, 02:32 AM
Post Reply Email Thread
12th March 2020, 01:37 AM |#931  
osm0sis's Avatar
OP Recognized Developer / Recognized Contributor
Flag Halifax
Thanks Meter: 31,106
 
Donate to Me
More
Quote:
Originally Posted by moham_96

New devices on android 9 have a boot image without a ramdisk so the anykernel script has to call only the flash_boot and flash_dtbo methods without any of the ramdisk methods or else it will fail and tell you that it couldn't unpack the ramdisk,
but if the current boot image is rooted with magisk then the magisk flash will add a ramdisk that contains it's files and you have to edit the anykernel script to call the relevant ramdisk methods.
Is it possible to setup anykernel3 so that it detect whether the boot partition has a ramdisk or not and based on that decides to call the ramdiks methods or not?

Actually the newest devices will have a 2-stage init (2SI) ramdisk again, so it's only the ones in the middle on A-only devices (or A/B devices that somehow aren't boot-as-recovery, like some weird Huawei Treble bullshit) that won't have a ramdisk at all.

If your device falls into that narrow category, then the solution is to replace dump_boot and write_boot in your anykernel.sh with the following snippets: https://github.com/osm0sis/AnyKernel...ment-573335100
The Following User Says Thank You to osm0sis For This Useful Post: [ View ]
25th March 2020, 12:05 PM |#932  
osm0sis's Avatar
OP Recognized Developer / Recognized Contributor
Flag Halifax
Thanks Meter: 31,106
 
Donate to Me
More
Awesome news for custom ROM users! If your custom kernel is up-to-date with the AnyKernel3 git HEAD, it automatically has support for my new FlashAfterUpdate addon.d-v2 script, so you can easily keep a custom kernel installed through an A/B ROM OTA!

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!

Setup is simple!

1) Download my latest 999-flashafterupdate.sh from the attachments of the scripts post in my Odds & Ends thread (read the blurb there/follow the links for more info).
2) Put the script at /system/addon.d/999-flashafterupdate.sh and give it rwxr-xr-x (755) permissions.
3) Create the /sdcard/FlashAfterUpdate directory and put the latest kernel zip there.

When you get an A/B OTA update the custom kernel zip should now be automatically flashed again at the end, over the boot partition of the updated slot, as part of the update process. Magisk root is required, and the latest Canary build is recommended.

You can also keep TWRP installed on A/B devices where recovery is inside the boot.img (boot-as-recovery)! See my 98-twrp_ab.sh addon.d-v2 script at the above link. With all of these in place, then TWRP, Magisk, and AK3 (via FlashAfterUpdate) all get retained through an OTA!

The script gets logged in logcat during booted OTAs, just like my TWRP A/B addon.d-v2 and Magisk addon.d-v2 scripts, so keep an eye there if you're curious, AND the next TWRP will also have support for addon.d-v2 thanks to the amazing work of @k4y0z, so keep an eye out for that.

P.S. If there are any other mod zips out there that would benefit from FlashAfterUpdate addon-d.v2 support (i.e. they wouldn't be better handled by their own addon.d-v2 script), then contact the mod developer and point them to this post so they can follow my instructions for adding support.

Lastly, also feel free to pester any and all kernel devs who aren't up-to-date with their AK3 zips yet, and please link them to this post, so that we can make things easier for everyone on custom ROMs and custom kernels.
The Following 7 Users Say Thank You to osm0sis For This Useful Post: [ View ]
28th March 2020, 12:19 AM |#933  
Senior Member
Ngayogyakarta Hadiningrat
Thanks Meter: 51
 
Donate to Me
More
Sir @osm0sis, do you have idea how to patch build.prop for a/b devices?
28th March 2020, 05:25 AM |#934  
osm0sis's Avatar
OP Recognized Developer / Recognized Contributor
Flag Halifax
Thanks Meter: 31,106
 
Donate to Me
More
Quote:
Originally Posted by WongJawa

Sir @osm0sis, do you have idea how to patch build.prop for a/b devices?

I've answered this a few times recently, please search and/or read back.
The Following User Says Thank You to osm0sis For This Useful Post: [ View ]
29th March 2020, 08:20 AM |#935  
Senior Member
Thanks Meter: 31
 
More
Hi @osm0sis, first an big thanks for this useful tool

My custom kernel adds two /dev entrys (/dev/hidg0 and /dev/hidg1). Basically the patch from https://github.com/pelya/android-keyboard-gadget but conflicts fixed. That works fine. But only with permissive SELinux - Enforcing denies access. How can I utilize magiskpolicy to fix it? (I can find out the SELinux rules for myself but magiskpolicy has not so great documentation + I don't know much things about SELinux, so I don't know what parameters are needed to patch the OS and not the recovery)
29th March 2020, 08:47 AM |#936  
osm0sis's Avatar
OP Recognized Developer / Recognized Contributor
Flag Halifax
Thanks Meter: 31,106
 
Donate to Me
More
Quote:
Originally Posted by nift4

Hi @osm0sis, first an big thanks for this useful tool

My custom kernel adds two /dev entrys (/dev/hidg0 and /dev/hidg1). Basically the patch from https://github.com/pelya/android-keyboard-gadget but conflicts fixed. That works fine. But only with permissive SELinux - Enforcing denies access. How can I utilize magiskpolicy to fix it? (I can find out the SELinux rules for myself but magiskpolicy has not so great documentation + I don't know much things about SELinux, so I don't know what parameters are needed to patch the OS and not the recovery)

Depends on your device how you'd go about patching the sepolicy. That said /dev is normally not accessible without root on modern devices.
29th March 2020, 12:23 PM |#937  
Senior Member
Thanks Meter: 31
 
More
Quote:
Originally Posted by osm0sis

Depends on your device how you'd go about patching the sepolicy. That said /dev is normally not accessible without root on modern devices.

Device details, okay.
Motorola Moto G5 (cedric)
Shipped with Nougat (7.0)
The kernel targets Android 10 and afaik it's SAR.
Anything else?

EDIT: About /dev is not accessible: That's the problem, yeah
29th March 2020, 01:22 PM |#938  
osm0sis's Avatar
OP Recognized Developer / Recognized Contributor
Flag Halifax
Thanks Meter: 31,106
 
Donate to Me
More
Quote:
Originally Posted by nift4

Device details, okay.
Motorola Moto G5 (cedric)
Shipped with Nougat (7.0)
The kernel targets Android 10 and afaik it's SAR.
Anything else?

EDIT: About /dev is not accessible: That's the problem, yeah

Well with SAR you likely have a split sepolicy and no way to switch to a monolith outside of Magisk, so you might as well use Magisk to change the sepolicy, either via a script in the root context in your kernel using magiskpolicy --live, or some other means, like a module with sepolicy.rule.

Is /dev even accessible with SELinux permissive? Not sure how to make it behave any differently. Probably just attempt what you want and see what the denial is in logcat or dmesg then change the policy to what you need.
29th March 2020, 02:13 PM |#939  
Senior Member
Thanks Meter: 31
 
More
Quote:
Originally Posted by osm0sis

Well with SAR you likely have a split sepolicy and no way to switch to a monolith outside of Magisk, so you might as well use Magisk to change the sepolicy, either via a script in the root context in your kernel using magiskpolicy --live, or some other means, like a module with sepolicy.rule.

Is /dev even accessible with SELinux permissive? Not sure how to make it behave any differently. Probably just attempt what you want and see what the denial is in logcat or dmesg then change the policy to what you need.

- Everyone uses Magisk here at Cedric
- /dev/hidg{0/1} works without Enforcing
- What do you suggest? I would go for a module.

Some additional notes about a module:
I enabled do.modules and do.systemless (I don't have any modules but I did anyway ) and already get an Magisk module. Can I add the sepolicy.rule to the existing module?
29th March 2020, 02:44 PM |#940  
osm0sis's Avatar
OP Recognized Developer / Recognized Contributor
Flag Halifax
Thanks Meter: 31,106
 
Donate to Me
More
Quote:
Originally Posted by nift4

- Everyone uses Magisk here at Cedric
- /dev/hidg{0/1} works without Enforcing
- What do you suggest? I would go for a module.

Some additional notes about a module:
I enabled do.modules and do.systemless (I don't have any modules but I did anyway ) and already get an Magisk module. Can I add the sepolicy.rule to the existing module?

If you aren't using it you really shouldn't enable it.

I would suggest a kernel boot script using overlay.d, within which you could use magiskpolicy --live. Instructions are linked in the OP.

Basically this but updated for overlay.d and only supporting Magisk: https://github.com/franciscofranco/r...init.fk.rc#L71
https://github.com/franciscofranco/r...it.supolicy.sh
The Following User Says Thank You to osm0sis For This Useful Post: [ View ]
7th April 2020, 01:35 AM |#941  
Member
Flag Kafr el Sheikh
Thanks Meter: 87
 
More
Hey man how are you Thanks for this awesome template
can i ask about something i edited the ramdisk files as overlay.d and added some configurations but when i set gpu to a max freq number it didnt be setted i dont know why ... i tried much to solve this issue but i cannot.. if you are free and can help me please check this and if you can configure what thing i miss
https://github.com/negrroo/AnyKernel3-LawRun
Post Reply Subscribe to Thread

Tags
anykernel, flashable zip, kernel, scripting, template

Guest Quick Reply (no urls or BBcode)
Message:
Previous Thread Next Thread
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes