UEFI boot with Clover
by Dmazar

As a general procedure, it would be good to get standard Clover working first (BIOS MBR -> boot0->boot1->boot->CloverX64.efi) and then try direct UEFI (UEFI -> CloverX64.efi). I think this is a good path, since if you manage to get standard Clover working, then you know that things are set up properly (Clover config, SMBIOS, DSDT) and any issues that may arise in UEFI boot and UEFI specific. I'll try to summarize here what I know so far.

For UEFI boot, I would recommend to first try it from FAT32 formatted USB stick.

1. FAT32 USB stick:
I have mine formatted in Windows. Ordinary MBR with FAT32 partition. Now, if I understood correctly from Applelife.ru, Troj80 says here that EFI partition (which is also usually FAT32) has to be formatted with the cluster size with the value between 1K and 8K in order to be usable from UEFI. Maybe the same thing should be done with the USB stick? I did not try formatting it in OSX - will have to try. Something like:
> newfs_msdos -F32 -b 1024 -v USBStick /dev/diskHsH
where /dev/diskHsH is partition on the stick.

My USB stick formatted in Windows looks like this:
CODE
> diskutil list
/dev/disk4
   #:                       TYPE NAME                    SIZE       IDENTIFIER
   0:     FDisk_partition_scheme                        *4.0 GB     disk4
   1:                 DOS_FAT_32 DUET                    4.0 GB     disk4s1
> newfs_msdos -N disk4s1
512 bytes per physical sector
/dev/rdisk4s1: 7816248 sectors in 977031 FAT32 clusters (4096 bytes/cluster)
bps=512 spc=8 res=32 nft=2 mid=0xf8 spt=32 hds=255 hid=2 drv=0x80 bsec=7831550 bspf=7634 rdcl=2 infs=1 bkbs=6

2. Standard Clover install
This is BIOS MBR -> boot0 -> boot1xxx -> boot ->CloverX64.efi boot.
You may skip this step and go directly to UEFI boot, but in case of any issues please go back and do this prior to asking help for UEFI boot. This is to eliminate problems with Clover installation and set up. I can try to help with UEFI boot, but It's easier and more likely to get help on standard Clover setup - ask for help in Clover thread.

Take the Clover installer from here and set it up on FAT32 USB stick. Then edit /EFI/config.plist to suit your needs, put DSDT (and SSDTs) in /EFI/ACPI/patched folder and leave /EFI/Drivers64 empty. Do classic boot from that USB stick. When this works, move to UEFi boot.

3. UEFI boot
That USB stick should have standard Clover installation. The same stick with the same Clover files from step 2. can be used here, except some additional drivers and (U)EFI shell are needed :
CODE
/EFI
  config.pist (or in OEM folder)
  /ACPI (or in OEM folder)
    ...
  /BOOT
    BootX64.efi
    CloverX64.efi
  /DRIVERS64
    HFSPlusX64.efi (or VBoxHfs.efi)
    OsxFatBinaryDrv.efi
    OsxAptioFixDrv.efi - this one only for Aptio boards
...

