[Nexus 5 Android Development] lukss12:
I have ported EFIDroid (developed by @m11kkaa) for the Nexus 5.

@m11kkaa's original EFIDroid thread here: https://xdaforums.com/android/software-hacking/efidroid-t3447466.

This is an unofficial port of beta software. I am not responsible for anything that may happen to your device. Use at your own risk.

NOTE: This has been tested with last LineageOS Build (21/03/2017) and TWRP 3.1.0-0. All other configurations are untested by me, but should work.

Working ROMs

[Here I will post the ROM's that are working for multiboot (Of course I will need people's feedback to fullfill this list)]

LineageOS 14.1 (As primary, as secondary with SELinux permissive option)

DU 11.2 (As primary, as secondary with SELinux permissive option) tested by [MENTION=4330004]AndresOrue[/MENTION]

PureNexus 7.1.1 (Should work as primary but not tested, as secondary with SELinux permissive option) tested by [MENTION=4330004]AndresOrue[/MENTION]

Lineage OS DarkRom by Dark_Eyes (As primary, not tested as secondary-should work with SELinux permissive option) tested by [MENTION=6558666]willyinpr4u[/MENTION]

AlmostVanillaAOSP Marshmallow (As primary, not tested as secondary-should work with SELinux permissive option) tested by [MENTION=5785796]alessio89g[/MENTION]

AOSP Nougat (Should work as primary but not tested, as secondary with SELinux permissive option) tested by [MENTION=5785796]alessio89g[/MENTION]

UntouchedAOSP 6.0.1 tested by [MENTION=4913921]BreckZeBoulay[/MENTION]

MiUI 8 tested by [MENTION=5648038]sa4ni[/MENTION]

Euclidean OS tested by [MENTION=6558666]willyinpr4u[/MENTION]

Xenon HD AOSP tested by [MENTION=6558666]willyinpr4u[/MENTION]

AICP 12.1 7.1.2 tested by [MENTION=6912643]phpbb3[/MENTION]

Elixr-hammerhead-V1.1-20140420 tested by [MENTION=6253695]playerkirk1[/MENTION]

Plasma-Mobile tested by me

Installation

Install the attached EFIDroid Manager apk. Since this is an unofficial port, the EFIDroid Manager app from the Play Store won't work. (This is modified to use my unofficial server)

Open the EFIDroid Manager app, open the menu (at the top left), and click "Install/Update".

Click the big orange Install button.

And voila, you're done in 3 easy steps! Reboot to see your new 2nd-stage bootloader!

Post below with your installed ROM if you have success.

To update EFIDroid, just repeat step 2, and the click the big orange Update button.

The app won't automatically check for updates, so I'll post an announcement on this thread whenever an important update is available.

Migrating from MultiROM

TWRP Backups should work fine but as /sdcard gets mocked on TWRP for secondary ROMs to prevent an "accidental" wipe there is some steps to follow

1-Create a new slot

2-Go to /data/media/0/multiboot/your_new_slot/data

3-Create folder media/0/TWRP/BACKUPS

4-Move/copy your backup to the created folder -remember the backup folder is the one that look like a hash (like "'03480ffg04395g234")

5-Boot TWRP from EFIDroid for the new slot

6-Format System

7-Flash your backup

Multibooting

You can use EFIDroid as a multiboot manager. To add a multiboot ROM, do the following:

Open the EFIDroid Manager app. Press the plus button at the bottom right side of the screen to start adding a multiboot slot.

Under "Location", there should be a couple paths. Select the one containing "/data/media/0".

You can give the slot a name/description by using the appropriate fields.

Press the checkmark at the top right side of the screen to create the multiboot slot.

Reboot. When EFIDroid comes up, select TWRP, then select the newly created slot.

Go to the "Wipe > Advanced Wipe" menu. Select "System", then swipe to wipe.

Install all the zips you want on that slot.

NOTE: To prevent accidentall data loss when booting in recovery the real /sdcard gets mocked so you are not going to find your .zips as usual under TWRP's /sdcard. To acces the "real" /sdcard go to /multiboot/data/media/0

Reboot, and when EFIDroid comes up, your new slot should automatically be selected. Press the power button to boot, and enjoy!

IMPORTANT:your main ROM should boot without changing any configuration on EFIDroid but secondary ROM's are used to fail because of selinux denials. I strongly reccomend you to enable Force SELinux to permissive under EFIDroid options (the Gear icon in the main screen placed at the top right) - Once you kwon your secondary ROM is working you can try to boot without this option disabled - If you end up in a bootloop logcat and dmesg are welcome.

Troubleshooting

If you are unable to boot the OS/recovery from EFIDroid, do the following (you do have a working boot.img (from your main OS) and recovery.img (TWRP 3.1.0-0 recommended), right?)

