前情提要:

从零开始的ZYNQ学习(基于矿卡EBAZ4205)(一)

从零开始的ZYNQ学习(基于矿卡EBAZ4205)(二)

文章目录

  • 0. 声明
  • 7. 让我们移植一个Ubuntu吧!(基于Debootstrap)
    • 7.1 宿主机环境配置
    • 7.2 使用Debootstrap生成最小Rootfs
    • 7.3 系统配置
      • (1)Debootstrap第二阶段展开
      • (2)创建登录用户
      • (3)为apt工具换源
      • (4)修改网络连接
  • 8. 让我们移植一个Ubuntu吧!(基于Ubuntu Base 20.04)
    • 8.1 宿主机环境配置
    • 8.2 系统配置
      • (1)安装必要的软件
      • (2)创建登录用户
      • (3)验证根文件系统运行
        • ·1)系统启动验证
        • ·2)直连网络验证
        • ·3)局域网络验证
        • ·4)互联网连接配置
    • 8.3 生成根文件系统镜像
  • 参考资料
    • 1. 相关信息
    • 2. 参考描述

0. 声明

本文由长春理工大学电子信息工程学院C&I实验室所有,已获得原作者发布授权。转载请注明出处。

本文编写过程中参考了很多前辈的记录,在此表示感谢,已将所有参考项列于文末。

当前版本R1.0(预发布)。

作者联系方式:E-mail: WindForest@yeah.net

7. 让我们移植一个Ubuntu吧!(基于Debootstrap)

还记得吗?在6.4-(3)-2)章节中,我们设置“Image Packaging Configuration(镜像打包配置)”->“Root filesystem type(根文件系统类型)”为“INITRAMFS”。这一章我们拟将其改为“SD Card”模式并基于TF卡移植一个Ubuntu,当然相关的教程已是非常多了,这只是我个人的学习记录而已(后辈の自嘲)。至于为什么不移植到NAND Flash?那是因为板载NAND的容量不足以安装它。

7.1 宿主机环境配置

Ubuntu和其它的发行版一样,都是基于Linux内核,不同的是它们使用的根文件系统,因此,我们希望移植一个Ubuntu的时候,我们实际上需要做的是构建一个Ubuntu的根文件系统。Debootstrap就是Debian/Ubuntu下完成该任务的工具。在Fedora下也有相似的工具名为Febootstarp。Bootstrap意为“引导”,两种工具的命名均是在此基础上增加了前缀。

制作根文件系统自然要在Linux环境下,因此我们需要配置宿主机的Linux系统并安装必要的工具和环境,本章使用的宿主机系统为Ubuntu20.04。

为了让学习更简单一些,本章我们不使用chroot命令和qemu,而是将根文件系统的解包放在板端进行。

首先安装Debootstrap,在Terminal中执行:

sudo apt install debootstrap

Debootstrap生成Ubuntu根文件系统分为两个阶段,第一个阶段是在宿主机上下载Ubuntu的必要包,第二阶段则是展开它们。

7.2 使用Debootstrap生成最小Rootfs

保证宿主机的联网状态,随便找一个目录,在Terminal中执行:

sudo debootstrap --arch=armhf --foreign bionic ./rootfs

即可在当前目录下生成一个名为rootfs的根文件夹,Debootstrap会将Ubuntu对应版本所需包下载到该文件夹中。

注:Ubuntu系统每个版本会有一个代号,例如:

Ubuntu16.04 —— Xenial

Ubuntu17.04 —— Zesty

Ubuntu18.04 —— Bionic

Ubuntu19.04 —— Disco

Ubuntu20.04 —— Focal

Ubuntu21.04 —— Hirsute

截至目前Debootstrap(arch=armhf)仅支持以上项目中的Xenial和Bionic。

7.3 系统配置

有了前面章节的基础,这里要进行的操作非常简单,首先准备一张TF卡并在宿主机下使用Gparted分成两个区,第一分区为几十到几百兆的FAT/FAT32/RAW格式,第二分区为ext4格式,并对两分区进行格式化。

仿照先前的步骤重新生成一个Petalinux工程,并将Petalinux工程配置中的“Image Packaging Configuration(镜像打包配置)”->“Root filesystem type(根文件系统类型)”改为“SD Card”模式。将编译、打包后的BOOT.BIN和image.ub存放在TF卡的第一分区(这里生成的image.ub少了约6MB,因为其中不再包含initramfs),将Debootstrap生成的Rootfs中的内容复制到第二分区。

注:复制时可使用“sudo cp -r 源目录 目标目录”,防止root目录权限问题无法复制。

(1)Debootstrap第二阶段展开

使矿卡从该TF启动,即可进入到控制台(使用/bin/sh),注意此时未对系统配置,因此不支持命令补全和特殊字符等。在终端执行:

/debootstrap/debootstrap --second-stage

即可解压Ubuntu Rootfs:

# /debootstrap/debootstrap --second-stage
I: Installing core packages...
I: Unpacking required packages...
...
I: Configuring required packages...
...
I: Unpacking the base system...
..
I: Configuring the base system...
...
I: Base system installed successfully.

此时切记**不要断电!**在重启之前一定先把用户创建完成!!不然面对登录对话你会欲哭无泪:P

(2)创建登录用户

我喜欢风,因此这里使用wind作为登录用户名和密码。

首先设置当前账户(root)密码:

passwd

输入并二次确认密码。接着创建名为“wind”的用户:

useradd -m wind

注:使用-m参数可自动在/home/目录下创建该用户目录。