/EFI/BOOT/BootX64.efi can be:
- copied CloverX64.efi, but if it hangs (see here), then it should be shell
- in case of UEFI v2.3 this can be UEFI Shell (also known as edk2 shell, shell2): here
- in case of older UEFIs, this should be older EFI shell (also known as edk1 shell or it's port to GCC called GccShell): here

Drivers64:
- HFSPlusX64.efi (or VBoxHfs.efi) for HFS+ support
- OsxFatBinaryDrv.efi for multi architecture (FatBin) binaries like boot.efi
- OsxAptioFixDrv.efi (this one only for Aptio boards)

Modify Clover's /EFI/config.plist:
- to be able to boot Mountain Lion add slide=0 to boot-args. this option will be ignored by other version of OSX, but will (oh, may) enable ML booting. for example:
<key>boot-args</key>
<string>-v arch=x86_64 slide=0</string>

Booting from that USB stick on my board goes like this:
- power on
- pressing F8 during POST screen shows boot options (like drive selection)
- if USB stick is FAT32 and contains /efi/boot/bootx64.efi, then option "UEFI: The name of the stick" will appear as a boot option
- selecting that option starts /efi/boot/bootx64.efi - which is shell or Clover

On Aptio boards you can also put shell to the root folder as ShellX64.efi, and then can start it from UEFI Setup screen/Exit/Start shell (or something similar).

If bootx64.efi is a shell, then shell will start and prompt will appear. Use the commands in 4. below to start Clover. Unless you know what you are doing and why, there is no need to load any drivers before starting Clover - Clover will load drivers from /efi/drivers64 folder when it starts.

4. (U)EFI Shell
EFI shell (old shell) user guide and command manual: here
> help -b
list shell commands
> help <command> -b
> help <command> -b -v
prints command help. in the shell2 use later version.
> ver
will print UEFI version
> map fs*
will list current shell file system/volume/partition mappings
> fs0:
> fs1:
> fsXX:
changes the current volume
> ls
lists files in the current directory
> cd \efi\boot
changes the current directory
> cloverx64.efi
starts clover

So, find and start Clover and try to boot OSX. When you get that working, then you can install Clover to a hard disk.

5. Install to HDD EFI partition
By default, UEFI can only access FAT partitions, for example EFI partition(s), so the only option is to install it to EFI partition.

My EFI partition created by SnowLeo installation is FAT16. Clover works from there, but sometimes I have problems with certain files - they get short XXXX~1.yyy names. I need to try to reformat it to FAT32 as Troj80 suggested and see if this helps.

Installation requires copying /EFI folder from USB stick to EFI partition and adding CloverX64.efi as a boot option.

5.1.1 copying from the shell
Use:
> map fs*
> fs0:
> ls
> fs1:
...
to identify USB volume (for example fs1) and EFI volume (for example fs0). Use:
> fs0:
> cd \EFI
> cp -r fs1:\EFI\* .
> ls

5.1.2 copying from OSX
- open terminal
- mount EFI partition
> diskuti list
to identify EFI partition, and
> mkdir /Volumes/efi
> sudo mount -t msdos /dev/diskXs1 /Volumes/efi
to mount it (where /dev/diskXs1 is EFI partition device).
- it should appear in Finder as EFI volume
- then use Finder to copy whole /EFI folder to EFI volume
- check it from terminal:
> ls /Volumes/efi/EFI/*
this should list ACPI, BOOT and other Clover folders.

5.2 Add Clover as a boot option
On Aptio, it's not enough to rename Cloverx64.efi on HDD to BootX64.efi to enable it to start (see here). But it seems that's what you need to do on Gigabyte Hybrid EFI. Standard procedure for adding an OS boot option in UEFI is to add boot option variable to NVRAM - that's what is needed on Aptio.

Boot options can be managed with bcfg command in a shell. But, this command is available only in UEFI shell (shell2) and since shell2 requires UEFI 2.3 or newer, users with older UEFI have a problem. If you are the "lucky" one with older UEFI where shell2 does not work, try with my modified shell2 from here. This is not fully working port, but bcfg works and I'm using it only for boot options manipulation with bcfg.

Users of UEFI 2.3 or newer can put shell2 to FAT32 USB stick as /efi/boot/bootx64.efi and just use this one. Since I need old shell for normal use and moded shell2 for bcfg, I have old shell set as /efi/boot/bootx64.efi and moded shell2 as /shellx64.efi (in the root of USB) - in this way I can press F8 during POST and choose "UEFI: stick name" to load older shell or press Del to enter UEFI Setup screens and then select Exit/Start shell to load moded shell2. Actually, I have both shells copied to HDD EFI partition and added as separate boot options, but that can be done later.

Boot into shell2 (real one or moded) and find Cloverx64.efi on HDD EFI partition with some combination of the following commands:
> map fs*
> fs0: (or fs1: or fs2: ...)
> ls
> cd \efi\boot
> ls

And then:
> help bcfg -b -v
and try to understand help from the screen
> bcfg boot dump
to list current boot options
> bcfg boot add N cloverx64.efi "OSX through Clover"
to add cloverx64.efi from the current dir as a boot option labeled "OSX through Clover". N should be boot option number: 0 if you wan it to be the first, 1 to be the second ...
> bcfg boot dump
to check if it is added
> reset
to reset the system and to try to load Clover from HDD

When it is added, reset the system and press F8 during POST (or whatever key is needed to get selection of boot options) and "OSX through Clover" should be there. Select it and try if it works.

6. Troubleshooting
- If you can not boot through UEFI and did not try to set it up as standard Clover boot, please try standard BIOS MBR Clover setup first. Maybe the issue is in the Clover setup and not UEFI boot.
- When asking for help, please copy UEFIDump.nsh script to your FAT32 USB, boot into shell, choose FAT32 volume with fs0: or fs1: or ... , execute UEFIDump.nsh > dump.txt and post it here.

- If you can boot into OSX but have some issues, search for latest version of DarwinDumper here (usually the last post) and post it's logs here if it will be needed.