跳到主要内容

安装 S3000 2.5.0(Ubuntu)

安装驱动依赖包


安装依赖包

apt install dkms lightdm

关闭自动休眠

systemctl mask sleep.target suspend.target hibernate.target hybrid-sleep.target

安装驱动


安装驱动

根据系统架构获取相应的驱动包,并执行以下命令安装:

dpkg -i musa_2.5.0-server-Ubuntu_amd64.deb

驱动安装后,您可以选择重启操作系统以加载新的驱动,或者直接加载新的驱动而不重启系统。

重启系统加载驱动

通过以下命令重启系统以加载新的驱动:

shutdown -r now

不重启系统加载驱动

如果选择不重启系统,则需要执行以下步骤。

停止当前运行的相关业务,并暂停 Xorg 服务:

killall Xorg

service lightdm stop

卸载已加载的 kmd 模块:

rmmod mtgpu

检查是否成功卸载 mtgpu:

lsmod |grep mtgpu

重新加载 kmd:

modprobe mtgpu

查看是否成功加载 mtgpu:

lsmod |grep mtgpu

更换驱动


更换驱动,不重启系统加载。在更换驱动之前,请执行以下步骤。

停止正在运行的相关业务,暂停 Xorg 服务:

pkill Xorg
service lightdm stop

卸载已经安装的原有驱动:

dpkg -P musa

安装新版本的驱动:

dpkg -i musa_2.5.0-server-Ubuntu_amd64.deb

卸载已加载的 kmd 模块:

rmmod mtgpu

检查是否成功卸载 mtgpu:

lsmod |grep mtgpu

重新加载 kmd:

modprobe mtgpu

检查是否成功加载 mtgpu:

lsmod |grep mtgpu

配置 Xorg


配置 Xorg 需要修改配置文件,并在修改后重启 Xorg 以使配置生效。

配置 xorg.conf

在服务器环境中,通常存在集成显卡。当安装 MT 显卡用于图形渲染时,需要配置多显卡的 Xorg。此配置支持集成显卡用于 BMC 远程桌面显示,同时 MT 显卡可以用于图形渲染。

Xorg 的配置路径为 /etc/X11/xorg.conf,主要配置包括集成显卡、MT 显卡以及公共部分。集显和 MT 显卡的配置主要由 Device,Monitor,Screen 组成,公共部分配置由 OutputClass,ServerLayout,ServerFlags 组成。

集显配置

如果集显用作 BMC 远程桌面显示,则集显做为主显,Identifier 的编号都为 0,DISPLAY 为 :0.0。

Device 配置项说明:

  • Identifier:指定 Device 的编号,如果集成显卡是主显,编号应为 "Video Device0"。
  • Driver:指定集成显卡的驱动,设置为 “modesetting”。
  • BusID:指定集成显卡的 PCIe BusID。使用 lspci 命令获取集成显卡的 PCIe 地址, 需要将 16 进制地址转换为 10 进制。例如,如果 lspci 输出的地址是 “05:00.0”,则 BusID 配置为 "PCI:5:00:0"。

要获取显卡的 PCIe 地址,可以使用以下命令:

# lspci | grep -E 'VGA|3D|Display'

这将输出类似以下的信息:

02:00.0 VGA compatible controller: Matrox Electronics Systems Ltd. MGA G200e [Pilot] ServerEngines (SEP1) (rev 42)
19:00.0 3D controller: Moore Threads Technology Co.,Ltd MTT S3000
1a:00.0 3D controller: Moore Threads Technology Co.,Ltd MTT S3000
1b:00.0 3D controller: Moore Threads Technology Co.,Ltd MTT S3000
1c:00.0 3D controller: Moore Threads Technology Co.,Ltd MTT S3000
b3:00.0 3D controller: Moore Threads Technology Co.,Ltd MTT S3000
b4:00.0 3D controller: Moore Threads Technology Co.,Ltd MTT S3000
b5:00.0 3D controller: Moore Threads Technology Co.,Ltd MTT S3000
b6:00.0 3D controller: Moore Threads Technology Co.,Ltd MTT S3000

要将 16 进制地址转换为 10 进制,可以使用如下命令:

# echo $((16#1a))

例如,对于 "1a",上述命令将输出:

26

Monitor 配置项说明:

  • Identifier:指定 Monitor 的编号,如果集成显卡是主显,则编号应为 "Monitor0"。

Screen配置项说明:

  • Identifier:指定 Screen 的编号,如果集成显卡是主显,则编号应为 "Screen0"。
  • Monitor:配置 Monitor 部分 Identifier 的值,为 "Monitor0"。
  • Device:配置 Device 部分 Identifier 的值,为 "Video Device0"。

集显为主显的配置示例:

Section "Device"
Identifier "Video Device0"
Driver "modesetting"
BusID "PCI:5:00:0"
EndSection

Section "Monitor"
Identifier "Monitor0"
EndSection

Section "Screen"
Identifier "Screen0"
Monitor "Monitor0"
Device "Video Device0"
EndSection

MT 显卡配置

每张 MT 显卡都由三个部分组成:Device、Monitor、Screen。有几张卡就有几组 Device、Monitor、Screen。在集成显卡作为主显的情况下,MT 显卡的 Device、Monitor、Screen 的 Identifier 编号从1开始,每张卡依此递增。第一张 MT 显卡的显示器为 :0.1,第二张为 :0.2。

Device 配置项说明

  • Identifier:指定 Device 的编号,例如:Video Device1。
  • Driver:指定 MT 显卡的驱动,设置为 “mtgpu”。
  • BusID:指定 MT 显卡的 PCIe BusID。获取 MT 显卡的 PCIe 地址,使用 lspci 命令获取的地址是16进制,BusID 需要配置为10进制。需要将16进制转换为10进制;另外,lspci 获取的地址分隔符为“.”,而 BusID 的分隔符为“:”。例如,使用 lspci 获取 PCIe 地址为:“01:00.0”,配置项则为 "PCI:1:00:0"。具体命令可以参考上节。

Monitor 配置项说明

  • Identifier:指定 Monitor 的编号,例如:Monitor1。
  • Modeline:指定显示器的显示模式。例如:"1024x768_60.00" 63.50 1024 1072 1176 1328 768 771 775 798 -hsync +vsync。
  • Option:指定偏好的显示模式,设置为:"PreferredMode" "1024x768_60.00"。

注:为了更好地支持集显作为 BMC 远程显示,建议将 MT 显卡和集显的分辨率和刷新率设置为相同。本指南推荐在 ServerLayout 部分将 Screen 叠加在一起,以避免不同分辨率可能导致小屏幕上的鼠标点击发生偏移。

Screen配置项说明:

  • Identifier:指定 Screen 的编号,如果集成显卡是主显,则编号应为 Screen1。
  • Monitor:配置 Monitor 部分 Identifier 的值,为 Monitor1。
  • Device:配置 Device 部分 Identifier 的值,为 Video Device1。

示例:

Section "Device" Identifier "Video Device1"
Driver "mtgpu"
BusID "PCI:1:00:0"
EndSection

Section "Monitor"
Identifier "Monitor1"
Modeline "1024x768_60.00" 63.50 1024 1072 1176 1328 768 771 775 798 -hsync +vsync
Option "PreferredMode" "1024x768_60.00"
EndSection

Section "Screen"
Identifier "Screen1"
Monitor "Monitor1"
Device "Video Device1"
EndSection

公共部分配置

公共部分配置由 OutputClass、ServerLayout 和 ServerFlags 组成。其中 OutputClass 和 ServerFlags 的配置无需单独修改;ServerLayout 将根据配置的显卡数量包括集显和 MT 显卡,实现屏幕叠加摆放。

OutputClass 配置

Section "OutputClass"
Identifier "mtgpu display"
MatchDriver "mtgpu"
EndSection

ServerLayout 配置

将所有显卡,包括集显和 mtgpu,叠加摆放在屏幕上。以下示例展示了三张卡的配置,其中一张为集显,两张为 MT 显卡。

Section "ServerLayout"
Identifier "Server Layout"
Screen 0 "Screen0" 0 0
Screen 1 "Screen1" 0 0
Screen 2 "Screen2" 0 0
EndSection

ServerFlags 配置

Section "ServerFlags"
Option "DefaultServerLayout" "Server Layout"
Option "PrimaryBusDriver" "mtgpu"
Option "AutoAddGPU" "off"
EndSection

