amd vega and radeon series vga card driver for FreeBSD 12.1 and 12.2 tutorial for beginner[update 2020-12-16]

amd apu vga card driver for FreeBSD 12.1 tutorial for beginner

I’m a newbie for freebsd and have some experience for linux.
I have just installed FreeBSD for one week, I met a lot of trouble when I use it.
I just want to tell everyone that how to solve this problem then you could save you time .

This article only use for amd ryzen cpu (r3 2300u , r5 3500u, r7 3700u),radeon series , vega series vga card

R5 3500u have been tested


FreeBSD 12.1 can’t detect your vga card with drm driver , because the driver have bug .


I found this driver in FreeBSD github after searching a lot.

https://github.com/FreeBSDDesktop/kms-drm/tree/drm-v5.0-fbsd12.1

download it and unzip it
unzip kms-drm-drm-v5.0-fbsd12.1.zip

you have to install xorg before you do following steps

at first you have to install drm-kmo and gpu-firmware package from ports or pkg , it will install gpu-firmware automaticly

$ sudo pkg install drm-kmod
New packages to be INSTALLED:
drm-kmod: g20181126 [FreeBSD]
drm-current-kmod: 4.16.g20190305 [FreeBSD]
Message from drm-current-kmod-4.16.g20190305:

add a line into /etc/rc.conf.

For amdgpu: kld_list="amdgpu"
For radeonkms: kld_list="/boot/modules/radeonkms.ko"

to install xf86 admgpu driver

$ sudo pkg install xf86-video-amdgpu

