Author: zzssdd2
E-mail: zzssdd2@foxmail.com
1, Ubuntu-base20.04.3
Ubuntu has officially made the root file system of base version of each architecture and version. Just download it and make a few changes.
-
download Ubuntu Base 20.04.3 LTS (Focal Fossa)
ubuntu-base-20.04.3-base-armhf.tar.gz 2021-08-19 10:56 22M
-
decompression
mkdir rootfs sudo chmod 777 rootfs tar -zxvf ubuntu-base-20.04.3-base-armhf.tar.gz -C rootfs #Avoid errors in later software updates sudo chmod 777 ./rootfs/tmp/
-
Installation tools
sudo apt-get install qemu-user-static sudo cp /usr/bin/qemu-arm-static ./rootfs/usr/bin/
-
Copy host DNS
sudo cp /etc/resolv.conf ./rootfs/etc/resolv.conf
-
Replace download source
cp ./rootfs/etc/apt/source.list ./rootfs/etc/apt/source.list.bak vim ./rootfs/etc/apt/source.list `Esc` + `:` %s/ports.ubuntu.com/mirror.tuna.tsinghua.edu.cn/g `Enter`
-
Create the mount script vim mount.sh
The contents are as follows:
#!/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
Change permissions:
sudo chmod +x mount.sh
-
mount
source mount.sh -m ./rootfs/
-
Update software
apt update apt install sudo vim kmod net-tools ethtool ifupdown rsyslog htop iputils-ping language-pack-en-base ssh
Note: ssh must be installed, or the following link serial port service will make an error
-
Set user name and password
root@zsd-virtual-machine:/# passwd root New password: Retype new password: passwd: password updated successfully root@zsd-virtual-machine:/# adduser zsd New password: Retype new password: `Enter` `Enter` ...... `Enter` `Enter`
-
Set IP and name
root@zsd-virtual-machine:/# echo "zzssdd2-imx6ull" > /etc/hostname root@zsd-virtual-machine:/# echo "127.0.0.1 localhost" >> /etc/hosts root@zsd-virtual-machine:/# echo "127.0.0.1 zzssdd2-imx6ull" >> /etc/hosts
-
Set serial port terminal
ln -s /lib/systemd/system/getty@.service /etc/systemd/system/getty.target.wants/getty@ttymxc0.service
be careful:
If an error is reported, the prompt is as follows:
root@zsd-virtual-machine:/# ln -s /lib/systemd/system/getty@.service /etc/systemd/system/getty.target.wants/getty@ttymxc0.service /usr/bin/ln: failed to create symbolic link '/etc/systemd/system/getty.target.wants/getty@ttymxc0.service': No such file or directory
Note there is no getty.target.wants directory in / etc/systemd/system /.
Solution: the directory will be created when ssh is installed, and then re execute the command to set the serial port terminal.
-
sign out
#Exit qemu simulator exit #Unmount source mount.sh -u ./rootfs/ #pack sudo tar -czvf ubuntu-base-20.04.3-rootfs.tar.gz rootfs/*
2, Debian 11
- Directly use the Debian root file system made by three parties, such as Linaro
- use Multistrap or Debootstrap Tool to build your own Debian root file system
Next, I use the debootstrap tool to build the Debian 11 root file system (don't ask why you don't use multistrap, just don't ask) []
-
Installation tools
sudo apt install binfmt-support qemu qemu-user-static debootstrap
-
Extract Debain file system
sudo debootstrap --arch=armhf --foreign bullseye rootfs https://mirrors.tuna.tsinghua.edu.cn/debian/
Parameter Description:
arch: CPU architecture
Bull eye: debian version name, which is the name of version 11
foreign: this parameter needs to be specified when it is different from the host architecture. It is only used for initial unpacking
rootfs: the folder where you want to store the file system
https://mirrors.tuna.tsinghua.edu.cn/debian/ : Download source. Here, the domestic Tsinghua source is used
After successful extraction:
$ ls ./rootfs/ bin debootstrap etc lib root sbin tmp var boot dev home proc run sys usr
-
Copy QEMU arm static to the basic system you just built
sudo cp /usr/bin/qemu-arm-static ./rootfs/usr/bin
-
File system boot complete
sudo DEBIAN_FRONTEND=noninteractive DEBCONF_NONINTERACTIVE_SEEN=true chroot rootfs debootstrap/debootstrap --second-stage
Parameter Description:
-
chroot rootfs
Change the root directory to rootfs: that is, change the visible root path of the current process and its child processes. After the change, the program cannot access files and commands outside the visible root directory.
-
DEBIAN_FRONTEND=noninteractive DEBCONF_NONINTERACTIVE_SEEN=true
Avoiding debconf asking users any questions (non interactive) is equivalent to silently configuring the installation.
Learn more debconf - Debian Wiki
-
debootstrap
man debootstrap or debootstrap --help
Learn more Debootstrap - Debian Wiki
The prompt after completion is as follows:
I: Base system installed successfully.
-
-
Replace download source
#backups sudo cp ./rootfs/etc/apt/sources.list ./rootfs/etc/apt/sources.list.bak #edit sudo vim ./rootfs/etc/apt/sources.list #Replace with the following: # The source image is annotated by default to improve apt update speed. You can cancel the annotation if necessary deb https://mirrors.tuna.tsinghua.edu.cn/debian/ bullseye main contrib non-free # deb-src https://mirrors.tuna.tsinghua.edu.cn/debian/ bullseye main contrib non-free deb https://mirrors.tuna.tsinghua.edu.cn/debian/ bullseye-updates main contrib non-free # deb-src https://mirrors.tuna.tsinghua.edu.cn/debian/ bullseye-updates main contrib non-free deb https://mirrors.tuna.tsinghua.edu.cn/debian/ bullseye-backports main contrib non-free # deb-src https://mirrors.tuna.tsinghua.edu.cn/debian/ bullseye-backports main contrib non-free deb https://mirrors.tuna.tsinghua.edu.cn/debian-security bullseye-security main contrib non-free # deb-src https://mirrors.tuna.tsinghua.edu.cn/debian-security bullseye-security main contrib non-free
-
Create the mount script vim mount.sh
The contents are as follows:
#!/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
Change permissions:
sudo chmod +x mount.sh
-
mount
source mount.sh -m ./rootfs/
-
Execute the following command
# <file system> <mount point> <type> <options> <dump> <pass> echo "proc /proc proc defaults 0 0" >> etc/fstab
-
Setting locale environment parameters in Linux
export LC_ALL=C
If it is not set, the following prompt will appear when installing the software later:
perl: warning: Setting locale failed. perl: warning: Please check that your locale settings: LANGUAGE = "zh_CN:en_US:en", LC_ALL = (unset), LC_PAPER = "zh_CN.UTF-8", LC_NUMERIC = "zh_CN.UTF-8", LC_IDENTIFICATION = "zh_CN.UTF-8", LC_MEASUREMENT = "zh_CN.UTF-8", LC_NAME = "zh_CN.UTF-8", LC_TELEPHONE = "zh_CN.UTF-8", LC_ADDRESS = "zh_CN.UTF-8", LC_MONETARY = "zh_CN.UTF-8", LC_TIME = "zh_CN.UTF-8", LANG = "zh_CN.UTF-8" are supported and installed on your system. perl: warning: Falling back to the standard locale ("C"). /usr/bin/locale: Cannot set LC_CTYPE to default locale: No such file or directory /usr/bin/locale: Cannot set LC_MESSAGES to default locale: No such file or directory /usr/bin/locale: Cannot set LC_ALL to default locale: No such file or directory
-
Install software
apt update apt install sudo apt install net-tools apt install ethtool apt install htop apt install ssh ......
-
Set user
#Set root user password passwd root #Add new user adduser zzssdd2
-
Set up Ethernet
echo "auto eth0" > /etc/network/interfaces.d/eth0 echo "iface eth0 inet dhcp" >> /etc/network/interfaces.d/eth0
-
Set IP and name
echo "zzssdd2-imx6ull" > /etc/hostname echo "127.0.0.1 localhost" >> /etc/hosts echo "127.0.0.1 zzssdd2-imx6ull" >> /etc/hosts
-
sign out
#Exit qemu environment exit # Unmount source mount.sh -u ./rootfs/ #pack sudo tar -zcvf debian_bullseye-rootfs.tar.gz ./rootfs/*
3, Builderoot
Buildroot Is a simple, efficient and easy-to-use tool, which can generate embedded Linux system through cross compilation. Refer to the official manual for more details The Buildroot user manual
Next, use build root-2021.08.1 to configure the IMX6ULL platform.
-
Download: https://buildroot.org/download.html
-
Unzip: tar -jxvf builderoot-2021.08.1.tar.bz2
-
Enter the graphical configuration interface: make menuconfig
Note: the options posted below are manually configured and changed. If they are not posted, it means that the default settings are used
-
Configure Target options
Target options ---> Target Architecture (ARM (little endian)) Target Binary Format (ELF) Target Architecture Variant (cortex-A7) Target ABI (EABIhf) Floating point strategy (NEON/VFPv4) ARM instruction set (ARM)
-
Configure Toolchain
Toolchain ---> Toolchain type (External toolchain) Toolchain (Custom toolchain) Toolchain origin (Pre-installed toolchain) (/usr/local/arm/gcc-arm-10.3-2021.07-x86_64-arm-none-linux-gnueabihf) Toolchain path ($(ARCH)-none-linux-gnueabihf) Toolchain prefix External toolchain gcc version (10.x) External toolchain kernel headers series (4.20.x) External toolchain C library (glibc/eglibc) [ ] Toolchain has RPC support? [*] Toolchain has C++ support?
-
Configure System configuration
System configuration ---> (zzssdd2) System hostname (Hello zzssdd2) System banner /dev management (Dynamic using devtmpfs + mdev) (root) Root password (eth0) Network interface to configure through DHCP
-
Configure Target packages
In this step, you can select the package you need to install according to your own needs (here, I keep the default selection for faster compilation in the next step).
-
After the on-demand configuration is completed: save -- > Exit -- > execute the make command and wait until the compilation is completed. The compiled root file system can be seen in the output/images directory under the Buildroot root directory.
be careful:
- If you have executed make before compiling, you need to execute make clean first and then execute the make command, otherwise an error may be reported.
- If some packages are extremely slow to download, do not move down, or fail to download, you can copy them to the browser for manual download according to the address prompted by the compilation information. After downloading it, copy it to the dl directory under the root directory of builderoot, and then CTRL+C terminates the compilation -- > make clean clears the last compilation -- > make recompile.
4, Verify
reference resources Building NFS & TFTP environment with development board directly connected to computer