请参考附录以获取完整的 Xorg 配置示例。

重启 Xorg 进程

停止Xorg进程

如果 Xorg 进程正在运行,先关闭它:

pkill Xorg

如果 Xorg 进程是由 lightdm 服务启动的,还需要关闭 lightdm 进程:

service lightdm stop

启动 Xorg 进程

如果只需要启动 Xorg 进程,可以使用以下命令:

Xorg &

如果需要启动窗口管理系统,可以使用如下命令:

service lightdm start

显示配置


S3000显卡有DP显示接口,可以连接显示器。S3000可以做为主显,也可以做为副显,两种方式的Xorg配置不同。

驱动配置检查

S3000用作显示,需要MT显卡驱动加载的display参数为”mt“,否则无法点亮显示器。以下命令可以检查当前加载驱动的display参数:

# cat /sys/module/mtgpu/parameters/display mt

设置display参数可以修改/etc/modprobe.d/mtgpu.conf配置文件:

# cat /etc/modprobe.d/mtgpu.conf options mtgpu display=mt

修改配置后,重启系统生效。

update-initramfs -u -k $(uname-r) shutdown -r now

MT 显卡作为主显

如果 MT 显卡被配置为主显,您需要编辑 /etc/X11/xorg.conf 文件。将其中一张 MT 显卡配置为主显,而集显则配置为副显。具体配置可参考附录MT显卡作为主显的内容。

完成 Xorg 配置的修改后,需要停止 Xorg 进程。具体请参考重启Xorg进程部分内容。

接着,通过以下命令启动 lightdm 服务,以确保显示器正常亮起:

service lightdm start

注:如果 MT 显卡被配置为主显,可能会导致 BMC 远程桌面显示为黑屏。

MT 显卡作为副显

安装依赖包 gnome-shell

apt install gnome-shell

配置 Xorg

如果 MT 显卡作为副显,集显作为主显,配置 /etc/X11/xorg.conf,具体配置可参考附录集显作为主显部分的内容。

修改Xorg配置之后需要停止Xorg进程,具体请参考重启Xorg进程部分内容。

启动lightdm,则显示器可点亮。

service lightdm start

获取桌面权限

为了通过 BMC 远程桌面登录,需要执行以下命令获取桌面权限。其中,-u 参数指定用于 BMC 登录桌面的用户。例如,如果使用 root 登录桌面,则 -u 参数应为 root。

sudo -u root DISPLAY=:0.0 xhost +

启动桌面

指定 /etc/X11/xorg.conf 中显卡和 Screen 一一对应的关系后,可以使用以下命令在对应的 display 上启动桌面。如果 MT 显卡对应 Screen1,则对应的 display 为 :0.1;如果 MT 显卡对应 Screen2,则对应的 display 为 :0.2,依此类推。

export XAUTHORITY=/var/run/lightdm/root/:0
DISPLAY=:0.1 gnome-shell --replace
DISPLAY=:0.2 gnome-shell --replace

注:这种方式启动桌面具备键鼠和窗口功能。

DirectStream 配置


为了启用 DirectStream 抓屏编码功能,需要在 Xorg 配置中打开相应的选项并设置环境变量。

安装依赖包

apt install libva2 libva-drm2

修改 Xorg 配置

修改 /etc/X11/xorg.conf 文件,将每张 mtgpu 的 Device 部分添加 ”Option ``"MTFBCAP" "true"“,例如:

Section "Device"
Identifier "Video Device1"
Driver "mtgpu"
BusID "PCI:25:00:0"
Option "MTFBCAP" "true"
EndSection

重启 Xorg 以使配置文件生效,参考重启Xorg进程部分。

用户权限设置

如果使用非 root 用户抓屏编码,需要将用户添加到 video 和 render 组:

sudo usermod -a -G video user
sudo usermod -a -G render user

修改分辨率

如果服务器连接了显示器,则直接修改分辨率。如果服务器未连接显示器,需要修改 kmd 的加载方式为 dummy。 检查 driver 的加载模式是否为mt:

cat /sys/module/mtgpu/parameters/display
mt

修改 kmd 的加载模式,然后重启系统:

sudo sed -i 's/=mt/=dummy/' /etc/modprobe.d/mtgpu.conf

