以下内容在 Rockchip 的 Linux SDK 目录下完成,请先解压 Linux SDK。
Ubuntu-Base 是Ubuntu官方构建的ubuntu最小文件系统,基础包大小通常只有几十兆,可以很方便的个性化定制嵌入式环境。使用北京外国语大学镜像站加速下载,注意选择根据开发板架构选择arm64或其他架构。
wget https://mirrors.bfsu.edu.cn/ubuntu-cdimage/ubuntu-base/releases/22.04.2/release/ubuntu-base-22.04.2-base-arm64.tar.gz
# 安装依赖软件
sudo apt-get install git ssh make gcc libssl-dev liblz4-tool expect g++ patchelf chrpath gawk texinfo chrpath diffstat binfmt-support qemu-user-static live-build bison flex fakeroot cmake gcc-multilib g++-multilib unzip device-tree-compiler ncurses-dev python-is-python3 python-dev-is-python3 -y
# 创建一个文件夹存放根文件系统
mkdir ubuntu_rootfs
# 解压到文件夹
sudo tar -xvf ubuntu-base-22.04-base-arm64.tar.gz -C ubuntu_rootfs/
# 配置网络,复制本机 resolv.conf 文件
sudo cp /etc/resolv.conf ubuntu_rootfs/etc/resolv.conf
sudo echo "nameserver 8.8.8.8" >> ubuntu_rootfs/etc/resolv.conf
sudo echo "nameserver 114.114.114.114" >> ubuntu_rootfs/etc/resolv.conf
# 编辑根文件系统中的软件源配置文件
sudo vim ./ubuntu_rootfs/etc/apt/sources.list
以下是 Ubuntu 22.04 版本的镜像,请注意删除根文件系统 ./ubuntu_rootfs/etc/apt/sources.list 文件中原有的内容。
# 默认注释了源码镜像以提高 apt update 速度,如有需要可自行取消注释
deb http://mirrors.bfsu.edu.cn/ubuntu-ports/ jammy main restricted universe multiverse
# deb-src http://mirrors.bfsu.edu.cn/ubuntu-ports/ jammy main restricted universe multiverse
deb http://mirrors.bfsu.edu.cn/ubuntu-ports/ jammy-updates main restricted universe multiverse
# deb-src http://mirrors.bfsu.edu.cn/ubuntu-ports/ jammy-updates main restricted universe multiverse
deb http://mirrors.bfsu.edu.cn/ubuntu-ports/ jammy-backports main restricted universe multiverse
# deb-src http://mirrors.bfsu.edu.cn/ubuntu-ports/ jammy-backports main restricted universe multiverse
# deb http://mirrors.bfsu.edu.cn/ubuntu-ports/ jammy-security main restricted universe multiverse
# # deb-src http://mirrors.bfsu.edu.cn/ubuntu-ports/ jammy-security main restricted universe multiverse
deb http://ports.ubuntu.com/ubuntu-ports/ jammy-security main restricted universe multiverse
# deb-src http://ports.ubuntu.com/ubuntu-ports/ jammy-security main restricted universe multiverse
# 预发布软件源,不建议启用
# deb http://mirrors.bfsu.edu.cn/ubuntu-ports/ jammy-proposed main restricted universe multiverse
# # deb-src http://mirrors.bfsu.edu.cn/ubuntu-ports/ jammy-proposed main restricted universe multiverse
X86 架构下的Ubuntu 系统默认不支持Arm架构,可以通过安装 qemu-user-static 实现仿真运行,从而构建 ubuntu 文件系统。
# 拷贝 qemu-aarch64-static 到 ubuntu_rootfs/usr/bin/ 目录下。
sudo cp /usr/bin/qemu-aarch64-static ubuntu_rootfs/usr/bin/
首先编写挂载脚本 mount.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
保存退出后,给脚本增加执行权限,并挂载。
# 增加脚本执行权限
sudo chmod +x mount.sh
# 挂载文件系统
./mount.sh -m ubuntu_rootfs/
# 进入根文件系统
sudo chroot ubuntu_rootfs/
退出根文件系统后,需要卸载文件系统,可用以下命令。
# 卸载文件系统
./mount.sh -u ubuntu_rootfs/
# 更新软件
apt update
apt upgrade -y
# 必要工具
apt install vim bash-completion net-tools iputils-ping ifupdown ethtool ssh rsync udev htop rsyslog curl openssh-server apt-utils dialog nfs-common psmisc language-pack-en-base sudo kmod apt-transport-https -y
以下内容可选安装
# 网络、Wi-Fi & 蓝牙
apt install bluetooth* bluez* blueman* wireless-tools network-manager -y
# 开发工具
apt install gcc g++ make cmake ninja-build build-essential ffmpeg libopencv-dev libv4l-dev v4l-utils yavta -y
# OpenGL
apt install mesa-utils libgl1-mesa-dev -y
#OpenCL
apt install ocl-icd-* opencl-headers clinfo -y
#Vulkan
apt install mesa-* libwayland-dev libxrandr-dev libvulkan1 mesa-vulkan-drivers vulkan-tools libvulkan-dev -y
# GStreamer
apt install gstreamer1.0-plugins-bad gstreamer1.0-plugins-base gstreamer1.0-plugins-ugly gstreamer1.0-plugins-good gstreamer1.0-libav gstreamer1.0-tools gstreamer1.0-alsa gstreamer1.0-plugins-base-apps gstreamer1.0-opencv -y
# Qt6
apt install libqt6widgets6 libqt6websockets6-dev libqt6websockets6 libqt6webchannel6 libqt6waylandclient6 libqt6uitools6 libqt6sql6-sqlite libqt6sql6 libqt6serialport6 libqt6multimedia6 libqt6multimediawidgets6 libqt6core5compat6 libqt6concurrent6 libqt6core6 qt6-wayland-dev qt6-wayland qt6-wayland-dev-tools qt6-image-formats-plugins libqt6concurrent6 libqt6opengl6 libqt6openglwidgets6 qt6-tools-dev qt6-multimedia-dev qt6-tools-dev-tools qt6-qpa-plugins qt6-l10n-tools qt6-image-formats-plugins qt6-base-dev-tools linguist-qt6 libqt6serialport6-dev -y
# ntfs exfat
apt install exfat* ntfs-3g -y
# 输入法
apt install ibus-pinyin ibus-sunpinyin -y
# 视频播放
apt install libdvdnav4 ubuntu-restricted-extras vlc -y
# Eigen
apt install libeigen3-dev -y
# xkb
apt install libxkbcommon-dev -y
# 安装 GNOME 最小桌面环境
apt install --no-install-recommends ubuntu-desktop -y
# 设置开机默认切换到图形界面
systemctl set-default graphical.target
# 安装时区
apt install locales tzdata
# 时区选择
dpkg-reconfigure tzdata
# Asia/Shanghai
# 勾选英文/中文环境
dpkg-reconfigure locales
# en_US.UTF-8 UTF-8
# zh_CN.UTF-8 UTF-8
# 修改 root 密码
passwd root
# 添加新用户并设置密码
adduser m1
修改 /etc/sudoers 文件,用于控制哪些用户可以以超级管理员(root)的身份执行特定的命令。
# 编辑 /etc/sudoers
vim /etc/sudoers
添加以下内容
m1 ALL=(ALL:ALL) ALL
添加完成后
# 主机名
echo "RK3588" > /etc/hostname
# 主机 IP
echo "127.0.0.1 localhost" >> /etc/hosts
echo "127.0.0.1 RK3588" >> /etc/hosts
echo "127.0.0.1 localhost RK3588" >> /etc/hosts
Network-Manager 服务会自动配置网卡,但是其默认配置文件将 Ethernet 加入了黑名单,会导致 Ubuntu 提示 unmanned。
# 编辑文件
vim /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
RK3588开发板有两块网卡,因此将两块网卡默认配置为自动DHCP获取。
# 网卡0
echo "auto eth0" > /etc/network/interfaces.d/eth0
echo "iface eth0 inet dhcp" >> /etc/network/interfaces.d/eth0
# 网卡1
echo "auto eth1" > /etc/network/interfaces.d/eth1
echo "iface eth1 inet dhcp" >> /etc/network/interfaces.d/eth1
在实际测试中网口必须接入网线系统才能正常启动,就是在不联网的情况下,每次开机都要等待很久,卡在网络连接上5分钟。
修改下面这个文件
vim /lib/systemd/system/networking.service
将里面的TimeoutStartSec=5min 修改为:
TimeoutStartSec=5sec
修改 LightDM 登录管理器
# 修改
vim /usr/share/lightdm/lightdm.conf.d/50-ubuntu.conf
# 添加下面的内容
greeter-show-manual-login=true #手动输入登陆系统的用户名和密码
all-guest=false #不允许guest登录
修改 gdm-autologin 的PAM认证配置,可以允许root账户进行自动登录。
vim /etc/pam.d/gdm-autologin
# 注释掉下面这行
# auth required pam_succeed_if.so user != root quiet_success
修改 gdm-password的PAM认证配置,可以允许root账户进行自动登录。
vim /etc/pam.d/gdm-password
# 注释掉下面这行
# auth required pam_succeed_if.so user != root quiet_success
配置检查当前终端是否可用
vim /root/.profile
# 添加下面的内容,替换掉 mesg n || true 这一行
tty -s && mesg n || true
修改GDM3的配置文件
vim /etc/gdm3/custom.conf
# 添加下面的内容,AutomaticLogin即自动登录的账户名
[daemon]
AutomaticLoginEnable=true # 开启自动登录功能。
AutomaticLogin=root # 自动登录的账户名为root。
TimedLoginEnable=true # 开启定时登录功能。
TimedLogin=user # 定时登录的账户名为root。
TimedLoginDelay=10 # 定时登录前等待10秒钟。
# 设置禁止休眠
systemctl mask sleep.target suspend.target hibernate.target hybrid-sleep.target
# 查看休眠状态
systemctl status sleep.target
Wi-Fi、蓝牙、CH341串口驱动等需要先通过 kernel 编译成驱动模块。
# 在SDK根目录下执行命令,生成驱动文件
./build.sh modules
根据需要安装开发板驱动和其他配置文件,可使用 mk-rootfs-ubuntu.sh 自动执行,请注意该脚本需要按需要修改。
# 执行脚本
sudo ./mk-rootfs-ubuntu.sh
# 驱动自动加载,修改init.d下的配置文件
# 设置系统默认壁纸
xrandr left
# 设置系统自动横屏
# 设置 vim 默认配置 .vimrc
# 设置 ssh 允许 root 远程登录 .sshdconfig
# 安装配置管理工具
sudo apt-get install x11-xserver-utils dconf-editor dbus-x11 -y
gsettings set org.gnome.desktop.screensaver lock-enabled false
gsettings set org.gnome.desktop.session idle-delay 60
gsettings set org.gnome.desktop.screensaver lock-delay 5
gsettings set org.gnome.settings-daemon.plugins.xrandr rotation 'right'
使用 mk-image.sh 脚本打包
# 打包
sudo ./mk-image.sh
mk-image.sh 内容如下:
#!/bin/bash -e # 使用bash解释器,并开启错误检查模式
TARGET_ROOTFS_DIR=./ubuntu_rootfs # 定义目标根文件系统目录路径
ROOTFSIMAGE=ubuntu-rootfs.img # 定义根文件系统镜像文件名
EXTRA_SIZE_MB=300 # 定义额外的磁盘空间大小
IMAGE_SIZE_MB=$(( $(sudo du -sh -m ${TARGET_ROOTFS_DIR} | cut -f1) + ${EXTRA_SIZE_MB} )) # 计算根文件系统镜像文件大小
echo Making rootfs! # 输出提示信息
if [ -e ${ROOTFSIMAGE} ]; then # 如果根文件系统镜像文件已经存在,则删除
rm ${ROOTFSIMAGE}
fi
sudo ./post-build.sh ${TARGET_ROOTFS_DIR} # 运行post-build.sh脚本,完成根文件系统的后处理工作
dd if=/dev/zero of=${ROOTFSIMAGE} bs=1M count=0 seek=${IMAGE_SIZE_MB} # 创建指定大小的空白镜像文件
sudo mkfs.ext4 -d ${TARGET_ROOTFS_DIR} ${ROOTFSIMAGE} # 在指定目录下创建ext4文件系统,并将其写入到镜像文件中
echo Rootfs Image: ${ROOTFSIMAGE} # 输出根文件系统镜像文件名
post-build.sh 内容如下:
#!/bin/bash -e
TARGET_DIR=$1
shift
RK_LEGACY_PARTITIONS=" \
${RK_OEM_FS_TYPE:+oem:/oem:${RK_OEM_FS_TYPE}}
${RK_USERDATA_FS_TYPE:+userdata:/userdata:${RK_USERDATA_FS_TYPE}}
"
# :::
# RK_EXTRA_PARTITIONS="oem:/oem:ext2:oem_normal userdata:/userdata:vfat:userdata_empty"
RK_EXTRA_PARTITIONS=${RK_EXTRA_PARTITIONS:-${RK_LEGACY_PARTITIONS}}
function fixup_root()
{
echo "Fixing up rootfs type: $1"
FS_TYPE=$1
sed -i "s#\([[:space:]]/[[:space:]]\+\)\w\+#\1${FS_TYPE}#" \
${TARGET_DIR}/etc/fstab
}
function fixup_part()
{
echo "Fixing up partition: $@"
if echo $1 | grep -qE "^/"; then
DEV=$1
else
DEV="PARTLABEL=$1"
fi
MOUNT=${2:-/$1}
FS_TYPE=${3:-auto}
OPT=${4:-defaults}
sed -i "#[[:space:]]${MOUNT}[[:space:]]#d" ${TARGET_DIR}/etc/fstab
echo -e "${DEV}\t${MOUNT}\t${FS_TYPE}\t${OPT}\t0 2" >> \
${TARGET_DIR}/etc/fstab
mkdir -p ${TARGET_DIR}/${MOUNT}
}
function fixup_fstab()
{
echo "Fixing up /etc/fstab..."
case "${RK_ROOTFS_TYPE}" in
ext[234])
fixup_root ${RK_ROOTFS_TYPE}
;;
*)
fixup_root auto
;;
esac
for part in ${RK_EXTRA_PARTITIONS}; do
fixup_part $(echo "${part}" | xargs -d':')
done
}
function add_build_info()
{
[ -f ${TARGET_DIR}/etc/os-release ] && \
sed -i "/^BUILD_ID=/d" ${TARGET_DIR}/etc/os-release
echo "Adding build-info to /etc/os-release..."
echo "BUILD_INFO=\"$(whoami)@$(hostname) $(date)${@:+ - $@}\"" >> \
${TARGET_DIR}/etc/os-release
}
function add_dirs_and_links()
{
echo "Adding dirs and links..."
cd ${TARGET_DIR}
mkdir -p mnt/sdcard mnt/usb0
ln -sf media/usb0 udisk
ln -sf mnt/sdcard sdcard
ln -sf userdata data
}
echo "Executing $(basename $0)..."
add_build_info $@
[ -f ${TARGET_DIR}/etc/fstab ] && fixup_fstab
add_dirs_and_links
exit 0
mk-rootfs-ubuntu.sh 内容如下:
#!/bin/bash -e
# Directory contains the target rootfs
#TARGET_ROOTFS_DIR="binary"
TARGET_ROOTFS_DIR="ubuntu_rootfs"
ARCH=arm64
echo -e "\033[36m Building for $ARCH \033[0m"
#if [ -d "$TARGET_ROOTFS_DIR" ]; then
# Control will enter here if $DIRECTORY exists.
# rm -rf $TARGET_ROOTFS_DIR
# sleep 5
#fi
#if [ ! -e ubuntu-22.04.1-arm64.tar.gz ]; then
# echo "\033[please put ubuntu-22.04.1-arm64.tar.gz file in this contents \033[0m"
# exit -1
#fi
finish() {
sudo umount $TARGET_ROOTFS_DIR/dev
exit -1
}
trap finish ERR
echo -e "\033[36m Extract image \033[0m"
# sudo tar -xpf ubuntu-22.04.1-arm64.tar.gz
# packages folder
sudo mkdir -p $TARGET_ROOTFS_DIR/packages
sudo cp -rf packages/$ARCH/* $TARGET_ROOTFS_DIR/packages
# overlay folder
sudo cp -rf overlay/* $TARGET_ROOTFS_DIR/
# overlay-firmware folder
sudo cp -rf overlay-firmware/* $TARGET_ROOTFS_DIR/
# overlay-debug folder
# adb, video, camera test file
sudo cp -rf overlay-debug/* $TARGET_ROOTFS_DIR/
## hack the serial
sudo cp -f overlay/usr/lib/systemd/system/[email protected] $TARGET_ROOTFS_DIR/lib/systemd/system/[email protected]
# adb
sudo cp -f overlay-debug/usr/local/share/adb/adbd-64 $TARGET_ROOTFS_DIR/usr/bin/adbd
# bt/wifi firmware
sudo mkdir -p $TARGET_ROOTFS_DIR/system/lib/modules/
sudo mkdir -p $TARGET_ROOTFS_DIR/vendor/etc
sudo find ../kernel/drivers/net/wireless/rockchip_wlan/* -name "*.ko" | \
xargs -n1 -i sudo cp {} $TARGET_ROOTFS_DIR/system/lib/modules/
sudo find ../kernel/drivers/bluetooth/* -name "*.ko" | \
xargs -n1 -i sudo cp {} $TARGET_ROOTFS_DIR/system/lib/modules/
#ch341
sudo find ../kernel/drivers/usb/serial/* -name "*.ko" | \
xargs -n1 -i sudo cp {} $TARGET_ROOTFS_DIR/system/lib/modules/
echo -e "\033[36m Change root.....................\033[0m"
#sudo cp -f /etc/resolv.conf $TARGET_ROOTFS_DIR/etc/
#sudo cp /usr/bin/qemu-aarch64-static $TARGET_ROOTFS_DIR/usr/bin/
sudo mount -o bind /dev $TARGET_ROOTFS_DIR/dev
sudo mount -o bind /dev/pts $TARGET_ROOTFS_DIR/dev/pts
cat << EOF | sudo chroot $TARGET_ROOTFS_DIR/
apt-get update
apt-get upgrade -y
chmod o+x /usr/lib/dbus-1.0/dbus-daemon-launch-helper
export APT_INSTALL="apt-get install -fy --allow-downgrades"
apt remove -fy firefox-esr chromium* firefox
#---------------power management --------------
\${APT_INSTALL} pm-utils triggerhappy bsdmainutils
cp /etc/Powermanager/triggerhappy.service /lib/systemd/system/triggerhappy.service
#rm /etc/Powermanager -rf
#---------------Rga--------------
\${APT_INSTALL} /packages/rga/*.deb
\${APT_INSTALL} /packages/rga2/*.deb
echo -e "\033[36m Setup Video.................... \033[0m"
#\${APT_INSTALL} gstreamer1.0-plugins-bad gstreamer1.0-plugins-base gstreamer1.0-plugins-ugly gstreamer1.0-tools gstreamer1.0-alsa \
# gstreamer1.0-plugins-base-apps qtmultimedia5-examples gstreamer1.0-opencv
#for package in $(sudo apt-get upgrade 2>&1 | sudo grep "warning: files list file for package '" | sudo grep -Po "[^'\n ]+'" | sudo grep -Po "[^']+"); do sudo apt-get install --reinstall "$package"; done
\${APT_INSTALL} /packages/mpp/*
\${APT_INSTALL} /packages/gst-rkmpp/*.deb
#---------Camera---------
echo -e "\033[36m Install camera.................... \033[0m"
\${APT_INSTALL} cheese
\${APT_INSTALL} /packages/rkisp/*.deb
\${APT_INSTALL} /packages/rkaiq/*.deb
#\${APT_INSTALL} /packages/libv4l/*.deb
#--------------before deb--------------
#\${APT_INSTALL} /packages/topeet/*.deb
#---------------Openbox--------------
#echo -e "\033[36m Install openbox.................... \033[0m"
#\${APT_INSTALL} /packages/openbox/*.deb
#---------update chromium-----
#\${APT_INSTALL} /packages/chromium/*.deb
#\${APT_INSTALL} firefox
#------------------libdrm------------
echo -e "\033[36m Install libdrm.................... \033[0m"
\${APT_INSTALL} /packages/libdrm/*.deb
#------------------libdrm-cursor------------
echo -e "\033[36m Install libdrm-cursor.................... \033[0m"
\${APT_INSTALL} /packages/libdrm-cursor/*.deb
# Only preload libdrm-cursor for X
sed -i "/libdrm-cursor.so/d" /etc/ld.so.preload
sed -i "1aexport LD_PRELOAD=libdrm-cursor.so.1" /usr/bin/X
#------------------pcmanfm------------
echo -e "\033[36m Install pcmanfm.................... \033[0m"
\${APT_INSTALL} /packages/pcmanfm/*.deb
#------------------blueman------------
echo -e "\033[36m Install blueman.................... \033[0m"
\${APT_INSTALL} blueman
echo exit 101 > /usr/sbin/policy-rc.d
chmod +x /usr/sbin/policy-rc.d
\${APT_INSTALL} blueman
rm -f /usr/sbin/policy-rc.d
#------------------rkwifibt------------
echo -e "\033[36m Install rkwifibt.................... \033[0m"
rm -rf /usr/lib/firmware
\${APT_INSTALL} /packages/rkwifibt/*.deb
ln -s /system/etc/firmware /vendor/etc/
mkdir -p /lib/firmware/
cp /packages/rkwifibt/8723du/* /lib/firmware/
#------------------glmark2------------
echo -e "\033[36m Install glmark2.................... \033[0m"
\${APT_INSTALL} /packages/glmark2/*.deb
echo -e "\033[36m Install Chinese fonts.................... \033[0m"
# Uncomment zh_CN.UTF-8 for inclusion in generation
sed -i 's/^# *\(zh_CN.UTF-8\)/\1/' /etc/locale.gen
echo "LANG=zh_CN.UTF-8" >> /etc/default/locale
# Generate locale
locale-gen
# Export env vars
echo "export LC_ALL=zh_CN.UTF-8" >> ~/.bashrc
echo "export LANG=zh_CN.UTF-8" >> ~/.bashrc
echo "export LANGUAGE=zh_CN.UTF-8" >> ~/.bashrc
source ~/.bashrc
\${APT_INSTALL} fonts-aenigma
\${APT_INSTALL} xfonts-intl-chinese
# HACK debian11.3 to fix bug
\${APT_INSTALL} fontconfig --reinstall
#\${APT_INSTALL} xfce4
#ln -sf /usr/bin/startxfce4 /etc/alternatives/x-session-manager
# mark package to hold
apt list --installed | grep -v oldstable | cut -d/ -f1 | xargs apt-mark unhold
#---------------GPU--------------
cp /packages/libmali/*.deb /
cp -rf /packages/rga/ /
cp -rf /packages/rga2/ /
# mark rga package to unhold
apt-mark unhold librga2 librga-dev librga2-dbgsym
cp /packages/libmali/libmali-valhall-g610-g6p0-x11.so /usr/lib/aarch64-linux-gnu/
ln -s /usr/lib/aarch64-linux-gnu/libmali-valhall-g610-g6p0-x11.so /usr/lib/aarch64-linux-gnu/libmali.so
ln -s /usr/lib/aarch64-linux-gnu/libmali-valhall-g610-g6p0-x11.so /usr/lib/aarch64-linux-gnu/libmali.so.1
#---------------Custom Script--------------
systemctl mask systemd-networkd-wait-online.service
systemctl mask NetworkManager-wait-online.service
rm /lib/systemd/system/[email protected]
#----------------beautiful terminal_________
echo " alias ls='ls --color' " >>/root/.bashrc
#-----------beautiful login---------------
\${APT_INSTALL} toilet
rm -rf /usr/share/figlet/*
cp /packages/figlet-fonts/* /usr/share/figlet/
timedatectl set-timezone Asia/Shanghai
cp /packages/libdrm/lightdm.conf /etc/lightdm/
#echo "tty -s && mesg n || true" >> /root/.profile
#---------------background---------------
rm -rf /usr/share/backgrounds/*.jpg
rm -rf /usr/share/backgrounds/*.png
#cp /packages/backdrops/* /usr/share/xfce4/backdrops/
cp /packages/backgrounds/* /usr/share/backgrounds/
apt update
apt upgrade -y
#------remove unused packages------------
apt remove --purge -fy linux-firmware*
#---------------Clean--------------
if [ -e "/usr/lib/arm-linux-gnueabihf/dri" ] ;
then
cd /usr/lib/arm-linux-gnueabihf/dri/
cp kms_swrast_dri.so swrast_dri.so rockchip_dri.so /
rm /usr/lib/arm-linux-gnueabihf/dri/*.so
mv /*.so /usr/lib/arm-linux-gnueabihf/dri/
elif [ -e "/usr/lib/aarch64-linux-gnu/dri" ];
then
cd /usr/lib/aarch64-linux-gnu/dri/
cp kms_swrast_dri.so swrast_dri.so rockchip_dri.so /
rm /usr/lib/aarch64-linux-gnu/dri/*.so
mv /*.so /usr/lib/aarch64-linux-gnu/dri/
rm /etc/profile.d/qt.sh
fi
cd -
rm -rf /var/lib/apt/lists/*
rm -rf /var/cache/
rm -rf /packages/
mkdir -p /var/cache/apt/archives/partial
EOF
sudo umount $TARGET_ROOTFS_DIR/dev/pts
sudo umount $TARGET_ROOTFS_DIR/dev
打包镜像完成后,会生成 ubuntu-rootfs.img 文件,使用该文件烧录进开发板即可。