topjohnwu / Magisk

The Magic Mask for Android
GNU General Public License v3.0
46.65k stars 11.77k forks source link

MagiskInit Incompatible with MTK devices #3042

Closed mrmazakblu closed 3 years ago

mrmazakblu commented 4 years ago

Continued from https://github.com/topjohnwu/Magisk/issues/3040

Magisk patches boot.img. Log shows complete. But magisk.init is not run on boot.

same result with 20.4 and latest canary. Previous similar issue with devices on android 11 and boot.img has no 'apex' dir.

This problem is on android 10 and the boot.img does have 'apex' dir,

can confirm patched image is flashed by spflash readback. It is same image as was flashed.

magisk_canary-boot-logcat.txt magisk_install_log_2020-08-03T065156Z.log

magisk_patched.zip

mrmazakblu commented 4 years ago

Do not know how to tell if it's a pactching issue or boot order issue. The logcat does not seem any different from stock or patched boot.img. at least to me.

Is there a way to manually patch the boot.img to try something different?

mrmazakblu commented 4 years ago

Just putting out this question. Could the separate dtbo image be effecting the ability of magisk_patched boot having working root?

mrmazakblu commented 4 years ago

seems similar to this issue.

https://github.com/topjohnwu/Magisk/issues/3021

but i have been unable to download the referenced canary build to verify.

mrmazakblu commented 4 years ago

beta canary 20420 does same. it patches boot.img Log looks normal. fastboot flash boot magisk_patched.img completes, no error. Reboot to android, magisk is not installed.

topjohnwu commented 4 years ago

Duplicate #2994

mrmazakblu commented 4 years ago

Thanks for the attention. But is this issue a duplicate of the one you referenced The devices commenting on that issue are on Android 11, and there bootmimg does not have an apex folder in ramdisk. Neither are true on my device.

mrmazakblu commented 4 years ago

@topjohnwu @osm0sis has said 2 times now, that this problem is not same as the issue in duplicate tag.

Because this is not on an Android 11 , and the ramdisk does have the apex dir

Are there any logs that I would help identify what is happening during the boot up?

I have a very limited twrp working. But I should be able to get lask kmsg with it if it may help

None of the last_kmsg I have show "magisk" anywhere in it, so probably will not help.

mrmazakblu commented 4 years ago

I've been trying to try recovery mode magisk. Thinking maybe the boot.img has ramdisk, but is fake, not used.

But with patched recovery, recovery load just fails, and booting does a loop, like it tried to boot recovery, then reboots to normal boot

mrmazakblu commented 4 years ago

Magisk packed recovery with canary 20420 will not allow recovery to boot and does not give root.

Patched recovery with stable 20.4 will allow recovery to boot, but did not allow rooted boot.

Might be due to the boot menu on mtk device. Reboot with vol up does not boot recovery, it boots to a boot menu.

mrmazakblu commented 3 years ago

Just tried new canary. I know this issue is not listed on change log. but I tried anyway.

magisk patched boot.img with canary 20421, phone still boots, and magisk init has not ran.

osm0sis commented 3 years ago

Any change with 20422?

mrmazakblu commented 3 years ago

20422 Still not seeing any sign of modified init or magisk. Still normal boot process and no magisk.

only entry in logcat for magisk , is reference to the manager app.

https://del.dog/abihutogry

topjohnwu commented 3 years ago

Please let me know the device info from Magisk Manager. A/B? SAR? Ramdisk?

Also, I mean info from Magisk Manager, please do NOT assume any of the info above and report what is shown in the app's home screen

mrmazakblu commented 3 years ago

15992583709553985655640340538679 Ab no Sar yes Ramdisk yes

I have tried recovery mode (not on latest yet)

When try to boot recovery when patched, neither recovery nor rooted system would boot.// Unrooted system only booted

mrmazakblu commented 3 years ago

Just tried recovery mode with 20424. Recovery will not boot. Just pauses few moments, then reboots to system (unrooted).

Noticed when I updated the canary manager app, the option for recovery mode has gone.

lss4 commented 3 years ago