This assumes you have fastboot properly setup. (Ubuntu: sudo apt-get install android-tools-fastboot - Windows: just google for the binaries)

OPTION 1:

In EFIDroid, use the volume keys to navigate to "Fastboot", the press the power key to select it.

There should only be one entry in the Fastboot menu. Press the power key to select it.

Connect your phone to your computer with a USB cable. Run the following (on the computer), one line at a time:

fastboot flash boot <path/to/boot.img>
fastboot flash recovery <path/to/recovery.img>
fastboot oem exit

In EFIDroid, use the volume keys to navigate to the back button at the top of the screen. Press the power key to select.

Use the volume keys to navigate to "Reboot", then press the power key to select.

OPTION 2:

Enter LG's Fastboot Mode (Volume Down + Power Off)

Connect your phone to your computer with a USB cable. Run the following (on the computer), one line at a time:

fastboot flash boot <path/to/boot.img>
fastboot flash recovery <path/to/recovery.img>
fastboot reboot-bootloader

Use the volume keys to navigate and select "Start" or "Recovery", then press the power key to select.

You should be able to boot the installed OS/recovery now. If this doesn't work, you can always enter Fastboot Mode (Volume Down + Power Off) and then flash your recovery and boot from there.

Clarifications

When Installing EFIDroid boot and recovery partitions are flashed so you only can enter recovery through EFIDroid to prevent any confusion

To enter Recovery just select your recovery on EFIDroid and then select the ROM you want the recovery to apply the .zip you are going to flash (EFIDroid properly patches TWRP ramdisk to affect the desire slot/ROM)

How does this work?

Well I'm going to explain it a little:

Right now you have your ROM kernel (boot.img) custom or stock ( it don't mind) in your boot partition and your recovery.img (I think TWRP) in your recovery partition. UEFIDroid is a kernel but it is not a linux kernel, it's based on Little Kernel aka LK... Qualcom port LK to Snapdragon chipsets and developed their custom bootloader, then the EFIDroid developer take this and implemented UEFI over the Qualcom's LK port.

Whe you install EFIDroid this is what happens:

-EFIDroid Manager backups your boot.img and recovery.img in /data/media/0/UEFIESP folder

-EFIDroid Manager flash EFIDroid in your boot and your recovery partitions (the recovery is flashed to prevent you using your recovery without booting it from EFIDroid)

Then the next time you boot the stock bootloader aka aboot loads UEFIDroid that is flashed in your boot partition, LK kernel boots and execute UEFI. Then the UEFI looks for the original boot.img (for booting your actual ROM aka Internal) and looks for your actual recovery.img, remember both were saved into /data/media/0/UEFIESP.

And finally it looks for slots/ROMs in /data/media/0/multiboot (of course these are the slots for multibooting a lot of ROMs).

A slot for a ROM is composed by a data folder, a system.img(1GB) and a boot.img (these are the ones used/mounted to boot the ROM you select in multiboot menu) -slots are added from EFIDroid Manager app.

In the last step it shows you the Menu to select what you want to boot and it applies the propers patchs to ramdisk to use the correct data folder and system.img, then boot the correct boot.img using libboot (the usually used by android bootloaders)

Recoveries

I personally tested EFIDroid with TWRP and TWRP CAF in their 3.1.0.0 versions and they worked great.

As I stated before, your current recovery is backed up to /data/media/0/partition_recovery.img so if you somehow ended having trouble to boot your recovery, you can boot to your main OS and replace /data/media/0/partition_recovery.img with another recovery (ofc change the name of the new recovery to partition_recovery.img) - YOU NEED A ROOT BROWSER -

Custom Kernels

Well custom kernels are known to break things, so to say that a ROM is working I need you to test with the stock kernel that comes with it, then of course if you want to test custom kernels you're welcome and I will update this post with your feedback.

NOT WORKING CUSTOM KERNELS:

ElementalX 7.09 (Don't pass EFIDroid boot Splash Screen) tested by [MENTION=4330004]AndresOrue[/MENTION] with DU 11.2 (It should not matter because it's not booting the ROM at all) -may be ramdisk patching problem-

WORKING CUSTOM KERNELS:

BluSpark r122 tested by [MENTION=4330004]AndresOrue[/MENTION]

Franco.Kernel r105 tested by [MENTION=5785796]alessio89g[/MENTION]

ElementalX 8.00 tested by me

Credits

-All credit goes to @m11kkaa for doing all the hard work in developing EFIDroid.

-@abraha2d for the help with porting and giving permission to use his post for Note 4 as the base for this one!

Kernel Special Features: UEFI, MultiBoot

Version Information

Status: Beta

Current Beta Version: 0.1

EFI Specification: 2.60

Beta Release Date: 2017-03-27

Created 2017-03-28

Last Updated 2017-04-17