restart your computer after above steps .
You will see this kind of infomations:
Feb 1 16:07:58 Raffeale kernel: [drm] amdgpu kernel modesetting enabled.
Feb 1 16:07:58 Raffeale kernel: drmn0: <drmn> on vgapci0
Feb 1 16:07:58 Raffeale kernel: vgapci0: child drmn0 requested pci_enable_io
Feb 1 16:07:58 Raffeale syslogd: last message repeated 1 times
Feb 1 16:07:58 Raffeale kernel: [drm] initializing kernel modesetting (RAVEN 0x1002:0x15D8 0x103C:0x8589 0xD2).
Feb 1 16:07:58 Raffeale kernel: [drm] register mmio base: 0xF0600000
Feb 1 16:07:58 Raffeale kernel: [drm] register mmio size: 524288
Feb 1 16:07:58 Raffeale kernel: [drm] add ip block number 0 <soc15_common>
Feb 1 16:07:58 Raffeale kernel: [drm] add ip block number 1 <gmc_v9_0>
Feb 1 16:07:58 Raffeale kernel: [drm] add ip block number 2 <vega10_ih>
Feb 1 16:07:58 Raffeale kernel: [drm] add ip block number 3 <psp>
Feb 1 16:07:58 Raffeale kernel: [drm] add ip block number 4 <gfx_v9_0>
Feb 1 16:07:58 Raffeale kernel: [drm] add ip block number 5 <sdma_v4_0>
Feb 1 16:07:58 Raffeale kernel: [drm] add ip block number 6 <powerplay>
Feb 1 16:07:58 Raffeale kernel: [drm] add ip block number 7 <dm>
Feb 1 16:07:58 Raffeale kernel: [drm] add ip block number 8 <vcn_v1_0>
Feb 1 16:07:58 Raffeale kernel: drmn0: successfully loaded firmware image with name: amdgpu/picasso_sdma.bin
Feb 1 16:07:58 Raffeale kernel: [drm] VCN decode is enabled in VM mode
Feb 1 16:07:58 Raffeale kernel: [drm] VCN encode is enabled in VM mode
Feb 1 16:07:58 Raffeale kernel: [drm] VCN jpeg decode is enabled in VM mode
Feb 1 16:07:58 Raffeale kernel: [drm] vm size is 262144 GB, 4 levels, block size is 9-bit, fragment size is 9-bit
Feb 1 16:07:58 Raffeale kernel: drmn0: VRAM: 512M 0x000000F400000000 - 0x000000F41FFFFFFF (512M used)
Feb 1 16:07:58 Raffeale kernel: drmn0: GART: 1024M 0x0000000000000000 - 0x000000003FFFFFFF
Feb 1 16:07:58 Raffeale kernel: drmn0: AGP: 267419648M 0x000000F800000000 - 0x0000FFFFFFFFFFFF
Feb 1 16:07:58 Raffeale kernel: Successfully added WC MTRR for [0xc0000000-0xdfffffff]: 0;
Feb 1 16:07:58 Raffeale kernel: [drm] Detected VRAM RAM=512M, BAR=512M
Feb 1 16:07:58 Raffeale kernel: [drm] RAM width 128bits DDR4
Feb 1 16:07:58 Raffeale kernel: [TTM] Zone kernel: Available graphics memory: 8071804 kiB
Feb 1 16:07:58 Raffeale kernel: [TTM] Zone dma32: Available graphics memory: 2097152 kiB
Feb 1 16:07:58 Raffeale kernel: [TTM] Initializing pool allocator
Feb 1 16:07:58 Raffeale kernel: [drm] amdgpu: 512M of VRAM memory ready
Feb 1 16:07:58 Raffeale kernel: [drm] amdgpu: 3072M of GTT memory ready.
Feb 1 16:07:58 Raffeale kernel: i_size_write not implemented -- see your local kernel hacker
Feb 1 16:07:58 Raffeale kernel: [drm] GART: num cpu pages 262144, num gpu pages 262144
Feb 1 16:07:58 Raffeale kernel: [drm] PCIE GART of 1024M enabled (table at 0x000000F4007E9000).
Feb 1 16:07:58 Raffeale kernel: drmn0: successfully loaded firmware image with name: amdgpu/picasso_asd.bin
Feb 1 16:07:58 Raffeale kernel: ugen2.3: <vendor 0x06cb product 0x00b7> at usbus2
Feb 1 16:07:58 Raffeale kernel: drmn0: successfully loaded firmware image with name: amdgpu/picasso_pfp.bin
Feb 1 16:07:58 Raffeale kernel: drmn0: successfully loaded firmware image with name: amdgpu/picasso_me.bin
Feb 1 16:07:58 Raffeale kernel: drmn0: successfully loaded firmware image with name: amdgpu/picasso_ce.bin
Feb 1 16:07:58 Raffeale kernel: drmn0: successfully loaded firmware image with name: amdgpu/picasso_rlc.bin
Feb 1 16:07:58 Raffeale kernel: drmn0: successfully loaded firmware image with name: amdgpu/picasso_mec.bin
Feb 1 16:07:58 Raffeale kernel: drmn0: successfully loaded firmware image with name: amdgpu/picasso_mec2.bin
...
Feb 1 16:07:58 Raffeale kernel: drmn0: ring vcn_dec uses VM inv eng 1 on hub 1
Feb 1 16:07:58 Raffeale kernel: drmn0: ring vcn_enc0 uses VM inv eng 4 on hub 1
Feb 1 16:07:58 Raffeale kernel: drmn0: ring vcn_enc1 uses VM inv eng 5 on hub 1
Feb 1 16:07:58 Raffeale kernel: drmn0: ring vcn_jpeg uses VM inv eng 6 on hub 1
Feb 1 16:07:58 Raffeale kernel: pm_runtime_mark_last_busy not implemented -- see your local kernel hacker
Feb 1 16:07:58 Raffeale kernel: [drm] Initialized amdgpu 3.27.0 20150101 for drmn0 on minor 0

that means your amdgpu driver is loaded correctly.

add your UID is a member of the "video" group.
$ sudo pw groupmod video -m $USER


Run startx , go to xwindows, if have some problem with going into xwindows ,
you could find some message in /var/log/Xorg.0.log or run startx will got "[KMS] drm report modesetting isn't supported "
it maybe the pcids file is missing your device_id, just put your device_id in it.

You should run pciconf -lv to find vga card
for example:
#pciconf -lv

iwm0@pci0:2:0:0: class=0x028000 card=0x00148086 chip=0x25268086 rev=0x29 hdr=0x00
vendor = 'Intel Corporation'
device = 'Wireless-AC 9260'
class = network
vgapci0@pci0:4:0:0: class=0x030000 card=0x8589103c chip=0x15d81002 rev=0xd2 hdr=0x00
vendor = 'Advanced Micro Devices, Inc. [AMD/ATI]'
device = 'Picasso'
class = display
subclass = VGA
there are deivce id and vendor id in chip field.
0x15d8 is device_id
0x1002 is vendor_id


find your device_id in you /usr/local/share/pciids/pci.ids files
add your device id in AMD group when you can't find it in the file.

And then run startx again , it works fine

if you xorg have VSync problem ,enable TearFree into your xorg.conf


Section "Device"

### [arg]: arg optional
#Option "ShadowFB" # [<bool>]
#Option "DefaultRefresh" # [<bool>]
#Option "ModeSetClearScreen" # [<bool>]
Identifier "Card0"
Driver "amdgpu"
BusID "PCI:4:0:0"

Option "TearFree" "On"

Option "DRI" "True"
Option "AccelMethod" "exa"
Option "MigrationHeuristic" "greedy"
EndSection


for saving power , put this in your loader.conf . the following lines will enable dynamic power management on you gpu
compat.linuxkpi.amdgpu_dpm=1
compat.linuxkpi.amdgpu_bapm=1
compat.linuxkpi.amdgpu_runpm=1
compat.linuxkpi.amdgpu_dc=1


if you got xorg issue with "No Screen found " , maybe you work on securelevel mode , you can look at your /var/log/Xorg.0.log , you will find these information here

[ 18393.601] (WW) checkDevMem: failed to open /dev/mem (Operation not permitted)
[ 18393.601] (II) "glx" will be loaded. This was enabled by default and also specified in the config file.

solution: turn off securelevel and restart



#note:
(1)don’t use any secure level when you start the Xorg first time because /dev/kmem and /dev/memory can't be accessed as you open the secure level,when you start xorg , you can enable securelevel again. it's ok!
(2)mtrr will be not added correctly when your bios setup the video memory to auto , maybe this is drivers bug,because windows10 have not any problem.
(3) you can use "pkg lock drm-fbsd12.0-kmod" for preventing it from upgrading

offical article for vga card
https://freebsddesktop.github.io/2018/12/08/drm-kmod-primer.html

2020-04-06 UPDATE:
add solution for Xorg "No Screen Found"

2020-12-16 UPDATE:
solving laptop suspend and resume problem for amdgpu drm5.0 , look this thread, i have just posted it.

https://forums.freebsd.org/threads/...ies-apu-tested-suspending-and-resuming.74451/
freebsd 12.2 driver compile and installation
https://forums.freebsd.org/threads/freebsd-12-2-amd-vega-and-radeon-driver-solution-with-drm5.78080/
 
Last edited:
Thank you. The 5.0 driver allows my RX590 to work! I am only having problems now with the fan speed, as it appears the GPU fans are spinning at near full speed, creating too much noise.

A little clean-up for the instructions is needed, as there are some problems with the link. The direct download for the file is:
https://github.com/FreeBSDDesktop/kms-drm/archive/drm-v5.0-fbsd12.1.zip

You will also need to download the firmware and install it.
https://github.com/FreeBSDDesktop/kms-firmware/archive/master.zip

A problem with following the instructions above, about installing drm-kmod from packages is that if you later on simply run pkg upgrade, it will overwright the updated drivers.
 
The power management options do not Need Linux support,it’s amdgpu drm driver option. You can search them in bing.com.
 
The power management options do not Need Linux support,it’s amdgpu drm driver option. You can search them in bing.com.
Thank you. I have found the documentation for the options. Hopefully I will have opportunity to try it out later this week.
 
You know, this is entertaining, but actually quite wrong. To install drm-v5.0 you need the graphics/drm-devel-kmod port and, of course, you won't be able to build it on 12.1.
 
i have already installed drm5.0 on freebsd12.1 ,just use offical github drm5.0 for freebsd12.1 and it works fine
 
Interesting. You still should rather edit the version stuff in the port's makefile instead of all these strange steps.
 
if you want to resume and suspend works, you should change linuxkpi makefile. but it works fine without suspend and resume when you dont change anything.
the follow post is for suspending and resuming I made it.
 
You will also need to download the firmware and install it.
https://github.com/FreeBSDDesktop/kms-firmware/archive/master.zip

This confuses me - what firmware? I installed graphics/drm-kmod and x11-drivers/xf86-video-amdgpu and the system works perfectly, 3d graphics included. There is some garbling of the FreeBSD boot logo before the AMD driver kicks in but other than that it works fine.