注:此处用户将使用/bin/sh登录,这很不方便,但为了有不一样的体验,暂不使用/bin/bash,下一章再说:D

而后为用户设置密码:

passwd wind

输入并二次确认密码,重新上电即可进入Ubuntu:

U-Boot 2017.01 (Nov 11 2020 - 19:34:58 +0800)Board: Xilinx Zynq
DRAM:  ECC disabled 256 MiB
NAND:  128 MiB
MMC:   sdhci@e0100000: 0 (SD)In:    serial
Out:   serial
Err:   serial
Net:   ZYNQ GEM: e000b000, phyaddr ffffffff, interface gmii
eth0: ethernet@e000b000
U-BOOT for EBAZ4205_linux_TF_with_external_rootfs...(此处省略部分Uboot启动信息)Starting kernel ......(此处省略部分Kernel启动信息)Freeing unused kernel memory: 1024K (c0900000 - c0a00000)
systemd[1]: System time before build time, advancing clock.
systemd[1]: Failed to insert module 'autofs4': No such file or directory
cgroup: cgroup2: unknown option "nsdelegate"
systemd[1]: systemd 237 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)
systemd[1]: Detected architecture arm.Welcome to Ubuntu 18.04 LTS!systemd[1]: Set hostname to <ubuntu>.
systemd[1]: File /lib/systemd/system/systemd-journald.service:36 configures an IP firewall (IPAddressDeny=any), but the local system does not support BPF/cgroup based firewalling.
systemd[1]: Proceeding WITHOUT firewalling in effect! (This warning is only shown for the first loaded unit using IP firewalling.)
systemd[1]: Started Dispatch Password Requests to Console Directory Watch.
[  OK  ] Started Dispatch Password Requests to Console Directory Watch.
systemd[1]: Started Forward Password Requests to Wall Directory Watch.
[  OK  ] Started Forward Password Requests to Wall Directory Watch.
systemd[1]: Reached target Paths.
[  OK  ] Reached target Paths.
systemd[1]: Reached target Local Encrypted Volumes.
[  OK  ] Reached target Local Encrypted Volumes.
systemd[1]: Reached target Swap.
[  OK  ] Reached target Swap.
[  OK  ] Created slice System Slice.
[  OK  ] Listening on Journal Socket.
[  OK  ] Listening on udev Kernel Socket.
[  OK  ] Listening on udev Control Socket.Starting Set the console keyboard layout...
[  OK  ] Listening on /dev/initctl Compatibility Named Pipe.Starting Remount Root and Kernel File Systems...Starting Load Kernel Modules...Starting udev Coldplug all Devices...
[  OK  ] Reached target Remote File Systems.Starting Create Static Device Nodes in /dev...
[  OK  ] Created slice User and Session Slice.
[  OK  ] Reached target Slices.
[  OK  ] Listening on Syslog Socket.
[  OK  ] Listening on Journal Socket (/dev/log).Starting Journal Service...
[  OK  ] Created slice system-serial\x2dgetty.slice.
[  OK  ] Started Remount Root and Kernel File Systems.
[  OK  ] Started Journal Service.
[  OK  ] Started Set the console keyboard layout.
[  OK  ] Started Load Kernel Modules.
[  OK  ] Started Create Static Device Nodes in /dev.Starting Apply Kernel Variables...Mounting Kernel Configuration File System...
[  OK  ] Reached target Local File Systems (Pre).Starting Flush Journal to Persistent Storage...Starting udev Kernel Device Manager...
[  OK  ] Reached target Local File Systems.Starting Set console font and keymap...Starting Load/Save Random Seed...
[  OK  ] Started udev Coldplug all Devices.
[  OK  ] Started Apply Kernel Variables.
[  OK  ] Started udev Kernel Device Manager.
[  OK  ] Mounted Kernel Configuration File System.
[  OK  ] Started Set console font and keymap.
[  OK  ] Started Load/Save Random Seed.
[  OK  ] Found device /dev/ttyPS0.
[  OK  ] Started Flush Journal to Persistent Storage.Starting Create Volatile Files and Directories...
[  OK  ] Started Create Volatile Files and Directories.Starting Network Name Resolution...Starting Update UTMP about System Boot/Shutdown...Starting Network Time Synchronization...
[  OK  ] Started Update UTMP about System Boot/Shutdown.
[  OK  ] Started Network Name Resolution.
[  OK  ] Reached target Host and Network Name Lookups.
[  OK  ] Started Network Time Synchronization.
[  OK  ] Reached target System Initialization.
[  OK  ] Listening on D-Bus System Message Bus Socket.
[  OK  ] Reached target Sockets.
[  OK  ] Reached target Basic System.Starting Login Service...Starting System Logging Service...
[  OK  ] Started Regular background program processing daemon.
[  OK  ] Started Set the CPU Frequency Scaling governor.Starting Dispatcher daemon for systemd-networkd...
[  OK  ] Started Daily Cleanup of Temporary Directories.Starting Permit User Sessions...
[  OK  ] Started D-Bus System Message Bus.
[  OK  ] Started Login Service.
[  OK  ] Started Message of the Day.
[  OK  ] Reached target System Time Synchronized.
[  OK  ] Started Daily apt download activities.
[  OK  ] Started Daily apt upgrade and clean activities.
[  OK  ] Started Discard unused blocks once a week.
[  OK  ] Reached target Timers.
[  OK  ] Started System Logging Service.
[  OK  ] Started Permit User Sessions.Starting Set console scheme...
[  OK  ] Started Serial Getty on ttyPS0.
[  OK  ] Started Set console scheme.
[  OK  ] Created slice system-getty.slice.
[  OK  ] Started Getty on tty1.
[  OK  ] Reached target Login Prompts.
[  OK  ] Started Dispatcher daemon for systemd-networkd.
[  OK  ] Reached target Multi-User System.
[  OK  ] Reached target Graphical Interface.Starting Update UTMP about System Runlevel Changes...
[  OK  ] Started Update UTMP about System Runlevel Changes.Ubuntu 18.04 LTS ubuntu ttyPS0ubuntu login:

在这里输入刚才设置过的用户名和密码即可登陆成功:

Welcome to Ubuntu 18.04 LTS (GNU/Linux 4.9.0-xilinx-v2017.4 armv7l)* Documentation:  https://help.ubuntu.com* Management:     https://landscape.canonical.com* Support:        https://ubuntu.com/advantageThe 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.

(3)为apt工具换源

修改/etc/apt/sources.list文件,改为以下内容:

deb http://ports.ubuntu.com/ubuntu-ports bionic main restricted universe multiverse
deb http://ports.ubuntu.com/ubuntu-ports bionic-security main restricted universe multiverse
deb http://ports.ubuntu.com/ubuntu-ports bionic-updates main restricted universe multiverse
deb http://ports.ubuntu.com/ubuntu-ports bionic-proposed main restricted universe multiverse
deb http://ports.ubuntu.com/ubuntu-ports bionic-backports main restricted universe multiverse
deb-src http://ports.ubuntu.com/ubuntu-ports bionic main restricted universe multiverse
deb-src http://ports.ubuntu.com/ubuntu-ports bionic-security main restricted universe multiverse
deb-src http://ports.ubuntu.com/ubuntu-ports bionic-updates main restricted universe multiverse
deb-src http://ports.ubuntu.com/ubuntu-ports bionic-proposed main restricted universe multiverse
deb-src http://ports.ubuntu.com/ubuntu-ports bionic-backports main restricted universe multiverse

在命令行中执行:

sudo vi /etc/apt/sources.list

命令模式下使用:

dd

删除仅有的一行,而后使用:

i

转换到插入模式,在终端直接粘贴上面的源地址,按ESC键返回。而后输入:

:wq

保存并退出。

注:如果执行sudo提权时提示:

[用户名] is not in the sudoers file.  This incident will be reported.

则依次执行:

su #进入root
sudo adduser [用户名] sudo #添加用户到sudo组
su [用户名]

而后该账户即可使用sudo提权。

注:如果认为vi操作比较麻烦,可以直接把卡挂载到宿主机上修改。

注:vi的操作效果可能因虚拟终端设置而异,即可能存在显示错乱问题,这姑且算是…正常的。

(4)修改网络连接

由于初始的根文件系统没有配置网络,因此也没办法方便地下载工具和组件。配置网络使用的相关软件安装包链接如下:

  1. Net-tools Download for Linux (apk, deb, rpm, tgz, txz, xz)

  2. Ethtool Download for Linux (apk, deb, eopkg, ipk, rpm, tgz, txz, xz, zst)

  3. Ifupdown Download for Linux (apk, deb)

  4. Iputils-ping Download for Linux (deb, ipk)

下载后保存在TF卡中,板端上电,在安装包所在目录执行:

sudo dpkg -i [文件名]

即可从deb包中安装。

**================================================================================**

系统基本工具安装、网络连接配置以及镜像生成过程等请参见后续章节8.2-(1)和8.2-(3)-4)。

由于后续章节先于本章写完,因此烦请读者往后翻翻吧~;P

**================================================================================**

8. 让我们移植一个Ubuntu吧!(基于Ubuntu Base 20.04)

如果你是严格按照上面记录进行复现,且不说在调试过程中的诸多限制,Debootstrap支持的Ubuntu版本太老就已经使人意兴阑珊。我们不经意间想到:如果官方能够将各版本的Ubuntu最小根文件系统制作好并打包,我们不就可以省过漫长的下载-解包的过程,而是拿来直接使用了吗?

Ubuntu Base就是这样的最小根文件系统。本章将尝试基于Ubuntu Base 20.04.1 LTS (Focal Fossa)制作可供矿卡运行的根文件系统。

8.1 宿主机环境配置

在宿主机任意目录下解压Ubuntu Base。

注:以下演示中,该目录使用压缩包本来的名称。命令执行所在目录为目标根文件系统上一级。

Qemu是一种通用的开源计算机仿真器和虚拟器。随着Qemu的发展,安装也变得与以前不同:

sudo apt install qemu-system-[架构] #系统级虚拟机
sudo apt install qemu-user #进程级虚拟机
sudo apt install qemu-utils #qemu工具包

安装完成后,将qemu-arm复制到目标根文件系统中:

sudo cp /usr/bin/qemu-arm ubuntu-base-20.04.1-base-armhf/usr/bin/

而后拷贝bash执行所需环境,动态库主要集中在宿主机的/lib/x86_64-linux-gnu/和/lib64/目录下。

使用ldd命令可列出bash指令:

wkc@ubuntu:~$ ldd /bin/bashlinux-vdso.so.1 (0x00007ffe341b4000)libtinfo.so.6 => /lib/x86_64-linux-gnu/libtinfo.so.6 (0x00007f66323f0000)libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007f66323ea000)libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f66321f8000)/lib64/ld-linux-x86-64.so.2 (0x00007f6632564000)

同理查看qemu-arm的依赖:

wkc@ubuntu:~$ ldd /usr/bin/qemu-armlinux-vdso.so.1 (0x00007ffc45d09000)libz.so.1 => /lib/x86_64-linux-gnu/libz.so.1 (0x00007ff048120000)libgmodule-2.0.so.0 => /lib/x86_64-linux-gnu/libgmodule-2.0.so.0 (0x00007ff04811a000)libglib-2.0.so.0 => /lib/x86_64-linux-gnu/libglib-2.0.so.0 (0x00007ff047ff1000)libgnutls.so.30 => /lib/x86_64-linux-gnu/libgnutls.so.30 (0x00007ff047e1b000)librt.so.1 => /lib/x86_64-linux-gnu/librt.so.1 (0x00007ff047e10000)libstdc++.so.6 => /lib/x86_64-linux-gnu/libstdc++.so.6 (0x00007ff047c2f000)libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007ff047ade000)libgcc_s.so.1 => /lib/x86_64-linux-gnu/libgcc_s.so.1 (0x00007ff047ac3000)libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007ff047aa0000)libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007ff0478ae000)libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007ff0478a8000)libpcre.so.3 => /lib/x86_64-linux-gnu/libpcre.so.3 (0x00007ff047835000)libp11-kit.so.0 => /lib/x86_64-linux-gnu/libp11-kit.so.0 (0x00007ff0476fd000)libidn2.so.0 => /lib/x86_64-linux-gnu/libidn2.so.0 (0x00007ff0476dc000)libunistring.so.2 => /lib/x86_64-linux-gnu/libunistring.so.2 (0x00007ff04755a000)libtasn1.so.6 => /lib/x86_64-linux-gnu/libtasn1.so.6 (0x00007ff047544000)libnettle.so.7 => /lib/x86_64-linux-gnu/libnettle.so.7 (0x00007ff04750a000)libhogweed.so.5 => /lib/x86_64-linux-gnu/libhogweed.so.5 (0x00007ff0474d2000)libgmp.so.10 => /lib/x86_64-linux-gnu/libgmp.so.10 (0x00007ff04744c000)/lib64/ld-linux-x86-64.so.2 (0x00007ff04a62d000)libffi.so.7 => /lib/x86_64-linux-gnu/libffi.so.7 (0x00007ff047440000)

我比较嫌麻烦,因此直接把/lib/x86_64-linux-gnu/文件夹里的东西都复制过去了:

mkdir ubuntu-base-20.04.1-base-armhf/lib64
sudo cp /lib64/ld-linux-x86-64.so.2 ubuntu-base-20.04.1-base-armhf/lib64/
mkdir ubuntu-base-20.04.1-base-armhf/lib/x86_64-linux-gnu
sudo cp /lib/x86_64-linux-gnu/lib* ubuntu-base-20.04.1-base-armhf/lib/x86_64-linux-gnu/

而后为目标根文件系统配置网络:

sudo cp /etc/resolv.conf ubuntu-base-20.04.1-base-armhf/etc/resolv.conf

在终端执行:

sudo chroot ./ubuntu-base-20.04.1-base-armhf

即可切换到目标根文件系统。

8.2 系统配置

(1)安装必要的软件

在chroot环境下执行:

apt update
apt upgrade
apt install sudo ifupdown net-tools ethtool udev wireless-tools iputils-ping resolvconf wget apt-utils wpasupplicant vim git gcc build-essential openssh-server nfs-common

即可在宿主机上为目标根文件系统安装基本应用。

注:如果安装过程中出现:

perl: warning: Setting locale failed.
perl: warning: Please check that your locale settings:
LANGUAGE = (unset),
LC_ALL = (unset),
LC_TIME = "zh_CN.UTF-8",
LC_MONETARY = "zh_CN.UTF-8",
LC_ADDRESS = "zh_CN.UTF-8",
LC_TELEPHONE = "zh_CN.UTF-8",
LC_NAME = "zh_CN.UTF-8",
LC_MEASUREMENT = "zh_CN.UTF-8",
LC_IDENTIFICATION = "zh_CN.UTF-8",
LC_NUMERIC = "zh_CN.UTF-8",
LC_PAPER = "zh_CN.UTF-8",
LANG = "en_US.UTF-8"
are supported and installed on your system.
perl: warning: Falling back to the standard locale ("C").

安装中文支持包即可:

apt install language-pack-zh-hans

在宿主机语言为中文时,chroot从宿主机继承语言设置,可能会出现上述情况。

(2)创建登录用户

首先设置当前账户(root)密码:

passwd

输入并二次确认密码。接着创建名为“wind”的用户,设置使用bash和sudo身份:

useradd -s '/bin/bash' -m -G adm,sudo wind

注:使用-m参数可自动在/home/目录下创建该用户目录。

而后为用户设置密码:

passwd wind

输入并二次确认密码即可。

注:笔者在chroot环境中操作时,passwd提示:

passwd: Authentication token manipulation error
passwd: password unchanged

笔者的做法是执行:

passwd -d root
passwd -d wind

以删除用户的密码,在板端运行时再重新设置即可。

注:板端运行过程中,使用sudo提示:

sudo: /usr/bin/sudo must be owned by uid 0 and have the setuid bit set

在root下设置setuid位即可:

chmod 4755 /usr/bin/sudo

(3)验证根文件系统运行

·1)系统启动验证

如果不经验证直接打包镜像,一旦出了错误就会白费很多精力。验证的步骤可参见7.3章节,在板端运行一遍:

U-Boot 2017.01 (Nov 11 2020 - 19:34:58 +0800)Board: Xilinx Zynq
DRAM:  ECC disabled 256 MiB
NAND:  128 MiB
MMC:   sdhci@e0100000: 0 (SD)In:    serial
Out:   serial
Err:   serial
Net:   ZYNQ GEM: e000b000, phyaddr ffffffff, interface gmii
eth0: ethernet@e000b000
U-BOOT for EBAZ4205_linux_TF_with_external_rootfs...(此处省略部分Uboot启动信息)Starting kernel ......(此处省略部分Kernel启动信息)Freeing unused kernel memory: 1024K (c0900000 - c0a00000)
random: fast init done
systemd[1]: System time before build time, advancing clock.
systemd[1]: Failed to look up module alias 'autofs4': Function not implemented
cgroup: cgroup2: unknown option "nsdelegate"
systemd[1]: systemd 245.4-4ubuntu3.3 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)
systemd[1]: Detected architecture arm.Welcome to Ubuntu 20.04.1 LTS!systemd[1]: Set hostname to <localhost.localdomain>.
systemd[1]: /lib/systemd/system/dbus.socket:5: ListenStream= references a path below legacy directory /var/run/, updating /var/run/dbus/system_bus_socket → /run/dbus/system_bus_socket; please update the unit file accordingly.
systemd[1]: system-getty.slice: unit configures an IP firewall, but the local system does not support BPF/cgroup firewalling.
systemd[1]: (This warning is only shown for the first unit using IP firewalling.)
systemd[1]: Created slice system-getty.slice.
[  OK  ] Created slice system-getty.slice.
systemd[1]: Created slice system-modprobe.slice.
[  OK  ] Created slice system-modprobe.slice.
systemd[1]: Created slice system-serial\x2dgetty.slice.
[  OK  ] Created slice system-serial\x2dgetty.slice.
systemd[1]: Created slice User and Session Slice.
[  OK  ] Created slice User and Session Slice.
systemd[1]: Started Dispatch Password Requests to Console Directory Watch.
[  OK  ] Started Dispatch Password …ts to Console Directory Watch.
systemd[1]: Started Forward Password Requests to Wall Directory Watch.
[  OK  ] Started Forward Password R…uests to Wall Directory Watch.
systemd[1]: Condition check resulted in Arbitrary Executable File Formats File System Automount Point being skipped.
systemd[1]: Reached target Local Encrypted Volumes.
[  OK  ] Reached target Local Encrypted Volumes.
systemd[1]: Reached target Remote File Systems.
[  OK  ] Reached target Remote File Systems.
systemd[1]: Reached target Slices.
[  OK  ] Reached target Slices.
systemd[1]: Reached target Swap.
[  OK  ] Reached target Swap.
systemd[1]: Listening on initctl Compatibility Named Pipe.
[  OK  ] Listening on initctl Compatibility Named Pipe.
systemd[1]: Condition check resulted in Journal Audit Socket being skipped.
systemd[1]: Listening on Journal Socket (/dev/log).
[  OK  ] Listening on Journal Socket (/dev/log).
systemd[1]: Listening on Journal Socket.
[  OK  ] Listening on Journal Socket.
systemd[1]: Listening on udev Control Socket.
[  OK  ] Listening on udev Control Socket.
systemd[1]: Listening on udev Kernel Socket.
[  OK  ] Listening on udev Kernel Socket.
systemd[1]: Condition check resulted in Huge Pages File System being skipped.
systemd[1]: Condition check resulted in POSIX Message Queue File System being skipped.
systemd[1]: Condition check resulted in Kernel Debug File System being skipped.
systemd[1]: Condition check resulted in Kernel Trace File System being skipped.
systemd[1]: Starting Journal Service...Starting Journal Service...
systemd[1]: Condition check resulted in Create list of static device nodes for the current kernel being skipped.
systemd[1]: Condition check resulted in Load Kernel Module drm being skipped.
systemd[1]: Started Nameserver information manager.
[  OK  ] Started Nameserver information manager.
systemd[1]: Reached target Network (Pre).
[  OK  ] Reached target Network (Pre).
systemd[1]: Condition check resulted in Set Up Additional Binary Formats being skipped.
systemd[1]: Starting Load Kernel Modules...Starting Load Kernel Modules...
systemd[1]: Starting Remount Root and Kernel File Systems...Starting Remount Root and Kernel File Systems...
systemd[1]: Starting udev Coldplug all Devices...Starting udev Coldplug all Devices...
systemd[1]: Started Journal Service.
[  OK  ] Started Journal Service.
[  OK  ] Finished Load Kernel Modules.
[  OK  ] Finished Remount Root and Kernel File Systems.Mounting Kernel Configuration File System...Starting Flush Journal to Persistent Storage...Starting Load/Save Random Seed...
systemd-journald[676]: Received client request to flush runtime journal.Starting Apply Kernel Variables...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 udev Coldplug all Devices.Starting Helper to synchronize boot up for ifupdown...
[  OK  ] Finished Helper to synchronize boot up for ifupdown.
[  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 Raise network interfaces...Starting Create Volatile Files and Directories...Starting udev Kernel Device Manager...
[  OK  ] Finished Create Volatile Files and Directories.Starting Network Name Resolution...Starting Network Time Synchronization...Starting Update UTMP about System Boot/Shutdown...
[  OK  ] Finished Update UTMP about System Boot/Shutdown.
[  OK  ] Started udev Kernel Device Manager.
[  OK  ] Finished Raise network interfaces.
[  OK  ] Found device /dev/ttyPS0.
[  OK  ] Started Network Time Synchronization.
[  OK  ] Reached target System Initialization.
[  OK  ] Started resolvconf-pull-resolved.path.
[  OK  ] Started Daily Cleanup of Temporary Directories.
[  OK  ] Reached target Paths.
[  OK  ] Reached target System Time Set.
[  OK  ] Reached target System Time Synchronized.
[  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 Message of the Day.
[  OK  ] Reached target Timers.
[  OK  ] Listening on D-Bus System Message Bus Socket.
[  OK  ] Reached target Sockets.
[  OK  ] Reached target Basic System.
[  OK  ] Started D-Bus System Message Bus.Starting Remove Stale Onli…t4 Metadata Check Snapshots...Ubuntu 20.04.1 LTS localhost.localdomain ttyPS0localhost login:

输入之前创建的用户名(root或wind)即可直接登录:

Welcome to Ubuntu 20.04.1 LTS (GNU/Linux 4.9.0-xilinx-v2017.4 armv7l)* Documentation:  https://help.ubuntu.com* Management:     https://landscape.canonical.com* Support:        https://ubuntu.com/advantageThis 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 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.

注:在板端为用户设置密码的步骤不再重复,仿照先前所述即可。

注:板端运行时无需宿主机的qemu和chroot运行库,可手动删除相关目录和文件,不删除也不会有影响。

·2)直连网络验证

将矿卡网口和PC网口直连,直连可能需要使用交叉线。

测试时本地以太网设置为:

以太网适配器 以太网:IPv4 地址 : 169.254.134.39子网掩码   : 255.255.255.0默认网关   : 169.254.134.1

开发板中设置网络为:

sudo ifconfig eth0 169.254.134.37 broadcast 169.254.134.255 netmask 255.255.255.0

双机互ping非常完美:

wind@localhost:~$ ping 169.254.134.39
PING 169.254.134.39 (169.254.134.39) 56(84) bytes of data.
64 bytes from 169.254.134.39: icmp_seq=1 ttl=128 time=1.89 ms
64 bytes from 169.254.134.39: icmp_seq=2 ttl=128 time=0.700 ms
64 bytes from 169.254.134.39: icmp_seq=3 ttl=128 time=2.86 ms
64 bytes from 169.254.134.39: icmp_seq=4 ttl=128 time=0.835 ms
64 bytes from 169.254.134.39: icmp_seq=5 ttl=128 time=0.677 ms
64 bytes from 169.254.134.39: icmp_seq=6 ttl=128 time=0.660 ms
^C
--- 169.254.134.39 ping statistics ---
6 packets transmitted, 6 received, 0% packet loss, time 5172ms
rtt min/avg/max/mdev = 0.660/1.270/2.858/0.831 ms
正在 Ping 169.254.134.37 具有 32 字节的数据:
来自 169.254.134.37 的回复: 字节=32 时间<1ms TTL=64
来自 169.254.134.37 的回复: 字节=32 时间<1ms TTL=64
来自 169.254.134.37 的回复: 字节=32 时间=1ms TTL=64
来自 169.254.134.37 的回复: 字节=32 时间<1ms TTL=64169.254.134.37 的 Ping 统计信息:数据包: 已发送 = 4,已接收 = 4,丢失 = 0 (0% 丢失),
往返行程的估计时间(以毫秒为单位):最短 = 0ms,最长 = 1ms,平均 = 0ms

·3)局域网络验证

将矿卡和PC连接在同一路由器,测试中手动设置矿卡的IP地址:

sudo ifconfig eth0 192.168.1.150

查看PC的网络配置:

C:\Users\[用户名]>ipconfig
...
无线局域网适配器 WLAN:IPv4 地址 : 192.168.1.100子网掩码   : 255.255.255.0默认网关   : 192.168.1.1

双机互ping结果:

wind@localhost:~$ ping 192.168.1.100
PING 192.168.1.100 (192.168.1.100) 56(84) bytes of data.
64 bytes from 192.168.1.100: icmp_seq=1 ttl=128 time=4.38 ms
64 bytes from 192.168.1.100: icmp_seq=2 ttl=128 time=2.09 ms
64 bytes from 192.168.1.100: icmp_seq=3 ttl=128 time=2.64 ms
64 bytes from 192.168.1.100: icmp_seq=4 ttl=128 time=4.22 ms
64 bytes from 192.168.1.100: icmp_seq=5 ttl=128 time=4.14 ms
64 bytes from 192.168.1.100: icmp_seq=6 ttl=128 time=1.88 ms
64 bytes from 192.168.1.100: icmp_seq=7 ttl=128 time=7.34 ms
64 bytes from 192.168.1.100: icmp_seq=8 ttl=128 time=4.30 ms
64 bytes from 192.168.1.100: icmp_seq=9 ttl=128 time=5.83 ms
64 bytes from 192.168.1.100: icmp_seq=10 ttl=128 time=10.0 ms
^C
--- 192.168.1.100 ping statistics ---
10 packets transmitted, 10 received, 0% packet loss, time 9014ms
rtt min/avg/max/mdev = 1.878/4.687/10.048/2.381 ms
正在 Ping 192.168.1.150 具有 32 字节的数据:
来自 192.168.1.150 的回复: 字节=32 时间=8ms TTL=64
来自 192.168.1.150 的回复: 字节=32 时间=4ms TTL=64
来自 192.168.1.150 的回复: 字节=32 时间=3ms TTL=64
来自 192.168.1.150 的回复: 字节=32 时间=8ms TTL=64192.168.1.150 的 Ping 统计信息:数据包: 已发送 = 4,已接收 = 4,丢失 = 0 (0% 丢失),
往返行程的估计时间(以毫秒为单位):最短 = 3ms,最长 = 8ms,平均 = 5ms

