edk2-porting / edk2-msm

Broken edk2 port for Qualcomm platforms xD
https://renegade-project.tech/
BSD 2-Clause "Simplified" License
2.32k stars 439 forks source link

Add a better way for dualbooting UEFI and Android #265

Closed MollySophia closed 1 year ago

MollySophia commented 1 year ago

Description

This series of commits adds a better way for dualbooting UEFI and Android, whose mechanism was initially designed by @gus33000 (Huge thanks!), and an UEFI Application for easily reboot to Android at SimpleInit boot menu.

An option --installer-zip is introduced into build.sh, and the original code without adding this option remains the same.

For now this is tested on LG G8X (stock Android 12) and Xiaomi MiPad 5 (MIUI 14 for Pad) and Xiaomi Mi 9 (which is an a-only device, tested by @qaz6750) to be working.

Checklist

qaz6750 commented 1 year ago
TheMorc commented 1 year ago

Going to try it on my 7TP in a bit, I'll edit and update the comment later with the results.

EDIT 4:

  1. this theoretically shouldn't be needed for 7TP since it is a A/B phone? Or is this primarily for A/B devices?
  2. the -z switch doesn't seem to work for me, --installer-zip does though?.
  3. I think it would be nice to mention that you also need to have zip installed (which I didn't have on my WSL installation 😅) + I guess it's more of a thing for guides since those have all needed dependencies listed
  4. the zip doesn't install because 7TP still "has a recovery partition" apparently (probably just a carried over and missed part from the original twrp_abtemplate? https://github.com/MollySophia/Flashable_UEFI_Installer/blob/2666a4abf50facdf606d2f8128d72d57290a1382/META-INF/com/google/android/update-binary#L29-L34)
  5. rebooting to android from UEFI doesn't work right now, probably because it needs to be installed through the zip which patches the kernel?? (that is if I understood it correctly)
MollySophia commented 1 year ago

~Going to try it on my 7TP in a bit, I'll edit and update the comment later with the results.~

EDIT 4:

  1. this theoretically shouldn't be needed for 7TP since it is a A/B phone? Or is this primarily for A/B devices?

This was primarily intended for devices that have trouble dualbooting android and uefi, like nabu which doesn't have SwitchSlotApp working, or g8x that have a cumbersome way to enter TWRP. These two are all a/b devices I believe.

  1. the -z switch doesn't seem to work for me, --installer-zip does though?.

Yeah I took a look and this is a bug in build.sh :P

  1. I think it would be nice to mention that you also need to have zip installed (which I didn't have on my WSL installation 😅) + I guess it's more of a thing for guides since those have all needed dependencies listed

~Otherwise how do you pack the zip lol~

  1. the zip doesn't install because 7TP still "has a recovery partition" apparently (probably just a carried over and missed part from the original twrp_abtemplate? https://github.com/MollySophia/Flashable_UEFI_Installer/blob/2666a4abf50facdf606d2f8128d72d57290a1382/META-INF/com/google/android/update-binary#L29-L34)

This was initially a check added by myself in the thought that devices with recovery partition don't really need this. However, I think this method may still gain the benefit of keeping the recovery for these devices while doing dualbooting. Speaking of which, I may also try to preserve the recovery for A/B devices with this method too XD

  1. rebooting to android from UEFI doesn't work right now, probably because it needs to be installed through the zip which patches the kernel?? (that is if I understood it correctly)

Yes, this is correct. You can see that if building without the -z/--installer-zip option, the boot option as well as the Reboot2Payload app won't be included in the FD. https://github.com/MollySophia/edk2-msm/blob/d14972ae965938356801f184773b0c156e5d5e26/Platform/Qualcomm/sm8150/sm8150.fdf#L217

Thanks a lot for your testing!

TheMorc commented 1 year ago

This was initially a check added by myself in the thought that devices with recovery partition don't really need this. However, I think this method may still gain the benefit of keeping the recovery for these devices while doing dualbooting. Speaking of which, I may also try to preserve the recovery for A/B devices with this method too XD

Well, that recovery detection was already in the twrp_abtemplate you forked originally, wasn't it? It doesn't matter to be honest. But I guess it should be "universally" supported on all devices with LinuxUtils. Atleast mu implements it using the alert switch for 7TP even though it is a A/B device with recovery. The feature as is, is just a nice addition and also feels nice to use btw.

Yes, this is correct. You can see that if building without the -z/--installer-zip option, the boot option as well as the Reboot2Payload app won't be included in the FD. https://github.com/MollySophia/edk2-msm/blob/d14972ae965938356801f184773b0c156e5d5e26/Platform/Qualcomm/sm8150/sm8150.fdf#L217

Yeah, I noticed that the first time. The thing was that I just flashed the boot image because the zip didn't work and it didn't occur to me first time (for some reason) that it needs to be patched and that the zip does the work. That's also why I edited the message like 4 times :joy:

halal-beef commented 1 year ago

Just tested on my vayu again, it actually works! Seems like the kernel I'm using was the problem :(