基于讯为RK3588平台搭建Ubuntu20.04.5根文件系统

这篇具有很好参考价值的文章主要介绍了基于讯为RK3588平台搭建Ubuntu20.04.5根文件系统。希望对大家有所帮助。如果存在错误或未考虑完全的地方,请大家不吝赐教,您也可以点击"举报违法"按钮提交疑问。

准备工作

在搭建系统之前,需要详细阅读讯为公司提供的一些资料(虽然他们家资料一直都做的不完善),搭建好用于开发的Ubuntu虚拟机环境,熟练使用一些常用工具如烧录系统的工具RKDevTool、传输文件的工具FileZilla、远程连接工具MobaXterm等等。当然,本章只针对根文件系统,uboot、kernel的镜像文件和驱动文件需要提前准备好,编译讯为提供的Rockchip的SDK即可得到这些文件。

最小Ubuntu根文件系统

Ubuntu在镜像网站Index of / (ubuntu.com)提供了各种版本的镜像文件,我们从下面的连接下载最小系统,之后继续安装桌面软件包,进行一系列的配置就可以获得我们需要的系统。

ubuntu-base-20.04.1-base-arm64.tar.gz

先寻找一个空白的文件夹放置ubuntu-base-20.04.1-base-arm64.tar.gz,然后以root权限建立一个文件夹,将根文件系统解压到这个文件夹中。

sudo mkdir ubuntu-rootfs
sudo tar -xvpf ubuntu-base-20.04.5-base-arm64.tar.gz -C ubuntu-rootfs

接下来在Ubuntu虚拟机上模拟运行arm64架构的最小文件系统,为此需要安装qemu-user-static。

sudo apt-get install qemu-user-static
# 适用于arm 32位架构
sudo cp /usr/bin/qemu-arm-static ubuntu-rootfs/usr/bin/
# 适用于aarch64即arm64架构
sudo cp /usr/bin/qemu-aarch64-static ubuntu-rootfs/usr/bin/

为了连接网络,需要拷贝resolv.conf文件以及配置国内的镜像源。

# 拷贝文件
sudo cp -b /etc/resolv.conf ubuntu-rootfs/etc/resolv.conf
# 修改镜像源
sudo gedit ubuntu-rootfs/etc/apt/sources.list

下面是阿里云镜像源,可以直接复制内容覆盖源镜像列表文件。

# See http://help.ubuntu.com/community/UpgradeNotes for how to upgrade to
# newer versions of the distribution.
deb http://mirrors.aliyun.com/ubuntu-ports/ focal main restricted
# deb-src http://mirrors.aliyun.com/ubuntu-ports/ focal main restricted

## Major bug fix updates produced after the final release of the
## distribution.
deb http://mirrors.aliyun.com/ubuntu-ports/ focal-updates main restricted
# deb-src http://mirrors.aliyun.com/ubuntu-ports/ focal-updates main restricted

## N.B. software from this repository is ENTIRELY UNSUPPORTED by the Ubuntu
## team. Also, please note that software in universe WILL NOT receive any
## review or updates from the Ubuntu security team.
deb http://mirrors.aliyun.com/ubuntu-ports/ focal universe
# deb-src http://mirrors.aliyun.com/ubuntu-ports/ focal universe
deb http://mirrors.aliyun.com/ubuntu-ports/ focal-updates universe
# deb-src http://mirrors.aliyun.com/ubuntu-ports/ focal-updates universe

## N.B. software from this repository is ENTIRELY UNSUPPORTED by the Ubuntu
## team, and may not be under a free licence. Please satisfy yourself as to
## your rights to use the software. Also, please note that software in
## multiverse WILL NOT receive any review or updates from the Ubuntu
## security team.
deb http://mirrors.aliyun.com/ubuntu-ports/ focal multiverse
# deb-src http://mirrors.aliyun.com/ubuntu-ports/ focal multiverse
deb http://mirrors.aliyun.com/ubuntu-ports/ focal-updates multiverse
# deb-src http://mirrors.aliyun.com/ubuntu-ports/ focal-updates multiverse