Running this on an RX570 but that shouldn't matter should it?

As a side note, is there any way to get the GPU temperature?
 
This confuses me - what firmware? I installed graphics/drm-kmod and x11-drivers/xf86-video-amdgpu and the system works perfectly, 3d graphics included. There is some garbling of the FreeBSD boot logo before the AMD driver kicks in but other than that it works fine.

Running this on an RX570 but that shouldn't matter should it?

As a side note, is there any way to get the GPU temperature?
The firmware is part of graphics/drm-kmod. If you are manually installing the source from github, you will need to also manually install the firmware. There is no need to install the port if you are manually installing, and as I found out, if it is installed beforehand, running a blanket pkg upgrade will overwrite the 5.0 drivers. If installing the port gives you proper graphics support, then you don't need to install the 5.0 drivers. In my case, the 4.16 drivers from ports would not work.

I too am hoping to have some way to monitor the GPU temperature and fan speeds, but that may not be doable right now.
 
  • Like
Reactions: a6h
Ah ok, thanks for the clarification. I installed from ports so I should be good to go. Everything works fine: the monitor sleeps and wakes up, 3D works, I can go from fluxbox to terminal with no issues. The only issue is screen jumble after the FreeBSD logo during boot, until the driver kicks in but I can live with that.
 
amd apu vga card driver for FreeBSD 12.1 tutorial for beginner

I’m a newbie for freebsd and have some experience for linux.
I have just installed FreeBSD for one week, I met a lot of trouble when I use it.
I just want to tell everyone that how to solve this problem then you could save you time .

This article only use for amd ryzen cpu (r3 2300u , r5 3500u, r7 3700u),radeon series , vega series vga card

R5 3500u have been tested


FreeBSD 12.1 can’t detect your vga card with drm driver , because the driver have bug .


I found this driver in FreeBSD github after searching a lot.

https://github.com/FreeBSDDesktop/kms-drm/tree/drm-v5.0-fbsd12.1

download it and unzip it
unzip kms-drm-drm-v5.0-fbsd12.1.zip

you have to install xorg before you do following steps

at first you have to install drm-kmo and gpu-firmware package from ports or pkg , it will install gpu-firmware automaticly

$ sudo pkg install drm-kmod
New packages to be INSTALLED:
drm-kmod: g20181126 [FreeBSD]
drm-current-kmod: 4.16.g20190305 [FreeBSD]
Message from drm-current-kmod-4.16.g20190305:

add a line into /etc/rc.conf.

For amdgpu: kld_list="amdgpu"
For radeonkms: kld_list="/boot/modules/radeonkms.ko"

to install xf86 admgpu driver

$ sudo pkg install xf86-video-amdgpu