查看修改是否成功:

cat /etc/modprobe.d/mtgpu.conf
options mtgpu display=dummy EnableFWContextSwitch=27

重启操作系统:

update-initramfs -u -k $(uname -r)
shutdown -r now

查看指定 Screen 的分辨率:

export DISPLAY=:0.1
xrandr

设置指定Screen分辨率,“-s”指定分辨率,“-r”指定刷新率,以4K为例:

export DISPLAY=:0.1
xrandr -s 3840x2160 -r 60

启动抓屏编码

设置环境变量

在启动抓屏编码之前,需要设置两个环境变量,分别是 LIBVA_DRIVER_NAME 和 LIBVA_DRIVERS_PATH。执行以下命令:

export LIBVA_DRIVER_NAME=mtgpu
export LIBVA_DRIVERS_PATH=/usr/lib/x86_64-linux-gnu/dri

启动抓屏的应用程序

使用以下命令启动对应 Screen 的抓屏应用程序,以 glxgears 为例:

export DISPLAY=:0.1
glxgears -fullscreen

启动抓屏编码应用程序

使用以下命令启动抓屏编码应用程序 MtCaptureToEncodeDemo,以生成编码数据:

MtCaptureToEncodeDemo -n 9000 -f 60 -s 1 -c 0 -o test

查看抓屏编码应用程序的用法

如果需要查看更多关于 MtCaptureToEncodeDemo 应用程序的用法,可以执行以下命令:

MtCaptureToEncodeDemo -h
MtCaptureToEncodeDemo: option requires an argument -- 'h'
Usage: MtCaptureToEncodeDemo [options]

Options:
-n <n> Number of frames to capture (default: 1000)
-f <n> Target fps (default: 60)
-o <str> Name of the output file
-x <n> Grab frame start x (default: 0)
-y <n> Grab frame start y (default: 0)
-w <n> Grab frame width (default: screen width)
-h <n> Grab frame height (default: screen height)
-p <n> Src pixel format (0-BGRA; 1-NV12)
-W <n> Dst frame width (default equal w)
-H <n> Dst frame height (default equal h)
-s <n> Select capture screen (default primary)
-c <n> Encode Type (0-h264; 1-h265; default h264)
-b <n> Average bit rate (kbps, default 8000 kbps)
-E <n> Export bitstream to file (0-NO; 1-Yes, default Yes)
-i <n> Show information about DS (0-NO; 1-Yes, default NO)
-m <n> Enable hardware mouse (0-NO; 1-Yes, default No)
-d <n> Use damage mode to capture screen (0-NO; 1-Yes, default NO)

更多抓屏编码用法请参考 DirectStream API 文档。

附录


集显作为主显

以下是 xorg.conf 的配置示例,其中包含一张集显和两张 MT 显卡,三个 Screen 叠加摆放。

# X.Org X server configuration file.

Section "Device"
Identifier "Video Device0"
Driver "modesetting"
BusID "PCI:5:00:0"
EndSection

Section "Monitor"
Identifier "Monitor0"
EndSection

Section "Screen"
Identifier "Screen0"
Monitor "Monitor0"
Device "Video Device0"
EndSection

Section "Device"
Identifier "Video Device1"
Driver "mtgpu"
BusID "PCI:1:00:0"
EndSection

Section "Monitor"
Identifier "Monitor1"
Modeline "1024x768_60.00" 63.50 1024 1072 1176 1328 768 771 775 798 -hsync +vsync
Option "PreferredMode" "1024x768_60.00"
EndSection

Section "Screen"
Identifier "Screen1"
Monitor "Monitor1"
Device "Video Device1"
EndSection

Section "Device"
Identifier "Video Device2"
Driver "mtgpu"
BusID "PCI:129:00:0"
EndSection

Section "Monitor"
Identifier "Monitor2"
Modeline "1024x768_60.00" 63.50 1024 1072 1176 1328 768 771 775 798 -hsync +vsync
Option "PreferredMode" "1024x768_60.00"
EndSection

Section "Screen"
Identifier "Screen2"
Monitor "Monitor2"
Device "Video Device2"
EndSection

Section "OutputClass"
Identifier "mtgpu display"
MatchDriver "mtgpu"
EndSection

