FORUMS
Remove All Ads from XDA

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

13,802 posts
Thanks Meter: 30,583
 
By osm0sis, Recognized Developer / Recognized Contributor on 5th March 2014, 03:32 AM
Post Reply Email Thread
10th May 2019, 08:43 AM |#821  
Senior Member
Thanks Meter: 764
 
More
Quote:
Originally Posted by osm0sis

Ah sorry! I had it working but a typo crept in right before commit apparently!

I just fixed it and pushed remotely. Added to the above post.

All good now. Thank you for a very quick fix.
More importantly, your time that you contribute.

Cheers.
The Following User Says Thank You to ipdev For This Useful Post: [ View ] Gift ipdev Ad-Free
17th May 2019, 04:59 AM |#822  
Senior Member
Thanks Meter: 190
 
More
Quote:
Originally Posted by osm0sis

That's a bad idea. Stay enforcing. Log denials. Use magiskpolicy to update the sepolicy in the ramdisk, or su.d/post-fs-data.d to --live alter the sepolicy with what you need. Do it right.

Any working examples of this? I tried to use spectrum to write sysfs values like kcal, but it keeps getting denied.
17th May 2019, 03:30 PM |#823  
osm0sis's Avatar
OP Recognized Developer / Recognized Contributor
Flag Halifax
Thanks Meter: 30,583
 
Donate to Me
More
Quote:
Originally Posted by Watanabe_You

Any working examples of this? I tried to use spectrum to write sysfs values like kcal, but it keeps getting denied.

Franco has a sepolicy --live modding script he runs at boot time on some of his older devices: https://github.com/franciscofranco/r...it.supolicy.sh

Should give you a good example to go by for the boot script method.

And here's one for modding the sepolicy in the ramdisk on non-system-as-root devices: https://github.com/franciscofranco/r...t/anykernel.sh
The Following User Says Thank You to osm0sis For This Useful Post: [ View ]
23rd May 2019, 10:36 PM |#824  
wight554's Avatar
Senior Member
Flag Vinnytsia
Thanks Meter: 471
 
Donate to Me
More
Hi there
Found a problem with system-as-root aonly in anykernel
While flashing anykernel zip no matter if ramdisk changes are included i see 'Ramdisk not found' error
Afaik it doesn't fail on SAR AB with excluded ramdisk
Can u have a look into this?
I can give any log u need
23rd May 2019, 11:43 PM |#825  
osm0sis's Avatar
OP Recognized Developer / Recognized Contributor
Flag Halifax
Thanks Meter: 30,583
 
Donate to Me
More
Quote:
Originally Posted by wight554

Hi there
Found a problem with system-as-root aonly in anykernel
While flashing anykernel zip no matter if ramdisk changes are included i see 'Ramdisk not found' error
Afaik it doesn't fail on SAR AB with excluded ramdisk
Can u have a look into this?
I can give any log u need

So is there a ramdisk to modify?

Have you tried just doing "OG AK" as described in the OP? That way it won't even touch the ramdisk.

I'd say go ahead and rename your zip to test-debugging.zip, flash it and upload the debug .tgz it creates for me to look at.
25th May 2019, 11:28 PM |#826  
wight554's Avatar
Senior Member
Flag Vinnytsia
Thanks Meter: 471
 
Donate to Me
More
Quote:
Originally Posted by osm0sis

So is there a ramdisk to modify?

Have you tried just doing "OG AK" as described in the OP? That way it won't even touch the ramdisk.

I'd say go ahead and rename your zip to test-debugging.zip, flash it and upload the debug .tgz it creates for me to look at.

1) There is no ramdisk
2) Sorry seems like i'm too blind to find OG AK in OP, the only way to pass ramdisk step i found so far is to kill ramdisk manipulations in dump_boot and write_boot, wonder if there is a way to do that with untouched backend
3) System is mounted to /system_root in TWRP (just in case)
4) Here is debug.tgz (found ak3 patch somewhere on gitlab, but it's the same without it, also ramdisk was present in zip, but again, it's the same without it)
https://drive.google.com/file/d/1Dlv...w?usp=drivesdk
26th May 2019, 02:36 AM |#827  
osm0sis's Avatar
OP Recognized Developer / Recognized Contributor
Flag Halifax
Thanks Meter: 30,583
 
Donate to Me
More
Quote:
Originally Posted by wight554

1) There is no ramdisk
2) Sorry seems like i'm too blind to find OG AK in OP, the only way to pass ramdisk step i found so far is to kill ramdisk manipulations in dump_boot and write_boot, wonder if there is a way to do that with untouched backend
3) System is mounted to /system_root in TWRP (just in case)
4) Here is debug.tgz (found ak3 patch somewhere on gitlab, but it's the same without it, also ramdisk was present in zip, but again, it's the same without it)
https://drive.google.com/file/d/1Dlv...w?usp=drivesdk

That's hilarious that someone posted my WIP patch somewhere. I'm waiting on some needed additions to magiskboot for feature parity before pushing to production.

There being no ramdisk in the partition is precisely why you need to use an "OG AK" setup. I intentionally split up the original dump+split+unpack and pack+build+flash functions of AK2 to allow more granular control awhile back. It is explained in the OPs. Basically you need to change the dump_boot and write_boot commands in anykernel.sh to their "OG AK" counterparts so it doesn't try to do anything to a ramdisk.