restart your computer after above steps .
You will see this kind of infomations:
Feb 1 16:07:58 Raffeale kernel: [drm] amdgpu kernel modesetting enabled.
Feb 1 16:07:58 Raffeale kernel: drmn0: <drmn> on vgapci0
Feb 1 16:07:58 Raffeale kernel: vgapci0: child drmn0 requested pci_enable_io
Feb 1 16:07:58 Raffeale syslogd: last message repeated 1 times
Feb 1 16:07:58 Raffeale kernel: [drm] initializing kernel modesetting (RAVEN 0x1002:0x15D8 0x103C:0x8589 0xD2).
Feb 1 16:07:58 Raffeale kernel: [drm] register mmio base: 0xF0600000
Feb 1 16:07:58 Raffeale kernel: [drm] register mmio size: 524288
Feb 1 16:07:58 Raffeale kernel: [drm] add ip block number 0 <soc15_common>
Feb 1 16:07:58 Raffeale kernel: [drm] add ip block number 1 <gmc_v9_0>
Feb 1 16:07:58 Raffeale kernel: [drm] add ip block number 2 <vega10_ih>
Feb 1 16:07:58 Raffeale kernel: [drm] add ip block number 3 <psp>
Feb 1 16:07:58 Raffeale kernel: [drm] add ip block number 4 <gfx_v9_0>
Feb 1 16:07:58 Raffeale kernel: [drm] add ip block number 5 <sdma_v4_0>
Feb 1 16:07:58 Raffeale kernel: [drm] add ip block number 6 <powerplay>
Feb 1 16:07:58 Raffeale kernel: [drm] add ip block number 7 <dm>
Feb 1 16:07:58 Raffeale kernel: [drm] add ip block number 8 <vcn_v1_0>
Feb 1 16:07:58 Raffeale kernel: drmn0: successfully loaded firmware image with name: amdgpu/picasso_sdma.bin
Feb 1 16:07:58 Raffeale kernel: [drm] VCN decode is enabled in VM mode
Feb 1 16:07:58 Raffeale kernel: [drm] VCN encode is enabled in VM mode
Feb 1 16:07:58 Raffeale kernel: [drm] VCN jpeg decode is enabled in VM mode
Feb 1 16:07:58 Raffeale kernel: [drm] vm size is 262144 GB, 4 levels, block size is 9-bit, fragment size is 9-bit
Feb 1 16:07:58 Raffeale kernel: drmn0: VRAM: 512M 0x000000F400000000 - 0x000000F41FFFFFFF (512M used)
Feb 1 16:07:58 Raffeale kernel: drmn0: GART: 1024M 0x0000000000000000 - 0x000000003FFFFFFF
Feb 1 16:07:58 Raffeale kernel: drmn0: AGP: 267419648M 0x000000F800000000 - 0x0000FFFFFFFFFFFF
Feb 1 16:07:58 Raffeale kernel: Successfully added WC MTRR for [0xc0000000-0xdfffffff]: 0;
Feb 1 16:07:58 Raffeale kernel: [drm] Detected VRAM RAM=512M, BAR=512M
Feb 1 16:07:58 Raffeale kernel: [drm] RAM width 128bits DDR4
Feb 1 16:07:58 Raffeale kernel: [TTM] Zone kernel: Available graphics memory: 8071804 kiB
Feb 1 16:07:58 Raffeale kernel: [TTM] Zone dma32: Available graphics memory: 2097152 kiB
Feb 1 16:07:58 Raffeale kernel: [TTM] Initializing pool allocator
Feb 1 16:07:58 Raffeale kernel: [drm] amdgpu: 512M of VRAM memory ready
Feb 1 16:07:58 Raffeale kernel: [drm] amdgpu: 3072M of GTT memory ready.
Feb 1 16:07:58 Raffeale kernel: i_size_write not implemented -- see your local kernel hacker
Feb 1 16:07:58 Raffeale kernel: [drm] GART: num cpu pages 262144, num gpu pages 262144
Feb 1 16:07:58 Raffeale kernel: [drm] PCIE GART of 1024M enabled (table at 0x000000F4007E9000).
Feb 1 16:07:58 Raffeale kernel: drmn0: successfully loaded firmware image with name: amdgpu/picasso_asd.bin
Feb 1 16:07:58 Raffeale kernel: ugen2.3: <vendor 0x06cb product 0x00b7> at usbus2
Feb 1 16:07:58 Raffeale kernel: drmn0: successfully loaded firmware image with name: amdgpu/picasso_pfp.bin
Feb 1 16:07:58 Raffeale kernel: drmn0: successfully loaded firmware image with name: amdgpu/picasso_me.bin
Feb 1 16:07:58 Raffeale kernel: drmn0: successfully loaded firmware image with name: amdgpu/picasso_ce.bin
Feb 1 16:07:58 Raffeale kernel: drmn0: successfully loaded firmware image with name: amdgpu/picasso_rlc.bin
Feb 1 16:07:58 Raffeale kernel: drmn0: successfully loaded firmware image with name: amdgpu/picasso_mec.bin
Feb 1 16:07:58 Raffeale kernel: drmn0: successfully loaded firmware image with name: amdgpu/picasso_mec2.bin
...
Feb 1 16:07:58 Raffeale kernel: drmn0: ring vcn_dec uses VM inv eng 1 on hub 1
Feb 1 16:07:58 Raffeale kernel: drmn0: ring vcn_enc0 uses VM inv eng 4 on hub 1
Feb 1 16:07:58 Raffeale kernel: drmn0: ring vcn_enc1 uses VM inv eng 5 on hub 1
Feb 1 16:07:58 Raffeale kernel: drmn0: ring vcn_jpeg uses VM inv eng 6 on hub 1
Feb 1 16:07:58 Raffeale kernel: pm_runtime_mark_last_busy not implemented -- see your local kernel hacker
Feb 1 16:07:58 Raffeale kernel: [drm] Initialized amdgpu 3.27.0 20150101 for drmn0 on minor 0