Try installing Magisk 20407. If that works for you then we're having a similar issue. Magisk on my Pixel C broke since 20408 and is still broken on 20424.

On Android 10, Pixel C is in a similar state as yours: A/B - no SAR - yes Ramdisk - yes

osm0sis commented 3 years ago

You said you tried recovery mode, try regular on 424 also

mrmazakblu commented 3 years ago

I needed to be more specific, yes I did try both ways with 20422 and 424

Have not gone back to 20407 as suggested above yet though.

lss4 commented 3 years ago

I think I might take a look at what happened between 20407 (2aede977) and 20408 (87de0e7a) and look for a possible cause...

Is there a guide for testing specific commits? I'm still new to git bisect...

EDIT: It seems I need some more details regarding build environment. Attempted ./build.py all at a commit in between (8ab04533), set by git bisect, failed with these errors...

This is on latest Manjaro Linux, currently using GCC10. I have latest Android Studio installed from AUR, pointed the terminal environment to use bundled JRE, and have successfully run ./build.py ndk.

I don't know if this commit compiles, but I need to make sure my build environment is correct first. By the way, I'm not sure if I should use --recurse-submodules when cloning the repo for bisecting...

EDIT 2: Guess I need to use git submodule update. After doing that, ./build.py all finished without issues.

mrmazakblu commented 3 years ago

I am not able to try the older build ( i read a comment that old builds are not supported any way)

I allways get an error downloading the files when I try.

old release builds download, but old canary builds do not., When adding the raw address to release.jason to custom chanel address Is that normal?

lss4 commented 3 years ago

Older canary build in the magisk_files repo is always available. The link/commit I pointed previously is the one containing the 20407 builds.

Older canary builds are not supported because certain issues might have been fixed in latest builds (as such, the bug reports would be invalid). However, they'll still be helpful in finding regressions, in case an older build worked for you, but the latest build doesn't.

mrmazakblu commented 3 years ago

UPDATE on device root. Not really on the magisk issue though. Unless this information tells magisk dev anything

I have factory rom (leak or release, not sure which) the firmware spflash files included "boot-debug.img" when this is flashed to boot from fastboot, adb root is allowed and root shell is available. At this time i do not kow if this can be used to elevate apps to root access though.

magisk patching this boot-debug.img did not allow magisk to run. still shows "Status N/A"

lss4 commented 3 years ago

UPDATE on device root. Not really on the magisk issue though. Unless this information tells magisk dev anything

I have factory rom (leak or release, not sure which) the firmware spflash files included "boot-debug.img" when this is flashed to boot from fastboot, adb root is allowed and root shell is available. At this time i do not kow if this can be used to elevate apps to root access though.

magisk patching this boot-debug.img did not allow magisk to run. still shows "Status N/A"

That brings back memories. You're using a Mediatek device, right... I remembered that my old Mediatek devices also had the boot-debug.img variant in the factory image, which contained an "insecure" adbd that'll give you a root shell from adb (similar to what used to be called "temporary root"). From what I remember, the "insecure" adbd was useful for some tools to inject a custom recovery for the device so you can flash other stuffs from there.

Unfortunately my experience with Mediatek devices was only around JB/KitKat, and it was before I get to know Magisk. Back then CWM's Superuser was my favorite tool for root.

Well, back to the topic... I don't think using a boot-debug.img should have any issue with Magisk. It should be the same, just without certain "protections" set in place on normal boot images.

mrmazakblu commented 3 years ago

Well I was thinking more along the lines using the debug-boot feature of Android 10 as the main root entry point.

As described on this Google developers white page, root is simply given when you set debug prop, and add your own plat_sepolicy.cil

https://source.android.com/compatibility/vts/vts-on-gsi

lss4 commented 3 years ago

Have you tried 20407 canary? Does it work for you?

Currently I need to know whether we're having the same issue to further assess the impact of the regression. I've already found which specific commit broke mine (see my issue).

mrmazakblu commented 3 years ago

--Edited--

I have tried, and it did not work. No magisk. Phone boots with the patched boot, but no magisk.

(I kept getting download error, whenever I used the release.json from 20407. But when I used the debug.json, download worked in manager)