Section "ServerLayout"
Identifier "Server Layout"
Screen 0 "Screen0" 0 0
Screen 1 "Screen1" 0 0
Screen 2 "Screen2" 0 0
EndSection

Section "ServerFlags"
Option "DefaultServerLayout" "Server Layout"
Option "PrimaryBusDriver" "mtgpu"
Option "AutoAddGPU" "off"
EndSection

MT 显卡作为主显

以下是 xorg.conf 的配置示例,其中包含一张集显和两张 MT 显卡,三个 Screen 叠加摆放。

# X.Org X server configuration file.

Section "Device"
Identifier "Video Device0"
Driver "mtgpu"
BusID "PCI:1:00:0"
EndSection

Section "Monitor"
Identifier "Monitor0"
Modeline "1024x768_60.00" 63.50 1024 1072 1176 1328 768 771 775 798 -hsync +vsync
Option "PreferredMode" "1024x768_60.00" EndSection

Section "Screen"
Identifier "Screen0"
Monitor "Monitor0"
Device "Video Device0"
EndSection

Section "Device"
Identifier "Video Device1"
Driver "modesetting"
BusID "PCI:5:00:0"
EndSection

Section "Monitor"
Identifier "Monitor1"
EndSection

Section "Screen"
Identifier "Screen1"
Monitor "Monitor1"
Device "Video Device1"
EndSection

Section "Device"
Identifier "Video Device2"
Driver "mtgpu"
BusID "PCI:129:00:0"
EndSection

Section "Monitor"
Identifier "Monitor2"
Modeline "1024x768_60.00" 63.50 1024 1072 1176 1328 768 771 775 798 -hsync +vsync
Option "PreferredMode" "1024x768_60.00"
EndSection

Section "Screen"
Identifier "Screen2"
Monitor "Monitor2"
Device "Video Device2"
EndSection

Section "OutputClass"
Identifier "mtgpu display"
MatchDriver "mtgpu"
EndSection

Section "ServerLayout"
Identifier "Server Layout"
Screen 0 "Screen0" 0 0
Screen 1 "Screen1" 0 0
Screen 2 "Screen2" 0 0
EndSection

Section "ServerFlags"
Option "DefaultServerLayout" "Server Layout"
Option "PrimaryBusDriver" "mtgpu"
Option "AutoAddGPU" "off"
EndSection

示例输出

root@mccx:/usr/local/etc/X11# Xorg &
[1] 239616
root@mccx:/usr/local/etc/X11#
X.Org X Server 1.20.10
X Protocol Version 11, Revision 0
Build Operating System: Linux
Current Operating System: Linux mccx 5.4.0-42-generic #46-Ubuntu SMP Fri Jul 10 00:24:02 UTC 2020 x86_64
Kernel command line: BOOT_IMAGE=/vmlinuz-5.4.0-42-generic root=/dev/mapper/ubuntu--vg-ubuntu--lv ro crashkernel=4096M
Build Date: 12 April 2023 04:11:42PM

Current version of pixman: 0.38.4
Before reporting problems, check http://wiki.x.org
to make sure that you have the latest version.
Markers: (--) probed, (**) from config file, (==) default setting,
(++) from command line, (!!) notice, (II) informational,
(WW) warning, (EE) error, (NI) not implemented, (??) unknown.
(==) Log file: "/usr/local/var/log/Xorg.0.log", Time: Thu Apr 13 17:27:43 2023
(==) Using config file: "/usr/local/etc/X11/xorg.conf"
(==) Using system config directory "/usr/local/share/X11/xorg.conf.d"
(II) MTGPU(0): Initializing kms color map for depth 24, 8 bpc.
(II) MTGPU(1): Initializing kms color map for depth 24, 8 bpc.
(II) MTGPU(2): Initializing kms color map for depth 24, 8 bpc.
(II) MTGPU(3): Initializing kms color map for depth 24, 8 bpc.
(II) MTGPU(4): Initializing kms color map for depth 24, 8 bpc.
(II) MTGPU(5): Initializing kms color map for depth 24, 8 bpc.
(II) MTGPU(6): Initializing kms color map for depth 24, 8 bpc.
(II) MTGPU(7): Initializing kms color map for depth 24, 8 bpc.