How to install official AMDGPU linux driver with kernel 4.19.x on Stretch and Buster

My system is made of an AMD Athlon 200GE CPU/APU with Vega3 graphics on a B450M motherboard (Asus PRIME B450M-A). This APU uses the amdgpu driver provided by the linux kernel.

Although I upgraded to linux 4.19 on stretch, the system freezes during boot-up and until now the only way to make it boot was either to use kernel >= 4.20 or use the "nomodeset" kernel parameter.

However it is possible to make that system boot with the AMDGPU driver (v19.10) provided by AMD on a linux kernel 4.19 (which is currently backported on Stretch and also the linux kernel version of Buster).

I guess that could help also those having a Ryzen 2200G if they face a similar issue.

Steps in brief

  1. Get the linux driver from amd's website
  2. Install amdgpu-dkms & amdgpu-core packages

  3. Slight modification of linux-headers' Makefile (to allow compiliation of amdgpu-dkms)
  4. Apply a patch to the amdgpu-dkms source so that is does compile with linux 4.19
  5. reconfigure amdgpu-dkms
  6. You're done

Notes:

What you need/Prerequistes

Procedure

  1. Extract the archive downloaded from AMD

    • ~$ tar -xvJf amdgpu-pro-19.10-785425-ubuntu-18.04.tar.xz

  2. Install only these 2 packages : amdgpu-dkms & amdgpu-core. This will fail at the end because it cannot compile on 4.19 without applying my patch.

    • ~# dpkg -i amdgpu-dkms_19.10-785425_all.deb amdgpu-core_19.10-785425_all.deb

  3. Modify the following file /usr/src/linux-headers-<version>-amd64/Makefile and change the value of the 2 first lines to the version of the kernel (4 and 19 for kernel 4.19 in this case)

    • ~# editor /usr/src/linux-headers-<version>-amd64/Makefile

VERSION = 4
PATCHLEVEL = 19
  1. Apply the patch to the amdgpu source code
    • ~# patch -p1 < 01-amdgpu_19.10_for_linux_4.19.patch

  2. Reconfigure the amdgpu-dkms package so that it does compile against 4.19
    • ~# dpkg-reconfigure amdgpu-dkms

  3. Normally, building & installation should have succeeded

  4. Reboot
  5. Check which version is loaded during boot (for me it says "version: 19.10.9.418")

    • ~# dmesg | grep "amdgpu version

Additional notes