## N.B. software from this repository may not have been tested as
## extensively as that contained in the main release, although it includes
## newer versions of some applications which may provide useful features.
## Also, please note that software in backports WILL NOT receive any review
## or updates from the Ubuntu security team.
deb http://mirrors.aliyun.com/ubuntu-ports/ focal-backports main restricted universe multiverse
# deb-src http://mirrors.aliyun.com/ubuntu-ports/ focal-backports main restricted universe multiverse

## Uncomment the following two lines to add software from Canonical's
## 'partner' repository.
## This software is not part of Ubuntu, but is offered by Canonical and the
## respective vendors as a service to Ubuntu users.
# deb http://archive.canonical.com/ubuntu focal partner
# deb-src http://archive.canonical.com/ubuntu focal partner

deb http://mirrors.aliyun.com/ubuntu-ports/ focal-security main restricted
# deb-src http://mirrors.aliyun.com/ubuntu-ports/ focal-security main restricted
deb http://mirrors.aliyun.com/ubuntu-ports/ focal-security universe
# deb-src http://mirrors.aliyun.com/ubuntu-ports/ focal-security universe
deb http://mirrors.aliyun.com/ubuntu-ports/ focal-security multiverse
# deb-src http://mirrors.aliyun.com/ubuntu-ports/ focal-security multiverse

编写一个挂载脚本mount.sh,方便进入和退出arm64的文件系统

#!/bin/bash
function 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 -t devpts -o gid=5,mode=620 devpts ${2}dev/pts
  sudo mount -o bind /dev/pts ${2}dev/pts
  sudo chroot ${2}
}
function 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

更新与安装

进入arm64的根文件系统后,终端将只能操作arm64的根文件系统,通过exit命令退出并返回Ubuntu虚拟机的终端。

# 进入arm64的根文件系统
./mount.sh -m ubuntu-rootfs/

更新并升级根文件系统。

apt update
apt upgrade

安装一些必要的软件,如vim、sudo、网络管理、蓝牙管理等等。

apt install apt-utils dialog
apt install vim sudo
apt install bash-completion 
apt install net-tools iputils-ping ifupdown ethtool
apt install wireless-tools network-manager
apt install ssh rsync udev htop rsyslog
apt install bluetooth* bluez* blueman*
# 可装可不装
apt install curl
apt install openssh-server
apt install git
apt install ffmpeg

配置系统的时区、文字编码。

apt install locales tzdata
# 时区选择
# Asia/Shanghai
dpkg-reconfigure locales
# 勾选英文和中文环境
# en_US.UTF-8 UTF-8
# zh_CN.UTF-8 UTF-8

安装图形环境,依赖非常多,占用空间3G多。

apt install ubuntu-desktop

开机默认切换到图形界面。

systemctl set-default graphical.target

Network-Manager服务会自动配置网卡,但是其默认配置文件将Ethernet加入了黑名单,以至于Ubuntu提示unmanned。

vi /usr/lib/NetworkManager/conf.d/10-globally-managed-devices.conf
# 文件内容改为如下内容
[keyfile]
unmanaged-devices=*,except:type:ethernet,except:type:wifi,except:type:gsm,except:type:cdma

设置主机名,增加用户,修改账户密码。

# 主机名
echo "RK3588" > /etc/hostname
# 主机IP地址
echo "127.0.0.1 localhost RK3588" > /etc/hosts
# 添加用户
useradd -s '/bin/bash' -m -G adm,sudo user
# 设置密码
passwd user
passwd root

安装中英文语言包和中文输入法。

# 英文环境
apt install language-pack-en-base 
apt install language-pack-gnome-en-base 

# 中文环境
apt install language-pack-zh-hans-base 
apt install language-pack-gnome-zh-hans-base

# 中文输入法
apt install ibus-table-wubi ibus-pinyin ibus-sunpinyin

服务配置

