UEFI Patch & ASRock E3C226D2I

To get OSX booting on the ASRock E3C226D2I you can either patch the OSX Kernel (Power Management Patch) or you can patch the BIOS err… UEFI Firmware. I have chosen the latter and it works straight forward. Specifically what this Firmware Patch does is to prevent locking MSR 0xE2 and therefore make the system compatible with native OS X power management, wich nowadays is integrated in the Kernel.

The tools is available on GitHub and the Firmware is available here.

This is how you patch your firmware:

Xeon:~ userone$./UEFIPatch 226D2IL2.10 
patch: replaced 10 bytes at offset E82h 75080FBAE80F89442430 -> EB080FBAE80F89442430
Image patched
Xeon:~ userone$

And you will get a file: 226D2IL2.10.patched, which you shall flash to your machine using the Instant Flash function during boot or in the BIOS.

Unfortunately after, you have to add clover again. So go into the UEFI Shell.

Shell> fs0:EFI\CLOVER\CLOVERX64.efi

And go the relevant menu to add the clover entries. Thats it folks !

Advertisements

UEFI booting

Well well, getting UEFI booting to work is definitely giving me a headache. On the disk below (disk0) I installed Clover in the EFI partition disk0s1 of my Yosemite 10.10.1 install but it doesn’t show up in the boot menu:

Last login: Sat Nov 29 20:27:01 on ttys000
Xeon:~ userone$ diskutil list
/dev/disk0
   #:                       TYPE NAME                    SIZE       IDENTIFIER
   0:      GUID_partition_scheme                        *1.0 TB     disk0
   1:                        EFI EFI                     209.7 MB   disk0s1
   2:                  Apple_HFS Macintosh HD            999.3 GB   disk0s2
   3:                 Apple_Boot Recovery HD             650.0 MB   disk0s3
Xeon:~ userone$

Well the immediate solution is to boot into the Build-in EFI Shell and invoke this command – and even this took my a while to find out.

Shell> fs0:EFI\CLOVER\CLOVERX64.efi

And then in the Clover options choose:

  • Add as UEFI boot option.
Colver Boot Options

Colver Boot Options

But I wanted to know whats the cause and if its related to my BIOS (… err UEFI firmware to be correct). So I installed Fedora 20 on anther disk. Well in difference to Colver, Fedora shows up perfectly fine as boot option directly:

IMG_2324If I run the Built-in EFI Shell I get the following output with the “Fedora” disk plugged in:

"Fedora Disk" EFI ShellOr as text:

EFI shell version 2.31 [4.654]
Current running mode 1.1.2
Device manning table
fso :HardDisk - Alias hd33e65535a1 blk0
PciRoot(0x0)/Pci(0x1f,0x2)/Sata(0x4,0x0)/HD(1,GPT,bf05974d-0ccd-4228—b002—0170d4264b84,0x800,0x64000)
blk0 :HardDisk - Alias hd33e65535a1 fs0
PciRoot(0x0)/Pci(0x1f,0x2)/Sata(0x4,0x0)/HD(1,GPT,bf05974d-0ccd~4228-b002-0170d4264b84,0x800,0x64000)
blkl :HardDisk — Alias: (null)
PclRoot(0x0)/Pci(0x1f,0x2)/Sata(0x4,0x0)/HD(2,GPT,ad5f0168-1a2d-4785-bc39-e3fa0941cd99,0x64800,0xfa000)
blk2 :HardDisk - Alias (null)
PciRoot(0x0)/Pci(0x1f,0x2)/Sata(0x4,0x0)/HD(3,GPT,228f1d21—3a10—4f80-9d31-467fae6a0642,0x15e800,0xfa4000)
blk3 :HardDisk - Alias (null)
PciRoot(0x0)/Pci(Ox1f,0x2)/Sata(0x4,0x0)/HD(4,GPT,2692efa9-e9e3-4c23-a3fb—5caf24fb5abc,0x1102800,0x64000O0)
blk4 :HardDisk — Alias (null)
PciRoot(0x0)/Pci(0x1f,0x2)/Sata(0x4,0x0)/HD(5,GPT,021035c7-3d3b—4458-8e3c-6290997fb491,0x7502800,0x32e83800)
blk5 :BlockDevice — Alias: (null)
PciRoot(0x0)/Pci(0x1f,0x2)/Sata(0x4,0x0)
Press ESC in 1 seconds to skip startup.nsh, any other keg to continue.
Shell> _

So this got me started to try out various OSs and to check if it shows up in the boot menu:

Below are some initial results.

Yosemite 10.10.1

This the Built-in EFI Shell output with the “OS X” Yosemite 10.10.1 disk plugged in (doesn’t show up in boot menu):

Yosemite 10.10.1

Yosemite 10.10.1

Built-in EFI Shell output of Yosemite 10.10.1:

EFI Shell version 2.31 [4.654]
Current running mode 1.1.2
Device mapping table
fs0 :HardDisk — Alias hd33b65535a1 blk0
PciRoot(0x0)/Pci(0x1f,0x2)/Sata(0x1,0x0)/HD(1,GPT,fcc8030a-0876-4763-b8c2—a343e6dd0ad7,0x28,0x64000)
blk0 :HardDisk - Alias hd33b65535a1 fs0
PciRoot(0x0)/Pci(0x1f,0x2)/Sata(0x1,0x0)/HD(1,GPT,fcc8030a-0876-4763-b8c2—a343e6dd0ad7,0x28,0x64000)
blk1 :HardDisk — Alias (null)
PciRoot(0x0)/Pci(0x1f,0x2)/Sata(0x1,0x0)/HD(2,GPT,f4f53e60-1a97-4687-943a—a2d41ea848b5,0x64028,0x7456ce40)
blk2 :HardDisk — Alias (null)
PciRoot(0x0)/Pci(0x1f,0x2)/Sata(0x1,0x0)/HD(3,GPT,84e7b614-c07e-4cb5—b2d9-25b34d1f7905,0x745d0e68,0x135f20)
b1k3 :BlockDevice - Alias (null)
PciRoot(0x0)/Pci(0x1f,0x2)/Sata(0x1,0x0)
Press ESC in 1 seconds to skip startup.nsh, any other keg to continue.
Shell> _

diskutil output of Yosemite 10.10.1:

Last login: Sat Nov 29 20:27:01 on ttys000
Xeon:~ userone$ diskutil list
/dev/disk0
   #:                       TYPE NAME                    SIZE       IDENTIFIER
   0:      GUID_partition_scheme                        *1.0 TB     disk0
   1:                        EFI EFI                     209.7 MB   disk0s1
   2:                  Apple_HFS Macintosh HD            999.3 GB   disk0s2
   3:                 Apple_Boot Recovery HD             650.0 MB   disk0s3
Xeon:~ userone$

Parted output of Yosemite 10.10.1:

userone@un:~$ sudo parted /dev/sda -l
Model: ATA WDC WD10EADS-00L (scsi)
Disk /dev/sda: 1000GB
Sector size (logical/physical): 512B/512B
Partition Table: gpt

Number  Start   End     Size   File system  Name                  Flags
 1      20.5kB  210MB   210MB  fat32        EFI System Partition  boot
 2      210MB   1000GB  999GB  hfs+         Macintosh HD
 3      1000GB  1000GB  650MB  hfs+         Recovery HD

blkid output of Yosemite 10.10.1:

userone@un:~$ sudo blkid
/dev/sda1: LABEL="EFI" UUID="67E3-17ED" TYPE="vfat"
/dev/sda2: UUID="3a813953-b791-3843-853f-b031a233f518" LABEL="Macintosh HD" TYPE="hfsplus"
/dev/sda3: UUID="fe432067-44c6-36dd-90d0-67d3bb7e1ea6" LABEL="Recovery HD" TYPE="hfsplus"

Windows 10 Technical Preview 9879

This is what I get with Windows 10 TechnicalPreview-9879-x64 disk plugged in (does show up in boot menu):

Windows 10 TechnicalPreview-9879

Windows 10 TechnicalPreview-9879

Built-in EFI Shell output of Windows 10 TechnicalPreview-9879:

EFI Shell version 2.31 [4.654]
Current running mode 1.1.2
Device mapping table
fs0 :HardDisk - Alias hd33e65535a1 blk0
PciRoot(0x0)/Pci(0x1f,0x2)/Sata(0x4,0x0)/HD(1,GPT,96485d55-c364-4fce-a89a-8be2dde93044,0x800,0x96000)
fs1 :HardDisk - Alias hd33e65535a2 blk1
PciRoot(0x0)/Pci(0x1f,0x2)/Sata(0x4,0x0)/HD(2,GPT,d1427ee8-f3fa-4894-b59e-2d87a4b4621e,0x96800,0x32000)
fs2 :HardDisk - Alias hd33e65535a4 blk2
PciRoot(0x0)/Pci(0x1f,0x2)/Sata(0x4,0x0)/HD(4,GPT,a6f3e83f-f1fb-4ff9-8ff9-a9f7d80e0e2c,0x108800,0x3a27d800)
blk0 :HardDisk - Alias hd33e65535a1 fs0
PciRoot(0x0)/Pci(0x1f,0x2)/Sata(0x4,0x0)/HD(1,GPT,96485d55-c364-4fce-a89a-8be2dde93044,0x800,0x96000)
blk1 :HardDisk - Alias hd33e655353a2 fs1
PciRoot(0x0)/Pci(0x1f,0x2)/Sata(0x4,0x0)/HD(2,GPT,d1427ee8-f3fa-4894-b59e-2d87a4b4621e,0x96800,0x32000)
blk2 :HardDisk - Alias hd33e65535a4 fs2
PciRoot(0x0)/Pci(0x1f,0x2)/Sata(0x4,0x0)/HD(4,GPT,a6f3e83f-f1fb-4ff9-8ff9-a9f7d80e0e2c,0x108800,0x3a27d800)
blk3 :HardDisk - Alias (null)
PciRoot(0x0)/Pci(0x1f,0x2)/Sata(0x4,0x0)/HD(3,GPT,dcf0df4d-bafd-4d4b-9c4c-3a857a904c12,0xc8800,0x40000)
b1k4 :BlockDevice - Alias (null)
PciRoot(0x0)/Pci(0x1f,0x2)/Sata(0x4,0x0)
Press ESC in 1 seconds to skip startup.nsh, any other key to continue.
Shell> _

diskutil output of Windows 10 TechnicalPreview-9879:

Last login: Mon Dec  1 22:43:24 on ttys000
Xeon:~ userone$ diskutil list
/dev/disk1
   #:                       TYPE NAME                    SIZE       IDENTIFIER
   0:      GUID_partition_scheme                        *500.1 GB   disk1
   1: DE94BBA4-06D1-4D40-A16A-BFD50179D6AC               314.6 MB   disk1s1
   2:                        EFI NO NAME                 104.9 MB   disk1s2
   3:         Microsoft Reserved                         134.2 MB   disk1s3
   4:       Microsoft Basic Data                         499.6 GB   disk1s4
Xeon:~ userone$

Parted output of Windows 10 TechnicalPreview-9879:

userone@un:~$ sudo parted /dev/sdc -l
Model: ATA WDC WD5000AADS-0 (scsi)
Disk /dev/sdc: 500GB
Sector size (logical/physical): 512B/512B
Partition Table: gpt

Number  Start   End    Size   File system  Name                          Flags
 1      1049kB  316MB  315MB  ntfs         Basic data partition          hidden, diag
 2      316MB   420MB  105MB  fat32        EFI system partition          boot
 3      420MB   555MB  134MB               Microsoft reserved partition  msftres
 4      555MB   500GB  500GB  ntfs         Basic data partition          msftdata

blkid output of Windows 10 TechnicalPreview-9879:

userone@un:~$ sudo blkid
/dev/sdc1: LABEL="Recovery" UUID="744651444651086E" TYPE="ntfs"
/dev/sdc2: UUID="F853-2FA4" TYPE="vfat"
/dev/sdc4: UUID="F42056312055FB56" TYPE="ntfs"

Ubuntu 14.04.1

This is what I get with the Ubuntu-14.04.1-desktop-amd64 disk plugged in (does show up in boot menu):

Ubuntu-14.04.1 desktop-amd64

Ubuntu-14.04.1 desktop-amd64

Built-in EFI Shell output of Ubuntu-14.04.1:

EFI Shell version 2.31 [4.654]
Current running mode 1.1.2
Device mapping table
fs0 :HardDisk - Alias hd33d65535a1 blk0
PciRoot(0xo0)Pci(0x1f,0x2)/Sata(0x3,0x0)/HD(1,GPT,ff18a6ce-f9f0-40d5-302c-f8d3f51bedeb,0x800,0x100000)
blk0 :HardDisk - Alias hd33d65535a1 fs0
PciRoot(0x0)/Pci(0x1f,0x2)/Sata(0x3,0x0)/HD(1,GPT,ff18a6ce-f9f0-40d5-302c-f8d3f51bedeb,0x800,0x100000)
blk1 :HardDisk - Alias (null)
PciRoot(0x0)/Pci(0x1f,0x2)/Sata(0x3,0x0)/HD(2,GPT,d152dde4-e9d9-49ac-bd8a-1598cc81a0ef,0xl00800,0x29a0800)
blk2 :HardDisk - Alias (null)
PciRoot(0x0)/Pci(0x1f,0x2)/Sata(0x3,0x0)/HD(3,GPT,7fff267a-63f8-413e-84ff-6a38e0757ce7,0x2aa1000,0x1fe0000)
blk3 :BlockDevice - Alias (null)
PciRoot(0x0)/Pci(0x1f,0x2)/Sata(0x3,0x0)
Press ESC in 1 seconds to skip startup.nsh, any other key to continue.
Shell> _

