~jakintosh/patch-radeon-module

273558d4 — Jak Tiano 5 months ago
changed: require 'KERNEL_NAME' now to avoid linux/linux-lts folder issues for Module.symvers
1d4a3aea — Jak Tiano 8 months ago
changed: updated radeon_bios.patch for latest source changes (tested Linux 6.8.2-arch-2-1)
Linux 6.5.5-arch1-1: initial commit

refs

main
browse  log 

clone

read-only
https://git.sr.ht/~jakintosh/patch-radeon-module
read/write
git@git.sr.ht:~jakintosh/patch-radeon-module

You can also use your local clone with git send-email.

#Patch Radeon Module

#About

This repository is for patching the Radeon linux kernel module to be able to load a custom video BIOS file. It is intended to solve a very specific problem for the MacBook Pro 2,2 (A1211) from 2006 which has a a particular set of EFI and BIOS related non-conformities, and is, as far as I can tell, the only way of getting the X1600 graphics card in that specific computer to be operational on modern linux systems in the year 2023.

NOTE: These instructions are written against Arch Linux, and this process has only been tested on Arch Linux as of September 2023. There may be distribution-specific changes to the instructions that you'll have to make.

#Acquiring a vBIOS

There is a vbios.bin file in this repository that I extracted on my MacBook Pro 2,2 (A1211) with an AMD X1600 GPU. I do not know if the hardware is identical across all shipped machines with that identifier, and if not there is a chance that the vBIOS included in this repository can brick your graphics card. If you have a functional DVD drive on your A1211, I suggest you extract your own vBIOS just to be sure. If you're in a YOLO mood, you can just use the one I gave you and skip the rest of this section.

To extract your own vBIOS, you need to burn an install DVD with an old linux distribution that boots in BIOS compatibility mode, and then manually extract the vBIOS into a file. To save you time, I can confirm that http://old-releases.ubuntu.com/releases/10.04.0/ubuntu-10.04.4-desktop-i386.iso worked for me. I downloaded and burned that image to a blank DVD with Disk Utility in OS X, and then booted from the disc on the MacBook Pro. I was unable to figure out how to boot this image from a USB drive, and while it still might be possible, it will save a lot of time and headache to use the DVD route if your DVD drive still works.

Once you boot into Ubuntu 10 from the DVD, open the terminal and dump the vbios like so:

# extract the vbios out of physical memory
$ dd if=/dev/mem of=vbios.rom bs=65536 skip=12 count=1

# verify that the extracted vbios starts with bytes: 55 aa
$ hexdump -C vbios.bin | head -n 1
00000000  55 aa 7d e9 7f 02 00 00  00 00 00 00 00 00 00 00  |U.}.............|

Save that vbios.rom file you created to somewhere that will survive a reboot, and then replace the vbios.rom that I provided in this folder with the one you just extracted. (If there was no git diff after swapping, then the work you just did was unnecessary... but it's better safe than a bricked GPU).

#How to Use This Repo

These instructions are wordy because the process is nuanced and you should understand what is going on, even though this repo implements 99% of the work that needs to happen.

DO ONCE:

First, you have to prepare your system for the patched kernel module. You'll need to compress the vbios.rom file using whatever is the current kernel compression standard (as of this writing, that is zstd on arch), move it into the /usr/lib/firmware/radeon folder, and then update your /etc/mkinitcpio.conf file to load that file.

NOTE: Compression standards, locations for the firmware, and the "mkinitcpio" process may be different on your distribution.

$ zstd vbios.bin
$ sudo mv vbios.bin.zst /usr/lib/firmware/radeon/vbios.bin.zst
$ sudo $EDITOR /etc/mkinitcpio.conf
 >  MODULES=(radeon)
 >  FILES=(/usr/lib/firmware/radeon/vbios.bin.zst)

Now, during boot, the kernel will load the radeon module and also make the vbios.bin file available for it to read.

DO ONCE FOR EACH KERNEL VERSION:

Next, you have to patch the radeon kernel module. You will have to do this every time you update the kernel. To patch the kernel, run the patch_radeon.sh script from inside the root of this repository. Always cd into this folder before running the script, because it depends on the radeon_bios.patch file to work. This script will download the linux kernel source, then patch and recompile the radeon module, then compress and replace the module, and finally load the new module.

$ cd patch-radeon-module
$ ./patch_radeon.sh

The script will ask you for your password toward the end to run some sudo commands for rebuilding the ramdisk and loading the module. The entire process takes about 7 and a half minutes.

You must be running the kernel you want to patch. The first time you run this script, you will most likely just run it on our existing installation. However, when you update your kernel you'll have to reboot before you can patch the module so that the new kernel is running. This creates an awkward situation where you update the kernel and need to reboot with an unpatched radeon module.

To cause the fewest problems, I recommend updating the kernel, rebooting with the modprobe.blacklist=radeon kernel parameter, and then patching the radeon module. Without blacklisting, you may lose graphics during boot and have to SSH into the machine to finish the kernel patch. Once the patch is complete, the module will be loaded and you should be able to continue using the machine.