注:手动设置矿卡的IP地址时,注意不要与同网络中其它主机冲突,可在路由器管理界面查看或设置为自动获取IP。

自动获取IP所需工具,可在连接互联网后手动安装。

·4)互联网连接配置

首先需配置DNS服务器,执行:

sudo vim /etc/resolv.conf

编辑该文件,修改nameserver项为:

nameserver 8.8.8.8

注:DNS服务器地址可使用上述的谷歌DNS服务器,也可以使用各运营商提供的DNS服务。

配置矿卡的IP地址,以及在系统路由表中添加网关地址:

sudo ifconfig eth0 192.168.1.150
sudo route add default gw 192.168.1.1

注:如果路由表中没有有效网关,则与外网通信时会报错:Network is unreachable(网络不可达)。使用命令:

route

可查看本地路由表。

此时ping必应等网站就可以正常ping通啦!看!

wind@localhost:~# ping cn.bing.com
PING a-0001.a-msedge.net (204.79.197.200) 56(84) bytes of data.
64 bytes from a-0001.a-msedge.net (204.79.197.200): icmp_seq=1 ttl=111 time=61.0 ms
64 bytes from a-0001.a-msedge.net (204.79.197.200): icmp_seq=2 ttl=111 time=60.3 ms
64 bytes from a-0001.a-msedge.net (204.79.197.200): icmp_seq=3 ttl=111 time=60.3 ms
64 bytes from a-0001.a-msedge.net (204.79.197.200): icmp_seq=5 ttl=111 time=60.7 ms
64 bytes from a-0001.a-msedge.net (204.79.197.200): icmp_seq=6 ttl=111 time=60.2 ms
64 bytes from a-0001.a-msedge.net (204.79.197.200): icmp_seq=7 ttl=111 time=60.6 ms
64 bytes from a-0001.a-msedge.net (204.79.197.200): icmp_seq=8 ttl=111 time=60.4 ms
64 bytes from a-0001.a-msedge.net (204.79.197.200): icmp_seq=9 ttl=111 time=60.5 ms
^C
--- a-0001.a-msedge.net ping statistics ---
9 packets transmitted, 8 received, 11.1111% packet loss, time 8014ms
rtt min/avg/max/mdev = 60.215/60.500/61.014/0.250 ms

在上述DNS服务器修改方式中,重新启动矿卡则文件内容会被重置(其实文件注释里已经说过了,不过我打赌你没看>v<),所以为了让系统记住修改,需要修改另外的文件:

sudo vim /etc/systemd/resolved.conf

将DNS行解注释,修改为:

[Resolve]
DNS=8.8.8.8
...

再次重启系统,则DNS服务器不需重新设置了。

注:有报告说这种修改方式存在无效的可能,不过在笔者调试时,确实解决了联网问题。

同样,为了实现在开机时对网络的自动设置,可做如下修改:

sudo vim /etc/network/interfaces

在其中添加如下设置即可(请根据具体需求更改参数):

auto lo
iface lo inet loopbackauto eth0
iface eth0 inet static
address 192.168.1.150
netmask 255.255.255.0
gateway 192.168.1.1

8.3 生成根文件系统镜像

以下操作在目标根文件系统上层目录依次进行:

mkdir rootfs
dd if=/dev/zero of=Ubuntu20.04_EBAZ4205.img bs=1M count=2500 #生成的空镜像大小需根据待写入文件数量确定
mkfs.ext4 Ubuntu20.04_EBAZ4205.img
sudo mount Ubuntu20.04_EBAZ4205.img rootfs/
sudo cp -rfp [目标根文件系统文件夹]/*  rootfs/
sudo umount rootfs/
e2fsck -p -f Ubuntu20.04_EBAZ4205.img #检查档案完整性
resize2fs -M Ubuntu20.04_EBAZ4205.img #重新调整镜像大小

最终得到该分区的镜像文件可作他用。

至此,基于Ubuntu Base 20.04的系统移植完成。

参考资料

本文编写过程中参考的所有资料均列在下方。本文若与任何列表之外的文章、博客、视频、教程等描述相同或相似则纯属巧合。

另在此处再次对以下资料的作者们表示感谢。

1. 相关信息

  1. ubuntu系统debootstrap的使用
  2. 创建 Ubuntu 根文件系统
  3. ubuntu 20.04 安装qemu
  4. QEMU入门指南
  5. 【Ubuntu】Ubuntu 各版本代号简介_简书
  6. useradd 与adduser的区别_CSDN
  7. [已解决]user is not in the sudoers file. This incident will be reported._CSDN
  8. 移植ubuntu 16.04.4 到arm平台(i.MX6UL)_CSDN
  9. ubuntu20.04 LTS 更换国内163源、阿里源、清华源、中科大源_博客园
  10. perl: warning: Setting locale failed. 解决
  11. linux中一些特殊的权限(setuid/setgid/sticky)_CSDN
  12. mount: /bak: bad option; for several filesystems (e.g. nfs, cifs) you might need a /sbin/mount. helper program
  13. 关于ARM开发板通过有线接入互联网自动获取IP地址问题_CSDN
  14. 关于connect: network is unreachable 问题的解决_CSDN
  15. Ubuntu 18.04 解决Temporary failure in name resolution DNS解析问题_CSDN
  16. ubuntu 网络配置

2. 参考描述

  1. zynq[3] bootstrap Ubuntu

————2020-11-18 @燕卫博————

从零开始的ZYNQ学习(基于矿卡EBAZ4205)(三)相关推荐

  1. 从零开始的ZYNQ学习(基于矿卡EBAZ4205)(四)

    前情提要: 从零开始的ZYNQ学习(基于矿卡EBAZ4205)(一) 从零开始的ZYNQ学习(基于矿卡EBAZ4205)(二) 从零开始的ZYNQ学习(基于矿卡EBAZ4205)(三) 文章目录 0. ...

  2. 从零开始的ZYNQ学习(基于矿卡EBAZ4205)(一)

    文章目录 0. 声明 1. 矿卡EBAZ4205介绍 2. 学习要点和目标 3. 成品板?开发板! 4. 板载外设们 4.1 TF卡及TF卡启动配置 4.2 PWM输出电路的修改 4.3 LED 4. ...

  3. EBAZ4205矿卡控制卡

    EBAZ4205矿卡控制卡 写在前面: ​ 前一段由于学习需要,在某鱼入手了一张EBAZ4205的控制卡,当时号称最便宜,最具性价比的ZYNQ开发板,对于穷学生一枚的我,果断入手,仅消耗30.然而在继 ...

  4. 成本低廉的深度学习与渲染显卡购买方案--英伟达矿卡P106

    此方案适用于个人或小型企业,此方案有不稳定性,如果预算充足请购买Tesla 显卡 转载请注明出处 视频:https://www.bilibili.com/video/av35317062 渲染,深度学 ...

  5. 用矿卡P106升级tensorflow深度学习服务器

    PS:本文绝不是广告,也和淘宝店主没任何关系!!! 最近发现淘宝上的矿卡便宜的让人心动,虽然去年已经买了一块技嘉的大将1066显卡,但是如果错失这个大好良机,那势必会给自己留下难以抹去的遗憾!400元 ...

  6. STM32CubeMX学习笔记(49)——USB接口使用(MSC基于SD卡模拟U盘)

    一.USB简介 USB(Universal Serial BUS)通用串行总线,是一个外部总线标准,用于规范电脑与外部设备的连接和通讯.是应用在 PC 领域的接口技术.USB 接口支持设备的即插即用和 ...

  7. ZYNQ学习之路17.自定义SDSoC硬件平台

    前言 在前面的学习中,我们已经学会了使用Vivado及SDK开发环境,熟悉了硬件开发与Linux软件驱动之间的联系及开发流程.本系列教程我们学习SDSoc的开发,在SDSoc IDE中,Xilinx为 ...

  8. 【致敬未来的攻城狮计划】— 连续打卡第三天:欲速则不达,今天是对RA2E1 基础知识的补充学习。

    系列文章目录 1.连续打卡第一天:提前对CPK_RA2E1是瑞萨RA系列开发板的初体验,了解一下 2.开发环境的选择和调试(从零开始,加油) 文章目录 目录 系列文章目录 文章目录 前言 一.RA是什 ...

  9. ZYNQ学习之路13.创建PetaLinux工程

    在前面的学习中,我们知道如何根据PetaLinux BSP设计去创建一个工程,现在,我们结合Vivado设计我们自己PetaLinux系统. 开发环境:Ubuntu16 64bit, PetaLinu ...

  10. Android学习-- 基于位置的服务 LBS(基于百度地图Android SDK)--定位SDK

    原文:Android学习-- 基于位置的服务 LBS(基于百度地图Android SDK)--定位SDK 版权声明:本文为博主原创文章,未经博主允许不得转载. https://blog.csdn.ne ...

最新文章

  1. Cocos2d-x Win7环境编译apk
  2. 世界排名前20的大学毕业生去做银行柜员,柜员工资是不是很高?
  3. golang商城_Golang——简单是终极的成熟
  4. Linux新建用户可以在shell中切换到该用户也能登录到图形桌面
  5. 简单粗暴的多目标跟踪神器 – DeepSort
  6. 几种SQL取日期部分的方法
  7. ubuntu中mysql怎么退出命令_Ubuntu中mysql启动和关闭
  8. 策略模式思想及示例代码(Strategy)
  9. js中删除数组中某一项的方法
  10. webpack的css样式文件加载依赖
  11. redis通用key操作
  12. Python解决高等数学问题
  13. 电脑每次开机都出现check file system on:C 的解决办法
  14. 向量检索milvus之一:以图搜图
  15. (ICCV 19) Deep Closest Point: Learning Representations for Point Cloud Registration
  16. VR火得不行 那么它商业化的突破点到底在哪里?
  17. Google 在遗忘权下删除了超过 17 万链接
  18. 快排C语言三种实现方法(大同小异)
  19. 用不可描述的图片做可以描述的事情
  20. redis源码学习-03_动态字符串SDS

热门文章

  1. VC++ Call Stack调试
  2. sql2000 mysql_sql2000迷你版 超精简版SQL Server 2000数据库下载
  3. 操作系统复习资料(考研+期末)
  4. 如何选择网页更新提醒工具
  5. 超标量处理器设计 姚永斌 第2章 Cache 摘录
  6. 基于springboot+vue的毕业论文选题答辩管理系统
  7. 【小程序-开篇】国内IT技术圈的技能树貌似点歪了?
  8. 类似Rainmeter、Conky的安卓插件
  9. makefile中文手册_如何学习GCC英文手册
  10. uploadify php 重命名,自定义uploadify服务器端上传脚本