Linux 常用定制
APT 软件源配置
1. 查看软件版本,根据版本查找软件源替换
$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 20.04.6 LTS
Release: 20.04
Codename: focal
2. 软件源路径
Tip
旧版本 APT 系统源配置文件为 sources.list(One-Line-Style)格式文件 新版本 APT 系统源配置文件为 DEB822 格式 .sources 文件 (如 Debian12、Ubuntu24.04 等系统)
3. 修改软件源为中科大镜像源
sources.list 格式
DEB22 格式
# Debian 系统
sudo sed -i 's/deb.debian.org/mirrors.ustc.edu.cn/g' /etc/apt/sources.list.d/debian.sources
# Ubuntu 系统
sudo sed -i 's/deb.debian.org/mirrors.ustc.edu.cn/g' /etc/apt/sources.list.d/ubuntu.sources
# 更新源缓存
sudo apt update
开机自启程序
开机自启动脚本:
操作示例:
赋予脚本运行权限,将开机启动程序命令添加至kickpi.sh脚本中,实现开机自启。
开机自启服务
添加 /usr/lib/systemd/system/test-boot.service 服务配置文件
[Unit]
Description=boot test service
After=graphical.target
[Service]
Type=simple
ExecStart=/usr/bin/test.sh
User=root
Environment=DISPLAY=:0
[Install]
WantedBy=graphical.target
添加 /usr/bin/test.sh 脚本及权限,启动后,可通过 /tmp/test.log 日志确认是否启动成功。
$ sudo vim /usr/bin/test.sh
#!/bin/bash
echo "hello test boot service" > /tmp/test.log
$ sudo chmod 777 /usr/bin/test.sh
开启自启服务
关闭自启服务
串口自动登录
通过串口登录时,默认登录方式
vim /lib/systemd/system/serial-getty@.service
-ExecStart=-/sbin/agetty --autologin root --keep-baud 115200,38400,9600 %I $TERM
+ExecStart=-/sbin/agetty -o '-p -- \\u' --keep-baud 115200,57600,38400,9600 - $TERM
通过串口登录时,默认以 kickpi 用户登录
vim /lib/systemd/system/serial-getty@.service
-ExecStart=-/sbin/agetty -o '-p -- \\u' --keep-baud 115200,57600,38400,9600 - $TERM
+ExecStart=-/sbin/agetty --autologin kickpi --keep-baud 115200,38400,9600 %I $TERM
通过串口登录时,默认以 root 用户登录
vim /lib/systemd/system/serial-getty@.service
-ExecStart=-/sbin/agetty -o '-p -- \\u' --keep-baud 115200,57600,38400,9600 - $TERM
+ExecStart=-/sbin/agetty --autologin root --keep-baud 115200,38400,9600 %I $TERM
用户配置
账号和密码
不同系统的默认用户名和密码如下:
| 系统 | 用户名 | 密码 |
|---|---|---|
| Debian | linaro | linaro |
| Debian | root | root |
| Ubuntu | kickpi | kickpi |
| Ubuntu | root | root |
修改用户密码
Tip
输入当前用户密码例如:kickpi 。
New Password:输入要设置的root密码 (密码不显示)。
Retype new password:再次确认。
password updated successfully:表示成功。
设置root密码
切换用户
Note
最新桌面版系统默认登录用户为:kickpi
执行某些命令时可能需要 root 权限,在命令前添加 sudo 或进入 root 用户。
桌面登录配置
图形化界面默认登录为 kickpi,修改相关显示管理器配置。
确认当前显示管理器
SLiM
修改 silm 配置文件默认登录用户,重启生效。
LightDM
修改 lightdm 配置文件默认登录用户,重启生效。
Tip
由于系统配置不同,路径不同 /etc/lightdm/lightdm.conf /etc/lightdm/lightdm.conf.d/50-myconfig.conf
添加 root 登录权限
sudo vim /etc/pam.d/lightdm-autologin
--auth required pam_succeed_if.so user != root quiet_success
++#auth required pam_succeed_if.so user != root quiet_success
命令行登录配置
查看当前系统启动模式
禁止桌面环境
修改系统默认启动多用户文本模式,重启生效
启用桌面环境
修改系统默认启动图形桌面模式,重启生效
语言配置
Tip
命令执行后,重启生效。
- 设置英文语言
sudo locale-gen en_US.UTF-8
sudo sed -i 's/^# *\(en_US.UTF-8\)/\1/' /etc/locale.gen
sudo echo "LANG=en_US.UTF-8" >> /etc/default/locale
sudo echo "export LC_ALL=en_US.UTF-8" >> /etc/profile.d/zh_CN.sh
sudo echo "export LANG=en_US.UTF-8" >> /etc/profile.d/zh_CN.sh
sudo echo "export LANGUAGE=en_US:en" >> /etc/profile.d/zh_CN.sh
sudo reboot
- 设置中文语言
sudo locale-gen zh_CN.UTF-8
sudo sed -i 's/^# *\(zh_CN.UTF-8\)/\1/' /etc/locale.gen
sudo echo "LANG=zh_CN.UTF-8" >> /etc/default/locale
sudo echo "export LC_ALL=zh_CN.UTF-8" >> /etc/profile.d/zh_CN.sh
sudo echo "export LANG=zh_CN.UTF-8" >> /etc/profile.d/zh_CN.sh
sudo echo "export LANGUAGE=zh_CN:zh" >> /etc/profile.d/zh_CN.sh
sudo reboot
时区配置
Tip
命令执行后,重启生效。
- 设置时区亚洲/上海
- 设置时区美国/纽约
时间配置
系统时间配置
# 设置系统当前时间
date -s "2026-04-14 15:30:00"
# 只设置日期
date -s "2026-04-14"
# 只设置时间
date -s "15:35:00"
# 查看系统时间
date
RTC 时间配置
# 看硬件 RTC 时间
hwclock -r
# 如果有多个 RTC,可指定设备
hwclock -r --rtc=/dev/rtc0
# 把系统时间写入硬件 RTC
hwclock -w
hwclock --systohc
# 硬件 RTC 时间同步到系统时间
hwclock -s
hwclock --hctosys
RTC 节点
配置开机同步 RTC 时间
$ vim /etc/init.d/rockchip.sh
- [ -f /dev/rtc0 ] && hwclock --systohc
+ [ -f /dev/rtc0 ] && hwclock --hctosys
开机 LOGO
Note
1. rockchip 平台区分 Uboot、Kernel两个阶段显示LOGO,logo.bmp 为Uboot阶段,logo_kernel.bmp为Kernel阶段。
2. LOGO的分辨率必须小于显示屏的分辨率。
3. 替换的LOGO格式需和原本LOGO图片格式一致,例如bmp、bit 位等参数。
| 主控 | 型号 | LOGO路径 |
|---|---|---|
| A133 | K5/K5C | device/config/chips/a133/configs/c3/android/bootlogo.bmp |
| RK3562/RK3568/RK3588 | K1/K1B/K3/K8 | kerne/logo.bmp kernel/logo_kernel.bmp |
| RK3576 | K7/K7C | kernel-6.1/logo.bmp kernel-6.1/logo_kernel.bmp |
| T527 | K9 | device/config/chips/t527/boot-resource/boot-resource/bootlogo.bmp |
屏幕显示方向配置
- 查看当前屏幕信息
Tip
根据打印信息可知,当前系统为单屏幕显示,并且显示设备名称为 HDMI-1。
$ xrandr
Screen 0: minimum 320 x 200, current 1920 x 1080, maximum 16384 x 16384
HDMI-1 connected primary 1920x1080+0+0 (normal left inverted right x axis y axis) 0mm x 0mm
1920x1080 60.00*+ 60.00 50.00 59.94 30.00 24.00 29.97 23.98
1920x1080i 60.00 50.00 50.00 59.94
1280x1024 60.02
1440x900 59.90
1360x768 60.02
1280x720 60.00 50.00 50.00 59.94
1024x768 60.00
800x600 60.32
720x576 50.00 50.00
720x576i 50.00
720x480 60.00 60.00 59.94 59.94
720x480i 60.00 59.94
640x480 60.00 59.94 59.94
- 旋转屏幕显示方向
Note
normal:将显示设备正常的显示。
left:将显示设备逆时针旋转 90 度。
inverted:将显示设备顺时针旋转 90 度。
right:将显示设备旋转 180 度。
设置指定显示设备的旋转方向
操作示例:配置 HDMI-1 显示逆时针旋转 90 度。
- 开机自启动旋转服务参考
Ubuntu系统
配置 LVDS-1 显示逆时针旋转 90 度
root@ubuntu2004:~# vim /etc/systemd/system/xrandr-startup.service
[Unit]
Description=Start xrandr script on boot
After=graphical.target
[Service]
Type=oneshot
Environment="DISPLAY=:0"
Environment="XAUTHORITY=/home/kickpi/.Xauthority"
ExecStart=/usr/bin/xrandr --output LVDS-1 --rotate left
User=kickpi
[Install]
WantedBy=graphical.target
Debian系统
配置 DSI-1 显示逆时针旋转 90 度
vim /etc/systemd/system/xrandr-startup.service
[Unit]
Description=Start xrandr script on boot
After=graphical.target
[Service]
Type=oneshot
TimeoutStartSec=10
Environment="DISPLAY=:0"
Environment="XAUTHORITY=/home/linaro/.Xauthority"
ExecStart=/usr/local/bin/wait-for-x11.sh /usr/bin/xrandr --output DSI-1 --rotate left
User=linaro
[Install]
WantedBy=graphical.target
脚本配置
root@linaro-alip:/# cat /usr/local/bin/wait-for-x11.sh
#!/bin/bash
while ! xrandr --query > /dev/null 2>&1; do
sleep 1
echo "Waiting for X server to be ready..."
done
exec "$@"
服务配置
触摸显示方向配置
1. 安装工具
2. 查看设备和ID,根据打印信息可知,当前触摸设备为"goodix-ts",id为10
3. 配置输入设备的校准矩阵
操作示例:设置 goodix-ts 设备的校准矩阵
4. 配置输入设备坐标转换矩阵
// normal
$ xinput set-prop $id 'Coordinate Transformation Matrix' 1 0 0 0 1 0 0 0 1
// left
$ xinput set-prop $id 'Coordinate Transformation Matrix' 0 -1 1 1 0 0 0 0 1
// right
$ xinput set-prop $id 'Coordinate Transformation Matrix' 0 1 0 -1 0 1 0 0 1
// inverted
$ xinput set-prop $id 'Coordinate Transformation Matrix' -1 0 1 0 -1 1 0 0 1
操作示例:根据旋转情况使用对应命令,设置 goodix-ts 设备的坐标转换矩阵为left
5. 校准触摸
操作示例:校准 goodix-ts 设备
- 永久修改触摸方向
xinput修改成功后,修改旋转触摸。
Tip
Option "TransformationMatrix" "0 -1 1 1 0 0 0 0 1" 为添加的内容
vim /usr/share/X11/xorg.conf.d/40-libinput.conf
Section "InputClass"
Identifier "libinput touchscreen catchall"
MatchIsTouchscreen "on"
MatchDevicePath "/dev/input/event*"
Driver "libinput"
Option "TransformationMatrix" "0 -1 1 1 0 0 0 0 1"
EndSection
网络配置
常用配置
- 显示所有网络接口信息
Tip
网络接口名称根据实际情况会有所不同。
$ ifconfig -a
enP3p49s0: flags=4099<UP,BROADCAST,MULTICAST> mtu 1500
ether 82:76:b8:2f:96:6d txqueuelen 1000 (Ethernet)
RX packets 0 bytes 0 (0.0 B)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 0 bytes 0 (0.0 B)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
device interrupt 168 base 0xd000
enP4p65s0: flags=4099<UP,BROADCAST,MULTICAST> mtu 1500
ether 6a:cb:0c:a5:15:e0 txqueuelen 1000 (Ethernet)
RX packets 0 bytes 0 (0.0 B)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 0 bytes 0 (0.0 B)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
device interrupt 179 base 0x1000
...
- 显示特定网络接口信息
Tip
要显示特定网络接口(如eth0)的信息,可输入ifconfig eth0。
- 设置 IP 地址
操作示例:要为eth0接口设置 IP 地址为192.168.1.101,子网掩码为255.255.255.0,
- 启用网络接口
- 禁用网络接口
操作示例:禁用eth0接口
- 设置 MAC 地址
Tip
不同操作系统间可能存在一些差异,部分系统可能不允许通过 ifconfig 直接设置或需额外步骤进行设置。
静态IP地址配置
操作示例1:eth0网卡通过netplan的yaml配置静态IP地址为192.168.1.50
$ vim /etc/netplan/01-network-manager-all.yaml
network:
version: 2
ethernets:
eth0:
dhcp4: no
addresses: [192.168.199.160/24]
optional: true
routes:
- to: default
via: 192.168.199.1
nameservers:
addresses: [8.8.8.8, 8.8.4.4]
操作示例2:eth1网卡通过network/interfaces配置静态IP地址为192.168.77.196
$ sudo vim /etc/network/interfaces.d/eth1.cfg
auto eth1
iface eth1 inet static
address 192.168.77.196
netmask 255.255.255.0
gateway 192.168.77.1
dns-nameservers 8.8.4.4 8.8.8.8
重启服务
WIFI 热点配置
- 查看是否支持AP模式
Tip
AP/VLAN表示硬件支持。
$ iw list | grep AP
Device supports AP-side u-APSD.
* AP
* AP/VLAN
HE Iftypes: AP
HE Iftypes: AP
* wake up on EAP identity request
* AP/VLAN
* #{ managed } <= 1, #{ AP, P2P-client, P2P-GO } <= 1, #{ P2P-device } <= 1,
Driver supports full state transitions for AP/GO clients
Driver/device bandwidth changes during BSS lifetime (AP/GO mode)
* AP: 0x00 0x10 0x20 0x30 0x40 0x50 0x60 0x70 0x80 0x90 0xa0 0xb0 0xc0 0xd0 0xe0 0xf0
* AP/VLAN: 0x00 0x10 0x20 0x30 0x40 0x50 0x60 0x70 0x80 0x90 0xa0 0xb0 0xc0 0xd0 0xe0 0xf0
* AP: 0x00 0x20 0x40 0xa0 0xb0 0xc0 0xd0
* AP/VLAN: 0x00 0x20 0x40 0xa0 0xb0 0xc0 0xd0
虚拟接口热点
1. 安装依赖包
2. 创建虚拟网卡
Note
< wirelessname > 是真实无线网卡名,可通过ifconfig查看,< virtualwlanname > 是虚拟的无线网卡名。
操作示例:
3. 为虚拟网卡添加物理地址
Tip
< virtualwlanname >是虚拟的无线网卡名,可随意填写,产生冲突更换命名即可。
操作示例:
4. 查看创建情况
Warning
重启系统后,创建的虚拟网卡会失效。
$ sudo iw dev wlo2 info
Interface wlo2
ifindex 5
wdev 0x5
addr 22:33:44:55:66:00
type managed
wiphy 0
txpower 0.00 dBm
multicast TXQ:
qsz-byt qsz-pkt flows drops marks overlmt hashcol tx-bytestx-packets
0 0 0 0 0 0 0 0 0
5. 下载安装工具 create_ap
6. 使用create_ap创建热点
Note
< wirelessname > :无线网卡名称
< virtualwlanname > :虚拟网卡名称
< SSID > < password >:热点Wifi名称和密码。
操作示例:
如果创建的热点卡死,开启热点时报如下错误:
#RTNETLINK answers: Device or resource busy
#ERROR: Maybe your WiFi adapter does not fully support virtual interfaces.
# Try again with --no-virt.
停止之前创建的热点,重新启动开启热点。
物理接口热点
1. 安装依赖和create_ap
$ sudo apt-get install util-linux hostapd dnsmasq iptables iproute2 haveged make
$ git clone https://github.com/oblique/create_ap
$ cd */create_ap
$ sudo make install
2. 修改防火墙
$ sudo update-alternatives --set iptables /usr/sbin/iptables-legacy
$ sudo update-alternatives --set ip6tables /usr/sbin/ip6tables-legacy
$ iptables --version
3. 创建热点MyAccessPoint,密码:12345678,共享eth0网络
4. 使用 create_ap 后恢复 WiFi 节点
USB 摄像头
- 检查摄像头设备节点
- ffmpeg 打开摄像头
操作示例:
文件系统备份
导出文件系统
1.确认 ff_export_rootfs 脚本是否存在,不存在则下载 ff_export_rootfs 脚本拷贝至开发板 /usr/bin/ 路径上。
2. 插入U盘(≥ 16GB)或其他存储设备,导出文件系统至 U 盘路径。
Note
由于 FAT32 单文件不可超出 4G,请格式化 U 盘为 ext4、exfat 格式。 生成包名格式:例如 rootfs.img。 /mnt/usb :U盘挂载目录。
sudo chmod +x /usr/bin/ff_export_rootfs
sudo ./ff_export_rootfs $(out_path) -t ext4
# 导出镜像到 /mnt/usb 路径下
sudo ./ff_export_rootfs /mnt/usb -t ext4
3. 确保导出文件系统格式。
file Ubuntu_24.04.2_LTS_ext4_202503062020.img
# 打印信息类似 Ubuntu_24.04.2_LTS_ext4_202503062020.img: Linux rev 1.0 ext4 filesystem data, UUID=71584b93-ad99-452e-a8e2-6b9ed76eff7d, volume name "rootfs" (extents) (64bit) (large files) (huge files)
更新镜像文件系统
rootfs.img 可用于 RK 平台重新打包完整镜像,制作完整升级包 update-*.img 用于批量烧录,参考 RK 镜像解包和打包。
单独替换文件系统
Tip
通过这种方式替换后的 rootfs 可能存在 mount 挂载 UUID 问题,通过blkid查看正确的UUID,修改 /etc/fstab。
rootfs.img 可用于 RK 平台单独烧录替换主板文件系统,烧录后若根文件系统占用的存储空间与 rootfs.img 大小一致,需要执行命令还原大小。
RK 镜像解包与打包
RK固件在Linux中如何进行解包和重新打包的教程。
- 工具获取
1.点击获取工具,或从SDK寻找工具。
//Linux-SDK源码路径:
rk356x-linux\tools\linux\Linux_Pack_Firmware
//Android-SDK源码路径:
rk-android13.0\RKTools\linux\Linux_Pack_Firmware
- 解包
1. 将 Linux_Pack_Firmware 放到你的虚拟机工作目录中。
2. 将需要解包的固件放置于rockdev目录下,重命名为:update.img。
cd Linux_Pack_Firmware/rockdev
mv update-rk3568-kickpi-k1-linux-debian--20250403-150845.img update.img
3. 运行脚本进行解包
4. 解包文件位置。
- 打包
Tip
将解包出的镜像修改完成后可以进行重新打包。
1. 将文件拷贝至rockdev对应路径,删除之前用于解包的update.img镜像。
2. 修改package-file文件,将文件路径修改为对应文件放置路径。
# NAME PATH
package-file package-file
parameter Image/parameter.txt
bootloader Image/MiniLoaderAll.bin
uboot Image/uboot.img
misc Image/misc.img
boot Image/boot.img
recovery Image/recovery.img
backup RESERVED
rootfs Image/rootfs.img
3. 运行对应版本脚本进行打包。
4. 打包完成的镜像位于rockdev目录下。
RK 系统分区配置
Warning
重新分区均需要重新烧录,如需保留系统,不进行格式化,请先备份rootfs。
可通过两种方式完成修改:
- 完整镜像修改
参考 固件解包和打包,修改parameter.txt文件后重新打包。
- SDK内修改
对应路径下文件修改完成后,重新编译。
RK356x:
RK3588:
修改内容:
重新分区主要修改分区文件parameter.txt
操作示例:将剩余所有空间放至根目录下
mtdparts=:0x00002000@0x00004000(uboot),0x00002000@0x00006000(misc),0x00020000@0x00008000(boot),0x00040000@0x00028000(recovery),0x00010000@0x00068000(backup),-@0x00078000(rootfs:grow)
Note
文件分区规则:
分区大小:0x01c00000*512Byte/1024/1024/1014 ≈ 14G
分区起始地址:前一个分区起始地址+前一个分区大小
最后一个分区格式为:-@0x0xxxxx(xxx:grow) -表示剩余所有空间自适应。
Linux系统需要额外增加一步修改,注释oem userdate的自动挂载。
编译工具配置
安装命令
Samba 配置
1. 安装samba
2. 给予共享的文件权限
3. 添加samba用户
4. 配置samba
在smb.conf末尾处添加以下内容:
Tip
[kickpi] 为共享看到的文件夹名称
5. 重启服务
NFS 配置
- 环境配置
- 服务器端
1. 配置共享的文件
$ mkdir /home/kickpi/nfs_share
$ chmod 777 /home/kickpi/nfs_share
$ vi /etc/exports
+ /home/kickpi/nfs_share *(rw,sync,no_subtree_check,insecure)
2. 启动服务
3. 查看当前服务器共享文件,证明共享成果
- 客户端
1. 查看服务器共享文件
2. 挂载文件夹
3. 挂载成功
SSH 配置
SSH连接
在命令行中输入命令进行 SSH 连接:
root 登录配置
$ vim /etc/ssh/sshd_config
+ PermitRootLogin yes
$ cat /etc/ssh/sshd_config | grep PermitRootLogin
PermitRootLogin yes
$ sudo /etc/init.d/ssh restart
删除密钥
目标 Linux 主机重装系统 / 重置 SSH → 密钥指纹变了,Windows 本地还保存着旧的无效密钥 → 拒绝连接
SCP 文件传输
1. 用法提示
usage: scp [-346ABCOpqRrsTv] [-c cipher] [-D sftp_server_path] [-F ssh_config]
[-i identity_file] [-J destination] [-l limit]
[-o ssh_option] [-P port] [-S program] source ... target
2. 快速使用
Note
$local_path:本地文件路径
$username:用户名
$ip:主板ip
$target_path:目标路径
操作示例:
4G/5G 配置
脚本配置
4G/5G 移动模块开机自动配置,检测模块是否存在,进行配置拨号
Tip
开机默认仅会拨号一次,在信号不好或通讯异常情况,可能会存在拨号失败的情况,若无网络,可运行拨号脚本进行重试。
$ cat /usr/bin/hardware-optimization
4g_config() {
wait_time=30
for((i=1;i<=$wait_time;i++));
do
if [ -c /dev/ttyUSB2 ]; then
echo "$i: 4g /dev/ttyUSB2 exists and is a character device." >> $LOG_FILE
/usr/bin/4G_dialing.sh
break;
else
echo "$i: 4g /dev/ttyUSB2 does not exist or is not a character device." >> $LOG_FILE
sleep 1
fi
done
}
拨号脚本,已适配 RG200U / EC200 / EC20
网络测试
1. 判断是否接入模块,查看日志进行判断。
Tip
/dev/ttyUSB2 exists and is a character device.代表设备识别成功
$ cat /tmp/kickpi-hardware.log
1: 4g /dev/ttyUSB2 does not exist or is not a character device.
2: 4g /dev/ttyUSB2 does not exist or is not a character device.
...
24: 4g /dev/ttyUSB2 does not exist or is not a character device.
25: 4g /dev/ttyUSB2 exists and is a character device.
或查看/dev/ttyUSB2 是否存在
2. 判断是否拨号成功
Tip
设备名称格式为 enx*(* 为可变后缀),具体名称请参照实际环境。
(console)$ ifconfig
enxca7f24fb0e94: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 10.138.192.102 netmask 255.255.255.0 broadcast 10.138.192.255
inet6 fe80::583f:ed51:782d:318d prefixlen 64 scopeid 0x20<link>
ether ca:7f:24:fb:0e:94 txqueuelen 1000 (Ethernet)
RX packets 181 bytes 15185 (14.8 KiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 194 bytes 17394 (16.9 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
3. Ping网络测试
Tip
指定设备 enx3e003a5bd6ad 进行ping网络测试。
(console)$ ping www.baidu.com -I enxca7f24fb0e94
PING www.wshifen.com (103.235.46.115) from 10.138.192.102 enxca7f24fb0e94: 56(84) bytes of data.
64 bytes from 103.235.46.115 (103.235.46.115): icmp_seq=1 ttl=45 time=1094 ms
64 bytes from 103.235.46.115 (103.235.46.115): icmp_seq=2 ttl=45 time=3924 ms
64 bytes from 103.235.46.115 (103.235.46.115): icmp_seq=3 ttl=45 time=1870 ms
定制拨号功能
主板默认使用官方 quectel-CM 工具进行拨号,如需修改定制拨号功能,下载 移远官方Linux软件 进行定制。
GPU
GPU 使用率
操作示例:
实时监测 GPU 使用率,通过移动鼠标、拖动窗口或运行 GPU 专项测试的方式,即可判断硬件加速功能是否成功启用
GLmark2 性能测试
1. 使用 Rockchip官方提供的 npu 测试脚本
$ ls /rockchip-test/gpu
gpu_test.sh test_fullscreen_glmark2.sh test_normal_glmark2.sh test_offscreen_glmark2.sh test_stress_glmark2.sh
2. Debian / Ubuntu 文件系统已内置 glmark2-es 性能测试工具,使用虚拟终端或调试串口终端,执行以下命令开始 GPU 性能测试
Tip
Surface Size: 800x600 windowed glmark2 测试分数为1405。
测试结果仅做参考,实际分数以实际测量为准。
root@linaro-alip:/# source /rockchip-test/gpu/test_offscreen_glmark2.sh
run glmark2 x11 with offscreen......
arm_release_ver: g13p0-01eac0, rk_so_ver: 10
=======================================================
glmark2 2023.01
=======================================================
OpenGL Information
GL_VENDOR: ARM
GL_RENDERER: Mali-G52
GL_VERSION: OpenGL ES 3.2 v1.g13p0-01eac0.0fd2effaec483a5f4c440d2ffa25eb7a
Surface Config: buf=32 r=8 g=8 b=8 a=8 depth=24 stencil=0 samples=0
Surface Size: 800x600 windowed
=======================================================
=======================================================
glmark2 Score: 1405
=======================================================
NPU
NPU 测试
Rockchip 提供 npu 测试脚本
npu 频率测试脚本 npu_freq_scaling.sh
usage()
{
echo "Usage: npu_freq_scaling.sh [test_second] [every_freq_stay_second]"
echo "example: ./npu_freq_scaling.sh 3600 30"
echo "means npu_freq_scaling.sh will run 1 hour and every cpu frequency stay 30s"
}
操作示例:npu变频运行60秒,每10秒变频一次
# ./npu_freq_scaling.sh 60 10
test will run 60 seconds
every npu frqeucny will stay 10 seconds
set ddr frequency to 700000000
set ddr frequency to 300000000
...
======TEST SUCCESSFUL, QUIT=====
npu 压力测试脚本 npu_stress_test.sh
# ./npu_stress_test.sh
rknn_api/rknnrt version: 2.0.0b0 (35a6907d79@2024-03-24T10:31:14), driver version: 0.9.7
model input num: 1, output num: 1
input tensors:
index=0, name=input, n_dims=4, dims=[1, 224, 224, 3], n_elems=150528, size=150528, fmt=NHWC, type=INT8, qnt_type=AFFINE, zp=0, scale=0.007812
output tensors:
index=0, name=MobilenetV1/Predictions/Reshape_1, n_dims=2, dims=[1, 1001, 0, 0], n_elems=1001, size=2002, fmt=UNDEFINED, type=FP16, qnt_type=AFFINE, zp=0, scale=1.000000
custom string:
Begin perf ...
0: Elapse Time = 2.85ms, FPS = 351.12
1: Elapse Time = 2.70ms, FPS = 370.37
2: Elapse Time = 2.59ms, FPS = 386.85
3: Elapse Time = 2.69ms, FPS = 371.61
4: Elapse Time = 2.62ms, FPS = 381.97
5: Elapse Time = 2.61ms, FPS = 383.44
6: Elapse Time = 2.58ms, FPS = 387.75
7: Elapse Time = 2.70ms, FPS = 370.51
8: Elapse Time = 2.64ms, FPS = 378.36
9: Elapse Time = 2.68ms, FPS = 372.44
---- Top5 ----
0.935059 - 156
0.057037 - 155
0.003881 - 205
0.003119 - 284
0.000172 - 285
Note
性能测试数据解读:
在 Begin perf... 之后的内容,为模型多次推理的性能指标明细,每项数据包含测试轮次序号、单次推理耗时(Elapse Time)以及每秒推理帧数(FPS)。
以 0: Elapse Time = 2.85ms, FPS = 351.12 为例,其含义为第 1 轮模型推理的耗时为 2.85 毫秒,折算后每秒可完成 351.12 次推理运算。其中,FPS 的计算逻辑为1000ms ÷ 单次推理耗时,表征 NPU 的推理效率。
推理结果数据解读:
---- Top5 ----部分为模型推理输出的置信度排名前五的分类结果,每项数据由「类别置信概率」与「类别编号」两部分组成,具体含义如下:
1. 0.935059 - 156:模型判定输入样本属于编号 156 类别的置信概率为 93.51%,该概率值处于较高水平,反映模型对该分类结果的判定可信度高;
2. 后续条目 0.057037 - 155、0.003881 - 205、0.003119 - 284、0.000172 - 285,依次为置信度排名第 2 至第 5 的分类结果,其置信概率呈逐级递减趋势,对应模型对这些类别判定的把握程度逐步降低。
RKNN 部署
MPP
调试信息
开启调试信息
$ export mpp_syslog_perror=1
$ echo 0x100 > /sys/module/rk_vcodec/parameters/mpp_dev_debug
# 开启调试信息后,调用硬件编解码会有类似如下日志信息
[ 893.134037] rk_vcodec: 27b00100.rkvdec:0 session 3705:19 time: 1333 us hw 1312 us
[ 893.167444] rk_vcodec: 27b00100.rkvdec:0 session 3705:19 time: 1381 us hw 1313 us
[ 893.200503] rk_vcodec: 27b00100.rkvdec:0 session 3705:19 time: 1420 us hw 1313 us
关闭调试信息
mpi_enc_test 硬编码
- mpi_enc_test 硬编码测试
usage: mpi_enc_test [options]
-i input_file input frame file
-o output_file output encoded bitstream file
-w width the width of input picture
-h height the height of input picture
-hstride hor_stride the horizontal stride of input picture
-vstride ver_stride the vertical stride of input picture
-f format the format of input picture
-t type output stream coding type
-tsrc source type input file source coding type
-n max frame number max encoding frame number
-g gop reference mode gop_mode:gop_len:vi_len
-rc rate control mode set rc_mode, 0:vbr 1:cbr 2:fixqp 3:avbr
-bps bps target:min:max set tareget:min:max bps
-fps in/output fps set input and output frame rate
-qc quality control set qp_init:min:max:min_i:max_i
-fqc frm quality control set fqp min_i:max_i:min_p:max_p
-s instance_nb number of instances
-v trace option q - quiet f - show fps
-l loop count loop encoding times for each frame
-ini ini file encoder extra ini config file
-slt slt file slt verify data file
-sm scene mode scene_mode, 0:default 1:ipc
编码 H.264 4096x2160 100 帧测试
$ mpi_enc_test -w 4096 -h 2160 -t 7 -o ./test.h264 -n 100
# 测试结果
$ tail -f /var/log/syslog
kickpi mpp[3557]: mpi_enc_test: chn 0 encode 100 frames time 3763 ms delay 27 ms fps 26.57 bps 10605252
编码H.265 4096x2160 100帧测试
$ mpi_enc_test -w 4096 -h 2160 -t 16777220 -o ./test.h265 -n 100
# 测试结果
$ tail -f /var/log/syslog
kickpi mpp[3560]: mpi_enc_test: chn 0 encode 100 frames time 4086 ms delay 36 ms fps 24.47 bps 19594276
mpi_dec_test 硬解码
- mpi_dec_test 硬解码测试
usage: mpi_dec_test [options]
-i input_file input bitstream file
-o output_file output decoded frame file
-w width the width of input bitstream
-h height the height of input bitstream
-t type input stream coding type
-f format output frame format type
-n frame_number max output frame number
-s instance_nb number of instances
-v trace option q - quiet f - show fps
-slt slt file slt verify data file
-help help show help
-bufmode buffer mode hi - half internal (default) i -internal e - external
解码H.264 4096x2160 100帧测试
$ mpi_dec_test -t 7 -i test.h264 -n 100
# 测试结果
$ tail -f /var/log/syslog
kickpi mpp[3564]: mpi_dec_test: decode 100 frames time 596 ms delay 25 ms fps 167.53
解码H.265 4096x2160 100帧测试
$ mpi_dec_test -t 16777220 -i test.h265 -n 100
# 测试结果
$ tail -f /var/log/syslog
kickpi mpp[3569]: mpi_dec_test: decode 100 frames time 803 ms delay 49 ms fps 124.47
第三方软件硬件编解码
Tip
RK 平台 Linux Ubuntu chromium 和 gstreamer 等软件使用硬件编解码存在兼容性问题 RK 平台 Linux Ubuntu24.04 可通过修复脚本配置 chromium 或 gstreamer 软件的硬件编解码,由于兼容性问题,同时只能其中一个软件生效。 RK 平台硬件编解码推荐使用 Linux Debian 系统,兼容适配性较好。
- Chromium 视频测试
主板连接显示器,打开虚拟终端或调试串口终端,执行以下命令开始 Chromium 视频测试
默认配置 chromium 进行调用,若chromium未调用硬解码,需要以下命令进行修复
- gstreamer 视频测试
$ sudo GST_DEBUG=2 gst-launch-1.0 playbin uri=file:///usr/local/test.mp4 video-sink="autovideosink" audio-sink=fakesink
默认配置 chromium 进行调用,若需要 gstreamer 调用硬解码,需要以下命令进行修复(联网环境下进行)
- Chromium 硬件加速测试示例
测试平台:RK3568 Debian11 chromium
测试结果:
1080P_30帧/秒:GPU占用在42%-48%左右;每帧解码时间测试结果日志片段:
[ 639.172225] rk_vcodec: fdf80200.rkvdec:0 session 2268:56 time: 4195 us hw 4095 us
[ 639.180185] rk_vcodec: fdf80200.rkvdec:0 session 2268:56 time: 12116 us hw 7960 us
[ 639.190246] rk_vcodec: fdf80200.rkvdec:0 session 2268:56 time: 19541 us hw 10027 us
...
4K_30帧/秒:GPU占用在60%-68%左右;每帧解码时间测试结果日志片段:
[ 938.649847] rk_vcodec: fdf80200.rkvdec:0 session 2799:80 time: 93967 us hw 27794 us
[ 938.683932] rk_vcodec: fdf80200.rkvdec:0 session 2799:80 time: 93243 us hw 34114 us
[ 938.717400] rk_vcodec: fdf80200.rkvdec:0 session 2799:80 time: 93712 us hw 33463 us
...
常见问题
- Linux系统烧录后第一次开机重启 ?
部分系统为了兼容不同芯⽚,/etc/init.d/rockchip.sh 首次启动时,会根据芯⽚安装各种差异包,例如 libmali 、isp等packages,安装完成后会重启显⽰服务。 如果是独⽴项⽬可以在制作镜像时处理这部分差异即可。
- create_ap出现dnsmasq报错?
创建过程中遇到报错问题
因为create_ap 需要启动 dnsmasq,但是dnsmasq已经启动了
找到dnsmasq对应的PID
@@ -321,9 +321,9 @@ can_transmit_to_channel() {
if [[ $USE_IWCONFIG -eq 0 ]]; then
if [[ $FREQ_BAND == 2.4 ]]; then
- CHANNEL_INFO=$(get_adapter_info ${IFACE} | grep " 24[0-9][0-9] MHz \[${CHANNEL_NUM}\]")
+ CHANNEL_INFO=$(get_adapter_info ${IFACE} | grep " 24[0-9][0-9]\(\.0\+\)\? MHz \[${CHANNEL_NUM}\]")
else
- CHANNEL_INFO=$(get_adapter_info ${IFACE} | grep " \(49[0-9][0-9]\|5[0-9]\{3\}\) MHz \[${CHANNEL_NUM}\]")
+ CHANNEL_INFO=$(get_adapter_info ${IFACE} | grep " \(49[0-9][0-9]\|5[0-9]\{3\}\)\(\.0\+\)\? MHz \[${CHANNEL_NUM}\]")
fi
[[ -z "${CHANNEL_INFO}" ]] && return 1
[[ "${CHANNEL_INFO}" == *no\ IR* ]] && return 1
@@ -339,7 +339,9 @@ can_transmit_to_channel() {
# taken from iw/util.c
ieee80211_frequency_to_channel() {
- local FREQ=$1
+ local FREQ_MAYBE_FRACTIONAL=$1
+ local FREQ=${FREQ_MAYBE_FRACTIONAL%.*}
if [[ $FREQ -eq 2484 ]]; then
echo 14
elif [[ $FREQ -lt 2484 ]]; then
@@ -356,7 +358,7 @@ ieee80211_frequency_to_channel() {
}
is_5ghz_frequency() {
- [[ $1 =~ ^(49[0-9]{2})|(5[0-9]{3})$ ]]
+ [[ $1 =~ ^(49[0-9]{2})|(5[0-9]{3})(\.0+)?$ ]]
}
is_wifi_connected() {
return 1
}
- slim 登录器修改用户名异常
1. 启动后修改 hostname 为新用户名
2. 修改自动登录的用户配置为新用户名
3. usermod 修改用户名
Tip
kickpi-new:新用户名
kickpi: 旧用户名
4. 设置新用户名目录
5. 清除图像化界面缓存
6. 重新配置 silm 图像化