topjohnwu / Magisk

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

Can't physically enter into recovery mode after flashing patched recovery (device itself doesn't have volume buttons) #6293

Closed BlueGradientHorizon closed 1 year ago

BlueGradientHorizon commented 1 year ago

Device: Vontar X96S_P 2/32 android stick Android version: 9 Magisk version name: 38ab6858 Magisk version code: 25203 SoC: Amlogic S905Y2 (quad-core)

Magisk manager shows that this device (at least at stock ROM) have not ramdisk (Ramdisk No), so the only solution is Recovery mode. I installed manager directly on android stick and patched the stock recovery image. Then i rebooted into recovery by only pressing the Reset mainboard button. Then i flashed temporary TWRP recovery "3.2.2-0 for Amlogic by ViT" and flashed patched recovery image into device. After this i already was unable to boot into recovery by pressing Reset button. Manager found installed Magisk (Installed 38ab6858 (25203)), but complained about A su binary not from Magisk.

To control this android stick I have an IR remote control. There are volume buttons on it, but they don't have any effect during the boot phase. I've tried entering recovery mode using the reboot menu in the top right corner of Magisk manager, but that just shuts down my android stick without rebooting. So how do I still go into recovery mode?

I will provide boot and recovery images if needed, as well as logcat. Any help is appropriate.

BlueGradientHorizon commented 1 year ago

I fixed the problem about A "su" binary not from Magisk just by deleting the conflicting su binary file using adb and root. Probably this su file was included in stock ROM. So, the main issue is only how can i enter into recovery mode with patched recovery.

HuskyDG commented 1 year ago