桌面环境需要的包已经基本安装完成,接下来需要一些别的配置。

Ubuntu根文件系统打包成镜像并烧录到emmc后,所占分区大小和镜像的大小一样,为了充分利用emmc的空间,需要在第一次运行时扩充分区大小。根据parameter.txt中rootfs分区对应的名称配置, 默认是对/dev/mmcblk0p6分区进行扩充。创建一个脚本和服务来扩充分区。

vi etc/init.d/firstboot.sh
# 以下是firstboot.sh的内容
#!/bin/bash -e
# first boot configure
# resize filesystem mmcblk0p6
if [ ! -e "/usr/local/first_boot_flag" ] ;
then
  echo "Resizing /dev/mmcblk0p6..."
  resize2fs /dev/mmcblk0p6
  touch /usr/local/first_boot_flag
fi

添加运行权限。

chmod +x etc/init.d/firstboot.sh
vi lib/systemd/system/firstboot.service
# 以下是firstboot.service的内容
#start
[Unit]
Description=Setup rockchip platform environment
Before=lightdm.service
After=resize-helper.service
[Service]
Type=simple
ExecStart=/etc/init.d/firstboot.sh
[Install]
WantedBy=multi-user.target
#end

启动firstboot.service服务。

systemctl enable firstboot.service

启用ssh的root帐号登录。

vi /etc/ssh/sshd_config
# 将下面这项设置成yes
PermitRootLogin yes

Ubuntu默认不能用root登录界面,可以配置启用以root登录界面。

vi /usr/share/lightdm/lightdm.conf.d/50-ubuntu.conf
# 添加下面的内容
greeter-show-manual-login=true
all-guest=false

vi /etc/pam.d/gdm-autologin
# 注释掉下面这行
#auth   required        pam_succeed_if.so user != root quiet_success

vi /etc/pam.d/gdm-password
# 注释掉下面这行
#auth   required        pam_succeed_if.so user != root quiet_success

vi /root/.profile
# 添加下面的内容,替换掉 mesg n || true 这一行
tty -s && mesg n || true

可以设置界面的自动登录。

vi /etc/gdm3/custom.conf
# 添加下面的内容,user即账户名
[daemon]
AutomaticLoginEnable=true
AutomaticLogin=user
TimedLoginEnable=true
TimedLogin=user
TimedLoginDelay=10

为方便在没有网络的时候调试,设置通过串口登录root。

vi /lib/systemd/system/serial-getty\@.service
# 替换ExecStart这行
ExecStart=-/sbin/agetty --autologin root --noclear %I $TERM

打包镜像

退出arm64文件系统环境,回到宿主机环境,卸载挂载的目录

# 退出arm64的根文件系统
exit
# 卸载挂载的目录
./mount.sh -u ubuntu-rootfs/

讯为RK3588平台采用RTL8723du这款wifi和Bluetooth二合一基于USB总线的无线设备,其驱动被编译成了模块,需要安装这些模块才能启用无线和蓝牙,其中蓝牙还需要RTL官方的固件。这些文件可以在编译Debian后的输出目录的中(/lib/firmware)找到,需要将这些文件拷贝到我们的根文件系统中。8723du.ko是wifi的驱动,rtk_btusb.ko是蓝牙的驱动。

# copy 8723du.ko to ubuntu-rootfs/lib/modules/5.10.66
# copy rtk_btusb.ko to ubuntu-rootfs/lib/modules/5.10.66
# copy rtl8723du_config rtl8723du_fw to /lib/firmware
# Linux会自动安装modprobe安装过的驱动
# depmod也许会提示缺少modules.order modules.builtin文件,这些文件是编译内核后生成的,同样复制到ubuntu-rootfs/lib/modules/5.10.66即可
depmod
modprobe 8723du.ko
modprobe rtk_btusb.ko

制作镜像脚本,空间分配6G

vi mkimage.sh
# mkimage.sh内容如下
#!/bin/bash
rootfs_dir=$1
rootfs_file=$2
rootfs_mnt="mnt"
if [ ! $rootfs_dir ] || [ ! $rootfs_file ];
then
  echo "Folder or target is empty."
  exit 0