disuktuil output of Ubuntu-14.04.1:

Last login: Mon Dec  1 22:50:20 on console
Xeon:~ userone$ diskutil list
/dev/disk1
   #:                       TYPE NAME                    SIZE       IDENTIFIER
   0:      GUID_partition_scheme                        *40.0 GB    disk1
   1:                        EFI NO NAME                 536.9 MB   disk1s1
   2: 0FC63DAF-8483-4772-8E79-3D69D8477DE4               22.3 GB    disk1s2
   3:                 Linux Swap                         17.1 GB    disk1s3
Xeon:~ userone

Parted output of Ubuntu-14.04.1:

userone@un:~$ sudo parted /dev/sdb -l
Model: ATA WDC WD400BD-75JM (scsi)
Disk /dev/sdb: 40.0GB
Sector size (logical/physical): 512B/512B
Partition Table: gpt

Number  Start   End     Size    File system     Name  Flags
 1      1049kB  538MB   537MB   fat32                 boot
 2      538MB   22.9GB  22.3GB  ext4
 3      22.9GB  40.0GB  17.1GB  linux-swap(v1)

blkid output of Ubuntu-14.04.1:

userone@un:~$ sudo blkid
/dev/sdb1: UUID="C046-68DD" TYPE="vfat"
/dev/sdb2: UUID="5db35bcc-21bd-4940-98dd-741749e105bb" TYPE="ext4"
/dev/sdb3: UUID="9e316101-f472-4543-ac95-b75c38a3a6f0" TYPE="swap"

As I know it, the UEFI boot process uses the ESP (EFI System Partition) to store system bootstrap components. The ESP is a GPT (or MBR) partition with a specific identifier:

GPT: c12a7328-f81f-11d2-ba4b-00a0c93ec93b
MBR: 0xef

and contains a FAT (12,16 or 32) file system with a specified hierarchy and the boot process itself is as follows:

As I understand it, UEFI firmware runs at power up and searches for an OS loader in the EFI system partition. The path to the loader may be set by an EFI environment variable while defaulted to /EFI/BOOT/BOOTX64.EFI. There is a pretty extensive and worth reading article here.

But what seems to make the difference is the 0x800 entry – which is the starting sector… weird.

Clover, UEFI, etc

I am recently trying to switch from Chameleon (which has been my bootloader of choice for 6 years approximately) to Clover.

Turns out while some things are more clear others (which should be the easier ones) are more complex – or just my google-foo left me !

Anyway, while setting up the installer stick for Yosemite was rather simple in setting up, and the installation of Yosemite itself was flawless, getting Clover on the HD itself took my quite a while. And no ! I don’t want to multiboot Windows, Linux, Solaris and OS X ! I just have 1 HFS+ formatted Yosemite disk which I want to boot :).

Well turns out you have to format the EFI partitions 1st and install Clover into it, even if you only want to UEFI boot the HDD.

So first we find the HDD that has OS X installed on a GUID partition table, and look for the EFI partition. Consequently open terminal and type:

sudo -s
type password
diskutil list

So next apply a new filesystem to the EFI partition (be careful to choose the correct one)  and replace the X according to your disk setup. In terminal enter:

newfs_msdos -v EFI /dev/diskXsX

You will get some error about a non character device (which you can ignore):

newfs_msdos: warning: /dev/disk1s1 is not a character device 512 bytes per physical sector
/dev/disk1s1: 409160 sectors in 51145 FAT16 clusters (4096 bytes/cluster)
bps=512 spc=8 res=1 nft=2 rde=512 mid=0xf8 spf=200 spt=32 hds=32 hid=40 drv=0x80 bsec=409600

So if you want to mount it then this works as follows:

mkdir /Volumes/efi
sudo mount -t msdos /dev/diskXsX /Volumes/efi

And that’s it – if your board supports booting from SATA via UEFI. Some boards only support USB UEFI booting 😦