You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
164 lines
6.8 KiB
164 lines
6.8 KiB
\chapter{制作 ubuntu 文件系统}
|
|
在 主机的 Ubuntu 系统里面,可以制作 aarch64 的文件系统,这里介绍一下步骤。
|
|
\section{ 安装依赖软件}
|
|
\begin{minted}[bgcolor=lightgray!30,fontsize=\footnotesize]{bash}
|
|
sudo apt install qemu-user-static debootstrap
|
|
\end{minted}
|
|
|
|
\section{下载基础系统}
|
|
这里以安装 Ubuntu 22.04 为例:
|
|
\begin{minted}[bgcolor=lightgray!30,fontsize=\footnotesize]{bash}
|
|
mkdir ubuntu
|
|
sudo debootstrap --arch=arm64 --foreign jammy ubuntu
|
|
sudo cp /usr/bin/qemu-aarch64-static ubuntu/usr/bin
|
|
sudo chroot ubuntu /usr/bin/qemu-aarch64-static /bin/sh \
|
|
-i /debootstrap/debootstrap --second-stage
|
|
\end{minted}
|
|
|
|
\section{安装必备软件}
|
|
|
|
\subsection{安装基础软件}
|
|
给目标系统安装常用程序:
|
|
\begin{enumerate}[(1)]
|
|
\item 进入目标系统:
|
|
\begin{minted}[bgcolor=lightgray!30,fontsize=\footnotesize]{bash}
|
|
sudo mount -o bind /sys ubuntu/sys
|
|
sudo mount -o bind /proc ubuntu/proc
|
|
sudo mount -o bind /dev ubuntu/dev
|
|
sudo mount -o bind /dev/pts ubuntu/dev/pts
|
|
sudo chroot ubuntu /usr/bin/qemu-aarch64-static /bin/bash -i
|
|
\end{minted}
|
|
\item 修改 /etc/apt/sources.list 如下:
|
|
\begin{minted}[bgcolor=lightgray!30,fontsize=\footnotesize]{bash}
|
|
deb http://ports.ubuntu.com/ jammy main universe
|
|
deb-src http://ports.ubuntu.com/ jammy main universe
|
|
deb http://ports.ubuntu.com/ jammy-security main universe
|
|
deb-src http://ports.ubuntu.com/ jammy-security main universe
|
|
deb http://ports.ubuntu.com/ jammy-updates main universe
|
|
deb-src http://ports.ubuntu.com/ jammy-updates main universe
|
|
\end{minted}
|
|
\item 更新系统:
|
|
\begin{minted}[bgcolor=lightgray!30,fontsize=\footnotesize]{bash}
|
|
apt-get update
|
|
apt-get dist-upgrade
|
|
\end{minted}
|
|
\item 安装常用软件:
|
|
\begin{minted}[bgcolor=lightgray!30,fontsize=\footnotesize]{bash}
|
|
apt-get install -y vim-nox build-essential gdb u-boot-tools rsync \
|
|
socat jq tcpdump ifupdown minicom i2c-tools lrzsz tftp-hpa \
|
|
net-tools dosfstools pciutils memtool ethtool unzip python3-pip
|
|
\end{minted}
|
|
\item 设置 root 密码:
|
|
\begin{minted}[bgcolor=lightgray!30,fontsize=\footnotesize]{bash}
|
|
passwd root
|
|
\end{minted}
|
|
\item 设置时区:
|
|
\begin{minted}[bgcolor=lightgray!30,fontsize=\footnotesize]{bash}
|
|
ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
|
|
\end{minted}
|
|
\item 设置 hostname:
|
|
\begin{minted}[bgcolor=lightgray!30,fontsize=\footnotesize]{bash}
|
|
echo sytc > /etc/hostname
|
|
echo "127.0.0.1 sytc" >> /etc/hosts
|
|
\end{minted}
|
|
\item 设置bash为默认shell:
|
|
\begin{minted}[bgcolor=lightgray!30,fontsize=\footnotesize]{bash}
|
|
dpkg-reconfigure dash
|
|
\end{minted}
|
|
选择{\kx “}NO{\kx ”}。
|
|
\item 配置 locals:
|
|
\begin{minted}[bgcolor=lightgray!30,fontsize=\footnotesize]{bash}
|
|
dpkg-reconfigure locales
|
|
\end{minted}
|
|
至少选择 en\_US.UTF-8 和 zh\_CN.UTF-8。
|
|
\item 配置/etc/fstab,例如:
|
|
\begin{minted}[bgcolor=lightgray!30,fontsize=\scriptsize]{bash}
|
|
# <file system> <mount pt> <type> <options> <dump> <pass>
|
|
/dev/root / auto rw,noauto 0 1
|
|
tmpfs /tmp tmpfs mode=1777 0 0
|
|
tmpfs /run tmpfs mode=0755,nosuid,nodev 0 0
|
|
#PARTLABEL=oem /oem ext2 defaults 0 2
|
|
PARTLABEL=userdata /userdata ext4 defaults 0 0
|
|
proc /proc proc defaults 0 0
|
|
devtmpfs /dev devtmpfs defaults 0 0
|
|
devpts /dev/pts devpts mode=0620,ptmxmode=0666,gid=5 0 0
|
|
tmpfs /dev/shm tmpfs nosuid,nodev,noexec 0 0
|
|
sysfs /sys sysfs defaults 0 0
|
|
debugfs /sys/kernel/debug debugfs defaults 0 0
|
|
pstore /sys/fs/pstore pstore defaults 0 0
|
|
\end{minted}
|
|
\item 修改 getty 服务,使 root 自动登录。修改文件 /usr/lib/systemd/system/serial-getty@.service 的 ExecStart 对应的值:
|
|
\begin{minted}[bgcolor=lightgray!30,fontsize=\scriptsize]{ini}
|
|
[Service]
|
|
# The '-o' option value tells agetty to replace 'login' arguments with an
|
|
# option to preserve environment (-p), followed by '--' for safety, and then
|
|
# the entered username.
|
|
ExecStart=-/sbin/agetty --autologin root --noclear %I $TER
|
|
#ExecStart=-/sbin/agetty -o '-p -- \\u' --keep-baud 115200,38400,9600 %I $TERM
|
|
Type=idle
|
|
\end{minted}
|
|
使能串口服务:
|
|
\begin{minted}[bgcolor=lightgray!30,fontsize=\scriptsize]{ini}
|
|
systemctl enable serial-getty@ttyFIQ0.service
|
|
\end{minted}
|
|
\item 设置网络参数/etc/network/interfaces.d/eth1
|
|
\begin{minted}[bgcolor=lightgray!30,fontsize=\scriptsize]{ini}
|
|
auto eth1
|
|
iface eth1 inet static
|
|
address 192.168.1.80
|
|
netmask 255.255.255.0
|
|
gateway 192.168.1.1
|
|
\end{minted}
|
|
修改/etc/network/interfaces,执行命令:
|
|
\begin{minted}[bgcolor=lightgray!30,fontsize=\scriptsize]{bash}
|
|
echo "source-directory /etc/network/interfaces.d"> /etc/network/interfaces
|
|
\end{minted}
|
|
\end{enumerate}
|
|
\subsection{安装 ssh server}
|
|
\noindent 安装软件:
|
|
\begin{minted}[bgcolor=lightgray!30,fontsize=\footnotesize]{bash}
|
|
apt-get install openssh-server
|
|
\end{minted}
|
|
配置允许root登陆,将/etc/ssh/sshd\_config中的:
|
|
\begin{minted}[bgcolor=lightgray!30,fontsize=\footnotesize]{bash}
|
|
#PermitRootLogin prohibit-password
|
|
\end{minted}
|
|
改为:
|
|
\begin{minted}[bgcolor=lightgray!30,fontsize=\footnotesize]{bash}
|
|
PermitRootLogin yes
|
|
\end{minted}
|
|
|
|
\subsection{安装 rockchip 硬解码器}
|
|
添加软件源:
|
|
\begin{minted}[bgcolor=lightgray!30,fontsize=\footnotesize]{bash}
|
|
apt-get install software-properties-common
|
|
add-apt-repository ppa:george-coolpi/multimedia
|
|
apt update
|
|
\end{minted}
|
|
安装 gstreamer :
|
|
\begin{minted}[bgcolor=lightgray!30,fontsize=\footnotesize]{bash}
|
|
apt-get install libgstreamer1.0-dev libgstreamer-plugins-base1.0-dev \
|
|
libgstreamer-plugins-bad1.0-dev gstreamer1.0-plugins-base \
|
|
gstreamer1.0-plugins-good gstreamer1.0-plugins-bad \
|
|
gstreamer1.0-plugins-ugly gstreamer1.0-libav gstreamer1.0-tools \
|
|
gstreamer1.0-alsa gstreamer1.0-pulseaudio ffmpeg
|
|
\end{minted}
|
|
安装插件gstreamer1.0-rockchip
|
|
\begin{minted}[bgcolor=lightgray!30,fontsize=\footnotesize]{bash}
|
|
apt-get install gstreamer1.0-rockchip
|
|
\end{minted}
|
|
|
|
\subsection{打包成 ext4 文件系统}
|
|
|
|
清理并退出 chroot 环境:
|
|
\begin{minted}[bgcolor=lightgray!30,fontsize=\footnotesize]{bash}
|
|
apt-get clean
|
|
exit
|
|
\end{minted}
|
|
执行命令,打包成 ext4 的文件系统文件:
|
|
\begin{minted}[bgcolor=lightgray!30,fontsize=\footnotesize]{bash}
|
|
IMAGE_SIZE_MB=$(( $(sudo du -sh -m ubuntu | cut -f1) + 300 ))
|
|
dd if=/dev/zero of=ubuntu.img bs=1M count=0 seek=${IMAGE_SIZE_MB}
|
|
sudo mkfs.ext4 -d ubuntu ubuntu.img
|
|
\end{minted}
|
|
可以将 ubuntu.img 烧写到 EMMC 的 rootfs 分区上。
|