fi
if [ -f "$rootfs_file" ]; then
  echo "-- Delete exist $rootfs_file ..."
  rm -f "$rootfs_file"
fi
echo "-- Create $rootfs_file ..."
dd if=/dev/zero of="$rootfs_file" bs=1M count=6144
sudo mkfs.ext4 -F -L linuxroot "$rootfs_file"
if [ ! -d "$rootfs_mnt" ]; then
  mkdir $rootfs_mnt
fi
echo "-- Copy data to $rootfs_file ..."
sudo mount $rootfs_file $rootfs_mnt
sudo cp -rfp $rootfs_dir/* $rootfs_mnt
sudo sync
sudo umount $rootfs_mnt
rm -r $rootfs_mnt
echo "-- Resize $rootfs_file ..."
/sbin/e2fsck -p -f "$rootfs_file"
/sbin/resize2fs -M "$rootfs_file"
echo "-- Done."

制作镜像,制作完成后即可进行烧录。

./mkimage.sh ubuntu-rootfs rootfs.img

待解决的问题

1)Ubuntu选择语言的界面为空,选择输入法的界面为空,原因未知。

rk3588 rtl8723du,RK3588学习笔记,ubuntu,linux,arm开发,Powered by 金山文档
rk3588 rtl8723du,RK3588学习笔记,ubuntu,linux,arm开发,Powered by 金山文档

2)firefly的Ubuntu镜像优化的很不错,用wayland替代了XServer,界面非常流畅,但是运行在非firefly的设备上,会在开机显示logo时提示 This's not a firefly's product。文章来源地址https://www.toymoban.com/news/detail-781730.html

到了这里,关于基于讯为RK3588平台搭建Ubuntu20.04.5根文件系统的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处: 如若内容造成侵权/违法违规/事实不符,请点击违法举报进行投诉反馈,一经查实,立即删除!

领支付宝红包赞助服务器费用

相关文章

  • Gazebo——仿真平台搭建(基于Ubuntu20.04)
                    
            
1.gazebo--SpawnModel: Failure - model name mrobot already exists.

    Gazebo——仿真平台搭建(基于Ubuntu20.04) 1.gazebo--SpawnModel: Failure - model name mrobot already exists.

    目录 Gazebo安装配置 创建仿真环境  仿真使用 Rviz查看摄像头采集的信息 Kinect仿真 问题解决: 1.gazebo--SpawnModel: Failure - model name mrobot already exists. 1.设置你的电脑来接收软件 2.设置秘钥 3.安装Gazebo 4.检查你的安装是否有效果= 5.打开 /.gazebo文件夹 下载模型 如果出现fatal连接GitH

    2023年04月19日
    浏览(42)
  • Ubuntu20.04 搭建W版本OpenStack平台

    Ubuntu20.04 搭建W版本OpenStack平台

    目录 一、基础环境配置 1.controller、compute配置网卡地址 2.配置域名解析 3.NTP时间同步 二、添加OpenStack-wallaby软件包及基本环境 1、OpenStack 服务的所有节点上添加软件包 2、Mysql数据库 3、Rabbitmq消息队列 4、Memcached 5、etcd环境部署 三、keystone服务 四、glance镜像服务 五、Placement环

    2024年02月15日
    浏览(13)
  • Ubuntu20.04搭建PX4仿真环境及XTDrone开发平台(最详细最明白)

    Ubuntu20.04搭建PX4仿真环境及XTDrone开发平台(最详细最明白)

    PX4-Autopilot仿真平台是由PX4官方提供的集虚拟px4固件、真机烧录固件、gazebo环境及模型于一体的平台,用户可以自己编写程序,通过mavros接口与虚拟px4固件进行mavlink协议的通讯,并在gazebo中显示虚拟世界和模型。因此PX官方手册里给了一个经典的例程:offboard.cpp和offboard.py,让

    2024年02月04日
    浏览(64)
  • Rockchip平台rk3588源码下载编译(基于Android13)

    Rockchip平台rk3588源码下载编译(基于Android13)

    下载地址 服务器镜像下载 需要向RK申请SDK使用权限。 由于AOSP使用的repo管理源码仓库,所以为了方便开发者获取repo工具,RK也提供了repo工具的下载 本文介绍了如何使用Markdown撰写一篇关于搭建自己的repo代码服务器的文章。以下是详细的步骤和指导。 环境准备 在开始之前,

    2024年02月03日
    浏览(49)
  • 基于Ubuntu20.04创建共享文件夹

    提示:文章写完后,目录可以自动生成,如何生成可参考右边的帮助文档 文章目录 前言——什么是共享文件夹? 一、怎么创建共享文件夹 1.window设置 2.虚拟机设置 总结 Ubuntu系统是安装在 VMware 虚拟机中的,两者之间经常要互传文件。 所以需要共享文件夹,所谓共享文件夹

    2024年02月08日
    浏览(9)
  • Re.从零开始--基于UbuntuServer 20.04-OpenStack平台搭建_

    Re.从零开始--基于UbuntuServer 20.04-OpenStack平台搭建_

    前言: 本文档基于ubuntu-server20.04版本和OpenStack Victoria搭建openstack环境 部署最小化Ubuntu-openstack满足基本服务;本文档均采用手动环境搭建 ubuntu源指定为阿里源,故搭环境需连接外网; ens33 ens34 节点名称 Ubuntu-controller 192.168.100.10 192.168.200.10 controller Ubuntu-compute 192.168.100.20 192.

    2024年01月20日
    浏览(26)
  • 【RK3399】2.制作ubuntu20.04 roomfs

    firefly自带的文件系统,由于缺少一些基本功能模块,因此,我们可以自己手动制作一个ubuntu20.04的文件系统。 http://cdimage.ubuntu.com/ubuntu-base/releases/ 复制一下虚拟机的运行环境 将开发板挂载到虚拟机上,将开发板的/vendor,/system,/lib/firmware,这三个文件夹复制到我们自己的文件

    2024年02月01日
    浏览(21)
  • 制作RK3568 ubuntu20.04桌面版镜像

    制作RK3568 ubuntu20.04桌面版镜像

    主控: RK3568 编译主机: Ubuntu 20.04 AMD64 目标版本: Ubuntu 20.04      RK3568 是极具性价比的高能国产“芯“ , 是Rockchip面向与AIOT和工业市场打造的一款高性能、低功耗、功能丰富的国产化应用处理器。采用四核64位Cortex-A55架构,主频高达2.0GHz,集成Rockchip自研NPU, 1TOPS算力,满足轻

    2024年02月19日
    浏览(13)
  • RK3588平台开发系列讲解(项目篇)基于yolov5的物体识别

    RK3588平台开发系列讲解(项目篇)基于yolov5的物体识别

    平台 内核版本 安卓版本 RK3588 Linux 5.10 Android 12 沉淀、分享、成长,让自己和他人都能有所收获!😄 📢 本篇将给大家介绍,如

    2024年02月06日
    浏览(13)
  • 基于Ubuntu20.04搭建OpenHarmony v3.0.6的qemu仿真环境

    基于Ubuntu20.04搭建OpenHarmony v3.0.6的qemu仿真环境

    出于个人兴趣,也出于对国产操作系统的好奇,想尝试一下以LiteOS为内核的Openharmony。但过程相当不顺利,主要原因是官方文档内容组织的不敢恭维。挺好的东西,不把说明书写好,让用户怎么用?我研究的核心问题就一个:如何在基于Qemu仿真的Openharmony中输出一个hello worl

    2024年02月09日
    浏览(16)

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

博客赞助

微信扫一扫打赏

请作者喝杯咖啡吧~博客赞助

支付宝扫一扫领取红包,优惠每天领

二维码1

领取红包

二维码2

领红包