How about installing magisk into system directly (Currently Magisk doesn't support system installation)?

BlueGradientHorizon commented 1 year ago

I have never heard of this method of installing Magisk. Can you write, please, where I can find instructions for 'installing into system directly'? I didn't found any mentions about it here

HuskyDG commented 1 year ago

I have never heard of this method of installing Magisk. Can you write, please, where I can find instructions for 'installing into system directly'? I didn't found any mentions about it here

This is the method i used for installing Magisk on Emulator, similar to LSPosed/MagiskOnWSA. You can check: Install Magisk into system partition Assume you have su first in system (rooted with SuperSU or Superuser)

BlueGradientHorizon commented 1 year ago

Okay, i reflashed the stock ROM again to try again but this time using Magisk Delta. As described in your instructions i picked the Direct install into system partition option, but that didn't worked because of Cannot find sepolicy file error. I saved the installation log file, opened it and found 2 possible errors: mkdir: can't create directory '/dev/sysmount_mirror/block/system_root/sbin': Not a directory tr: write error: Broken pipe If you need full log or maybe stock boot and recovery images, just let me know.

pndwal commented 1 year ago

... Also, have you tried patching boot.img?

This actually works on A only legacy SAR devices where bootloader supports ramdisk in boot despite no OEM supplied boot ramdisk... Magisk will actually install a basic ramdisk in boot w/ magiskinit when patching (Magisk will still indicate ramdisk=no as John/Magisk app assumes no bootloader support where OEM doesn't supply ramdisk) for Xiaomi and other devices that support this...

A only legacy SAR devices accepting Magisk in boot include most Xiaomi models, several Samsung models, some TV boxes and more... The only way to know if Magisk in boot works (ie. device has inexplicable support in bootloader for ramdisk in boot) is to try...

pndwal commented 1 year ago

Seems this is a pre-rooted device, so this may be causing you issues... Would be good to know if OEM supplies root in boot or recovery... If in recovery, simply Magisk-patching the TWRP image (I'm assuming that's unrooted) and flashing that may fix issues...

Also, if you flashed TWRP initially (from device recovery or reset menu?), can you try flashing patched recovery directly that way (bypassing twrp)?... Also, do you have fastboot access?...

HuskyDG commented 1 year ago

Seems this is a pre-rooted device, so this may be causing you issues... Would be good to know if OEM supplies root in boot or recovery... If in recovery, simply Magisk-patching the TWRP image (I'm assuming that's unrooted) and flashing that may fix issues...

Also, if you flashed TWRP initially (from device recovery or reset menu?), can you try flashing patched recovery directly that way (bypassing twrp)?... Also, do you have fastboot access?...

I hope you don't misunderstand this problem: unable to boot into recovery by pressing Reset button (after installing magisk into recovery partition)

pndwal commented 1 year ago

I hope you don't misunderstand this problem: unable to boot into recovery by pressing Reset button (after installing magisk into recovery partition)

Why do you continue to give dislikes to my help in issues??? 🙁

I understand what was said very well... But the first thing this user said was:

Magisk manager shows that this device (at least at stock ROM) have not ramdisk (Ramdisk No), so the only solution is Recovery mode...

You should know that this is NOT always true; Magisk in boot often works despite ramdisk = no.

So this:

I installed manager directly on android stick and patched the stock recovery image... Then I... flashed patched recovery image into device...

might not be necessary... As I said, a user can't know unless they try!!...

I'm aware that your solution, taking advantage of pre-root, may well be workable, but would you advise against checking if normal Magisk in boot can work??... What makes you sure it won't??...

I suspect that if boot is already patched with SuperSU etc. there will be errors to be dealt with, but at least this user will know that if a clean boot image can be obtained Magisk in boot is viable in that case...

Also, if Magisk in boot can be achieved, this issue:

After this i already was unable to boot into recovery by pressing Reset button...

should be solved with standard boot image restoration unless device is already booting w/ root via recovery, which could complicate things...

HuskyDG commented 1 year ago

@Truuum can you try patching boot image like @pndwal, there are small chances that it can work like my legacy-SAR devices. Assume your device has boot image.

HuskyDG commented 1 year ago

I suspect that if boot is already patched with SuperSU etc. there will be errors to be dealt with, but at least this user will know that if a clean boot image can be obtained Magisk in boot is viable in that case...

@pndwal he said his ROM had su https://github.com/topjohnwu/Magisk/issues/6293#issuecomment-1257239217

pndwal commented 1 year ago

I suspect that if boot is already patched with SuperSU etc. there will be errors to be dealt with, but at least this user will know that if a clean boot image can be obtained Magisk in boot is viable in that case...

@pndwal he said his ROM had su #6293 (comment)

Of course I know that... He didn't say root is in boot ramdisk however, which is why I suggested testing... I assume su could still originate from ramdisk in recovery...

Thanks for reversing one of two dislikes...

pndwal commented 1 year ago

Why do you continue to give dislikes to my help in issues??? 🙁

... Thanks for reversing both dislikes... 😶

BlueGradientHorizon commented 1 year ago

Also, have you tried patching boot.img?

I apologize for not writing sooner. Yes, of course. My first attempt was just patching the boot image, which did not lead to anything. The manager did not find the installed Magisk (the inscription Installed N/A did not change after flashing the modified boot img).

from device recovery or reset menu?

Where is no 'reset menu'. There is only standard recovery menu. I can enter into stock recovery by pressing the 'reset' button on the mainboard during the boot phase.

Also, do you have fastboot access?

I tried to go into fastboot mode by plugging android stick into my laptop but with all drivers installed it didn't detect new device in fastboot mode. Most likely I can access the fastboot mode, but only if I connect the android stick not via micro usb, but via an additional usb-A 3.0 port. I don't have a usb-a to usb-a cable at the moment. But when the android stick is loaded into android system, I can access adb and internal storage via micro usb port.

Also, if you flashed TWRP initially

I want to clarify that the TWRP recovery I'm using is temporary. To boot into it, I first have to go into the stock recovery, and then flash the installation zip package (Apply update from EXT). After a couple of seconds, the TWRP recovery interface appears. But in fact, this installation package does not replace the stock recovery.

To help you better understand the problem, I created a zip archive with these files:

I can't upload archive to github because the size is above 25MB so i uploaded it into google drive https://drive.google.com/file/d/1vtJqivJoJVu7_pos887Fcx99yeEsX3Sy/view?usp=sharing

pndwal commented 1 year ago

Also, do you have fastboot access?

I tried to go into fastboot mode by plugging android stick into my laptop but with all drivers installed it didn't detect new device in fastboot mode. Most likely I can access the fastboot mode, but only if I connect the android stick not via micro usb, but via an additional usb-A 3.0 port. I don't have a usb-a to usb-a cable at the moment.

Actually a machine with USB 2.0 is often required also...

Also, if you flashed TWRP initially

I want to clarify that the TWRP recovery I'm using is temporary. To boot into it, I first have to go into the stock recovery, and then flash the installation zip package (Apply update from EXT). After a couple of seconds, the TWRP recovery interface appears. But in fact, this installation package does not replace the stock recovery.

If you're actually flashing (as opposed to simply loading an image to boot it), it's likely recovery is actually being replaced but system restores it to stock on booting system. I believe most devices have this protection and TWRP employs mechanisms to make it 'stick', eg users often need to reboot immediately to TWRP before booting system to prevent custom recovery from being overwritten... Or I may be way off here...

pndwal commented 1 year ago

This thread https://forum.xda-developers.com/t/v9-aidans-rom-s905x-s905w-s912-s905x2-s905y2-s905x3-s905w4-s922-android-tv-9-disney-google-play-certified-root.4199287/ may help you...

This Is A Firmware Port Of The Xiaomi Mi Box Firmware Designed To Run On Other Amlogic Devices

I've only had a cursory glance...

This may be more specific... Chrome to translate, See post no. 1, 'useful' stickies... https://4pda.to/forum/index.php?showtopic=934461

vvb2060 commented 1 year ago

https://github.com/topjohnwu/Magisk/blob/f9e82c9e8a3f9ceefa58abf0e509e351281eb6cf/app/src/main/java/com/topjohnwu/magisk/events/RebootEvent.kt#L22

/system/bin/svc power reboot recovery

If this command can not reboot into recovery, there is nothing we can do.