I have tried each release from 17 upwards. And they all fail to give root. I can only assume we have different issue

osm0sis commented 3 years ago

You can't use it as an update channel since it's always the same address in the .json, you need to download the zip yourself and then use the "Install from storage" feature in the Modules page.

mrmazakblu commented 3 years ago

I was following along with issue #3021

I checked my /proc/cmdline

My phone does have androidboot.hardware=mt6765

But I also see , what I thought strange. Maybe it's normal

Root=/dev/ram

Also , might not matter, but in stock boot ramdisk there are 2 fstab files.

osm0sis commented 3 years ago

Probably same as this: #3228

If so, might follow along there since this issue thread has become pretty convoluted.

mrmazakblu commented 3 years ago

Confirmed still same , MAGISK init not running with majisk 21 and manager 8 ON two of my phones now. the one i stated with BLU G90 now ULEFONE Note 9P

Crescendo-BLYAT commented 3 years ago

Guys, Magisk 20.3 is working perfectly on my MTK Redmi Note 8 Pro - MIUI 12 Global - Android 10.

Any version greater than that will cause random SIM unrecognized problem on simple reboot + bluetooth MAC to be defaulted to 00:00:46:00:00:01 (the BT_Addr file in nvdata folder is corrupted, needs TWRP restore to fix).