Search for "OG AK" in the second post of the thread: https://forum.xda-developers.com/sho...06&postcount=2
The Following User Says Thank You to osm0sis For This Useful Post: [ View ]
1st June 2019, 05:16 PM |#828  
osm0sis's Avatar
OP Recognized Developer / Recognized Contributor
Flag Halifax
Thanks Meter: 30,583
 
Donate to Me
More
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/AnyKernel...f783a97b3e8958

tools: rename ak2-core.sh to ak3-core.sh:
https://github.com/osm0sis/AnyKernel...bb6e37b15ad853

anykernel: Update for AK3:
https://github.com/osm0sis/AnyKernel...205b69a05021dd

README: Update for AK3:
https://github.com/osm0sis/AnyKernel...e90dae553bb697

AK3: fix elftool repack cmdline handling:
https://github.com/osm0sis/AnyKernel...3eaa2d867de021

AK3: allow workaround for dtbo devices with cat /dev/zero issues:
https://github.com/osm0sis/AnyKernel...3d351d52425cf0

README: updates and touchups for AK3:
https://github.com/osm0sis/AnyKernel...103d4146b694d5

AK3: resolve non-zero return code introduced by `cat <img> /dev/zero > <block>`:
https://github.com/osm0sis/AnyKernel...89e1ff95badc8f

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.

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.
The Following 49 Users Say Thank You to osm0sis For This Useful Post: [ View ]
3rd June 2019, 09:06 PM |#829  
jprimero15's Avatar
Recognized Developer
Flag Oof
Thanks Meter: 3,576
 
Donate to Me
More
Edit: im not reading lol
Attached Files
File Type: log recovery.log - [Click for QR Code] (28.6 KB, 18 views)
The Following User Says Thank You to jprimero15 For This Useful Post: [ View ]
9th June 2019, 05:00 AM |#830  
Senior Member
Thanks Meter: 764
 
More
Hate to ask but, I need some help.

Updated to AnyKernel 3 and now I get an error when trying to install on a boot image that was repacked by AIK, AK2 or AK3.
Quote:

New image larger than boot partition. Aborting...
Updater process ended with ERROR: 1

The new boot image is quite a bit larger for some reason?

No problems installing on a stock boot.img or a boot.img that was repacked by Magisk.
Magisk and AK2 both install on an AK3 repacked boot.img.

Since this is a kernel only swap, I did try the "OG AK" method, same results.
Replaced dump_boot with split_boot and write_boot with flash_boot.


I am probably missing something obvious.

AK-debug logs uploaded here. gDrive - Link

Note:
Clean git clone, only changed what was needed.
These debugs use block=boot

Error. (Stock boot.img + AK3 + Magisk-Debug)
anykernel3-2019-06-08_210753-debug.tgz

No Error. (Stock boot.img + Magisk-Debug)
anykernel3-2019-06-08_211915-debug.tgz
The Following User Says Thank You to ipdev For This Useful Post: [ View ] Gift ipdev Ad-Free
9th June 2019, 06:42 AM |#831  
osm0sis's Avatar
OP Recognized Developer / Recognized Contributor
Flag Halifax
Thanks Meter: 30,583
 
Donate to Me
More
Quote:
Originally Posted by ipdev

Hate to ask but, I need some help.

Updated to AnyKernel 3 and now I get an error when trying to install on a boot image that was repacked by AIK, AK2 or AK3.

The new boot image is quite a bit larger for some reason?

No problems installing on a stock boot.img or a boot.img that was repacked by Magisk.
Magisk and AK2 both install on an AK3 repacked boot.img.

Since this is a kernel only swap, I did try the "OG AK" method, same results.
Replaced dump_boot with split_boot and write_boot with flash_boot.


I am probably missing something obvious.

AK-debug logs uploaded here. gDrive - Link

Note:
Clean git clone, only changed what was needed.
These debugs use block=boot

Error. (Stock boot.img + AK3 + Magisk-Debug)
anykernel3-2019-06-08_210753-debug.tgz

No Error. (Stock boot.img + Magisk-Debug)
anykernel3-2019-06-08_211915-debug.tgz

So I'm not sure why yet, but for some reason your kernel_dtb (i.e. dtb split from the dumped boot.img's Image.gz-dtb) ends up as 40mb with the broken flash and 6.7mb with the working one.

Edit: Oh hey, one thing that would at least work around this for now would be if you named your replacement kernel correctly as Image.gz-dtb (or zImage-dtb for arm). If you don't do that then it won't know to delete the split kernel_dtb in split_img.

Edit 2: Ah sh*t, haven't checked it out in a hex editor to confirm yet, but I'm thinking the above must be why.. basically with repeat flashes the old kernel_dtb will get appended to your misnamed Image.gz-dtb, multiplying the dtb until it's 40mb and fails to flash back.

6.67mb x 6 = 40mb.

So yeah, I guess one caveat I didn't consider before with AK3 is that devs really need to just drop in their properly named build product (since AK2/3 has supported all name+compression variants for awhile now).
The Following 2 Users Say Thank You to osm0sis For This Useful Post: [ View ]
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