that means your amdgpu driver is loaded correctly.

add your UID is a member of the "video" group.
$ sudo pw groupmod video -m $USER


Run startx , go to xwindows, if have some problem with going into xwindows ,
you could find some message in /var/log/Xorg.0.log or run startx will got "[KMS] drm report modesetting isn't supported "
it maybe the pcids file is missing your device_id, just put your device_id in it.

You should run pciconf -lv to find vga card
for example:
#pciconf -lv

iwm0@pci0:2:0:0: class=0x028000 card=0x00148086 chip=0x25268086 rev=0x29 hdr=0x00
vendor = 'Intel Corporation'
device = 'Wireless-AC 9260'
class = network
vgapci0@pci0:4:0:0: class=0x030000 card=0x8589103c chip=0x15d81002 rev=0xd2 hdr=0x00
vendor = 'Advanced Micro Devices, Inc. [AMD/ATI]'
device = 'Picasso'
class = display
subclass = VGA
there are deivce id and vendor id in chip field.
0x15d8 is device_id
0x1002 is vendor_id


find your device_id in you /usr/local/share/pciids/pci.ids files
add your device id in AMD group when you can't find it in the file.

And then run startx again , it works fine

if you xorg have VSync problem ,enable TearFree into your xorg.conf


Section "Device"

### [arg]: arg optional
#Option "ShadowFB" # [<bool>]
#Option "DefaultRefresh" # [<bool>]
#Option "ModeSetClearScreen" # [<bool>]
Identifier "Card0"
Driver "amdgpu"
BusID "PCI:4:0:0"

Option "TearFree" "On"

Option "DRI" "True"
Option "AccelMethod" "exa"
Option "MigrationHeuristic" "greedy"
EndSection


for saving power , put this in your loader.conf . the following lines will enable dynamic power management on you gpu
compat.linuxkpi.amdgpu_dpm=1
compat.linuxkpi.amdgpu_bapm=1
compat.linuxkpi.amdgpu_runpm=1
compat.linuxkpi.amdgpu_dc=1


if you got xorg issue with "No Screen found " , maybe you work on securelevel mode , you can look at your /var/log/Xorg.0.log , you will find these information here

[ 18393.601] (WW) checkDevMem: failed to open /dev/mem (Operation not permitted)
[ 18393.601] (II) "glx" will be loaded. This was enabled by default and also specified in the config file.

solution: turn off securelevel and restart



#note:
(1)don’t use any secure level when you use the Xorg because the driver will be not loaded as you open the secure level. it’s so strange but it’s true.
(2)mtrr will be not added correctly when your bios setup the video memory to auto , maybe this is drivers bug,because windows10 have not any problem.
(3) you can use "pkg lock drm-fbsd12.0-kmod" for preventing it from upgrading

offical article for vga card
https://freebsddesktop.github.io/2018/12/08/drm-kmod-primer.html

2020-04-06 UPDATE:
add solution for Xorg "No Screen Found"
I can confirm that both solutions amdgpu and suspend works for me on the Lenovo E595. Thank you. It seems though that the sound doesn't work. Did you manage to get the sound working with your laptop?
Thank you
 
Thank you but I wasn't testing your solution :). My system works perfectly just using the standard x11/drm-kmod driver.

So what is the actual status on this to get vega working (all versions?)? Is it suffice to install x11/drm-kmod or x11/drm-kmod-devel and does it have to be from ports, or do packages work as well? I am asking the latter because on a system I have with an old Radeon the installation with packages gives:

Code:
$ pkg info | grep drm
drm-fbsd12.0-kmod-4.16.g20200221 DRM modules for the linuxkpi-based KMS components
drm-kmod-g20190710             Metaport of DRM modules for the linuxkpi-based KMS components
libdrm-2.4.102,1               Userspace interface to kernel Direct Rendering Module services
linux-c7-libdrm-2.4.91         Interface to kernel Direct Rendering Module (Linux CentOS 7.6.1810)
$
 
Back
Top