Rockchip RK3399 - 移植ubuntu 20.04.4根文件系统
----------------------------------------------------------------------------------------------------------------------------
开发板 :NanoPC-T4
开发板
eMMC
:16GB
LPDDR3
:4GB
显示屏 :15.6
英寸HDMI
接口显示屏
u-boot
:uboot 2023.04
linux
:6.3
----------------------------------------------------------------------------------------------------------------------------
在上一篇文章中,我们介绍了通过busybox
构建根文件系统,但是我们在使用的过程中有个致命的问题,就是缺少各种命令以及各种开发环境,比如python
,jdk
、mysql
啊。比如我们需要使用python
开发环境,那么我们就得自己去下载python
源码编译,然后移植到开发板中。那我们就开始想,我们是不是像centos
、ubuntu
这些文件系统一样,直接通过apt
、yum
命令搞定这些安装呢?
幸运的是,我们搜索网上资料发现,ubuntu
针对不同的CPU
架构提供相应的ubuntu base
根文件系统,目前提供的架构有amd64
、arm64
、armhf
、i386
、s390x
、ppc64
。因此我们可以直接构建基于ubuntu base
的根文件系统。
一、ubuntu base
ubuntu base
是用于为特定需求创建自定义映像的最小rootfs
,是ubuntu
可以运行的最小环境。
1.1 下载源码
下载ubuntu-base
的方式有很多,我们可以从官方的地址:《ttp://cdimage.ubuntu.com/ubuntu-base/releases
》。
也可以其它镜像地址下载,如清华源:《https://mirrors.tuna.tsinghua.edu.cn/ubuntu-cdimage/ubuntu-base/releases/
》。
根据需要,下载自己对应的发行版本,这里我们就已20.04
为例;
![](https://gitee.com/zyly2033/blog-pic/raw/master/202404272049271.png)
进入到对应的版本目录后,根据我们的CPU
类型,选择对应的文件下载,这里,我们使用的是RK3399
,64
位的CPU
,我们选择arm64
的版本;
![](https://gitee.com/zyly2033/blog-pic/raw/master/RockchipRK3399-移植ubuntu20.04.4根文件系统.md.assets/1328274-20230529230911109-1675539982.png)
在宿主机ubuntu
命令行运行如下命令,开始下载文件:
root@ubuntu:/work/sambashare/rk3399# wget https://mirrors.tuna.tsinghua.edu.cn/ubuntu-cdimage/ubuntu-base/releases/20.04/release/ubuntu-base-20.04.4-base-arm64.tar.gz
root@ubuntu:/work/sambashare/rk3399# ll ubuntu-base-20.04.4-base-arm64.tar.gz
-rw-r--r-- 1 root root 26228459 Feb 22 2022 ubuntu-base-20.04.4-base-arm64.tar.gz
下载完成后,在宿主机上选择建立一个rootfs/ubuntu
目录,将下载的文件ubuntu-base-20.04.4-base-arm64.tar.gz
解压到该目录下;
root@ubuntu:/work/sambashare/rk3399# mkdir -p rootfs/ubuntu
root@ubuntu:/work/sambashare/rk3399# sudo tar -xpvf ubuntu-base-20.04.4-base-arm64.tar.gz -C rootfs/ubuntu/
root@ubuntu:/work/sambashare/rk3399# cd rootfs/ubuntu/
root@ubuntu:/work/sambashare/rk3399/rootfs/ubuntu# ls
bin boot dev etc home lib media mnt opt proc root run sbin srv sys tmp usr var
需要注意的是:解压后的文件,需要保留ubuntu-base
中的文件权限及所有者,解压时需要root
权限或者sudo
操作,且使用-p
参数保留权限;
1.2 配置
1.2.1 安装qemu
qemu-user-static
是一个仿真器,可以选取arm64
配置文件仿真开发板运行环境,然后挂载下载的ubuntu-base
文件,从而构建ubuntu
文件系统。
root@ubuntu:/work/sambashare/rk3399/rootfs/ubuntu# sudo apt-get install qemu-user-static
由于下载的ubuntu-base
是aarch64
架构的,因此需要拷贝qemu-aarch64-static
到ubuntu/usr/bin/
下;
root@ubuntu:/work/sambashare/rk3399/rootfs/ubuntu# sudo cp /usr/bin/qemu-aarch64-static ./usr/bin/
1.2.2 设置软件源
什么是源?其实吧它就像苹果和案桌的软件应用商店一样,为Linux
用户提供软件下载及更新服务的。Linux
家族有三个软件源系统:
yum
源,使用这种软件管理器的主要是:redhat
,centos
;apt
源,使用这种软件管理器的主要是:ubuntu
;pacman
源,使用这种软件管理器的主要是:archlinux
还有新近崛起的manjaro
;
ubuntu
是外国人开发的系统,默认使用的也是国外的源,但是从国内FQ下载国外的软件(插件)源太慢。其实国内也有很多的镜像源,比如说阿里源,网易源,清华源,中科大源(推荐,不限速),兰州大源等。
需要注意的是,这里要用ARM
源,不能复制我们本机的源。
root@ubuntu:/work/sambashare/rk3399/rootfs/ubuntu# sudo vim ./etc/apt/sources.list
这里我们选择华为国内下载源,这里需要把原内容删除,全部替换为:
deb http://mirrors.huaweicloud.com/ubuntu-ports/ focal main multiverse restricted universe
deb http://mirrors.huaweicloud.com/ubuntu-ports/ focal-backports main multiverse restricted universe
deb http://mirrors.huaweicloud.com/ubuntu-ports/ focal-proposed main multiverse restricted universe
deb http://mirrors.huaweicloud.com/ubuntu-ports/ focal-security main multiverse restricted universe
deb http://mirrors.huaweicloud.com/ubuntu-ports/ focal-updates main multiverse restricted universe
deb-src http://mirrors.huaweicloud.com/ubuntu-ports/ focal main multiverse restricted universe
deb-src http://mirrors.huaweicloud.com/ubuntu-ports/ focal-backports main multiverse restricted universe
deb-src http://mirrors.huaweicloud.com/ubuntu-ports/ focal-proposed main multiverse restricted universe
deb-src http://mirrors.huaweicloud.com/ubuntu-ports/ focal-security main multiverse restricted universe
deb-src http://mirrors.huaweicloud.com/ubuntu-ports/ focal-updates main multiverse restricted universe
如要用于其他版本,把focal
换成其他版本代号即可: 22.04:jammy
;20.04:focal
;18.04:bionic
;16.04:xenial
;14.04:trusty
。
需要下载失败,尝试更换下载源。
其他源,比如清华源:
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu-ports/ focal main restricted universe multiverse
deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu-ports/ focal main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu-ports/ focal-updates main restricted universe multiverse
deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu-ports/ focal-updates main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu-ports/ focal-backports main restricted universe multiverse
deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu-ports/ focal-backports main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu-ports/ focal-security main restricted universe multiverse
deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu-ports/ focal-security main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu-ports/ focal-proposed main restricted universe multiverse
deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu-ports/ focal-proposed main restricted universe multiverse
163
源:
deb http://mirrors.163.com/ubuntu-ports/ focal main restricted universe multiverse
deb http://mirrors.163.com/ubuntu-ports/ focal-security main restricted universe multiverse
deb http://mirrors.163.com/ubuntu-ports/ focal-updates main restricted universe multiverse
deb http://mirrors.163.com/ubuntu-ports/ focal-proposed main restricted universe multiverse
deb http://mirrors.163.com/ubuntu-ports/ focal-backports main restricted universe multiverse
deb-src http://mirrors.163.com/ubuntu-ports/ focal main restricted universe multiverse
deb-src http://mirrors.163.com/ubuntu-ports/ focal-security main restricted universe multiverse
deb-src http://mirrors.163.com/ubuntu-ports/ focal-updates main restricted universe multiverse
deb-src http://mirrors.163.com/ubuntu-ports/ focal-proposed main restricted universe multiverse
deb-src http://mirrors.163.com/ubuntu-ports/ focal-backports main restricted universe multiverse
1.2.3 配置DNS
为了可以联网更新软件,我们拷贝本机的dns
配置文件到根文件系统;
root@ubuntu:/work/sambashare/rk3399/rootfs/ubuntu# sudo cp /etc/resolv.conf ./etc/resolv.conf
然后在/etc/resolv.conf
文件中添加dns
:
root@ubuntu:/work/sambashare/rk3399/rootfs/ubuntu# sudo vim ./etc/resolv.conf
添加内容如下:
nameserver 8.8.8.8
nameserver 114.114.114.114
修改/etc/systemd/resolved.conf
:
[Resolve]
DNS=8.8.8.8 114.114.114.114
1.3 挂载/卸载ubuntu-base
文件系统
在rootfs
目录下创建挂载脚本mnt_ubuntu.sh
:
#!/bin/bash
mnt() {
echo "MOUNTING"
sudo mount -t proc /proc ${2}proc
sudo mount -t sysfs /sys ${2}sys
sudo mount -o bind /dev ${2}dev
sudo mount -o bind /dev/pts ${2}dev/pts
sudo chroot ${2}
}
umnt() {
echo "UNMOUNTING"
sudo umount ${2}proc
sudo umount ${2}sys
sudo umount ${2}dev/pts
sudo umount ${2}dev
}
if [ "$1" == "-m" ] && [ -n "$2" ] ;
then
mnt $1 $2
elif [ "$1" == "-u" ] && [ -n "$2" ];
then
umnt $1 $2
else
echo ""
echo "Either 1'st, 2'nd or both parameters were missing"
echo ""
echo "1'st parameter can be one of these: -m(mount) OR -u(umount)"
echo "2'nd parameter is the full path of rootfs directory(with trailing '/')"
echo ""
echo "For example: ch-mount -m /media/sdcard/"
echo ""
echo 1st parameter : ${1}
echo 2nd parameter : ${2}
fi
增加脚本执行权限:
root@ubuntu:/work/sambashare/rk3399/rootfs# sudo chmod +x mnt_ubuntu.sh
1.3.1 挂载文件系统
执行如下命令将会挂载ubuntu-base
文件系统;
root@ubuntu:/work/sambashare/rk3399/rootfs# ./mnt_ubuntu.sh -m ubuntu/
执行该命令实际上就是执行:
sudo mount -t proc /proc ubuntu/proc
sudo mount -t sysfs /sys ubuntu/sys
sudo mount -o bind /dev ubuntu/dev
sudo mount -o bind /dev/pts ubuntu/dev/pts
sudo chroot ubuntu/
(1) proc
文件系统是指一类虚拟文件系统,它不是从磁盘上的分区中读取数据,而是通过内核在内存中动态生成的。
proc
文件系统通常用于提供有关系统内核和进程信息的接口,例如系统内存使用情况、硬件设备信息等。在Linux
系统中挂载proc
文件系统的命令格式如下:
mount -t proc [选项] /proc [挂载点]
其中,-t proc
参数表示将要挂载的文件系统类型是proc
文件系统;/proc
表示要挂载的proc
文件系统的挂载点;ubuntu/proc
表示挂载点在当前目录下的一个名为ubuntu
的子目录中的proc
子目录。通过这个命令,可以将proc
文件系统挂载到指定的挂载点,以便访问其中包含的有关系统内核和进程信息的接口。
(2)mount -y sysfs
命令和mount -t proc
同理;
(3) mount -o bind
命令将前一个目录挂载到后一个目录上,所有对后一个目录的访问其实都是对前一个目录的访问;
(4) chroot ubuntu/
命令把根目录换成指定的目的目录,此时根目录就变成了ubuntu-base
所在目录的;用ll
可以看到文件系统也有变化,此终端里的根文件系统已经切换到ubuntu
目录里的根文件系统,就像进入了一个新系统,所以这也叫作是模拟运行根文件系统;
我们可以在在命令行安装软件,更改系统配置;
root@ubuntu:/# ll
total 56
drwxr-xr-x 17 root root 4096 May 29 15:18 ./
drwxr-xr-x 17 root root 4096 May 29 15:18 ../
lrwxrwxrwx 1 root root 7 Feb 21 2022 bin -> usr/bin/
drwxr-xr-x 2 root root 4096 Apr 15 2020 boot/
drwxr-xr-x 18 root root 4300 May 30 10:54 dev/
drwxr-xr-x 30 root root 4096 May 29 15:30 etc/
drwxr-xr-x 2 root root 4096 Apr 15 2020 home/
lrwxrwxrwx 1 root root 7 Feb 21 2022 lib -> usr/lib/
drwxr-xr-x 2 root root 4096 Feb 21 2022 media/
drwxr-xr-x 2 root root 4096 Feb 21 2022 mnt/
drwxr-xr-x 2 root root 4096 Feb 21 2022 opt/
dr-xr-xr-x 366 root root 0 May 30 11:19 proc/
drwx------ 2 root root 4096 May 29 15:38 root/
drwxr-xr-x 4 root root 4096 Feb 21 2022 run/
lrwxrwxrwx 1 root root 8 Feb 21 2022 sbin -> usr/sbin/
drwxr-xr-x 2 root root 4096 Feb 21 2022 srv/
dr-xr-xr-x 13 root root 0 May 30 10:54 sys/
drwxrwxrwt 2 root root 4096 Feb 21 2022 tmp/
drwxr-xr-x 10 root root 4096 Feb 21 2022 usr/
drwxr-xr-x 11 root root 4096 Feb 21 2022 var/
文件系统配置完成,输入exit
,然后运行脚本卸载文件系统;
1.3.2 卸载文件系统
执行如下命令卸载文件系统:
root@ubuntu:/work/sambashare/rk3399/rootfs# ./mnt_ubuntu.sh -u ubuntu/
实际上就是把之前挂载的全部卸载掉。
1.4 安装软件以及桌面环境等
以下安装需要在挂载ubuntu-base
文件系统之后进行。
1.4.1 安装必要软件
默认下,ubuntu-base
基本没安装什么工具,如果要正常使用,我们可以根据需要安装,以下基本的几个建议都进行安装;
root@ubuntu:/# apt-get update #更新一下软件包的数据库
root@ubuntu:/# apt-get install net-tools
root@ubuntu:/# apt-get install ethtool
root@ubuntu:/# apt-get install ifupdown
root@ubuntu:/# apt-get install psmisc
root@ubuntu:/# apt-get install nfs-common
root@ubuntu:/# apt-get install htop
root@ubuntu:/# apt-get install vim
root@ubuntu:/# apt-get install rsyslog
root@ubuntu:/# apt-get install iputils-ping
root@ubuntu:/# apt-get install language-pack-en-base
root@ubuntu:/# apt-get install sudo
root@ubuntu:/# apt-get install network-manager systemd
root@ubuntu:/# apt install iputils-ping
root@ubuntu:/# apt install openssh-sftp-server
如果出现如下问题:
root@ubuntu:/# apt-get install net-tools
E: dpkg was interrupted, you must manually run 'sudo dpkg --configure -a' to correct the problem.
root@ubuntu:/# sudo dpkg --configure -a
1.4.2 安装桌面环境
ubuntu
官方考虑到使用者的不同需求,提供各种不同的发行板。虽然发布了几种版本的ubuntu
系统,但是他们的核心系统是一模一样的,可以这么说不同发行版的ubuntu
的区别在于:桌面环境的不同和预设安装的软件的不同;
(1) ubuntu
:ubuntu
是主要的发行版,它使用GNOME
这个桌面环境,相依的虚拟套件是ubuntu-desktop
;
(2) kubuntu
:采用以功能强大闻名的KDE
当成桌面环境,功能众多以及华丽桌面配置为其卖点,相依的虚拟套件是kubuntu-desktop
;
(3) xubuntu
:采用了比较轻量级的桌面环境Xfce
,所以这个版本的诉求是针对比较老旧的电脑。Xfce
的设计理念是减少使用的系统资源,并且成为一套完整可用的桌面环境。功能来说,虽没有像ubuntu
与kubuntu
功能众多,但也具备基本文书、上网与影音等功能。相依的虚拟套件是xubuntu-desktop
;
(4) lubuntu
:采用了比Xfce
更轻量的桌面环境Lxde
,是自从10.04
之后才新增的版本。这个版本的诉求是针对小笔电、效能较差的电脑或追求快速的使用者。虽然精简,但仍然符合大多数使用者对于桌面的要求。同样具备文书处理、上网和影音,更特别的是,它已经内建了几乎所有播放需要使用到的解码器,可直接播放mp3
及rmvb
等格式的档案,相依的虛擬套件是lubuntu-desktop
;
(5) edubuntu
:是ubuntu
的教育分支版。它主要的诉求是教育使用,所以里面有很多精心挑选的教育相关套件,和一些小游戏等。而为了可以让教师们快速安装到电脑教室或安装到老旧的电脑里,它还使用了LTSP
技术,可以让老师们在短短的一个小时内建立整个电脑教师环境。使用GNOME
桌面环境相依的虚拟套件是edubuntu-desktop
;使用KDE
桌面环境相依的虚拟套件是edubuntu-desktop-kde
;
LTSP (Linux Terminal Server Project)
的发展目的是提供多个工作站只负责显示,实际软体和计算在伺服器上面,也叫做thin-clients
机制。它的好处是工作站可以使用很老旧的电脑,因为工作站只用来当XTerminal
,所以一切资源都放在伺服器上。这个方式可以让维修成本和管理成本减少很多,所以特别适合公司和学校使用;
这里我们选择一个虚拟套件安装,这里我最初的虚拟套件是ubuntu-desktop
;
root@ubuntu:/# apt-get install ubuntu-desktop
需要注意:安装之后桌面环境在开发板运行起来后,CPU
占用率相对较高,这下图是我当时使用火狐浏览器打开视频的CPU
占用情况,在RK3399
上性能不咋样,因此如果不是必要尽量不要安装桌面环境环境,可以考虑采用安装x11vnc
远程桌面的解决方案。
后面我又尝试安装了xubuntu
,安装过程中有几点需要注意:
- 语言布局我选的
Chinese - Hanyu Pinyin (altgr)
; - 显示管理器(它们提供图形登录并处理用户身份验证)我选择的是
lightdm
;可以通过cat /etc/X11/default-display-manager
命令查看安装的哪一个;
后面介绍的流程都是针对ubuntu
的,当然对xubuntu
、lubuntu
等基本都是适用的(如果有差异,请自行更正)。
1.4.3 安装ubuntu-restricted-extras
ubuntu-restricted-extras
是一个包含各种基本软件,如Flash
插件、unrar
、gstreamer
、mp4
、ubuntu
中的chromium
浏览器的编解码器等的软件包。
由于这些软件不是开源软件,并且其中一些涉及软件专利,因此ubuntu
默认情况下不会安装它们。你必须使用multiverse
仓库,它是ubuntu
专门为用户提供非开源软件而创建的仓库。
由于ubuntu-restrcited-extras
软件包在multiverse
仓库中,因此你应验证系统上已启用multiverse
仓库:
root@ubuntu:/# sudo add-apt-repository multiverse
然后你可以使用以下命令安装:
root@ubuntu:/# sudo apt install ubuntu-restricted-extras
安装完成后,由于新安装的媒体编解码器,你应该可以播放MP3
和其他媒体格式了。
在kubuntu
、lubuntu
和xubuntu
都有此软件包,并有各自不同的名称。它们本应使用相同的名字,但不幸的是并不是。
在kubuntu
上,使用以下命令:
sudo apt install kubuntu-restricted-extras
在lubuntu
上,使用:
sudo apt install lubuntu-restricted-extras
在xubuntu
上,你应该使用:
sudo apt install xubuntu-restricted-extras
在kubuntu
、lubuntu
下安装我没有测试,但是在xubuntu
下安装发现找不到安装包,可以考虑安装ubuntu-restricted-extras
试试。
注意:如果有看视频的诉求,这个一定要安装,不然是无法观看视频的,浏览器也是无法打开视频。
1.5 系统设置
以下配置需要在挂载ubuntu-base
文件系统之后进行。
1.5.1 修改root
用户密码
为了方便, 这里我直接将密码设置为123456
;
root@ubuntu:/# passwd root
New password:
Retype new password:
passwd: password updated successfully
修改sshd
配置文件的PermitRootLogin
属性:
root@ubuntu:/# vim /etc/ssh/sshd_config
在最后面加上,PermitRootLogin yes
:
PermitRootLogin yes #是否允许root登录,默认是允许的,但建议设置为no
LoginGraceTime 600m #设置指定时间内没有成功登录,将会断开连接,若无单位则默认时间为秒
1.5.2 新增用户
新增用户,这个根据具体的情况,嵌入式的环境下,我们可以不用新增,直接使用root
的用户就行了,如果要新增,执行如下的步骤:
root@ubuntu:/# adduser zhengyang
perl: warning: Setting locale failed.
perl: warning: Please check that your locale settings:
LANGUAGE = (unset),
LC_ALL = (unset),
LC_TIME = "en_DK.UTF-8",
LANG = "zh_CN.UTF-8"
are supported and installed on your system.
perl: warning: Falling back to the standard locale ("C").
Adding user `zhengyang' ...
Adding new group `zhengyang' (1000) ...
Adding new user `zhengyang' (1000) with group `zhengyang' ...
Creating home directory `/home/zhengyang' ...
Copying files from `/etc/skel' ...
New password:
Retype new password:
passwd: password updated successfully
Changing the user information for zhengyang
Enter the new value, or press ENTER for the default
Full Name []:
Room Number []:
Work Phone []:
Home Phone []:
Other []:
Is the information correct? [Y/n] y
我了方便,这里新增的zhengyang
用户密码也是123456
;这里需要输入用户的一些信息,也可以直接回车保留默认值即可。
默认情况下新用户是不能使用sudo
命令的,我们需要修改/etc/sudoers
文件。
/etc/sudoers
文件默认是只读的,因此需要先修改此文件的写权限,使用如下命令:
root@ubuntu:/# chmod u+w /etc/sudoers
然后使用vim
打开/etc/sudoers
,找到root ALL=(ALL:ALL) ALL
这一行,在这一行下面添加:
zhengyang ALL=(ALL:ALL) ALL
修改完成以后保存退出,重新恢复/etc/sudoers
的只读属性,使用如下命令:
root@ubuntu:/# chmod u-w /etc/sudoers
1.5.3 设置主机名称和IP
root@ubuntu:/# echo "rk3399" > /etc/hostname
root@ubuntu:/# echo "127.0.0.1 localhost" >> /etc/hosts
root@ubuntu:/# echo "127.0.0.1 rk3399" >> /etc/hosts
/etc/hostname
中存放的是主机名,/etc/hosts
存放的是域名与ip
的对应关系,域名与主机名没有任何关系,你可以为任何一个IP
指定任意一个名字。
1.5.4 配置DHCP
我们配置一下网络DHCP
,这样系统启动以后就会自动设置好网络。RK3399
默认有1
个有线网卡、此外板载2.4G & 5G
双频WiFi
模组。
网卡eth0
:
root@ubuntu:/# echo auto eth0 > /etc/network/interfaces.d/eth0
root@ubuntu:/# echo iface eth0 inet dhcp >> /etc/network/interfaces.d/eth0
其中,eth0
是接口的名称,inet
是IPV4
协议的设置方式,dhcp
表示使用DHCP
服务器分配IP
地址,如果需要使用静态IP
地址,其值应改为static
,例如/etc/network/interfaces.d/eth0
:
auto eth0
iface eth0 inet static
address 192.168.0.105 #设置IP地址为192.168.0.105
netmask 255.255.255.0 #设置掩码为255.255.255.0
gateway 192.168.0.1 #设置默认网关为192.168.0.1
无线网卡wlan
:
root@ubuntu:/# echo auto wlan0 > /etc/network/interfaces.d/wlan0
root@ubuntu:/# echo allow-hotplug wlan0 >> /etc/network/interfaces.d/wlan0
root@ubuntu:/# echo iface wlan0 inet dhcp >> /etc/network/interfaces.d/wlan0
在实际测试中网口必须接入网线系统才能正常启动,就是在不联网的情况下,每次开机都要等待很久,卡在网络连接上5
分钟,这里我们可以修改下面这个文件:
root@ubuntu:/# vim /lib/systemd/system/networking.service
将里面的TimeoutStartSec=5min
修改为:
TimeoutStartSec=1sec
1.5.5 修改系统重启默认等待时间
重启开发板的时候,如果有进程没有结束,系统就会等待,默认等待时间很长,导致重启速度慢。
我们可以修改默认等待时间:
root@ubuntu:/# vim /etc/systemd/system.conf
找到这几行:
#DefaultTimeoutStartSec=90s
#DefaultTimeoutStopSec=90s
#DefaultTRestartSec=100ms
解除注释并将DefaultTimeoutStopSec=90s
修改为:
DefaultTimeoutStopSec=1s
1.5.6 设置开机免密登录到图形界面
(1) 我们使用以下命令修改50-ubuntu.conf
文件:
root@ubuntu:/# vim /usr/share/lightdm/lightdm.conf.d/50-ubuntu.conf
在文件末尾加入以下内容:
greeter-show-manual-login=true
all-guest=false
修改完成后保存退出。
(2) 输入以下命令修改gdm-autologin
文件内容:
root@ubuntu:/# vim /etc/pam.d/gdm-autologin
注释掉下面这一行,并保存退出。
#auth required pam_succeed_if.so user != root quiet_success
(3) 输入以下命令修改gdm-password
文件内容:
root@ubuntu:/# vim /etc/pam.d/gdm-password
注释掉下面这一行,并保存退出。
auth required pam_succeed_if.so user != root quiet_success
(4) 输入以下命令修改/root/.profile
文件:
root@ubuntu:/# vim /root/.profile
将文件最后一行改为以下内容,修改完成如所示:
tty -s && mesg n || true
(5) 输入以下命令修改custom.conf
文件:
root@ubuntu:/# vim /etc/gdm3/custom.conf
在文件末尾添加以下内容:
[daemon]
AutomaticLoginEnable=true
AutomaticLogin=root
TimedLoginEnable=true
TimedLogin=root
TimedLoginDelay=10
至此,我们构建的文件系统,就可以开启root
用户免密登录可视界面了!
1 .6 安装linux-headers
如果想在开发板上进行编译安装源代码,必须安装linux-headers
,具体参考:《Rockchip RK3399
- 移植uboot 2017.09 & linux 4.19
(友善之家脚本方式)》。
1.6.1 编译linux-headers
编译内核头文件:
root@ubuntu:/work/sambashare/rk3399/linux-6.3# make -j$(nproc) bindeb-pkg
make bindeb-pkg
是一个用于构建debian
包的命令,它通常用于编译linux
内核并生成对应的debian
软件包。
当执行make bindeb-pkg
命令时,它会读取当前目录下的linux
内核源代码,并根据配置文件进行内核编译。
编译过程将包括编译内核、生成模块、创建initramfs
等步骤。最后,它将生成一组二进制文件和相关的debian
控制文件,用于创建 debian
包。
linux 6.3
执行完成会在内核源码debian
目录生成以下文件;
root@ubuntu:/work/sambashare/rk3399/linux-6.3# ll debian/
-rw-r--r-- 1 root root 6 1月 30 23:06 arch
-rw-r--r-- 1 root root 137 1月 30 23:06 changelog
-rw-r--r-- 1 root root 1239 1月 30 23:06 control
-rw-r--r-- 1 root root 691 1月 30 23:06 copyright
-rw-r--r-- 1 root root 269 1月 30 23:12 files
drwxr-xr-x 5 root root 4096 1月 30 23:11 linux-headers/
drwxr-xr-x 7 root root 4096 1月 30 23:11 linux-image/
drwxr-xr-x 4 root root 4096 1月 30 23:11 linux-image-dbg/
drwxr-xr-x 4 root root 4096 1月 30 23:11 linux-libc-dev/
-rwxr-xr-x 1 root root 486 1月 30 23:06 rules*
同时会在内核上一级目录下生成如下deb
包:
root@ubuntu:/work/sambashare/rk3399# ll | grep linux
-rw-r--r-- 1 root root 8407716 1月 30 23:11 linux-headers-6.3.0_6.3.0-17_arm64.deb
-rw-r--r-- 1 root root 25455204 1月 30 23:11 linux-image-6.3.0_6.3.0-17_arm64.deb
-rw-r--r-- 1 root root 69655120 1月 30 23:12 linux-image-6.3.0-dbg_6.3.0-17_arm64.deb
-rw-r--r-- 1 root root 1260012 1月 30 23:11 linux-libc-dev_6.3.0-17_arm64.deb
-rw-r--r-- 1 root root 7391 1月 30 23:12 linux-upstream_6.3.0-17_arm64.buildinfo
-rw-r--r-- 1 root root 2161 1月 30 23:12 linux-upstream_6.3.0-17_arm64.changes
其中:
linux-image-<version>.deb
:内核镜像文件,用于安装和引导新的内核;linux-headers-<version>.deb
:内核头文件,用于开发其他软件或编译内核模块;linux-libc-dev_<version>.deb
:用于构建用户空间软件的头文件和静态库;
这些生成的debian
包可以在 debian
或基于debian
的系统上安装和使用。
1.6.2 安装linux-headers
在ubuntu
宿主机将我们编译的头文件拷贝到根文件系统/opt
目录下;
root@ubuntu:/work/sambashare/rk3399/rootfs/ubuntu# cp /work/sambashare/rk3399/linux-headers-6.3.0_6.3.0-17_arm64.deb ./opt
首先需要挂载ubuntu-base
文件系统;
root@ubuntu:/work/sambashare/rk3399/rootfs# ./mnt_ubuntu.sh -m ubuntu/
安装linux-headers
;
root@ubuntu:/# cd /opt
root@ubuntu:/opt# dpkg -i /opt/linux-headers-*.deb
Selecting previously unselected package linux-headers-6.3.0.
(Reading database ... 114184 files and directories currently installed.)
Preparing to unpack .../linux-headers-6.3.0_6.3.0-17_arm64.deb ...
Unpacking linux-headers-6.3.0 (6.3.0-17) ...
Setting up linux-headers-6.3.0 (6.3.0-17) ...
安装完成后,我们可以看一下/usr/src
目录下是否创建了linux-headers-$(uname-r)
文件;
root@ubuntu:/# ll /usr/src/
drwxr-xr-x 5 root root 4096 Nov 13 00:35 linux-headers-6.3.0
root@ubuntu:/# ll /usr/src/linux-headers-6.3.0/
-rw-r--r-- 1 root root 264166 Sep 23 20:58 .config
-rw-r--r-- 1 root root 71751 Jun 12 2023 Makefile
-rw-r--r-- 1 root root 1064676 Sep 23 20:58 Module.symvers
drwxr-xr-x 3 root root 4096 Nov 13 00:35 arch/
drwxr-xr-x 33 root root 4096 Nov 13 00:35 include/
drwxr-xr-x 17 root root 12288 Nov 13 00:35 scripts/
文件系统配置完成,输入exit
,然后执行如下命令卸载文件系统:
root@ubuntu:/work/sambashare/rk3399/rootfs# ./mnt_ubuntu.sh -u ubuntu/
1.7 安装驱动模块
安装驱动模块,具体参考:《Rockchip RK3399
- 移植uboot 2017.09 & linux 4.19
(友善之家脚本方式)》。
1.7.1 编译驱动模块
首先编译内核模块,如果已经编译过忽略即可:
root@ubuntu:/work/sambashare/rk3399/linux-6.3# export KMODULES_OUTDIR=`pwd`/out/output_rk3399_kmodules
root@ubuntu:/work/sambashare/rk3399/linux-6.3# rm -rf ${KMODULES_OUTDIR}
root@ubuntu:/work/sambashare/rk3399/linux-6.3# mkdir -p ${KMODULES_OUTDIR}
root@ubuntu:/work/sambashare/rk3399/linux-6.3# make modules -j$(nproc)
1.7.2 安装驱动模块
然后执行如下脚本install_modules.sh
:
#!/bin/bash
CROSS_COMPILE=arm-linux-
ARCH=arm64
# 用于构建并输出内核版本号
KERNEL_VER=`make CROSS_COMPILE=${CROSS_COMPILE} ARCH=${ARCH} kernelrelease`
KMODULES_OUTDIR=`pwd`/out/output_rk3399_kmodules/${KERNEL_VER}
rm -rf ${KMODULES_OUTDIR}
make CROSS_COMPILE=${CROSS_COMPILE} ARCH=${ARCH} INSTALL_MOD_PATH=${KMODULES_OUTDIR} modules_install
if [ $? -ne 0 ]; then
echo "failed to build kernel modules."
exit 1
fi
# 如果模块依赖文件modules.dep不存在,则生成内核模块的依赖关系
[ ! -f "${KMODULES_OUTDIR}/lib/modules/${KERNEL_VER}/modules.dep" ] && depmod -b ${KMODULES_OUTDIR} -E Module.symvers -F System.map -w ${KERNEL_VER}
# 去除驱动中的符号信息
(cd ${KMODULES_OUTDIR} && find . -name \*.ko | xargs ${CROSS_COMPILE}strip --strip-unneeded)
# 更新内核模块依赖
(cd ${KMODULES_OUTDIR}/lib/modules/${KERNEL_VER}/ && {
rm -rf ./build ./source
echo "depmod ${KMODULES_OUTDIR} ${KERNEL_VER} ..."
depmod -a -b ${KMODULES_OUTDIR} ${KERNEL_VER}
})
在ubuntu
宿主机将我们编译的驱动模块拷贝到根文件系统/lib/modules
目录下;
root@ubuntu:/work/sambashare/rk3399/linux-6.3# ll ${KMODULES_OUTDIR}
drwxr-xr-x 3 root root 4096 2月 3 11:57 lib/
root@ubuntu:/work/sambashare/rk3399/linux-6.3# ll ${KMODULES_OUTDIR}/lib
drwxr-xr-x 3 root root 4096 2月 3 11:57 modules/
root@ubuntu:/work/sambashare/rk3399/linux-6.3# ll ${KMODULES_OUTDIR}/lib/modules
drwxr-xr-x 3 root root 4096 2月 3 12:02 6.3.0/
root@ubuntu:/work/sambashare/rk3399/linux-6.3# ll ${KMODULES_OUTDIR}/lib/modules/6.3.0
drwxr-xr-x 9 root root 4096 2月 3 12:02 kernel/
-rw-r--r-- 1 root root 383978 2月 3 12:02 modules.alias
-rw-r--r-- 1 root root 376985 2月 3 12:02 modules.alias.bin
-rw-r--r-- 1 root root 45077 2月 3 12:01 modules.builtin
-rw-r--r-- 1 root root 83833 2月 3 12:02 modules.builtin.alias.bin
-rw-r--r-- 1 root root 48994 2月 3 12:02 modules.builtin.bin
-rw-r--r-- 1 root root 252258 2月 3 12:01 modules.builtin.modinfo
-rw-r--r-- 1 root root 73761 2月 3 12:02 modules.dep
-rw-r--r-- 1 root root 118208 2月 3 12:02 modules.dep.bin
-rw-r--r-- 1 root root 128 2月 3 12:02 modules.devname
-rw-r--r-- 1 root root 41203 2月 3 12:01 modules.order
-rw-r--r-- 1 root root 402 2月 3 12:02 modules.softdep
-rw-r--r-- 1 root root 131791 2月 3 12:02 modules.symbols
-rw-r--r-- 1 root root 162601 2月 3 12:02 modules.symbols.bin
root@ubuntu:/work/sambashare/rk3399/linux-6.3# cp -af ${KMODULES_OUTDIR}/lib/modules/* /work/sambashare/rk3399/rootfs/ubuntu/lib/modules
root@ubuntu:/work/sambashare/rk3399/linux-6.3# ll /work/sambashare/rk3399/rootfs/ubuntu/lib/modules
drwxr-xr-x 3 root root 4096 2月 3 12:18 6.3.0/
二、制作ext4根文件系统镜像
2.1 初始化
建立根文件系统挂载点ubuntu_rootfs
:
root@ubuntu:/work/sambashare/rk3399/rootfs# mkdir ubuntu_rootfs
创建空镜像文件ubuntu_ext4_rootfs.img
,大小6144
(设置为文件系统大小x2
),具体需要的大小可以通过du build -h
查看我们根文件系统大小调整;
root@ubuntu:/work/sambashare/rk3399/rootfs# dd if=/dev/zero of=ubuntu_ext4_rootfs.img bs=1M count=6144
root@ubuntu:/work/sambashare/rk3399/rootfs# ll ubuntu_ext4_rootfs.img
-rw-r--r-- 1 root root 6442450944 May 30 20:53 ubuntu_ext4_rootfs.img
root@ubuntu:/work/sambashare/rk3399/rootfs# mkfs.ext4 ubuntu_ext4_rootfs.img
2.2 挂载
将该镜像文件挂载到ubuntu_rootfs
:
root@ubuntu:/work/sambashare/rk3399/rootfs# mount ubuntu_ext4_rootfs.img ubuntu_rootfs/
然后将ubuntu
的文件复制到该空文件夹中:
root@ubuntu:/work/sambashare/rk3399/rootfs# cp ./ubuntu/* ./ubuntu_rootfs/ -af
使用df
命令可以查看是否已经挂载:
root@ubuntu:/work/sambashare/rk3399/rootfs# df ubuntu_rootfs
文件系统 1K-块 已用 可用 已用% 挂载点
/dev/loop12 6102624 3804372 1967296 66% /work/sambashare/rk3399/rootfs/ubuntu_rootfs
2.3 卸载
将之前挂载的卸载掉:
root@ubuntu:/work/sambashare/rk3399/rootfs# umount ubuntu_rootfs
root@ubuntu:/work/sambashare/rk3399/rootfs# ll ubuntu_rootfs/
总用量 8
drwxr-xr-x 2 root root 4096 May 30 20:57 ./
drwxr-xr-x 5 root root 4096 May 30 20:58 ../
此时我们已经得到了ext4
根文件系统镜像ubuntu_ext4_rootfs.img
:
root@ubuntu:/work/sambashare/rk3399/rootfs# ll ubuntu_ext4_rootfs.img
-rw-r--r-- 1 root root 6442450944 May 30 21:05 ubuntu_ext4_rootfs.img
删除文件夹ubuntu_rootfs
:
root@ubuntu:/work/sambashare/rk3399/rootfs# rm -rf ubuntu_rootfs
用e2fsck
修复及检测镜像文件系统,resize2fs
减小镜像文件的大小;
root@ubuntu:/work/sambashare/rk3399/rootfs# e2fsck -p -f ubuntu_ext4_rootfs.img
root@ubuntu:/work/sambashare/rk3399/rootfs# resize2fs -M ubuntu_ext4_rootfs.img
root@ubuntu:/work/sambashare/rk3399/rootfs# ll ubuntu_ext4_rootfs.img
-rw-r--r-- 1 root root 4323823616 May 30 21:08 ubuntu_ext4_rootfs.img
root@ubuntu:/work/sambashare/rk3399/rootfs# du -sh ubuntu_ext4_rootfs.img
3.8G ubuntu_ext4_rootfs.img
最终得到的ext4
根文件系统镜像ubuntu_ext4_rootfs.img
大小为3.8G
。
2.4 总结
我们将之前的步骤,编写成mk_rootfs.sh
脚本:
#!/bin/bash
rootfs_name=ubuntu_ext4_rootfs.img # 根文件系统名称
ubuntu_path=./ubuntu # ubuntu文件系统路径
rm -rf ubuntu_rootfs
mkdir ubuntu_rootfs
dd if=/dev/zero of=${rootfs_name} bs=1M count=6144
mkfs.ext4 ${rootfs_name}
mount ${rootfs_name} ubuntu_rootfs/
cp ${ubuntu_path}/* ./ubuntu_rootfs/ -af
umount ubuntu_rootfs
rm -rf ubuntu_rootfs
e2fsck -p -f ${rootfs_name}
resize2fs -M ${rootfs_name}
三、烧录根文件系统
在前面文章我们已经多次介绍过使用rkdeveloptool
烧录程序了,这里不再重复介绍rkdeveloptool
有关内容。
3.1 准备镜像
我们按照之前的流程得到了如下文件idbloader.img
、u-boot.itb
,kernel.itb
、ubuntu_ext4_rootfs.img
。
关于uboot 2023.04
镜像以及linux 6.3 FIT uImage
镜像制作参考:《Rockchip RK3399
- 移植uboot 2023.04
》。
按照Rockchip
官方要求将:
idbloader.img
烧录到eMMC
的0x40
扇区;u-boot.itb
烧录到0x4000
扇区;- 烧录
kernel.itb
到0x8000
扇区; ubuntu_ext4_rootfs.img
烧录到0x40000
扇区;
我们需要将idbloader.img
、u-boot.itb
、kernel.itb
、ubuntu_ext4_rootfs.img
拷贝到rkdeveloptool
路径下:
root@ubuntu:/work/sambashare/rk3399/rkdeveloptool# cp ../u-boot-2023.04/idbloader.img ./
root@ubuntu:/work/sambashare/rk3399/rkdeveloptool# cp ../u-boot-2023.04/u-boot.itb ./
root@ubuntu:/work/sambashare/rk3399/rkdeveloptool# cp ../linux-6.3/kernel.itb ./
root@ubuntu:/work/sambashare/rk3399/rkdeveloptool# mv ../rootfs/ubuntu_ext4_rootfs.img ./
3.2 进入MASKROM
升级模式
NanoPC-T4
开发板如需进入MASKROM
升级模式,需要进入如下操作:
- 将开发板连接上电源,并且连接
Type-C
数据线到PC
; - 按住
BOOT
键再长按Power
键开机(保持按下BOOT
键5
秒以上),将强制进入MASKROM
模式。
一般电脑识别到USB
连接,都会发出声音。或者观察虚拟机右下角是否突然多个USB
设备:右键点击链接;
3.3 下载ubuntu_ext4_rootfs.img
使用下载引导命令去使目标机器初始化DDR
与运行usbplug
(初始化DDR
的原因是由于升级需要很大的内存,所以需要使用到DDR
);
root@ubuntu:/work/sambashare/rk3399/rkdeveloptool# rkdeveloptool db rk3399_loader_v1.27.126.bin
Downloading bootloader succeeded.
由于BootROM
启动会将rk3399_loader_v1.27.126.bin
将在到内部SRAM
中,然后跳转到ddr.bin
代码进行DDR
的初始化,ddr.bin
执行之后会回跳到BootROM
程序,BootROM
程序继续加载usbplug.bin
,由usbplug.bin
完成程序的下载以及烧录到eMMC
。
使用wl
命令烧写镜像到目标机器的eMMC
,需要注意的是访问DDR
所需的所有其他命令都应在使用db
命令之后才能使用;
root@ubuntu:/work/sambashare/rk3399/rkdeveloptool# rkdeveloptool wl 0x40 idbloader.img
Write LBA from file (100%)
root@ubuntu:/work/sambashare/rk3399/rkdeveloptool# rkdeveloptool wl 0x4000 u-boot.itb
Write LBA from file (100%)
root@ubuntu:/work/sambashare/rk3399/rkdeveloptool# rkdeveloptool wl 0x8000 kernel.itb
Write LBA from file (100%)
root@ubuntu:/work/sambashare/rk3399/rkdeveloptool# rkdeveloptool wl 0x40000 ubuntu_ext4_rootfs.img
Write LBA from file (100%)
root@ubuntu:/work/sambashare/rk3399/rkdeveloptool# rkdeveloptool rd
Reset Device OK.
在烧写镜像完成后使用rd
命令重启目标机器:
root@ubuntu:/work/sambashare/rk3399/rkdeveloptool# rkdeveloptool rd
Reset Device OK.
3.4 启动内核
3.4.1 串口连接
使用准备好的USB
转串口适配器和连接线(需另购),连接开发板:
引脚 | 开发板接口 | USB转串口 |
---|---|---|
1 | GNC | - |
2 | VCC 5V | - |
3 | UART2DBG_TX | RX |
4 | UART2DBG_RX | TX |
3.4.2 MobaXterm
这里我使用的串口调试工具是MobaXterm
,选择串口端口,设置波特率为115200
,8
位数据位,1
位停止位。
3.4.3 开发板上电
将开发板通过HDMI
接口连接上显示器,给开发板上电,通过串口打印输出:
U-Boot TPL 2023.04 (May 30 2023 - 21:31:09)
Channel 0: LPDDR3, 800MHz
BW=32 Col=10 Bk=8 CS0 Row=15 CS1 Row=15 CS=2 Die BW=16 Size=2048MB
Channel 1: LPDDR3, 800MHz
BW=32 Col=10 Bk=8 CS0 Row=15 CS1 Row=15 CS=2 Die BW=16 Size=2048MB
256B stride
Trying to boot from BOOTROM
Returning to boot ROM...
U-Boot SPL 2023.04 (May 30 2023 - 21:31:09 +0800)
Trying to boot from MMC2
spl_load_fit_image: Skip load 'atf@5': image size is 0!
cannot find image node 'atf@6': -1
NOTICE: BL31: v2.8(release):c194aa0
NOTICE: BL31: Built : 19:26:54, May 11 2023
U-Boot 2023.04 (May 30 2023 - 21:31:23 +0800)
SoC: Rockchip rk3399
Reset cause: POR
Model: Rockchip RK3399 Evaluation Board
DRAM: 4 GiB (effective 3.9 GiB)
Core: 254 devices, 27 uclasses, devicetree: separate
MMC: mmc@fe320000: 1, mmc@fe330000: 0
Loading Environment from MMC... OK
In: serial
Out: serial
Err: serial
Model: Rockchip RK3399 Evaluation Board
Net: eth0: ethernet@fe300000
Hit any key to stop autoboot: 0
=>
在倒计时执行完之前,按CTRL+C
即可进入uboot
命令行。
3.4.4 设置ip
以及bootargs
这里我们这是本机和服务器的ip
地址:
=> setenv ipaddr 192.168.0.105
=> setenv serverip 192.168.0.200
=> saveenv
Saving Environment to MMC... Writing to MMC(0)... OK
设置启动命令参数:
=> setenv bootargs earlycon=uart8250,mmio32,0xff1a0000 console=tty0 console=ttyS2,115200n8 root=PARTUUID=B921B045-1D rw rootwait rootfstype=ext4 init=/sbin/init
=> saveenv
Saving Environment to MMC... Writing to MMC(0)... OK
=> print bootargs
bootargs=earlycon=uart8250,mmio32,0xff1a0000 console=tty0 console=ttyS2,115200n8 root=PARTUUID=B921B045-1D rw rootwait rootfstype=ext4 init=/sbin/init
在配置了console=ttyS2,115200n8
的情况下,只有配置了console=tty0
或者console=tty1
内核启动信息才会在显示器上显示,tty0
表示当前所使用虚拟终端的一个别名,内核启动的时候,内核日志会发送到console
指定的终端设备上。
/dev/tty1~/dev/tty6
是虚拟终端在文件系统中的表示(可以通过CTRL+ALT+[F1~F6]
切换虚终端),虚拟终端的输入数据来自键盘、同时将tty
驱动的输出到显示器,他们共享同一个的键盘显示器套件。
后面测试可以正常启动内核并进入ubuntu
桌面系统的话,最好把console=ttyS2,115200n8
配置移除掉,因为这个会严重影响CPU
的性能。
3.4.5 设置GPT
分区表
使用以下命令将分区信息写入GPT
分区表:
=> gpt write mmc 0 'uuid_disk=69DAD710-2CE4-4E3C-B16C-21A1D49ABED3;name=loader1,start=32K,size=4000K,uuid=8ef917d1-5bd0-2c4f-9a33-b225b21cf919;name=loader2,start=8MB,size=4MB,uuid=77877125-2374-ad40-8b02-609e37971c59;name=trust,size=4M,uuid=b4b84b8a-f8ae-0443-b5af-3605b195c4c9;name=boot,size=112M,bootable,uuid=35219908-db08-c643-9133-2213191e57ff;name=rootfs,size=-,uuid=b921b045-1df0-41c3-af44-4c6f280d3fae'
Writing GPT: success!
=> part list mmc 0 Partition Map for MMC device 0 -- Partition Type: EFI
Part Start LBA End LBA Name
Attributes
Type GUID
Partition GUID
1 0x00000040 0x00001f7f "loader1"
attrs: 0x0000000000000000
type: ebd0a0a2-b9e5-4433-87c0-68b6b72699c7
(data)
guid: 8ef917d1-5bd0-2c4f-9a33-b225b21cf919
2 0x00004000 0x00005fff "loader2"
attrs: 0x0000000000000000
type: ebd0a0a2-b9e5-4433-87c0-68b6b72699c7
(data)
guid: 77877125-2374-ad40-8b02-609e37971c59
3 0x00006000 0x00007fff "trust"
attrs: 0x0000000000000000
type: ebd0a0a2-b9e5-4433-87c0-68b6b72699c7
(data)
guid: b4b84b8a-f8ae-0443-b5af-3605b195c4c9
4 0x00008000 0x0003ffff "boot"
attrs: 0x0000000000000004
type: ebd0a0a2-b9e5-4433-87c0-68b6b72699c7
(data)
guid: 35219908-db08-c643-9133-2213191e57ff
5 0x00040000 0x01d1efde "rootfs"
attrs: 0x0000000000000000
type: ebd0a0a2-b9e5-4433-87c0-68b6b72699c7
(data)
guid: b921b045-1df0-41c3-af44-4c6f280d3fae
3.4.5 bootm
命令启动内核
将kernel.itb
从eMMC 0x8000
扇区加载到内存地址0x10000000
处,并使用bootm
命令启动内核;
=> mmc read 0x10000000 0x8000 0xA000
MMC read: dev # 0, block # 32768, count 40960 ... 40960 blocks read: OK
=> bootm 0x10000000
注意:为了避免每次都从eMMC
加载内核内核启动,可以在uboot
命令行修改distro_bootcmd
环境变量:
=> print distro_bootcmd
distro_bootcmd=for target in ${boot_targets}; do run bootcmd_${target}; done
=> setenv distro_bootcmd 'mmc read 0x10000000 0x8000 0xA000;bootm 0x10000000'
=> print distro_bootcmd
distro_bootcmd=mmc read 0x10000000 0x8000 0xA000;bootm 0x10000000
=> saveenv
Saving Environment to MMC... Writing to MMC(0)... OK
内核启动输出日志如下:
Code
## Loading kernel from FIT Image at 10000000 ...
Using 'conf-1' configuration
Trying 'kernel' kernel subimage
Description: Vanilla Linux kernel
Type: Kernel Image
Compression: gzip compressed
Data Start: 0x100000e8
Data Size: 13582219 Bytes = 13 MiB
Architecture: AArch64
OS: Linux
Load Address: 0x00280000
Entry Point: 0x00280000
Hash algo: crc32
Hash value: ff383b36
Hash algo: sha1
Hash value: 997567fa80b97a3cfdc0e7a5fec9cb953e11a529
Verifying Hash Integrity ... crc32+ sha1+ OK
bootm_find_os images.os.load=0x280000
bootm_find_os images.ep=0x280000
bootm_find_os images.os.image_start=0x100000e8
## Loading fdt from FIT Image at 10000000 ...
Using 'conf-1' configuration
Trying 'fdt' fdt subimage
Description: Flattened Device Tree blob
Type: Flat Device Tree
Compression: uncompressed
Data Start: 0x10cf419c
Data Size: 55789 Bytes = 54.5 KiB
Architecture: AArch64
Load Address: 0x08300000
Hash algo: crc32
Hash value: bf9a12b9
Hash algo: sha1
Hash value: 9b30f3614420b80abbe18b4518702c5c7c4087d2
Verifying Hash Integrity ... crc32+ sha1+ OK
Loading fdt from 0x10cf419c to 0x08300000
Booting using the fdt blob at 0x8300000
Working FDT set to 8300000
Uncompressing Kernel Image
kernel loaded at 0x00280000, end = 0x02948200
bootm_load_os 0x20000000=0x5aa5f00f
bootm_load_os 0x20000010=0xffffffff
Loading Device Tree to 00000000f4604000, end 00000000f46149ec ... OK
Working FDT set to f4604000
## Transferring control to Linux (at address 280000)...
boot_jump_linux 0x280000=0xfa405a4d
boot_jump_linux 0x280004=0x1469d827
boot_jump_linux 0x280014=0x0
boot_jump_linux 0xf4604000=0xedfe0dd0
boot_jump_linux 0xf4604004=0xe00000
boot_jump_linux 0xf4604014=0x11000000
Starting kernel ...
[ 0.000000] Booting Linux on physical CPU 0x0000000000 [0x410fd034]
[ 0.000000] Linux version 6.3.0 (root@ubuntu) (arm-linux-gcc (Arm GNU Toolchain 12.2.Rel1 (Build arm-12.24)) 12.2.1 20221205, GNU ld (Arm GNU Toolchain 12.2.Rel1 (Build arm-12.24)) 2.39.0.20221210) #10 SMP PREEMPT Tue Jun 13 20:34:22 CST 2023
[ 0.000000] Machine model: Rockchip RK3399 Evaluation Board
[ 0.000000] earlycon: uart8250 at MMIO32 0x00000000ff1a0000 (options '')
[ 0.000000] printk: bootconsole [uart8250] enabled
[ 0.000000] efi: UEFI not found.
[ 0.000000] [Firmware Bug]: Kernel image misaligned at boot, please fix your bootloader!
[ 0.000000] NUMA: No NUMA configuration found
[ 0.000000] NUMA: Faking a node at [mem 0x0000000000200000-0x00000000f7ffffff]
[ 0.000000] NUMA: NODE_DATA [mem 0xf77ea9c0-0xf77ecfff]
[ 0.000000] Zone ranges:
[ 0.000000] DMA [mem 0x0000000000200000-0x00000000f7ffffff]
[ 0.000000] DMA32 empty
[ 0.000000] Normal empty
[ 0.000000] Movable zone start for each node
[ 0.000000] Early memory node ranges
[ 0.000000] node 0: [mem 0x0000000000200000-0x00000000f7ffffff]
[ 0.000000] Initmem setup node 0 [mem 0x0000000000200000-0x00000000f7ffffff]
[ 0.000000] On node 0, zone DMA: 512 pages in unavailable ranges
[ 0.000000] cma: Reserved 32 MiB at 0x00000000f5600000
[ 0.000000] psci: probing for conduit method from DT.
[ 0.000000] psci: PSCIv1.1 detected in firmware.
[ 0.000000] psci: Using standard PSCI v0.2 function IDs
[ 0.000000] psci: MIGRATE_INFO_TYPE not supported.
[ 0.000000] psci: SMC Calling Convention v1.2
[ 0.000000] percpu: Embedded 22 pages/cpu s50472 r8192 d31448 u90112
[ 0.000000] Detected VIPT I-cache on CPU0
[ 0.000000] CPU features: detected: GIC system register CPU interface
[ 0.000000] CPU features: detected: ARM erratum 845719
[ 0.000000] alternatives: applying boot alternatives
[ 0.000000] Fallback order for Node 0: 0
[ 0.000000] Built 1 zonelists, mobility grouping on. Total pages: 999432
[ 0.000000] Policy zone: DMA
[ 0.000000] Kernel command line: earlycon=uart8250,mmio32,0xff1a0000 console=tty0 console=ttyS2,115200n8 root=PARTUUID=B921B045-1D rw rootwait rootfstype=ext4 init=/sbin/init
[ 0.000000] Dentry cache hash table entries: 524288 (order: 10, 4194304 bytes, linear)
[ 0.000000] Inode-cache hash table entries: 262144 (order: 9, 2097152 bytes, linear)
[ 0.000000] mem auto-init: stack:all(zero), heap alloc:off, heap free:off
[ 0.000000] Memory: 3909540K/4061184K available (16832K kernel code, 4192K rwdata, 10164K rodata, 8384K init, 607K bss, 118876K reserved, 32768K cma-reserved)
[ 0.000000] SLUB: HWalign=64, Order=0-3, MinObjects=0, CPUs=6, Nodes=1
[ 0.000000] rcu: Preemptible hierarchical RCU implementation.
[ 0.000000] rcu: RCU event tracing is enabled.
[ 0.000000] rcu: RCU restricting CPUs from NR_CPUS=256 to nr_cpu_ids=6.
[ 0.000000] Trampoline variant of Tasks RCU enabled.
[ 0.000000] Tracing variant of Tasks RCU enabled.
[ 0.000000] rcu: RCU calculated value of scheduler-enlistment delay is 25 jiffies.
[ 0.000000] rcu: Adjusting geometry for rcu_fanout_leaf=16, nr_cpu_ids=6
[ 0.000000] NR_IRQS: 64, nr_irqs: 64, preallocated irqs: 0
[ 0.000000] GICv3: GIC: Using split EOI/Deactivate mode
[ 0.000000] GICv3: 256 SPIs implemented
[ 0.000000] GICv3: 0 Extended SPIs implemented
[ 0.000000] Root IRQ handler: gic_handle_irq
[ 0.000000] GICv3: GICv3 features: 16 PPIs
[ 0.000000] GICv3: CPU0: found redistributor 0 region 0:0x00000000fef00000
[ 0.000000] ITS [mem 0xfee20000-0xfee3ffff]
[ 0.000000] ITS@0x00000000fee20000: allocated 65536 Devices @2c80000 (flat, esz 8, psz 64K, shr 0)
[ 0.000000] ITS: using cache flushing for cmd queue
[ 0.000000] GICv3: using LPI property table @0x0000000002c40000
[ 0.000000] GIC: using cache flushing for LPI property table
[ 0.000000] GICv3: CPU0: using allocated LPI pending table @0x0000000002c50000
[ 0.000000] GICv3: GIC: PPI partition interrupt-partition-0[0] { /cpus/cpu@0[0] /cpus/cpu@1[1] /cpus/cpu@2[2] /cpus/cpu@3[3] }
[ 0.000000] GICv3: GIC: PPI partition interrupt-partition-1[1] { /cpus/cpu@100[4] /cpus/cpu@101[5] }
[ 0.000000] rcu: srcu_init: Setting srcu_struct sizes based on contention.
[ 0.000000] arch_timer: cp15 timer(s) running at 24.00MHz (phys).
[ 0.000000] clocksource: arch_sys_counter: mask: 0xffffffffffffff max_cycles: 0x588fe9dc0, max_idle_ns: 440795202592 ns
[ 0.000001] sched_clock: 56 bits at 24MHz, resolution 41ns, wraps every 4398046511097ns
[ 0.013119] Console: colour dummy device 80x25
[ 0.018024] printk: console [tty0] enabled
[ 0.023589] Calibrating delay loop (skipped), value calculated using timer frequency.. 48.00 BogoMIPS (lpj=96000)
[ 0.034916] pid_max: default: 32768 minimum: 301
[ 0.040113] LSM: initializing lsm=capability,integrity
[ 0.045949] Mount-cache hash table entries: 8192 (order: 4, 65536 bytes, linear)
[ 0.054139] Mountpoint-cache hash table entries: 8192 (order: 4, 65536 bytes, linear)
[ 0.065468] cblist_init_generic: Setting adjustable number of callback queues.
[ 0.073495] cblist_init_generic: Setting shift to 3 and lim to 1.
[ 0.080338] cblist_init_generic: Setting shift to 3 and lim to 1.
[ 0.087389] rcu: Hierarchical SRCU implementation.
[ 0.092694] rcu: Max phase no-delay instances is 1000.
[ 0.098853] Platform MSI: msi-controller@fee20000 domain created
[ 0.105892] PCI/MSI: /interrupt-controller@fee00000/msi-controller@fee20000 domain created
[ 0.115282] fsl-mc MSI: msi-controller@fee20000 domain created
[ 0.128113] EFI services will not be available.
[ 0.133652] smp: Bringing up secondary CPUs ...
[ 0.139462] Detected VIPT I-cache on CPU1
[ 0.139542] GICv3: CPU1: found redistributor 1 region 0:0x00000000fef20000
[ 0.139565] GICv3: CPU1: using allocated LPI pending table @0x0000000002c60000
[ 0.139626] CPU1: Booted secondary processor 0x0000000001 [0x410fd034]
[ 0.140501] Detected VIPT I-cache on CPU2
[ 0.140562] GICv3: CPU2: found redistributor 2 region 0:0x00000000fef40000
[ 0.140581] GICv3: CPU2: using allocated LPI pending table @0x0000000002c70000
[ 0.140621] CPU2: Booted secondary processor 0x0000000002 [0x410fd034]
[ 0.141392] Detected VIPT I-cache on CPU3
[ 0.141453] GICv3: CPU3: found redistributor 3 region 0:0x00000000fef60000
[ 0.141472] GICv3: CPU3: using allocated LPI pending table @0x0000000002d00000
[ 0.141509] CPU3: Booted secondary processor 0x0000000003 [0x410fd034]
[ 0.142318] CPU features: detected: Spectre-v2
[ 0.142331] CPU features: detected: Spectre-v3a
[ 0.142341] CPU features: detected: Spectre-BHB
[ 0.142353] CPU features: detected: ARM erratum 1742098
[ 0.142360] CPU features: detected: ARM errata 1165522, 1319367, or 1530923
[ 0.142366] Detected PIPT I-cache on CPU4
[ 0.142436] GICv3: CPU4: found redistributor 100 region 0:0x00000000fef80000
[ 0.142455] GICv3: CPU4: using allocated LPI pending table @0x0000000002d10000
[ 0.142496] CPU4: Booted secondary processor 0x0000000100 [0x410fd082]
[ 0.143381] Detected PIPT I-cache on CPU5
[ 0.143440] GICv3: CPU5: found redistributor 101 region 0:0x00000000fefa0000
[ 0.143458] GICv3: CPU5: using allocated LPI pending table @0x0000000002d20000
[ 0.143492] CPU5: Booted secondary processor 0x0000000101 [0x410fd082]
[ 0.143607] smp: Brought up 1 node, 6 CPUs
[ 0.312474] SMP: Total of 6 processors activated.
[ 0.317673] CPU features: detected: 32-bit EL0 Support
[ 0.323363] CPU features: detected: 32-bit EL1 Support
[ 0.329038] CPU features: detected: CRC32 instructions
[ 0.334840] CPU: All CPU(s) started at EL2
[ 0.339397] alternatives: applying system-wide alternatives
[ 0.349457] devtmpfs: initialized
[ 0.364873] clocksource: jiffies: mask: 0xffffffff max_cycles: 0xffffffff, max_idle_ns: 7645041785100000 ns
[ 0.375633] futex hash table entries: 2048 (order: 5, 131072 bytes, linear)
[ 0.384074] pinctrl core: initialized pinctrl subsystem
[ 0.392766] DMI not present or invalid.
[ 0.397871] NET: Registered PF_NETLINK/PF_ROUTE protocol family
[ 0.405964] DMA: preallocated 512 KiB GFP_KERNEL pool for atomic allocations
[ 0.414193] DMA: preallocated 512 KiB GFP_KERNEL|GFP_DMA pool for atomic allocations
[ 0.423097] DMA: preallocated 512 KiB GFP_KERNEL|GFP_DMA32 pool for atomic allocations
[ 0.431879] audit: initializing netlink subsys (disabled)
[ 0.438041] audit: type=2000 audit(0.300:1): state=initialized audit_enabled=0 res=1
[ 0.439721] thermal_sys: Registered thermal governor 'step_wise'
[ 0.446598] thermal_sys: Registered thermal governor 'power_allocator'
[ 0.453279] cpuidle: using governor menu
[ 0.465046] hw-breakpoint: found 6 breakpoint and 4 watchpoint registers.
[ 0.472723] ASID allocator initialised with 65536 entries
[ 0.481422] Serial: AMBA PL011 UART driver
[ 0.514038] platform fe330000.mmc: Fixed dependency cycle(s) with /syscon@ff770000/phy@f780
[ 0.527841] platform ff940000.hdmi: Fixed dependency cycle(s) with /vop@ff8f0000/port/endpoint@2
[ 0.537533] platform ff940000.hdmi: Fixed dependency cycle(s) with /vop@ff900000/port/endpoint@2
[ 0.553070] gpio gpiochip0: Static allocation of GPIO base is deprecated, use dynamic allocation.
[ 0.563162] rockchip-gpio ff720000.gpio: probed /pinctrl/gpio@ff720000
[ 0.570858] gpio gpiochip1: Static allocation of GPIO base is deprecated, use dynamic allocation.
[ 0.580842] rockchip-gpio ff730000.gpio: probed /pinctrl/gpio@ff730000
[ 0.588430] gpio gpiochip2: Static allocation of GPIO base is deprecated, use dynamic allocation.
[ 0.598406] rockchip-gpio ff780000.gpio: probed /pinctrl/gpio@ff780000
[ 0.606060] gpio gpiochip3: Static allocation of GPIO base is deprecated, use dynamic allocation.
[ 0.616018] rockchip-gpio ff788000.gpio: probed /pinctrl/gpio@ff788000
[ 0.623606] gpio gpiochip4: Static allocation of GPIO base is deprecated, use dynamic allocation.
[ 0.633565] rockchip-gpio ff790000.gpio: probed /pinctrl/gpio@ff790000
[ 0.645318] KASLR disabled due to lack of seed
[ 0.651048] HugeTLB: registered 1.00 GiB page size, pre-allocated 0 pages
[ 0.658535] HugeTLB: 0 KiB vmemmap can be freed for a 1.00 GiB page
[ 0.665436] HugeTLB: registered 32.0 MiB page size, pre-allocated 0 pages
[ 0.672913] HugeTLB: 0 KiB vmemmap can be freed for a 32.0 MiB page
[ 0.679808] HugeTLB: registered 2.00 MiB page size, pre-allocated 0 pages
[ 0.687282] HugeTLB: 0 KiB vmemmap can be freed for a 2.00 MiB page
[ 0.694177] HugeTLB: registered 64.0 KiB page size, pre-allocated 0 pages
[ 0.701653] HugeTLB: 0 KiB vmemmap can be freed for a 64.0 KiB page
[ 0.710691] ACPI: Interpreter disabled.
[ 0.720494] iommu: Default domain type: Translated
[ 0.725874] iommu: DMA domain TLB invalidation policy: strict mode
[ 0.733096] SCSI subsystem initialized
[ 0.737742] usbcore: registered new interface driver usbfs
[ 0.743821] usbcore: registered new interface driver hub
[ 0.749723] usbcore: registered new device driver usb
[ 0.756917] pps_core: LinuxPPS API ver. 1 registered
[ 0.762394] pps_core: Software ver. 5.3.6 - Copyright 2005-2007 Rodolfo Giometti <giometti@linux.it>
[ 0.772457] PTP clock support registered
[ 0.777019] EDAC MC: Ver: 3.0.0
[ 0.781529] scmi_core: SCMI protocol bus registered
[ 0.788124] FPGA manager framework
[ 0.791986] Advanced Linux Sound Architecture Driver Initialized.
[ 0.799740] vgaarb: loaded
[ 0.803101] clocksource: Switched to clocksource arch_sys_counter
[ 0.810055] VFS: Disk quotas dquot_6.6.0
[ 0.814423] VFS: Dquot-cache hash table entries: 512 (order 0, 4096 bytes)
[ 0.822212] pnp: PnP ACPI: disabled
[ 0.836097] NET: Registered PF_INET protocol family
[ 0.841748] IP idents hash table entries: 65536 (order: 7, 524288 bytes, linear)
[ 0.854202] tcp_listen_portaddr_hash hash table entries: 2048 (order: 3, 32768 bytes, linear)
[ 0.863710] Table-perturb hash table entries: 65536 (order: 6, 262144 bytes, linear)
[ 0.872264] TCP established hash table entries: 32768 (order: 6, 262144 bytes, linear)
[ 0.881328] TCP bind hash table entries: 32768 (order: 8, 1048576 bytes, linear)
[ 0.890751] TCP: Hash tables configured (established 32768 bind 32768)
[ 0.898074] UDP hash table entries: 2048 (order: 4, 65536 bytes, linear)
[ 0.905616] UDP-Lite hash table entries: 2048 (order: 4, 65536 bytes, linear)
[ 0.913736] NET: Registered PF_UNIX/PF_LOCAL protocol family
[ 0.920435] RPC: Registered named UNIX socket transport module.
[ 0.926970] RPC: Registered udp transport module.
[ 0.932155] RPC: Registered tcp transport module.
[ 0.937333] RPC: Registered tcp NFSv4.1 backchannel transport module.
[ 0.944444] PCI: CLS 0 bytes, default 64
[ 0.949936] hw perfevents: enabled with armv8_cortex_a53 PMU driver, 7 counters available
[ 0.959444] hw perfevents: enabled with armv8_cortex_a72 PMU driver, 7 counters available
[ 0.969062] kvm [1]: IPA Size Limit: 40 bits
[ 0.976087] kvm [1]: vgic-v2@fff20000
[ 0.980170] kvm [1]: GIC system register CPU interface enabled
[ 0.986643] kvm [1]: vgic interrupt IRQ18
[ 0.991116] kvm [1]: Hyp mode initialized successfully
[ 0.998751] Initialise system trusted keyrings
[ 1.003875] workingset: timestamp_bits=42 max_order=20 bucket_order=0
[ 1.011405] squashfs: version 4.0 (2009/01/31) Phillip Lougher
[ 1.018150] NFS: Registering the id_resolver key type
[ 1.023762] Key type id_resolver registered
[ 1.028381] Key type id_legacy registered
[ 1.032820] nfs4filelayout_init: NFSv4 File Layout Driver Registering...
[ 1.040209] nfs4flexfilelayout_init: NFSv4 Flexfile Layout Driver Registering...
[ 1.048564] 9p: Installing v9fs 9p2000 file system support
[ 1.118933] Key type asymmetric registered
[ 1.123450] Asymmetric key parser 'x509' registered
[ 1.128887] Block layer SCSI generic (bsg) driver version 0.4 loaded (major 244)
[ 1.137035] io scheduler mq-deadline registered
[ 1.142029] io scheduler kyber registered
[ 1.146484] io scheduler bfq registered
[ 1.180080] EINJ: ACPI disabled.
[ 1.230196] Serial: 8250/16550 driver, 4 ports, IRQ sharing enabled
[ 1.240558] printk: console [ttyS2] disabled
[ 1.245355] ff1a0000.serial: ttyS2 at MMIO 0xff1a0000 (irq = 35, base_baud = 1500000) is a 16550A
[ 1.255368] printk: console [ttyS2] enabled
[ 1.255368] printk: console [ttyS2] enabled
[ 1.264799] printk: bootconsole [uart8250] disabled
[ 1.264799] printk: bootconsole [uart8250] disabled
[ 1.289739] SuperH (H)SCI(F) driver initialized
[ 1.295864] msm_serial: driver initialized
[ 1.307338] rockchip-vop ff8f0000.vop: Adding to iommu group 2
[ 1.314510] rockchip-vop ff900000.vop: Adding to iommu group 3
[ 1.326506] rockchip-drm display-subsystem: bound ff8f0000.vop (ops vop_component_ops)
[ 1.335493] [drm] unsupported AFBC format[3231564e]
[ 1.342057] rockchip-drm display-subsystem: bound ff900000.vop (ops vop_component_ops)
[ 1.351046] dwhdmi-rockchip ff940000.hdmi: supply avdd-0v9 not found, using dummy regulator
[ 1.360560] dwhdmi-rockchip ff940000.hdmi: supply avdd-1v8 not found, using dummy regulator
[ 1.378276] loop: module loaded
[ 1.383902] megasas: 07.725.01.00-rc1
[ 1.400183] tun: Universal TUN/TAP device driver, 1.6
[ 1.407592] thunder_xcv, ver 1.0
[ 1.411272] thunder_bgx, ver 1.0
[ 1.414918] nicpf, ver 1.0
[ 1.420464] hns3: Hisilicon Ethernet Network Driver for Hip08 Family - version
[ 1.428573] hns3: Copyright (c) 2017 Huawei Corporation.
[ 1.434580] hclge is initializing
[ 1.438316] e1000: Intel(R) PRO/1000 Network Driver
[ 1.443782] e1000: Copyright (c) 1999-2006 Intel Corporation.
[ 1.450254] e1000e: Intel(R) PRO/1000 Network Driver
[ 1.455819] e1000e: Copyright(c) 1999 - 2015 Intel Corporation.
[ 1.462488] igb: Intel(R) Gigabit Ethernet Network Driver
[ 1.468532] igb: Copyright (c) 2007-2014 Intel Corporation.
[ 1.474809] igbvf: Intel(R) Gigabit Virtual Function Network Driver
[ 1.481832] igbvf: Copyright (c) 2009 - 2012 Intel Corporation.
[ 1.489113] sky2: driver version 1.30
[ 1.495506] rk_gmac-dwmac fe300000.ethernet: IRQ eth_wake_irq not found
[ 1.502944] rk_gmac-dwmac fe300000.ethernet: IRQ eth_lpi not found
[ 1.509967] rk_gmac-dwmac fe300000.ethernet: PTP uses main clock
[ 1.516849] rk_gmac-dwmac fe300000.ethernet: clock input or output? (input).
[ 1.524758] rk_gmac-dwmac fe300000.ethernet: TX delay(0x28).
[ 1.531109] rk_gmac-dwmac fe300000.ethernet: RX delay(0x11).
[ 1.537459] rk_gmac-dwmac fe300000.ethernet: integrated PHY? (no).
[ 1.544434] rk_gmac-dwmac fe300000.ethernet: cannot get clock clk_mac_speed
[ 1.552237] rk_gmac-dwmac fe300000.ethernet: clock input from PHY
[ 1.564073] rk_gmac-dwmac fe300000.ethernet: init for RGMII
[ 1.570537] rk_gmac-dwmac fe300000.ethernet: User ID: 0x10, Synopsys ID: 0x35
[ 1.578551] rk_gmac-dwmac fe300000.ethernet: DWMAC1000
[ 1.584410] rk_gmac-dwmac fe300000.ethernet: DMA HW capability register supported
[ 1.592795] rk_gmac-dwmac fe300000.ethernet: RX Checksum Offload Engine supported
[ 1.601171] rk_gmac-dwmac fe300000.ethernet: COE Type 2
[ 1.607017] rk_gmac-dwmac fe300000.ethernet: TX Checksum insertion supported
[ 1.614912] rk_gmac-dwmac fe300000.ethernet: Wake-Up On Lan supported
[ 1.622199] rk_gmac-dwmac fe300000.ethernet: Normal descriptors
[ 1.628838] rk_gmac-dwmac fe300000.ethernet: Ring mode enabled
[ 1.635373] rk_gmac-dwmac fe300000.ethernet: Enable RX Mitigation via HW Watchdog Timer
[ 1.733967] RTL8211E Gigabit Ethernet stmmac-0:00: attached PHY driver (mii_bus:phy_addr=stmmac-0:00, irq=POLL)
[ 1.745294] RTL8211E Gigabit Ethernet stmmac-0:01: attached PHY driver (mii_bus:phy_addr=stmmac-0:01, irq=POLL)
[ 1.759073] VFIO - User Level meta-driver version: 0.3
[ 1.770861] ehci-platform fe3c0000.usb: EHCI Host Controller
[ 1.770892] ohci-platform fe3e0000.usb: Generic Platform OHCI controller
[ 1.770915] usbcore: registered new interface driver usb-storage
[ 1.771139] ehci-platform fe380000.usb: EHCI Host Controller
[ 1.771192] ehci-platform fe380000.usb: new USB bus registered, assigned bus number 1
[ 1.771202] ohci-platform fe3a0000.usb: Generic Platform OHCI controller
[ 1.771235] ohci-platform fe3a0000.usb: new USB bus registered, assigned bus number 2
[ 1.771360] ehci-platform fe380000.usb: irq 44, io mem 0xfe380000
[ 1.771387] ohci-platform fe3a0000.usb: irq 46, io mem 0xfe3a0000
[ 1.776204] i2c_dev: i2c /dev entries driver
[ 1.777242] ehci-platform fe3c0000.usb: new USB bus registered, assigned bus number 3
[ 1.777379] ehci-platform fe3c0000.usb: irq 43, io mem 0xfe3c0000
[ 1.779959] i2c 0-001b: Fixed dependency cycle(s) with /i2c@ff3c0000/pmic@1b/regulators/LDO_REG3
[ 1.785049] ohci-platform fe3e0000.usb: new USB bus registered, assigned bus number 4
[ 1.787138] ehci-platform fe380000.usb: USB 2.0 started, EHCI 1.00
[ 1.788317] hub 1-0:1.0: USB hub found
[ 1.788381] hub 1-0:1.0: 1 port detected
[ 1.807122] ehci-platform fe3c0000.usb: USB 2.0 started, EHCI 1.00
[ 1.814439] ohci-platform fe3e0000.usb: irq 45, io mem 0xfe3e0000
[ 1.823726] hub 3-0:1.0: USB hub found
[ 1.909206] hub 3-0:1.0: 1 port detected
[ 1.914847] hub 2-0:1.0: USB hub found
[ 1.919161] hub 2-0:1.0: 1 port detected
[ 1.924643] hub 4-0:1.0: USB hub found
[ 1.928894] hub 4-0:1.0: 1 port detected
[ 2.223120] usb 2-1: new low-speed USB device number 2 using ohci-platform
[ 2.499137] usb 4-1: new full-speed USB device number 2 using ohci-platform
[ 2.803123] rk3x-i2c ff3c0000.i2c: timeout, ipd: 0x00, state: 1
[ 2.809796] rk808 0-001b: failed to read the chip id at 0x17
[ 2.827292] rk808: probe of 0-001b failed with error -110
[ 2.834716] fan53555-regulator 0-0040: FAN53555 Option[8] Rev[1] Detected!
[ 2.847019] fan53555-regulator 0-0041: FAN53555 Option[8] Rev[1] Detected!
[ 2.865672] dw_wdt ff848000.watchdog: No valid TOPs array specified
[ 2.875403] ghes_edac: GHES probing device list is empty
[ 2.875822] cpu cpu0: OPP table can't be empty
[ 2.890602] sdhci: Secure Digital Host Controller Interface driver
[ 2.897553] sdhci: Copyright(c) Pierre Ossman
[ 2.904182] Synopsys Designware Multimedia Card Interface Driver
[ 2.913183] sdhci-pltfm: SDHCI platform and OF driver helper
[ 2.922273] mmc0: CQHCI version 5.10
[ 2.926469] ledtrig-cpu: registered to indicate activity on CPUs
[ 2.935329] SMCCC: SOC_ID: ARCH_SOC_ID not implemented, skipping ....
[ 2.951185] mmc0: SDHCI controller on fe330000.mmc [fe330000.mmc] using ADMA
[ 2.951460] input: SEMICO USB Keyboard as /devices/platform/fe3a0000.usb/usb2/2-1/2-1:1.0/0003:1A2C:4D7E.0001/input/input0
[ 3.023817] mmc0: Command Queue Engine enabled
[ 3.028875] mmc0: new HS400 Enhanced strobe MMC card at address 0001
[ 3.036340] hid-generic 0003:1A2C:4D7E.0001: input: USB HID v1.10 Keyboard [SEMICO USB Keyboard] on usb-fe3a0000.usb-1/input0
[ 3.037207] mmcblk0: mmc0:0001 AJNB4R 14.6 GiB
[ 3.058154] mmcblk0: p1 p2 p3 p4 p5
[ 3.063911] mmcblk0boot0: mmc0:0001 AJNB4R 4.00 MiB
[ 3.064694] input: SEMICO USB Keyboard Consumer Control as /devices/platform/fe3a0000.usb/usb2/2-1/2-1:1.1/0003:1A2C:4D7E.0002/input/input1
[ 3.071167] mmcblk0boot1: mmc0:0001 AJNB4R 4.00 MiB
[ 3.090686] mmcblk0rpmb: mmc0:0001 AJNB4R 4.00 MiB, chardev (511:0)
[ 3.144356] input: SEMICO USB Keyboard System Control as /devices/platform/fe3a0000.usb/usb2/2-1/2-1:1.1/0003:1A2C:4D7E.0002/input/input2
[ 3.159018] input: SEMICO USB Keyboard as /devices/platform/fe3a0000.usb/usb2/2-1/2-1:1.1/0003:1A2C:4D7E.0002/input/input4
[ 3.172066] hid-generic 0003:1A2C:4D7E.0002: input: USB HID v1.10 Keyboard [SEMICO USB Keyboard] on usb-fe3a0000.usb-1/input1
[ 3.190560] input: Logitech USB Receiver as /devices/platform/fe3e0000.usb/usb4/4-1/4-1:1.0/0003:046D:C52B.0003/input/input5
[ 3.260118] hid-generic 0003:046D:C52B.0003: input: USB HID v1.11 Keyboard [Logitech USB Receiver] on usb-fe3e0000.usb-1/input0
[ 3.280394] input: Logitech USB Receiver Mouse as /devices/platform/fe3e0000.usb/usb4/4-1/4-1:1.1/0003:046D:C52B.0004/input/input6
[ 3.294570] input: Logitech USB Receiver Consumer Control as /devices/platform/fe3e0000.usb/usb4/4-1/4-1:1.1/0003:046D:C52B.0004/input/input7
[ 3.368158] input: Logitech USB Receiver System Control as /devices/platform/fe3e0000.usb/usb4/4-1/4-1:1.1/0003:046D:C52B.0004/input/input8
[ 3.382821] hid-generic 0003:046D:C52B.0004: input: USB HID v1.11 Mouse [Logitech USB Receiver] on usb-fe3e0000.usb-1/input1
[ 3.400565] hid-generic 0003:046D:C52B.0005: device has no listeners, quitting
[ 3.408838] usbcore: registered new interface driver usbhid
[ 3.415101] usbhid: USB HID core driver
[ 3.433987] NET: Registered PF_PACKET protocol family
[ 3.439791] 9pnet: Installing 9P2000 support
[ 3.444669] Key type dns_resolver registered
[ 3.473412] registered taskstats version 1
[ 3.478430] Loading compiled-in X.509 certificates
[ 3.529732] rockchip-drm display-subsystem: bound ff8f0000.vop (ops vop_component_ops)
[ 3.539917] rockchip-drm display-subsystem: bound ff900000.vop (ops vop_component_ops)
[ 3.548924] dwhdmi-rockchip ff940000.hdmi: supply avdd-0v9 not found, using dummy regulator
[ 3.558528] dwhdmi-rockchip ff940000.hdmi: supply avdd-1v8 not found, using dummy regulator
[ 3.568175] dwhdmi-rockchip ff940000.hdmi: Detected HDMI TX controller v2.11a with HDCP (DWC HDMI 2.0 TX PHY)
[ 3.582364] rockchip-drm display-subsystem: bound ff940000.hdmi (ops dw_hdmi_rockchip_ops)
[ 3.593511] [drm] Initialized rockchip 1.0.0 20140818 for display-subsystem on minor 0
[ 3.727763] Console: switching to colour frame buffer device 240x67
[ 3.773484] rockchip-drm display-subsystem: [drm] fb0: rockchipdrmfb frame buffer device
[ 3.786139] ALSA device list:
[ 3.789543] No soundcards found.
[ 3.794828] dw-apb-uart ff1a0000.serial: forbid DMA for kernel console
[ 3.809517] EXT4-fs (mmcblk0p5): mounted filesystem 816ef390-7441-461e-b5df-547b6e69bd80 with ordered data mode. Quota mode: none.
[ 3.829064] VFS: Mounted root (ext4 filesystem) on device 179:5.
[ 3.838995] devtmpfs: mounted
[ 3.847418] Freeing unused kernel memory: 8384K
[ 3.854623] Run /sbin/init as init process
[ 4.000583] systemd[1]: System time before build time, advancing clock.
[ 4.048548] systemd[1]: systemd 245.4-4ubuntu3.21 running in system mode. (+PAM +AUDIT +SELINUX +IMA +APPARMOR +SMACK +SYSVINIT +UTMP +LIBCRYPTSETUP +GCRYPT +GNUTLS +ACL +XZ +LZ4 +SECCOMP +BLKID +ELFUTILS +KMOD +IDN2 -IDN +PCRE2 default-hierarchy=hybrid)
[ 4.075728] systemd[1]: Detected architecture arm64.
Welcome to Ubuntu 20.04.4 LTS!
[ 4.172180] systemd[1]: Set hostname to <rk3399>.
[ 4.207428] memfd_create() without MFD_EXEC nor MFD_NOEXEC_SEAL, pid=1 'systemd'
[ 4.455115] systemd[1]: Binding to IPv6 address not available since kernel does not support IPv6.
[ 4.465904] systemd[1]: Binding to IPv6 address not available since kernel does not support IPv6.
[ 7.375294] random: crng init done
[ 7.382370] systemd[1]: Created slice system-getty.slice.
[ OK ] Created slice system-getty.slice.
[ 7.408869] systemd[1]: Created slice system-modprobe.slice.
[ OK ] Created slice system-modprobe.slice.
[ 7.432911] systemd[1]: Created slice system-serial\x2dgetty.slice.
[ OK ] Created slice system-serial\x2dgetty.slice.
[ 7.460678] systemd[1]: Created slice User and Session Slice.
[ OK ] Created slice User and Session Slice.
[ 7.483820] systemd[1]: Started Forward Password Requests to Wall Directory Watch.
[ OK ] Started Forward Password R…uests to Wall Directory Watch.
[ 7.511676] systemd[1]: Condition check resulted in Arbitrary Executable File Formats File System Automount Point being skipped.
[ 7.526061] systemd[1]: Reached target User and Group Name Lookups.
[ OK ] Reached target User and Group Name Lookups.
[ 7.551616] systemd[1]: Reached target Slices.
[ OK ] Reached target Slices.
[ 7.567623] systemd[1]: Reached target Mounting snaps.
[ OK ] Reached target Mounting snaps.
[ 7.580405] systemd[1]: Reached target Mounted snaps.
[ OK ] Reached target Mounted snaps.
[ 7.595643] systemd[1]: Reached target Swap.
[ OK ] Reached target Swap.
[ 7.653110] systemd[1]: Listening on RPCbind Server Activation Socket.
[ OK ] Listening on RPCbind Server Activation Socket.
[ 7.680131] systemd[1]: Listening on Syslog Socket.
[ OK ] Listening on Syslog Socket.
[ 7.699880] systemd[1]: Listening on initctl Compatibility Named Pipe.
[ OK ] Listening on initctl Compatibility Named Pipe.
[ 7.724542] systemd[1]: Listening on Journal Audit Socket.
[ OK ] Listening on Journal Audit Socket.
[ 7.748117] systemd[1]: Listening on Journal Socket (/dev/log).
[ OK ] Listening on Journal Socket (/dev/log).
[ 7.772164] systemd[1]: Listening on Journal Socket.
[ OK ] Listening on Journal Socket.
[ 7.788177] systemd[1]: Listening on udev Control Socket.
[ OK ] Listening on udev Control Socket.
[ 7.811979] systemd[1]: Listening on udev Kernel Socket.
[ OK ] Listening on udev Kernel Socket.
[ 7.871934] systemd[1]: Mounting Huge Pages File System...
Mounting Huge Pages File System...
[ 7.900208] systemd[1]: Mounting POSIX Message Queue File System...
Mounting POSIX Message Queue File System...
[ 7.980051] systemd[1]: Mounting RPC Pipe File System...
Mounting RPC Pipe File System...
[ 8.008144] systemd[1]: Mounting Kernel Debug File System...
Mounting Kernel Debug File System...
[ 8.039921] systemd[1]: Condition check resulted in Kernel Trace File System being skipped.
[ 8.062939] systemd[1]: Starting Journal Service...
Starting Journal Service...
[ 8.088006] systemd[1]: Condition check resulted in Create list of static device nodes for the current kernel being skipped.
[ 8.144178] systemd[1]: Starting Load Kernel Module chromeos_pstore...
Starting Load Kernel Module chromeos_pstore...
[ 8.168781] systemd[1]: Condition check resulted in Load Kernel Module drm being skipped.
[ 8.182022] systemd[1]: Condition check resulted in Load Kernel Module efi_pstore being skipped.
[ 8.232321] systemd[1]: Starting Load Kernel Module pstore_blk...
Starting Load Kernel Module pstore_blk...
[ 8.260223] systemd[1]: Starting Load Kernel Module pstore_zone...
Starting Load Kernel Module pstore_zone...
[ 8.300231] systemd[1]: Starting Load Kernel Module ramoops...
Starting Load Kernel Module ramoops...
[ 8.329126] systemd[1]: Condition check resulted in Set Up Additional Binary Formats being skipped.
[ 8.408262] systemd[1]: Starting Load Kernel Modules...
Starting Load Kernel Modules...
[ 8.436311] systemd[1]: Starting Remount Root and Kernel File Systems...
Starting Remount Root and Kernel File Systems...
[ 8.504272] systemd[1]: Starting udev Coldplug all Devices...
Starting udev Coldplug all Devices...
[ 8.537822] systemd[1]: Started Journal Service.
[ OK ] Started Journal Service.
[ OK ] Mounted Huge Pages File System.
[ OK ] Mounted POSIX Message Queue File System.
[ OK ] Mounted RPC Pipe File System.
[ OK ] Mounted Kernel Debug File System.
[ OK ] Finished Load Kernel Module chromeos_pstore.
[ OK ] Finished Load Kernel Module pstore_blk.
[ OK ] Finished Load Kernel Module pstore_zone.
[ OK ] Finished Load Kernel Module ramoops.
[FAILED] Failed to start Load Kernel Modules.
See 'systemctl status systemd-modules-load.service' for details.
[ OK ] Finished Remount Root and Kernel File Systems.
Mounting Kernel Configuration File System...
Starting Flush Journal to Persistent Storage...
Starting Load/Save Random Seed...
Starting Apply Kernel Variables...
[ 8.857023] systemd-journald[1830]: Received client request to flush runtime journal.
Starting Create System Users...
[ OK ] Mounted Kernel Configuration File System.
[ OK ] Finished Load/Save Random Seed.
[ OK ] Finished Apply Kernel Variables.
[ OK ] Finished Flush Journal to Persistent Storage.
[ OK ] Finished Create System Users.
Starting Create Static Device Nodes in /dev...
[ OK ] Finished Create Static Device Nodes in /dev.
[ OK ] Reached target Local File Systems (Pre).
[ OK ] Reached target Local File Systems.
Starting Preprocess NFS configuration...
Starting Tell Plymouth To Write Out Runtime Data...
Starting Create Volatile Files and Directories...
Starting udev Kernel Device Manager...
[ OK ] Finished udev Coldplug all Devices.
[ OK ] Finished Preprocess NFS configuration.
[ OK ] Finished Tell Plymouth To Write Out Runtime Data.
[ OK ] Finished Create Volatile Files and Directories.
Starting Helper to synchronize boot up for ifupdown...
[ OK ] Reached target NFS client services.
Starting RPC bind portmap service...
Starting Network Name Resolution...
Starting Network Time Synchronization...
Starting Update UTMP about System Boot/Shutdown...
[ OK ] Started udev Kernel Device Manager.
[ OK ] Started RPC bind portmap service.
[ OK ] Reached target Remote File Systems (Pre).
[ OK ] Reached target Remote File Systems.
[ OK ] Reached target RPC Port Mapper.
[ OK ] Started Dispatch Password …ts to Console Directory Watch.
[ OK ] Reached target Local Encrypted Volumes.
[ OK ] Finished Update UTMP about System Boot/Shutdown.
[ OK ] Started Network Time Synchronization.
[ OK ] Reached target System Initialization.
[ OK ] Started CUPS Scheduler.
[ OK ] Started Daily Cleanup of Temporary Directories.
[ OK ] Started Ubuntu Advantage Timer for running repeated jobs.
[ OK ] Reached target Paths.
[ OK ] Reached target System Time Set.
[ OK ] Reached target System Time Synchronized.
[ OK ] Started Trigger anacron every hour.
[ OK ] Started Daily apt download activities.
[ OK ] Started Daily apt upgrade and clean activities.
[ OK ] Started Periodic ext4 Onli…ata Check for All Filesystems.
[ OK ] Started Discard unused blocks once a week.
[ OK ] Started Refresh fwupd metadata regularly.
[ OK ] Started Daily man-db regeneration.
[ OK ] Started Message of the Day.
[ OK ] Reached target Timers.
[ OK ] Listening on Avahi mDNS/DNS-SD Stack Activation Socket.
[ OK ] Listening on CUPS Scheduler.
[ OK ] Listening on D-Bus System Message Bus Socket.
Starting Socket activation for snappy daemon.
[ OK ] Started Network Name Resolution.
[ OK ] Listening on Socket activation for snappy daemon.
[ OK ] Reached target Host and Network Name Lookups.
[ OK ] Reached target Sockets.
[ OK ] Reached target Basic System.
Starting Accounts Service...
[ OK ] Started Run anacron jobs.
Starting LSB: automatic crash report generation...
Starting Avahi mDNS/DNS-SD Stack...
[ OK ] Started Regular background program processing daemon.
[ OK ] Started CUPS Scheduler.
[ OK ] Started D-Bus System Message Bus.
Starting Network Manager...
[ OK ] Started Save initial kernel messages after boot.
Starting Remove Stale Onli…t4 Metadata Check Snapshots...
Starting Dispatcher daemon for systemd-networkd...
[ OK ] Started Set the CPU Frequency Scaling governor.
Starting Authorization Manager...
Starting Restore /etc/reso… the ppp link was shut down...
Starting System Logging Service...
[ OK ] Reached target Login Prompts (Pre).
Starting Snap Daemon...
Starting Switcheroo Control Proxy service...
Starting Login Service...
Starting Disk Manager...
Starting WPA supplicant...
[ OK ] Finished Restore /etc/reso…re the ppp link was shut down.
[ OK ] Started System Logging Service.
[ OK ] Started WPA supplicant.
[ OK ] Started Network Manager.
[ OK ] Started Accounts Service.
[ OK ] Started Authorization Manager.
[ OK ] Started LSB: automatic crash report generation.
[ OK ] Started Switcheroo Control Proxy service.
[ OK ] Started Avahi mDNS/DNS-SD Stack.
Starting Network Manager Wait Online...
[ OK ] Started Make remote CUPS printers available locally.
Starting Modem Manager...
[ OK ] Started Disk Manager.
Starting Hostname Service...
[ OK ] Finished Remove Stale Onli…ext4 Metadata Check Snapshots.
[ OK ] Started Dispatcher daemon for systemd-networkd.
[ OK ] Started Modem Manager.
[ OK ] Started Login Service.
[ OK ] Started Snap Daemon.
[ OK ] Found device /dev/ttyS2.
Starting Wait until snapd is fully seeded...
[ OK ] Started Hostname Service.
Starting Network Manager Script Dispatcher Service...
Starting Time & Date Service...
[ OK ] Started Network Manager Script Dispatcher Service.
[ OK ] Started Time & Date Service.
[ OK ] Finished Network Manager Wait Online.
[ OK ] Finished Helper to synchronize boot up for ifupdown.
Starting Raise network interfaces...
[FAILED] Failed to start Raise network interfaces.
See 'systemctl status networking.service' for details.
[ OK ] Reached target Network.
[ OK ] Reached target Network is Online.
Starting Tool to automatic…mit kernel crash signatures...
Starting OpenVPN service...
Starting OpenBSD Secure Shell server...
Starting Permit User Sessions...
[ OK ] Started Unattended Upgrades Shutdown.
[ OK ] Started crash report submission daemon.
[ OK ] Finished OpenVPN service.
[ OK ] Finished Permit User Sessions.
Starting GNOME Display Manager...
Starting Hold until boot process finishes up...
[ OK ] Finished Hold until boot process finishes up.
[ OK ] Started OpenBSD Secure Shell server.
[ OK ] Started Serial Getty on ttyS2.
[ OK ] Reached target Login Prompts.
[ OK ] Started Tool to automatica…ubmit kernel crash signatures.
[ OK ] Started GNOME Display Manager.
[ OK ] Created slice User Slice of UID 0.
Starting User Runtime Directory /run/user/0...
[ OK ] Finished User Runtime Directory /run/user/0.
Starting User Manager for UID 0...
Ubuntu 20.04.4 LTS rk3399 ttyS2
rk3399 login: root
Password:
Welcome to Ubuntu 20.04.4 LTS (GNU/Linux 6.3.0 aarch64)
* Documentation: https://help.ubuntu.com
* Management: https://landscape.canonical.com
* Support: https://ubuntu.com/advantage
This system has been minimized by removing packages and content that are
not required on a system that users do not log into.
To restore this content, you can run the 'unminimize' command.
The list of available updates is more than a week old.
To check for new updates run: sudo apt update
The programs included with the Ubuntu system are free software;
the exact distribution terms for each program are described in the
individual files in /usr/share/doc/*/copyright.
Ubuntu comes with ABSOLUTELY NO WARRANTY, to the extent permitted by
applicable law.
root@rk3399:~#
3.5 ubuntu
设置以及测试
3.5.1 查看块设备
查看eMMC
块设备文件:
root@rk3399:~# ls /dev/mmc* -l
brw-rw---- 1 root disk 179, 0 Mar 15 23:04 /dev/mmcblk0
brw-rw---- 1 root disk 179, 32 Mar 15 23:04 /dev/mmcblk0boot0
brw-rw---- 1 root disk 179, 64 Mar 15 23:04 /dev/mmcblk0boot1
brw-rw---- 1 root disk 179, 1 Mar 15 23:04 /dev/mmcblk0p1
brw-rw---- 1 root disk 179, 2 Mar 15 23:04 /dev/mmcblk0p2
brw-rw---- 1 root disk 179, 3 Mar 15 23:04 /dev/mmcblk0p3
brw-rw---- 1 root disk 179, 4 Mar 15 23:04 /dev/mmcblk0p4
brw-rw---- 1 root disk 179, 5 Mar 15 23:04 /dev/mmcblk0p5
crw------- 1 root root 511, 0 Mar 15 23:04 /dev/mmcblk0rpmb
这里一共有8
个块设备节点和1
个字符设备节点;其中:
/dev/mmcblk0
表示的是eMMC
这个设备,其主设备号为179
,次设备号为0
;mmcblk0boot0
和mmcblk0boot1
对应两个Boot Area Partition
;每一个Boot Area Partition
大小都是4MB
;mmcblk0rpmb
则为RPMB Partition
;大小为4MB
;mcblk0px
为User Data Area
划分出来的SW Partitions
;实际上就是通过解析GPT
分区表创建的分区,分区编号依次为1,2,3,4,5
;
使用cat /proc/partitions
,可以查看全部分区信息:
root@rk3399:~# cat /proc/partitions
major minor #blocks name
179 0 15267840 mmcblk0
179 1 4000 mmcblk0p1
179 2 4096 mmcblk0p2
179 3 4096 mmcblk0p3
179 4 114688 mmcblk0p4
179 5 15136751 mmcblk0p5
179 32 4096 mmcblk0boot0
179 64 4096 mmcblk0boot1
其中blocks
表示分区的容量,每个blocks
是1KB
。这里:
mmcblk0p1
对应loader1
分区,大小为4000KB
;mmcblk0p2
对应loader2
分区,大小为4MB
;mmcblk0p3
对应trust
分区,大小为4MB
;mmcblk0p4
对应boot
分区,大小为112MB
;mmcblk0p5
对应rootfs
分区,大小为剩余所有空间;
3.5.2 查看磁盘空间并扩容
这里我们可以通过df -hT
查看磁盘空间信息;
root@rk3399:~# df -hT
Filesystem Type Size Used Avail Use% Mounted on
/dev/root ext4 3.9G 3.7G 19M 100% /
devtmpfs devtmpfs 1.9G 0 1.9G 0% /dev
tmpfs tmpfs 1.9G 0 1.9G 0% /dev/shm
tmpfs tmpfs 386M 1.5M 385M 1% /run
tmpfs tmpfs 5.0M 0 5.0M 0% /run/lock
tmpfs tmpfs 1.9G 0 1.9G 0% /sys/fs/cgroup
tmpfs tmpfs 386M 64K 386M 1% /run/user/0
显示内容参数说明:
Filesystem
:文件系统;Type
:文件系统类型;Siz
: 分区大小;Used
: 已使用容量;Avail
: 还可以使用的容量;Use%
: 已用百分比;Mounted on
: 挂载点;
这里我们可以看到根目录挂载在/dev/root
设备节点上,文件系统格式是ext4
,/dev/root
其实就是/dev/mmcblk0p5
,也就是eMMC
设备的rootfs
分区;
我们eMMC
卡是14.57G
,并且我们在u-boot
命令行写入的分区表中/dev/mmcblk0p5
扇区区间为:0x00040000
~0x01d1efde
,大小为14.4G
?但是为什么这里看到的/dev/root
大小只有3.9G
呢?
这主要是因为我们制作的根文件系统镜像就是那么大,这里我们可以通过resize2fs
指令调整ext2
、ext3
或ext4
文件系统的大小,以便利用分区中的额外空间或者缩小文件系统来适应较小的分区大小:
root@rk3399:~# resize2fs /dev/mmcblk0p5
resize2fs 1.45.5 (07-Jan-2020)
Filesystem at /dev/mmcblk0p5 is mounted on /; on-line resizing required
old_desc_blocks = 1, new_desc_blocks = 2
The filesystem on /dev/mmcblk0p5 is now 3784187 (4k) blocks long.
root@rk3399:~# df -hT
Filesystem Type Size Used Avail Use% Mounted on
/dev/root ext4 15G 3.7G 9.9G 28% /
devtmpfs devtmpfs 1.9G 0 1.9G 0% /dev
tmpfs tmpfs 1.9G 0 1.9G 0% /dev/shm
tmpfs tmpfs 386M 1.5M 385M 1% /run
tmpfs tmpfs 5.0M 0 5.0M 0% /run/lock
tmpfs tmpfs 1.9G 0 1.9G 0% /sys/fs/cgroup
tmpfs tmpfs 386M 64K 386M 1% /run/user/0
在我们扩容完成后,稍等一会,显示器上会进入ubuntu
桌面系统(如果不扩容的话,由于/目录没有磁盘空间了,也就进不了ubuntu
桌面环境的)。
如果无法进入ubuntu
系统,或者启动时显示器上没有输出任何启动日志,考虑配置内核时是否配置了DRM
驱动。
3.5.3 fdisk
分区命令
使用fdisk -l
查看磁盘分区情况:
root@rk3399:~# fdisk -l
Disk /dev/mmcblk0: 14.57 GiB, 15634268160 bytes, 30535680 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: gpt
Disk identifier: 69DAD710-2CE4-4E3C-B16C-21A1D49ABED3
Device Start End Sectors Size Type
/dev/mmcblk0p1 64 8063 8000 3.9M Microsoft basic data
/dev/mmcblk0p2 16384 24575 8192 4M Microsoft basic data
/dev/mmcblk0p3 24576 32767 8192 4M Microsoft basic data
/dev/mmcblk0p4 32768 262143 229376 112M Microsoft basic data
/dev/mmcblk0p5 262144 30535646 30273503 14.4G Microsoft basic data
Disk /dev/mmcblk0boot0: 4 MiB, 4194304 bytes, 8192 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk /dev/mmcblk0boot1: 4 MiB, 4194304 bytes, 8192 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
从上面的内容可以看到磁盘/dev/mmcblk0
大小为14.57GB
,总容量为1908480*16*512=15,634,268,160
字节。Disklabel type: gpt
表示分区表为gpt
。
3.5.4 parted
分区命令
对于GPT
格式的分区,fdisk
工具是无能为力的,同时,fdisk
工具对分区是有大小限制的,它只能划分小于2T
的磁盘。
但是现在的磁盘空间很多都已经是远远大于2T
,此时就需要另外一个磁盘管理工具parted
来完成大于2T
的磁盘分区工作。
使用parted
命令查看现在的分区情况,parted
后输入p
指令:
root@rk3399:~# parted
GNU Parted 3.3
Using /dev/mmcblk0
Welcome to GNU Parted! Type 'help' to view a list of commands.
(parted) p
Model: MMC AJNB4R (sd/mmc)
Disk /dev/mmcblk0: 15.6GB
Sector size (logical/physical): 512B/512B
Partition Table: gpt
Disk Flags:
Number Start End Size File system Name Flags
1 32.8kB 4129kB 4096kB loader1 msftdata
2 8389kB 12.6MB 4194kB loader2 msftdata
3 12.6MB 16.8MB 4194kB trust msftdata
4 16.8MB 134MB 117MB boot legacy_boot, msftdata
5 134MB 15.6GB 15.5GB ext4 rootfs msftdata
从上面的内容可以看到磁盘/dev/mmcblk0
大小为15.6GB
。Partition Tablete: gpt
表示分区表为gpt
。
3.5.5 tty
命令
在串口终端输入tty
,可以看到串口终端设备节点为/dev/ttyS2
:
root@rk3399:~# tty
/dev/ttyS2
3.5.6 ssh
远程连接
查看网络服务状态:
root@rk3399:~# systemctl status NetworkManager.service
● NetworkManager.service - Network Manager
Loaded: loaded (/lib/systemd/system/NetworkManager.service; enabled; vendor
preset: enabled)
Active: active (running) since Tue 2023-06-13 23:10:19 CST; 18mi
n ago
Docs: man:NetworkManager(8)
Main PID: 3803 (NetworkManager)
Tasks: 3 (limit: 4581)
Memory: 11.4M
CGroup: /system.slice/NetworkManager.service
└─3803 /usr/sbin/NetworkManager --no-daemon
Jun 13 23:10:20 rk3399 NetworkManager[3803]: <info> [1686669020.7622] ifupdown:
guessed connection type (wlan0) = 802-3-ethernet
Jun 13 23:10:20 rk3399 NetworkManager[3803]: <info> [1686669020.7698] device (l
o): carrier: link connected
Jun 13 23:10:20 rk3399 NetworkManager[3803]: <info> [1686669020.7726] manager:
(lo): new Generic device (/org/freedesktop/NetworkManager/Devices/1)
Jun 13 23:10:20 rk3399 NetworkManager[3803]: <info> [1686669020.7773] device (e
th0): driver '(null)' does not support carrier detection.
Jun 13 23:10:20 rk3399 NetworkManager[3803]: <info> [1686669020.7790] device (e
th0): driver 'unknown' does not support carrier detection.
Jun 13 23:10:20 rk3399 NetworkManager[3803]: <info> [1686669020.7816] manager:
(eth0): new Ethernet device (/org/freedesktop/NetworkManager/Devices/2)
Jun 13 23:10:20 rk3399 NetworkManager[3803]: <info> [1686669020.7944] manager:
NetworkManager state is now CONNECTED_GLOBAL
Jun 13 23:10:20 rk3399 NetworkManager[3803]: <info> [1686669020.8459] modem-man
ager: ModemManager available
Jun 13 23:10:21 rk3399 NetworkManager[3803]: <info> [1686669021.2532] manager:
startup complete
Jun 13 23:10:43 rk3399 NetworkManager[3803]: <info> [1686669043.6362] agent-man
ager: agent[c6904da43d63520f,:1.39/org.gnome.Shell.NetworkAgent/0]: agent regist
ered
输入ifconfig
命令后,由于我们配置了有线网卡驱动,因此可以看到网络配置信息;
root@rk3399:~# ifconfig -a
eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 192.168.0.101 netmask 255.255.255.0 broadcast 192.168.0.255
ether 92:a7:05:0f:19:86 txqueuelen 1000 (Ethernet)
RX packets 111 bytes 10678 (10.6 KB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 87 bytes 6286 (6.2 KB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
device interrupt 24
lo: flags=73<UP,LOOPBACK,RUNNING> mtu 65536
inet 127.0.0.1 netmask 255.0.0.0
loop txqueuelen 1000 (Local Loopback)
RX packets 133 bytes 10248 (10.2 KB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 133 bytes 10248 (10.2 KB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
我们可以看到开发板的ip
地址为192.168.0.101
,因此我们可以使用ping
测试和我们宿主机之间的网络通不通;
root@rk3399:~# ping 192.168.0.200
PING 192.168.0.200 (192.168.0.200) 56(84) bytes of data.
64 bytes from 192.168.0.200: icmp_seq=1 ttl=64 time=2.56 ms
64 bytes from 192.168.0.200: icmp_seq=2 ttl=64 time=1.75 ms
64 bytes from 192.168.0.200: icmp_seq=3 ttl=64 time=1.38 ms
64 bytes from 192.168.0.200: icmp_seq=4 ttl=64 time=1.43 ms
64 bytes from 192.168.0.200: icmp_seq=5 ttl=64 time=1.45 ms
^C
--- 192.168.0.200 ping statistics ---
5 packets transmitted, 5 received, 0% packet loss, time 4007ms
rtt min/avg/max/mdev = 1.380/1.712/2.563/0.444 ms
既然网络是通过的,那么我们就可以通过ssh
远程连接工具连接我们的开发板,这里我使用的是MobaXterm
,需要注意的是ubuntu
系统默认是禁止使用root
在用户登录的,这里我们使用zhengyang
用户登录,登录之后如下所示;
login as: zhengyang
┌────────────────────────────────────────────────────────────────────┐
│ • MobaXterm 11.1 • │
│ (SSH client, X-server and networking tools) │
│ │
│ ➤ SSH session to zhengyang@192.168.0.101 │
│ • SSH compression : ✔ │
│ • SSH-browser : ✔ │
│ • X11-forwarding : ✔ (remote display is forwarded through SSH) │
│ • DISPLAY : ✔ (automatically set on remote server) │
│ │
│ ➤ For more info, ctrl+click on help or visit our website │
└────────────────────────────────────────────────────────────────────┘
Welcome to Ubuntu 20.04.4 LTS (GNU/Linux 6.3.0 aarch64)
* Documentation: https://help.ubuntu.com
* Management: https://landscape.canonical.com
* Support: https://ubuntu.com/advantage
This system has been minimized by removing packages and content that are
not required on a system that users do not log into.
To restore this content, you can run the 'unminimize' command.
Expanded Security Maintenance for Applications is not enabled.
177 updates can be applied immediately.
125 of these updates are standard security updates.
To see these additional updates run: apt list --upgradable
Enable ESM Apps to receive additional future security updates.
See https://ubuntu.com/esm or run: sudo pro status
New release '22.04.2 LTS' available.
Run 'do-release-upgrade' to upgrade to it.
Last login: Tue Jun 13 22:32:24 2023 from 192.168.0.110
zhengyang@rk3399:~$
我们可以使用su
命令切换到root
用户:
zhengyang@rk3399:~$ su root
Password:
3.5.7 禁用系统休眠
禁用系统休眠;
root@rk3399:/# systemctl mask sleep.target suspend.target hibernate.target hybrid-sleep.target
root@rk3399:/# gsettings set org.gnome.desktop.screensaver lock-enabled false
root@rk3399:/# gsettings set org.gnome.desktop.session idle-delay 0
该设置可能无效,可以通过桌面系统设置,点击【右上角倒三角】-- 【Privacy
】--【Screen Lock
】;
![](https://gitee.com/zyly2033/blog-pic/raw/master/202404272049837.png)
3.5.8 top
我们查看CPU
使用情况
root@rk3399:~# top
top - 19:10:47 up 20 min, 2 users, load average: 1.12, 1.05, 0.90
Tasks: 215 total, 2 running, 213 sleeping, 0 stopped, 0 zombie
%Cpu(s): 10.7 us, 2.4 sy, 3.4 ni, 83.0 id, 0.1 wa, 0.2 hi, 0.2 si, 0.0 st
MiB Mem : 3875.0 total, 1843.1 free, 840.3 used, 1191.7 buff/cache
MiB Swap: 0.0 total, 0.0 free, 0.0 used. 2921.2 avail Mem
PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
5308 root 20 0 361524 192936 135180 R 62.4 4.9 5:45.10 unattended-upgr
8821 root 20 0 6004 3044 2316 R 0.7 0.1 0:00.14 top
92 root 20 0 0 0 0 I 0.3 0.0 0:01.03 kworker/u12:3-events_power_efficient
2916 message+ 20 0 10500 5996 3468 S 0.3 0.2 0:05.53 dbus-daemon
3620 root 20 0 320420 12412 9080 S 0.3 0.3 0:00.80 goa-identity-se
5119 zhengya+ 20 0 15292 6540 5228 S 0.3 0.2 0:00.64 sshd
5128 zhengya+ 20 0 320420 10288 9008 S 0.3 0.3 0:00.68 goa-identity-se
1 root 20 0 168244 10508 7232 S 0.0 0.3 0:12.70 systemd
2 root 20 0 0 0 0 S 0.0 0.0 0:00.01 kthreadd
3 root 0 -20 0 0 0 I 0.0 0.0 0:00.00 rcu_gp
4 root 0 -20 0 0 0 I 0.0 0.0 0:00.00 rcu_par_gp
5 root 20 0 0 0 0 I 0.0 0.0 0:00.08 kworker/0:0-cgroup_destroy
8 root 0 -20 0 0 0 I 0.0 0.0 0:00.00 mm_percpu_wq
9 root 20 0 0 0 0 S 0.0 0.0 0:00.04 ksoftirqd/0
我们发现第一个进程unattended-upgr CPU
占用率很高,这个UU(unattended upgrades)
进程就是ubuntu
搞的一个类似于windows
系统的自动更新程序,目的是让普通用户的系统能随时保持最新,但对于开发来说实属麻烦。这个进程会在后台自动下载和安装系统更新文件,会阻止关机,有时候还会阻止你安装其他软件。
因此直接将其卸载,输入如下命令:
root@rk3399:~# sudo apt remove unattended-upgrades
Waiting for cache lock: Could not get lock /var/lib/dpkg/lock-frontend. It is held by process 5308 (unattended-upgr)
Waiting for cache lock: Could not get lock /var/lib/dpkg/lock-frontend. It is held by process 5308 (unattended-upgr)
然而这里提示有ID
为5308
的进程占用,因此我们把5308
进程kill
掉,然后继续卸载;
root@rk3399:~# kill -9 5308
root@rk3399:~# sudo apt remove unattended-upgrades
再次查看CPU
的使用情况,发现已经恢复了正常;
root@rk3399:~# top
top - 19:18:30 up 28 min, 2 users, load average: 0.49, 0.91, 0.94
Tasks: 209 total, 1 running, 208 sleeping, 0 stopped, 0 zombie
%Cpu(s): 0.1 us, 0.1 sy, 0.0 ni, 99.8 id, 0.0 wa, 0.0 hi, 0.0 si, 0.0 st
MiB Mem : 3875.0 total, 1965.5 free, 782.1 used, 1127.4 buff/cache
MiB Swap: 0.0 total, 0.0 free, 0.0 used. 2979.5 avail Mem
PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
11212 root 20 0 5992 2940 2224 R 1.0 0.1 0:00.27 top
5119 zhengya+ 20 0 15292 6540 5228 S 0.3 0.2 0:00.70 sshd
1 root 20 0 168244 10520 7232 S 0.0 0.3 0:15.64 systemd
2 root 20 0 0 0 0 S 0.0 0.0 0:00.01 kthreadd
3 root 0 -20 0 0 0 I 0.0 0.0 0:00.00 rcu_gp
4 root 0 -20 0 0 0 I 0.0 0.0 0:00.00 rcu_par_gp
3.6 备份文件系统
3.6.1 方案一
ubuntu
虚拟机以及开发板安装rsync
服务:
root@ubuntu:~# cd /work/sambashare/rk3399/rootfs
root@ubuntu:/work/sambashare/rk3399/rootfs# apt install rsync # 虚拟机
root@rk3399:~# apt install rsync
在ubuntu
虚拟机创建一个操作目录,如ubuntu-focal
;
root@ubuntu:/work/sambashare/rk3399/ubuntu# mkdir ubuntu-focal
root@ubuntu:/work/sambashare/rk3399/rootfs# cd ubuntu-focal/
把开发板上的根文件系统克隆到ubuntu-focal
文件夹,此处假设开发板IP
为192.168.0.105
;
root@ubuntu:/work/sambashare/rk3399/rootfs/ubuntu-focal# rsync -avx root@192.168.0.105:/ ./
命令执行完后,./ubuntu-focal
里就保存着和开发板系统上一样的文件系统内容了;
执行如下命令打包生成ubuntu_focal_ext4_rootfs.img
文件:
#!/bin/bash
rootfs_name=ubuntu_focal_ext4_rootfs.img
ubuntu_path=./ubuntu-focal
rm -rf ubuntu_rootfs
mkdir ubuntu_rootfs
dd if=/dev/zero of=${rootfs_name} bs=1M count=6144
mkfs.ext4 ${rootfs_name}
mount ${rootfs_name} ubuntu_rootfs/
cp ${ubuntu_path}/* ./ubuntu_rootfs/ -af
umount ubuntu_rootfs
rm -rf ubuntu_rootfs
e2fsck -p -f ${rootfs_name}
resize2fs -M ${rootfs_name}
此时我们已经得到了ext4
根文件系统镜像ubuntu_focal_ext4_rootfs.img
,最终得到的ext4
根文件系统镜像ubuntu_focal_ext4_rootfs.img
大小为4.5G
。
3.6.2 方案二
开发板上执行以下命令,备份整个文件系统:
root@rk3399:~# sudo passwd root
root@rk3399:~# su root
root@rk3399:~# cd /
root@rk3399:~# tar --warning=no-file-changed -cvpzf /rootfs.tar.gz \
--exclude=/rootfs.tar.gz --exclude=/opt --one-file-system /
四、NFS
根文件系统支持
在《Rockchip RK3399
- 移植linux 5.2.8
》第4
小节,我们对bootargs
参数进行了详细的介绍;
bootargs=earlycon=uart8250,mmio32,0xff1a0000 console=tty0 console=ttyS2,115200n8 root=PARTUUID=B921B045-1D rw rootwait rootfstype=ext4 init=/sbin/init
尤其是根文件系统参数root
,通过root
属性指定根文件系统所在位置,当时我们将其配置为分区表中UUID
值为B921B045-1D
的分区。
这一节我们将介绍使用NFS
作为根文件系统,因为文件系统在宿主机中,这样在修改文件系统就非常方便,主要用于开发阶段使用。
4.1 准备工作
在之前的章节,我们曾经搭建了《NFS
服务器》,我们尝试通过nfs
来挂载根文件系统rootfs
,该文件系统位于/work/sambashare
路径下。我们将根文件系统复制到nfs
共享路径下:
root@ubuntu://work/sambashare/rk3399# mv rootfs/ubuntu /work/nfs_root/
4.2 设置bootargs
将开发板通过HDMI
接口连接上显示器,给开发板上电,通过串口打印输出。
在倒计时执行完之前,按CTRL+C
即可进入uboot
命令行,查看启动参数:
=> print bootargs
bootargs=earlycon=uart8250,mmio32,0xff1a0000 console=tty0 console=ttyS2,115200n8 root=PARTUUID=B921B045-1D rw rootwait rootfstype=ext4 init=/sbin/init
设置启动命令参数:
=> setenv bootargs earlycon=uart8250,mmio32,0xff1a0000 console=tty0 console=ttyS2,115200n8 root=/dev/nfs rw rootwait nfsroot=192.168.0.200:/work/nfs_root/ubuntu,vers=4 ip=192.168.0.105:192.168.0.200:192.168.0.1:255.255.255.0::eth0:off rootfstype=ext4
其中:
root
表示使用/dev/nfs
这个设备作为根文件系统。rw
表示可读可写的;rw
表示可以对根文件系统进行读写,默认配置是只读;rootwait
表示在根文件系统就绪之前无限等待。主要用于等待那些反应速度较慢的异步检测的设备就绪(例如USB/MMC/FireWire)
;nfsroot
表示服务器中rootfs
所在路径,注意需要跟上服务器的ip
地址;192.168.0.105
是板子启动之后的ip
地址;192.168.0.200
是nfs
服务器的ip
地址;192.168.0.1
是板子网关地址;255.255.255.0
是板子子网掩码;rootfstype
为根文件系统类型;
eth0
表示板子上的网络设备。 off
表示关闭动态获取ip
地址。 注意:eth0
前面有两个冒号,那是因为这里还可以填写一个板子的主机名,这里没有设置,所以为空。
注意:这里并没有保存启动参数。
4.3 启动内核
启动内核,这里就不输出内核启动日志了;
=> boot
4.4 查看磁盘空间
这里我们可以通过df -hT
查看磁盘空间信息;
root@rk3399:/# df -hT
Filesystem Type Size Used Avail Use% Mounted on
192.168.0.200:/work/nfs_root/ubuntu nfs4 196G 147G 41G 79% /
devtmpfs devtmpfs 1.9G 0 1.9G 0% /dev
tmpfs tmpfs 1.9G 0 1.9G 0% /dev/shm
tmpfs tmpfs 386M 1.9M 384M 1% /run
tmpfs tmpfs 5.0M 4.0K 5.0M 1% /run/lock
tmpfs tmpfs 1.9G 0 1.9G 0% /sys/fs/cgroup
tmpfs tmpfs 386M 128K 386M 1% /run/user/0
tmpfs tmpfs 386M 40K 386M 1% /run/user/1000
参考文章
[1] 基于ubuntu-base
构建根文件系统并移植到RK3568
开发板
[3] Ubuntu
根文件系统构建
[6] Linux DRM
(三) RK
平台DRM
代码分析 · Rockchip
[7] RK3399
探索之旅