Skip to content

Constructing

Ausdauersportler edited this page Apr 13, 2022 · 30 revisions

We will step by step construct an EFI BIOS for the W5170M card. This is an AMD Venus GPU and the only Apple Mac which has used this type of GPU is the Apple MacBookPro 15" Mid 2015. You need to get a recent firmware update or you may fetch the firmware from such a system using the app RomTool.

Get the EG2, EDIDParser, and CoreEG2 parts from an suitable Apple Mac (efi module)

Use the UEFITool-NE, open the firmware dump and search for the ASCII string ATY (which will occur within the particular module several times, and hopefully only in a single module). Another indicator is the size of approximately 185344 bytes. Some firmware files contain several graphics modules because the corresponding Apple models were offered (BTO) with different graphics options, like the iMac 2014 and 2015 models.

Finding the Apple video BIOS

Select the PE32 image section and right click Extract Body, the section will be safe with extension efi. We are ready to go. Load the file into the hex editor Hex Fiend.

Now find frame buffer name and change if with fantasy name to force the usage of the generic radeon framebuffer, which honors the connector information we changed in the original BIOS in the OBJ_INFO module. Search for text Parent and get ATY,RamenParent, the frame buffer is called Ramen. To avoid any changes in size just select a five letter code like AMDFB and make it to ATY,AMDFBParent. There may be more where the original Apple frame buffer name Ramen is used, search it and replace all strings starting with ATY,Ramen to ATY,AMDFB. In this particular case it will be only a single other one. Save and rename the file to M370.efi after making all changes.

Changing the frame buffer name

The list of supported device IDs of this software are right behind the spot you just found when searching for Parent, it is 20682168 25682768 23682B68, here we have to honor the endian and change bytes. We get the list of 6820 6821 6825 6827 6823 682B. The W5170M has the device-id of 6820, which fits perfectly.

Since the EDIDParser and CoreEG2 can be re-used in all EFI BIOS I will simply add the files to the repository instead of describing the extraction in detail. It follows the same scheme as just described from the same source file.

Compress the EFI module into a compatible EG2 BIOS

The GOP part is a compressed version of a similar EFI module, we want to replace the GOP module from the BIOS with our newly extracted and modified EG2 module. So we have to compress it in the same way using the program EFIrom:

./EfiRom -ec M370.efi -l 0x30000 -f 0x1002 -i 0x6820 -p -o M370-2820-EG2_.rom

This call creates a file named M370-2820-EG2_.rom with device-id 0x6820 and vendor-id 0x1002 . The "-p" argument makes EfiRom create a PCI 2.3 header instead of a PCI 3.0 header. This resulting file can be used to replace the GOP part using the hex editor, again.

Replace the GOP with the newly created EG2 part using Hex Fiend

This is the most easy exercise we will probably see here within the wiki. First duplicate the GOP BIOS W5170M-GOP.rom and rename it to W5170M-EG2.rom. The art is to choose the correct edit mode (overwrite), open the W5170M-EG2.rom with this overwrite mode and the newly created M370-2820-EG2_.rom in Read-only mode, select all data from the latter file in the editor and copy it to the buffer using the well known command+C, move over to the first file, place the cursor front of the second part of the BIOS starting with the 55AA (which denotes the beginning of either the legacy or GOP BIOS part) and insert (in overwrite mode) the buffer using command+V.

Replace the GOP BIOS with an Apple EG2 BIOS

Now save the modified file with name W5170M-EG2.rom. You are done with creating an EFI Boot Screen BIOS for this card.

Add the EDIDParser and CoreEG2 to OpenCore drivers section or the iMac firmware, in the latter case you the the EFI boot picker functionality on boot by pressing alt/option

There are two ways to test our newly created BIOS.

  1. You can either add the EFI modules to the driver section of your OpenCore config.plist as shown here:

<key>Drivers</key> <array> <dict> <key>Arguments</key> <string></string> <key>Enabled</key> <true/> <key>Path</key> <string>CoreEG2_x64.efi</string> </dict> <dict> <key>Arguments</key> <string></string> <key>Comment</key> <string></string> <key>Enabled</key> <true/> <key>Path</key> <string>EDIDParser_x64.efi</string> </dict> </array>

On boot you will no be able to force the EFI Boot Screen since both modules are clearly loaded late through OpenCore long after the first disk access. But you can check the functionality, the Apple system_profiler should report an EFI BIOS loaded.

  1. The other method give you the full functionality, but comes at the cost of great work and a firmware modification. As I wrote before the adoption rate is low, but it works great!

For now I will just refer to a post of the guy who (probably found) and published the method. Add the two ffs modules from the EG2 folder as shown in the video of this post or follow the not that complex verbal description.

  1. First update the firmware of your iMac to the known latest version. This version 3 of an ongoing series of posts contain the latest versions for the Apple systems we can modify. Apple stopped with updates when High Sierra went out of software support. So you can update your iMac by installing High Sierra on an internal disk an apply all available update, possibly the last security update will do the job.
  2. Now save the most recent firmware using the Romtool app.
  3. Apply the modifications as described in the video. Create a copy of the firmware file and keep an unmodified original file.
  4. Write the modified firmware back to the system board using a CH341A clip programmer.

Apple shut down the software BIOS flashing capability in most systems to fix a security hole.

After installing the W5170M card, flashing the newly EG2 BIOS the iMac should show an EFI Boot Screen on an external display.

Getting around the 128k (0x20000) size limitation (not really)

This is the most difficult part since it needs recalculation of numerous hex addresses within the vBIOS after deleting the VGA support of the legacy part. At the end we got the place to include the other two modules into the first 0x20000 bytes and get an EFI BIOS usable without a firmware modification or OpenCore.