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/
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: