作者: 付汉杰 hankf@xilinx.com hankf@amd.com 测试环境: Vivado/PetaLinux 2021.2, Linux 5.10.0
如何修改u-boot的boot.scr
修改修改components/yocto/layers/meta-xilinx/meta-xilinx-bsp/recipes-bsp/u-boot/u-boot-zynq-scr/ boot.cmd.generic,可以修改u-boot的boot.scr。
如何查找Linux kernel编译日志
按下列步骤,查找Linux kernel编译日志存储
- 进入petalinux工程的“build/tmp”子目录
[hankf@localhost tmp]$ pwd
/home/hankf/proj/vck190/vck190-0316-peta/build/tmp
- 查找目录“kernel-source”
[hankf@localhost tmp]$ find -name "kernel-source"
./work-shared/versal-generic/kernel-source
- 进入目录 kernel-source,并查看文件
[hankf@localhost tmp]$ cd work-shared/versal-generic/kernel-source/
[hankf@localhost kernel-source]$ ls
arch COPYING Documentation include Kbuild mm oe-workdir scripts tools
block CREDITS drivers init Kconfig lib MAINTAINERS net README security usr
certs crypto fs ipc kernel LICENSES Makefile oe-logs samples sound virt
- 进入目录“oe-logs”查找“log.do_compile_kernel*”文件
查看最近修改文件,或者log.do_compile_kernel* 文件。 最新的log.do_compile_kernel*文件,就是kernel的gcc编译日志。
代码语言:javascript复制[hankf@localhost kernel-source]$ cd oe-logs/
[hankf@localhost oe-logs]$ ls -alrt | tail -n 10
-rw-rw-r--. 1 hankf hankf 26082 Mar 17 04:00 run.extend_recipe_sysroot.18319
-rw-rw-r--. 1 hankf hankf 5488 Mar 17 04:00 log.task_order
lrwxrwxrwx. 1 hankf hankf 34 Mar 17 04:00 log.do_compile_kernelmodules -> log.do_compile_kernelmodules.18330
lrwxrwxrwx. 1 hankf hankf 30 Mar 17 04:00 run.do_assemble_fitimage -> run.do_assemble_fitimage.18319
lrwxrwxrwx. 1 hankf hankf 34 Mar 17 04:00 run.do_compile_kernelmodules -> run.do_compile_kernelmodules.18330
-rwxrwxr-x. 1 hankf hankf 23283 Mar 17 04:00 run.do_compile_kernelmodules.18330
-rwxrwxr-x. 1 hankf hankf 24552 Mar 17 04:00 run.do_assemble_fitimage.18319
-rw-rw-r--. 1 hankf hankf 3950 Mar 17 04:00 log.do_assemble_fitimage.18319
-rw-rw-r--. 1 hankf hankf 17835 Mar 17 04:00 log.do_compile_kernelmodules.18330
drwxrwxr-x. 2 hankf hankf 36864 Mar 17 04:00 .
[hankf@localhost oe-logs]$ ls log.do_compile_kernel*
log.do_compile_kernelmodules log.do_compile_kernelmodules.11901 log.do_compile_kernelmodules.19287 log.do_compile_kernelmodules.24979
log.do_compile_kernelmodules.11390 log.do_compile_kernelmodules.18330 log.do_compile_kernelmodules.19623
[1] Done gedit log.do_compile_kernelmodules.18330
[hankf@localhost oe-logs]$ gedit log.do_compile_kernelmodules.18330 &
[1] 20997
CentOS 7.9 下如何使用PetaLinux 2021.2
在CentOS 7.9 下使用PetaLinux 2021.2编译工程,会得到告警“Seems like your machine does not have gcc 6 or greater version”,并且不能编译。
代码语言:javascript复制[root@localhost vck190-0316-peta]# lsb_release -a
LSB Version: :core-4.1-amd64:core-4.1-noarch:cxx-4.1-amd64:cxx-4.1-noarch:desktop-4.1-amd64:desktop-4.1-noarch:languages-4.1-amd64:languages-4.1-noarch:printing-4.1-amd64:printing-4.1-noarch
Distributor ID: CentOS
Description: CentOS Linux release 7.9.2009 (Core)
Release: 7.9.2009
Codename: Core
[root@localhost vck190-0316-peta]# gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/libexec/gcc/x86_64-redhat-linux/4.8.5/lto-wrapper
Target: x86_64-redhat-linux
Configured with: ../configure --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --with-bugurl=http://bugzilla.redhat.com/bugzilla --enable-bootstrap --enable-shared --enable-threads=posix --enable-checking=release --with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions --enable-gnu-unique-object --enable-linker-build-id --with-linker-hash-style=gnu --enable-languages=c,c ,objc,obj-c ,java,fortran,ada,go,lto --enable-plugin --enable-initfini-array --disable-libgcj --with-isl=/builddir/build/BUILD/gcc-4.8.5-20150702/obj-x86_64-redhat-linux/isl-install --with-cloog=/builddir/build/BUILD/gcc-4.8.5-20150702/obj-x86_64-redhat-linux/cloog-install --enable-gnu-indirect-function --with-tune=generic --with-arch_32=x86-64 --build=x86_64-redhat-linux
Thread model: posix
gcc version 4.8.5 20150623 (Red Hat 4.8.5-44) (GCC)
[hankf@localhost vck190-0316-peta]$ petalinux-build
[INFO] Sourcing buildtools
[INFO] Building project
WARNING: Seems like your machine does not have gcc 6 or greater version,
Please enable buildtools Extended in petalinux-config --> yocto settings
[INFO] Extracting yocto SDK to components/yocto. This may take time!
ERROR: Failed to Extract Yocto SDK.
ERROR: Failed to build project. Check the /home/hankf/proj/vck190/dapd-0305-colour-peta/build/build.log file for more details...
CentOS 7.9自带的GCC是4.8.5,太旧了。PetaLinux要求gcc 6或者更高版本。 通过工具SCL,是可以在同一个系统上编译,安装,并且使用多个版本的软件。使用下列命令,为CentOS 7.9安装GCC 7.
代码语言:javascript复制sudo yum install centos-release-scl
sudo yum install devtoolset-7
然后通过下列命令启动一个新的 shell,就可以使用GCC 7
代码语言:javascript复制scl enable devtoolset-7 bash
gcc --version
gcc (GCC) 7.3.1 20180303 (Red Hat 7.3.1-5)
Copyright (C) 2017 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
注意,不能把“scl enable devtoolset-7 bash”加入".bashrc",它会导致命令行出现以下错误。
代码语言:javascript复制bash: fork: retry: No child processes
bash: fork: retry: No child processes
bash: fork: Resource temporarily unavailable
glibc git: No such file or directory
使用template新建的PetaLinux工程,编译遇到错误“glibc/2.32-r0/git: No such file or directory”。 更多信息如下。 再次执行petalinux-build,能正常编译通过。
代码语言:javascript复制NOTE: Running ../../../../../../../../../../../home/hankf/proj/vck190/vck190-0316-peta/build/tmp/work/cortexa72-cortexa53-xilinx-linux/glibc/2.32-r0/git/configure --build=x86_64-linux --host=aarch64-xilinx-linux --target=aarch64-xilinx-linux --prefix=/usr --exec_prefix=/usr --bindir=/usr/bin --sbindir=/usr/sbin --libexecdir=/usr/libexec --datadir=/usr/share --sysconfdir=/etc --sharedstatedir=/com --localstatedir=/var --libdir=/usr/lib --includedir=/usr/include --oldincludedir=/usr/include --infodir=/usr/share/info --mandir=/usr/share/man --disable-silent-rules --disable-dependency-tracking --with-libtool-sysroot=/home/hankf/proj/vck190/vck190-0316-peta/build/tmp/work/cortexa72-cortexa53-xilinx-linux/glibc/2.32-r0/recipe-sysroot --enable-kernel=3.14 --disable-profile --disable-debug --without-gd --enable-clocale=gnu --with-headers=/home/hankf/proj/vck190/vck190-0316-peta/build/tmp/work/cortexa72-cortexa53-xilinx-linux/glibc/2.32-r0/recipe-sysroot/usr/include --without-selinux --enable-tunables --enable-bind-now --enable-stack-protector=strong --enable-stackguard-randomization --disable-crypt --with-default-link --disable-static --enable-nscd
../../../../../../../../../../../home/hankf/proj/vck190/vck190-0316-peta/build/tmp/work/cortexa72-cortexa53-xilinx-linux/glibc/2.32-r0/git/configure: line 1323: cd: ../../../../../../../../../../../home/hankf/proj/vck190/vck190-0316-peta/build/tmp/work/cortexa72-cortexa53-xilinx-linux/glibc/2.32-r0/git: No such file or directory
configure: error: sources are in ../../../../../../../../../../../home/hankf/proj/vck190/vck190-0316-peta/build/tmp/work/cortexa72-cortexa53-xilinx-linux/glibc/2.32-r0/git, but `cd ../../../../../../../../../../../home/hankf/proj/vck190/vck190-0316-peta/build/tmp/work/cortexa72-cortexa53-xilinx-linux/glibc/2.32-r0/git' does not work
checking build system type... x86_64-pc-linux-gnu
checking host system type... aarch64-xilinx-linux-gnu
checking for aarch64-xilinx-linux-gcc... aarch64-xilinx-linux-gcc -mcpu=cortex-a72.cortex-a53 -march=armv8-a crc --sysroot=/home/hankf/proj/vck190/vck190-0316-peta/build/tmp/work/cortexa72-cortexa53-xilinx-linux/glibc/2.32-r0/recipe-sysroot
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether aarch64-xilinx-linux-gcc -mcpu=cortex-a72.cortex-a53 -march=armv8-a crc --sysroot=/home/hankf/proj/vck190/vck190-0316-peta/build/tmp/work/cortexa72-cortexa53-xilinx-linux/glibc/2.32-r0/recipe-sysroot accepts -g... yes
checking for gcc... gcc
checking for aarch64-xilinx-linux-readelf... aarch64-xilinx-linux-readelf
checking whether we are using the GNU C compiler... yes
checking whether aarch64-xilinx-linux-g -mcpu=cortex-a72.cortex-a53 -march=armv8-a crc --sysroot=/home/hankf/proj/vck190/vck190-0316-peta/build/tmp/work/cortexa72-cortexa53-xilinx-linux/glibc/2.32-r0/recipe-sysroot accepts -g... yes
checking whether aarch64-xilinx-linux-g -mcpu=cortex-a72.cortex-a53 -march=armv8-a crc --sysroot=/home/hankf/proj/vck190/vck190-0316-peta/build/tmp/work/cortexa72-cortexa53-xilinx-linux/glibc/2.32-r0/recipe-sysroot can link programs... no
../../../../../../../../../../../home/hankf/proj/vck190/vck190-0316-peta/build/tmp/work/cortexa72-cortexa53-xilinx-linux/glibc/2.32-r0/git/configure: line 3253: cd: ../../../../../../../../../../../home/hankf/proj/vck190/vck190-0316-peta/build/tmp/work/cortexa72-cortexa53-xilinx-linux/glibc/2.32-r0/git: No such file or directory
configure: error: you must configure in a separate build directory
修改文件变化通知机制Inotify的限制
编译PetaLinux 2021.2工程,遇到错误“Too many open files”。编译的命令行错误如下:
代码语言:javascript复制[hankf@localhost vck190-0316-peta]$ petalinux-build
[INFO] Sourcing buildtools
[INFO] Building project
[INFO] Sourcing build environment
[INFO] Adding user layers
ERROR: Failed to add user layer: /home/hankf/proj/vck190/vck190-0316-peta/project-spec/meta-user
ERROR: Failed to build project. Check the /home/hankf/proj/vck190/vck190-0316-peta/build/build.log file for more details...
build.log的内容如下:
代码语言:javascript复制NOTE: Starting bitbake server...
ERROR: Unable to start bitbake server (None)
ERROR: Server log for this session (/proj/hankf/vck190/vck190-0316-peta/build/bitbake-cookerdaemon.log):
3577 03:25:27.646174 --- Starting bitbake server pid 3577 at 2022-03-16 03:25:27.646160 ---
Traceback (most recent call last):
File "/proj/hankf/vck190/vck190-0316-peta/components/yocto/layers/core/bitbake/bin/bitbake-server", line 53, in <module>
bb.server.process.execServer(lockfd, readypipeinfd, lockname, sockname, timeout, xmlrpcinterface)
File "/proj/hankf/vck190/vck190-0316-peta/components/yocto/layers/core/bitbake/lib/bb/server/process.py", line 542, in execServer
cooker = bb.cooker.BBCooker(featureset, server.register_idle_function)
File "/proj/hankf/vck190/vck190-0316-peta/components/yocto/layers/core/bitbake/lib/bb/cooker.py", line 169, in __init__
self.configwatcher = pyinotify.WatchManager()
File "/proj/hankf/vck190/vck190-0316-peta/components/yocto/layers/core/bitbake/lib/pyinotify.py", line 1748, in __init__
raise OSError(err % self._inotify_wrapper.str_errno())
OSError: Cannot initialize new instance of inotify, Errno=Too many open files (EMFILE)
修改max_user_instances,可以修正错误,成功编译。
代码语言:javascript复制[hankf@localhost vck190-0316-peta]$ cat /proc/sys/fs/inotify/max_user_instances
128
[hankf@localhost vck190-0316-peta]$ sudo echo 99999999 > /proc/sys/fs/inotify/max_user_instances
bash: /proc/sys/fs/inotify/max_user_instances: Permission denied
[hankf@localhost vck190-0316-peta]$ ls -l -h /proc/sys/fs/inotify/max_user_instances
-rw-r--r--. 1 root root 0 Mar 15 23:31 /proc/sys/fs/inotify/max_user_instances
[hankf@localhost vck190-0316-peta]$ sudo su
[sudo] password for hankf:
[root@localhost vck190-0316-peta]# echo 99999999 > /proc/sys/fs/inotify/max_user_instances
[root@localhost vck190-0316-peta]# cat /proc/sys/fs/inotify/max_user_instances
99999999
[root@localhost vck190-0316-peta]# exit
exit
[hankf@localhost vck190-0316-peta]$ petalinux-build
[INFO] Sourcing buildtools
[INFO] Building project
[INFO] Sourcing build environment
[INFO] Adding user layers
[INFO] Generating workspace directory
..........
为了永久生效,需要在文件/etc/sysctl.conf里增加下列行。
代码语言:javascript复制fs.inotify.max_user_instances = 256
petalinuxbsp.conf里的RM_WORK_EXCLUDE行后不能加注释
在petalinuxbsp.conf的RM_WORK_EXCLUDE加注释,引起错误“unparsed line: 'RM_WORK_EXCLUDE = "linux-xlnx" # good'”。 去掉后面的注释,错误消失。错误信息如下。
代码语言:javascript复制NOTE: Starting bitbake server...
NOTE: No reply from server in 30s
ERROR: ParseError at /home/hankf/proj/vck190/vck190-0316-peta/project-spec/meta-user/conf/petalinuxbsp.conf:20: unparsed line: 'RM_WORK_EXCLUDE = "linux-xlnx" # good'
ERROR: ParseError at /home/hankf/proj/vck190/vck190-0316-peta/project-spec/meta-user/conf/petalinuxbsp.conf:20: unparsed line: 'RM_WORK_EXCLUDE = "linux-xlnx" # good'
ERROR: Exception in server main event loop running command [] ()
Traceback (most recent call last):
..........
使用gFTP更新单板系统映像
调试时,修改Linux代码、Linux驱动代码、Devicetree后,需要重新生成V单板系统映像的boot.bin, image.ub等文件。 如果单板从TF卡启动,一般需要把上面的文件复制到TF卡上。传统做法,是拔插TF卡到PC机,复制后再插TF卡到单板。
更方便的办法,是使用网络传输到单板的TF卡。Windows的winscp可以用来完成这个工作。但是Linux上流行的软件FileZilla 3.7.4.1, 与单板使用的Dropbear不能完成密钥交换,不能建立SFTP连接。下面是FileZilla报告的消息。
代码语言:javascript复制10:11:07 Trace: Couldn't agree a key exchange algorithm (available: curve25519-sha256,curve25519-sha256@libssh.org,ecdh-sha2-nistp521,ecdh-sha2-nistp384,ecdh-sha2-nistp256,diffie-hellman-group14-sha256,kexguess2@matt.ucc.asn.au)
10:11:07 Error: Couldn't agree a key exchange algorithm (available: curve25519-sha256,curve25519-sha256@libssh.org,ecdh-sha2-nistp521,ecdh-sha2-nistp384,ecdh-sha2-nistp256,diffie-hellman-group14-sha256,kexguess2@matt.ucc.asn.au)
经过尝试,在Linux上使用gFTP,能建立SFTP连接。另外,默认的PetaLinux工程生成的Linux,每次启动时会重新生成新的密钥。gFTP第二次连接时,会报告密钥错误,也不能建立连接。建议删除文件“~/.ssh/known_hosts”中的单板对应的条目,gFTP就能建立连接。如果没有其它应用程序使用这个文件,可以删除整个文件。
代码语言:javascript复制rm ~/.ssh/known_hosts
gftp