6 out of 10 reboot will throw the device with no SIM problem (airplane mode doesn't help) + bluetooth MAC become 00:00:46:00:00:01.

p3yot3 commented 3 years ago

Just a FYI, I've also been unable to get Magisk working on my MTK device - it's a Ulefone Armor 9. The previous release of Magisk worked fine on my older Armor 3 & I was able to update to the latest Magisk version after flashing, but I'm unable to do that with my Armor 9 for some reason.

Crescendo-BLYAT commented 3 years ago

I think I might take a look at what happened between 20407 (2aede97) and 20408 (87de0e7) and look for a possible cause...

Is there a guide for testing specific commits? I'm still new to git bisect...

CONFIRMED that the last working on my Redmi Note 8 Pro - Android 10 is 20407 (2aede97).

Higher than that will fail to load Magisk. Magisk isn't loaded at all.

vvb2060 commented 3 years ago

try https://raw.githubusercontent.com/vvb2060/magisk_files/master/mtk.json

kidonng commented 3 years ago

@vvb2060 Didn't work on Redmi Note 8 Pro.

vvb2060 commented 3 years ago

@kidonng https://raw.githubusercontent.com/vvb2060/magisk_files/7098b4acd0978d79e283ea2ccb1510593418acea/mtk.json

lss4 commented 3 years ago

I think I might take a look at what happened between 20407 (2aede97) and 20408 (87de0e7) and look for a possible cause... Is there a guide for testing specific commits? I'm still new to git bisect...

CONFIRMED that the last working on my Redmi Note 8 Pro - Android 10 is 20407 (2aede97).

Higher than that will fail to load Magisk. Magisk isn't loaded at all.

If that's the case (up to 20407 worked for you) you probably have the same issue as I did (#3021), although mine was not a MTK device.

Try doing a cat /proc/cmdline and see if your device's boot parameter has androidboot.hardware=<device> in it. From 20408 and onwards that boot parameter is mandatory for a proper Magisk installation, assuming your device's fstab, wherever it is, has a correct name format that would be fstab.<device>.

kidonng commented 3 years ago

@kidonng https://raw.githubusercontent.com/vvb2060/magisk_files/7098b4acd0978d79e283ea2ccb1510593418acea/mtk.json

It works! But one of my apps (FooView) reports the following error:

Root testing failed, please upgrade your SU or change SELinux to permissive mode

Anyway thanks for the effort.

Crescendo-BLYAT commented 3 years ago

If that's the case (up to 20407 worked for you) you probably have the same issue as I did (#3021), although mine was not a MTK device.

Try doing a cat /proc/cmdline and see if your device's boot parameter has androidboot.hardware=<device> in it. From 20408 and onwards that boot parameter is mandatory for a proper Magisk installation, assuming your device's fstab, wherever it is, has a correct name format that would be fstab.<device>.

Yes, same issue as #3021 except the latest Magisk Manager working normally sans the superuser prompt like your problem.

Also there's no androidboot.hardware=<device>. But the SIM missing & bluetooth MAC problems I encountered with 20400 is gone in this release 20407. I'll try older than 20407 & see about the prompt.

Anyway to manually add the androidboot.hardware=<device> in cmdline?

lss4 commented 3 years ago

If that's the case (up to 20407 worked for you) you probably have the same issue as I did (#3021), although mine was not a MTK device. Try doing a cat /proc/cmdline and see if your device's boot parameter has androidboot.hardware=<device> in it. From 20408 and onwards that boot parameter is mandatory for a proper Magisk installation, assuming your device's fstab, wherever it is, has a correct name format that would be fstab.<device>.

Yes, same issue as #3021 except the latest Magisk Manager working normally sans the superuser prompt like your problem.

Also there's no androidboot.hardware=<device>. But the SIM missing & bluetooth MAC problems I encountered with 20400 is gone in this release 20407. I'll try older than 20407 & see about the prompt.

Anyway to manually add the androidboot.hardware=<device> in cmdline?

Sadly I don't know of a good way without rebuilding the kernel... my issue was fixed after the developer built a new kernel with the parameter included.

Crescendo-BLYAT commented 3 years ago

@kidonng https://raw.githubusercontent.com/vvb2060/magisk_files/7098b4acd0978d79e283ea2ccb1510593418acea/mtk.json

WORKING PERFECTLY on Redmi Note 8 Pro - MIUI 12.0.2.0 - Android 10. Thanks a lot!!!

What did you do? Maybe you can initiate PR to main repo? @topjohnwu

Crescendo-BLYAT commented 3 years ago

Oops celebrate too soon... Although it's working, I can't access internal storage whatsoever. /storage/emulated is not present, only /storage/self is present.

Apart from that, it's working. Su is working as well.

Crescendo-BLYAT commented 3 years ago

@vvb2060 0c59f81 BOOT & WORKING! Internal Storage also available. I will test it further but initial test is ALL OK! KUDOS TO YOU!

Do you still need the Magisk log? Here's the log: magisk_log_20201128_214818.log

Crescendo-BLYAT commented 3 years ago

Confirmed: ALL OK! Only some modules need a reinstall like: ACC & EdXposed. The rest is ALL OK!

THANK YOU SO MUCH! @vvb2060

Crescendo-BLYAT commented 3 years ago

~~One failed boot but nothing's changed... It just boot to recovery out of blue then I reboot it to system & it boot just OK.~~ Here's the log: https://pastebin.com/YhCfMCiK

EDIT: The issue came from EdXposed. All working perfectly.

londbell commented 3 years ago

try https://raw.githubusercontent.com/vvb2060/magisk_files/master/mtk.json

It works.Thank you.

ivisible commented 3 years ago

try https://raw.githubusercontent.com/vvb2060/magisk_files/master/mtk.json

it work for blu g90 mt6762 g0310ww android 10 Ab no Sar yes Ramdisk yes

mrmazakblu commented 3 years ago

try https://raw.githubusercontent.com/vvb2060/magisk_files/master/mtk.json

it work for blu g90 mt6762 g0310ww android 10 Ab no Sar yes Ramdisk yes

That is same device I have, and the one I opened this original issue with Need to confirm on my device too. Thanks for mentioning it

mrmazakblu commented 3 years ago

@topjohnwu do you have some way to see what changes @vvb2060 made to his released magisk that allows it to work.

Yes I am confirming that I now see root permission on my mtk device, by using custom update chanel that @vvb2060 shared in this issue thread.

During install , magisk manager showed magisk version 21.1. The official 21.1 did not work though.

Need to try 21.1 on beta chanel again, to be certain...........

mrmazakblu commented 3 years ago

Using the update channel from @vvb2060 , I cannot get pass safety-net. Gives "asertattion failed", with and without hide-props

IMG_20201211_175405_662 IMG_20201211_183019_338