前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >专栏 >提高PetaLinux/Yocto的编译速度,暨整合Open Source U-Boot/Linux编译 -- PetaLinux 2021/2022版本

提高PetaLinux/Yocto的编译速度,暨整合Open Source U-Boot/Linux编译 -- PetaLinux 2021/2022版本

作者头像
hankfu
发布于 2022-11-23 08:46:03
发布于 2022-11-23 08:46:03
5.3K00
代码可运行
举报
文章被收录于专栏:hankhank
运行总次数:0
代码可运行

提高PetaLinux/Yocto的编译速度,暨整合Open Source U-Boot/Linux编译 -- PetaLinux 2021/2022版本

总结

通过使用本地文件、Open Source U-Boot/Linux编译,既能适应部分开发人员的工作习惯,也能提高U-Boot/Linux的编译速度。

概述

PetaLinux是Xilinx基于Yocto推出的Linux开发工具,可以一键编译出一个完整的嵌入式Linux发行版,包括上百万源代码文件,数千个应用程序。但是完整的一次PetaLinux/Yocto编译,可能需要从网络下载上GB的文件,可能需要几十分钟。即使只更改一行代码,也需要数分钟时间。

如果在调试单板时,仅仅改动一行代码,也需要执行这些操作,显得冗余,也影响开发效率。

为了适应开发人员的工作习惯,也为了提高速度,可以使用本地文件编译,还可以可以整合OpenSource U-Boot/Linux编译。

3年前,我写了整合Xilinx PetaLinux工程编译和Open Source U- Boot/Linux编译。相比3年前,PetaLinux已经做了很多更新。因此基于PetaLinux 2021/2022版本更新,以提供更准确的办法。另外,本文中提供了完整的脚本,从PetaLinux工程自动获取U-Boot/Linux源代码,以及从PetaLinux工程目录以Open Source流程编译U-Boot/Linux并更新PetaLinux工程的BOOT.BIN、image、image.ub。

PetaLinux的安装

对于PetaLinux的安装,请参考Xilinx文档UG1144 PetaLinux Tools Reference Guide, 和 一键离线安装PetaLinux依赖包

提高PetaLinux的编译速度

使用本地SState cache

在Xilinx下载网站嵌入式工具下载区 下载sstate cache。 目前SState cache已经分为Arm64(AArch64), Arm, mbfull, mblite四个文件。 2021.1版的AArch64 sstate cache的大小是11.84 GB,Arm sstate cache的大小是5.09 GB。 下载前,需要注册Xilinx网站的帐号。 登录后,选择aarch64 sstate-cache等,从类似于sstate_aarch64_2022.2_10071807.tar.gz 的地址下载SState cache文件。

下载后解压,以AArch64为例,可以看到类似下面的目录结构。

代码语言:javascript
代码运行次数:0
运行
AI代码解释
复制
hankf@XSZGS4:aarch64$ ls 
00  06  0c  12  18  1e  24  2a  30  36  3c  42  48  4e  54  5a  60  66  6c  72  78  7e  84  8a  90  96  9c  a2  a8  ae  b4  ba  c0  c6  cc  d2  d8  de  e4  ea  f0  f6  fc
01  07  0d  13  19  1f  25  2b  31  37  3d  43  49  4f  55  5b  61  67  6d  73  79  7f  85  8b  91  97  9d  a3  a9  af  b5  bb  c1  c7  cd  d3  d9  df  e5  eb  f1  f7  fd
02  08  0e  14  1a  20  26  2c  32  38  3e  44  4a  50  56  5c  62  68  6e  74  7a  80  86  8c  92  98  9e  a4  aa  b0  b6  bc  c2  c8  ce  d4  da  e0  e6  ec  f2  f8  fe
03  09  0f  15  1b  21  27  2d  33  39  3f  45  4b  51  57  5d  63  69  6f  75  7b  81  87  8d  93  99  9f  a5  ab  b1  b7  bd  c3  c9  cf  d5  db  e1  e7  ed  f3  f9  ff
04  0a  10  16  1c  22  28  2e  34  3a  40  46  4c  52  58  5e  64  6a  70  76  7c  82  88  8e  94  9a  a0  a6  ac  b2  b8  be  c4  ca  d0  d6  dc  e2  e8  ee  f4  fa  universal
05  0b  11  17  1d  23  29  2f  35  3b  41  47  4d  53  59  5f  65  6b  71  77  7d  83  89  8f  95  9b  a1  a7  ad  b3  b9  bf  c5  cb  d1  d7  dd  e3  e9  ef  f5  fb

在PetaLinux工程目录下执行命令petalinux-config,在菜单Yocto Settings->Local sstate feeds settings->local sstate feeds url设置本地SState cache的目录。

本地SState cache设置界面

对于MPSoC,使用aarch64,比如/opt/Xilinx/peta/2021.1/sstate/aarch64。对于Zynq-7000,使用arm,比如/opt/Xilinx/peta/2021.1/sstate/arm。设置后,文件project-spec/configs/config会包含指定的目录,比如下行:

CONFIG_YOCTO_LOCAL_SSTATE_FEEDS_URL="/opt/Xilinx/peta/2021.1/sstate/aarch64"

对于sstate的使用,可以参考Xilinx下载网站嵌入式工具下载区的README for state-cache

使用本地Downloads文件包

在Xilinx下载网站嵌入式工具下载区 下载 Downloads文件包。 2021.1的Downloads文件包有39.75GB。

Downloads文件包里,还有很多常用软件的压缩包。下载后解压,可以看到类似下面的目录结构。

代码语言:javascript
代码运行次数:0
运行
AI代码解释
复制
hankf@XSZGS4:downloads$ ls
acl-2.2.53.tar.gz                    git2_github.com.tpm2-software.tpm2-tss-engine.git.tar.gz           libxml2-2.9.10.tar.gz
acpica-unix-20200717.tar.gz          git2_github.com.troglobit.sysklogd.git.tar.gz                      libXmu-1.1.3.tar.bz2
adwaita-icon-theme-3.36.1.tar.xz     git2_github.com.ucb-bar.berkeley-softfloat-3.git.tar.gz            libXrandr-1.5.2.tar.bz2
alsa-lib-1.2.3.2.tar.bz2             git2_github.com.uclouvain.openjpeg.git.tar.gz                      libXrender-0.9.10.tar.bz2
alsa-plugins-1.2.2.tar.bz2           git2_github.com.vim.vim.git.tar.gz                                 libXres-1.2.0.tar.bz2
alsa-tools-1.2.2.tar.bz2                                              
......

在petalinux-config的配置菜单" -> Yocto Settings -> Add pre-mirror url "里,输入上述文件所在的目录“file://path/downloads”。

重用下载文件

PetaLinux在编译过程中下载所需要的文件。编译结束后,目录build/downloads/下可能含有额外下载的文件。如果来源是上述的本地downloads,那么只是文件链接。如果是从网络下载,那么就是真实的文件。可以使用命令“ls -l | grep -v ">" | grep -v done”排除链接和后缀为done的标志文件,从而只显示从网络下载的文件。

建议把真实的文件件拷贝到上述的本地downloads目录。以后编译PetaLinux工程,可以重用本地的这些文件。后续的编译,就不会从网络下载,速度会更快。

代码语言:javascript
代码运行次数:0
运行
AI代码解释
复制
$ ls build/downloads/*.xz
build/downloads/atk-2.28.1.tar.xz                    build/downloads/grep-3.1.tar.xz                build/downloads/netbase_5.4.tar.xz
build/downloads/at-spi2-atk-2.26.2.tar.xz            build/downloads/gst-rtsp-server-1.14.4.tar.xz  build/downloads/ofono-1.24.tar.xz
build/downloads/at-spi2-core-2.28.0.tar.xz           build/downloads/gtk+-2.24.32.tar.xz            build/downloads/pango-1.42.4.tar.xz
... ...

$ ls build/downloads/*.bz2
build/downloads/alsa-lib-1.1.6.tar.bz2         build/downloads/libassuan-2.5.1.tar.bz2       build/downloads/pcre-8.42.tar.bz2
build/downloads/alsa-plugins-1.1.6.tar.bz2     build/downloads/libgpg-error-1.32.tar.bz2     build/downloads/pixman-0.34.0.tar.bz2
build/downloads/alsa-tools-1.1.6.tar.bz2       build/downloads/libICE-1.0.9.tar.bz2          build/downloads/sysvinit-2.88dsf.tar.bz2
... ...

离线编译

如果确信所有软件包都已经在本地,可以去掉网络连接,执行离线编译,会提高编译速度。

在菜单Yocto Settings里,去掉“Enable Network sstate feeds”,选择“Enable BB NO NETWORK”。

PetaLinux编译Linux和U-Boot

PetaLinux在编译工程中,会自动编译Linux和U-Boot。

使用命令“petalinux-build -c kernel”, 只编译Linux; 使用命令“petalinux-build -c u-boot”, 只编译U-Boot。。

在build目录下的子目录kernel-build-artifacts也保存了Linux的配置文件.config。对于PetaLinux 2021.1的ZCU106 BSP工程,Linux的配置文件.config在build/tmp/work-shared/zynqmp-generic/kernel-build-artifacts/。

如果使用了image.ub格式,build目录下也有创建image.ub文件的its文件。对于PetaLinux 2021.1的ZCU106 BSP工程,its文件是build/tmp/work/zynqmp_generic-xilinx-linux/linux-xlnx/5.10+gitAUTOINC+c830a552a6-r0/linux-zynqmp_generic-standard-build/fit-image-petalinux-initramfs-image.its。

在build目录下的子目录build下,保存了UBoot的配置文件.config. 对于PetaLinux 2021.1的ZCU106 BSP工程,UBoot的配置文件.config在build/tmp/work/zynqmp_generic-xilinx-linux/u-boot-xlnx/v2021.01-xilinx-v2021.1+gitAUTOINC+41fc08b3fe-r0/build/。

devtool取得Linux和UBoot源代码

PetaLinux也提供Yocto的devtool工具,通过devtool能直接取得Linux和UBoot源代码。在2021及之后的版本里,PetaLinux直接提供命令petalinux-devtool,实现Yocto的devtool的功能。在2021之前的版本里,导入目录components/yocto/下的“environment-setup-aarch64-xilinx-linux” 和 “layers/core/oe-init-build-env”的环境,能使用Yocto的devtool工具。

通过执行命令“petalinux-devtool modify linux-xlnx”, Linux源代码会被保存至"components/yocto/workspace/sources/linux-xlnx"目录下。

通过执行命令“petalinux-devtool modify u-boot-xlnx”, Linux源代码会被保存至"components/yocto/workspace/sources/u-boot-xlnx"目录下。

工程师修改上述的Linux和UBoot源代码后,直接编译PetaLinux工程,修改就会生效。

调试完成后,再执行命令“petalinux-devtool finish linux-xlnx project-spec/meta-user”,能为Linux创建patch,并且不再使用上述代码。所以使用petalinux-devtool的方式获取代码,能更容易的创建patch,把修改合并回PetaLinux工程。

Open Source流程编译Linux和UBoot

结合devtool取得的Linux和UBoot源代码, 和build目录下的配置文件.config,可以整合Linux和UBoot的PetaLinux编译流程与Open Source 编译流程。

注意,在以Open Source流程编译Linux和UBoot之前,请先成功编译PetaLinux工程。

获取源代码和配置文件

下述脚本通过devtool取得的Linux和UBoot源代码, 并复制build目录下的Linux和UBoot配置文件.config到各自的源代码目录中。

代码语言:javascript
代码运行次数:0
运行
AI代码解释
复制
#!/bin/bash
# Author: Hank FU, hankf@amd.com; hankf@xilinx.com; 
# osl-fetch-source.sh
# Execute osl-fetch-source.sh in PetaLinux project directory. 

if [ ! -d ./project-spec/meta-user/recipes-bsp/ ]; then 
    echo "Not PetaLinux project directory."
    echo "No directory: ./project-spec/meta-user/recipes-bsp "
    echo "Exit."
    exit 1
fi 

echo "Check image of PetaLinux project."
ls -l ./images/linux/u-boot.elf 
ls -l ./images/linux/Image
if [ ! -f ./images/linux/u-boot.elf ] || [ ! -f ./images/linux/Image ]; then 
    echo "PetaLinux project is not built successfully."
    echo "Please build it first."
    exit 1
fi 

peta_dir=`pwd`

# check petalinux tool
echo "check petalinux tool:"  
which petalinux-build    
which petalinux-devtool  

petalinux_devtool=`which petalinux-devtool` 
echo "petalinux devtool:  $petalinux_devtool"  

# PetaLinux 2020.1: no petalinux-devtool
# source /opt/pkg/petalinux/settings.sh
# source <plnx-proj-root>/components/yocto/environment-setup-aarch64-xilinx-linux
# source <plnx-proj-root>/components/yocto/layers/core/oe-init-build-env
if [ "$petalinux_devtool" = "" ]; then
    echo "Source yocto environment"  

    # source components/yocto/environment-setup-aarch64-xilinx-linux  
    # source components/yocto/layers/core/oe-init-build-env          

    # No output re-direction, command "devtool" in the current bash after "source".
    if [ -f ./components/yocto/environment-setup-aarch64-xilinx-linux ]; then 
        echo "Source yocto environment: aarch64"  
        source ./components/yocto/environment-setup-aarch64-xilinx-linux         
    elif [ -f ./components/yocto/environment-setup-cortexa72-cortexa53-xilinx-linux ]; then
        echo "Source yocto environment: cortexa72"  
        source ./components/yocto/environment-setup-cortexa72-cortexa53-xilinx-linux         
    fi 

    source components/yocto/layers/core/oe-init-build-env    
        # It enter directory "build"  
        echo -e "\nShow current directory: "   
        pwd                                    
    if [ -d ../components/yocto/ ]; then 
        cd .. 
    fi 

    if [ ! -d ./components/yocto/ ]; then 
        echo -e "\nError current directory: "  
        pwd 
        exit
    fi 

    petalinux_devtool=`which devtool`
    echo "petalinux devtool:  $petalinux_devtool"  
    devtool create-workspace ./components/yocto/workspace/sources  
fi

if [ "$petalinux_devtool" = "" ]; then
    echo "Error: petalinux devtool is invalid"  
    exit
fi

echo -e "\nShow current directory: "   
pwd                                    

sources_dir=$peta_dir/components/yocto/workspace/sources
echo -e "\nTry to modify components into directory: $sources_dir\n"  

# ug1144 Table 42: petalinux-build -c Components
# 
# Get the source code from git url specifi ed  in meta-layers:
#     petalinux-devtool modify <recipe-name>
# 
# Creates a patch for the committed  changes in recipe sources directory.
#     petalinux-devtool finish <recipe-name> <destination layer path>

echo -e "\nTry to modify linux-xlnx"    
$petalinux_devtool modify linux-xlnx     

linux_kernel_config_file=`find -name ".config"     | grep -i kernel-build-artifacts`
if [ "$linux_kernel_config_file" = "" ]; then
    echo "Failed to findLinux-kernel .config file.";   
    exit 1
fi

echo -e "\nLinux-kernel .config file: $linux_kernel_config_file"      
if [ -d $sources_dir/linux-xlnx/ ]; then
    cp $linux_kernel_config_file  $sources_dir/linux-xlnx/config_file_used_by_petalinux   
    # only one arch config files is valid.
    cp $linux_kernel_config_file  $sources_dir/linux-xlnx/arch/arm64/configs/xilinx_peta_defconfig   
    cp $linux_kernel_config_file  $sources_dir/linux-xlnx/arch/arm/configs/xilinx_peta_defconfig    
    cp $linux_kernel_config_file  $sources_dir/linux-xlnx/   
else
    echo -e "\nNo Linux-kernel source code directory"          
fi

linux_kernel_its_file=`find -name "fit-image-petalinux*.its" | grep -i build `
if [ "$linux_kernel_its_file" = "" ]; then
    echo "Failed to find Linux-kernel image.ub its file.";   
    exit 1
fi

echo -e "\nLinux-kernel image.ub its file: $linux_kernel_its_file"      
if [ -d $sources_dir/linux-xlnx/ ]; then
    cp $linux_kernel_its_file  $sources_dir/linux-xlnx/   
else
    echo -e "\nNo Linux-kernel source code directory"          
fi

echo -e "\nTry to modify u-boot-xlnx"    
$petalinux_devtool modify u-boot-xlnx     

u_boot_config_file=`find -name ".config" | grep -i u-boot-xlnx | grep -i build `
if [ "$u_boot_config_file" = "" ]; then
    echo "Failed to find U-Boot .config file.";   
    exit 1
fi

echo -e "\nU-boot .config file: $u_boot_config_file"          
if [ -d $sources_dir/u-boot-xlnx/ ]; then
    cp $u_boot_config_file  $sources_dir/u-boot-xlnx/config_file_used_by_petalinux   
    cp $u_boot_config_file  $sources_dir/u-boot-xlnx/configs/xilinx_peta_defconfig   
    cp $u_boot_config_file  $sources_dir/u-boot-xlnx/ 
else
    echo -e "\nNo U-boot source code directory"          
fi

echo -e "\nShow current directory: "   
pwd                                    

if [ -d $sources_dir/ ]; then 
    echo -e "\nShow components that can be modified in $sources_dir/"   
     ls -l $sources_dir/          
else
        echo -e "\nNo components that can be modified in $sources_dir/"   
fi 

# petalinux-devtool finish <recipe-name> <destination layer path>
# 
# petalinux-devtool reset <recipe-name> to remove the source directory for the recipe from workspace.

Open Source流程编译UBoot

在上面脚本取得的UBoot目录中,编译UBoot,得到u-boot.elf文件,再借用PetaLinux工程生成的其它文件,生成BOOT.bin,可以启动并引导Linux。

在PetalLinux工程目录中执行下列脚本,能以Open Source流程编译UBoot,并自动生成BOOT.bin。

代码语言:javascript
代码运行次数:0
运行
AI代码解释
复制
#!/bin/bash
# Author: Hank FU, hankf@amd.com
# osl-make-uboot.sh
# Execute osl-make-uboot.sh in PetaLinux project directory. 
# Usage: osl-make-uboot.sh uboot_source_dir [ Default: components/yocto/workspace/sources/u-boot-xlnx]

if [ ! -d ./project-spec/meta-user/recipes-bsp/ ]; then 
    echo "Not PetaLinux project directory."
    echo "No directory: ./project-spec/meta-user/recipes-bsp "
    echo "Exit."
    exit 1
fi 

peta_dir=`pwd`
echo "Current directory: $peta_dir"

petalinux_tool=`which petalinux-build` 
if [ "$petalinux_tool" = "" ]; then
    echo "Error: petalinux-build is invalid"
    exit 1
fi

# Check PetaLinux building environment variable settings.
if [ "$ARCH" != "arm" ]; then
    if [ "$ARCH" != "arm64" ]; then
        echo "ARCH is not set correctly.";
        exit 1
    fi
fi

if [ "$CROSS_COMPILE" = "" ]; then
    echo "CROSS_COMPILE is not set.";
    exit 1
fi
echo "PetaLinux building environment variable is set.";
echo "ARCH: $ARCH"
echo -e "CROSS_COMPILE: $CROSS_COMPILE\n"

uboot_dir=$1
if [ "$uboot_dir" = "" ]; then

    if [ -d ./components/yocto/workspace/sources/u-boot-xlnx/arch/arm/ ]; then
            uboot_dir=./components/yocto/workspace/sources/u-boot-xlnx
    else
            uboot_dir=
    fi
fi

if [ ! -d  $uboot_dir ]; then 
    echo "No U-Boot source directory: $uboot_dir"
    echo "Usage: $0 uboot_source_dir [ Default: components/yocto/workspace/sources/u-boot-xlnx]"
    exit 1
fi 

cd $uboot_dir
echo "U-Boot source directory: "
pwd

if [ ! -f  .config ]; then 
    echo "Has no config file: .config."
    echo "U-Boot source code not configured."
    exit 1
fi 

make -j 
ls -l -h u-boot.elf

if [ ! -f  u-boot.elf ]; then 
    echo "Failed to build U-Boot in directory: $peta_dir/$uboot_dir"
    exit 1
fi 

cd  $peta_dir
rm -f images/linux/BOOT.BIN
cp  $uboot_dir/u-boot.elf ./images/linux/
petalinux-package --boot --u-boot $uboot_dir/u-boot.elf --force
ls -l -h images/linux/BOOT.BIN

Open Source流程编译Linux

在上面脚本取得的Linux目录中,编译Linux,得到Image文件,直接可以和system.dtb、rootfs.cpio.gz.u-boot一起启动。

还可以根据上述的its文件,创建image.ub。但是PetaLinux的its文件引用dtb文件、rootfs文件时,使用了内部的绝对路径,建议改成PetaLinux工程的images/linux目录。 注意下面的its文件,system-top.dtb被改为了system.dtb,petalinux-initramfs-image-zynqmp-generic.cpio.gz改为了rootfs.cpio.gz, 而且路径也改到了PetaLinux的images/linux目录。总之,要保证its文件中的设备树文件路径正确,文件系统的cpio.gz文件路径正确。

代码语言:javascript
代码运行次数:0
运行
AI代码解释
复制
/dts-v1/;

/ {
        description = "U-Boot fitImage for PetaLinux/5.10+gitAUTOINC+c830a552a6/zynqmp-generic";
        #address-cells = <1>;

        images {
                kernel-1 {
                        description = "Linux kernel";
                        data = /incbin/("linux.bin");
                        type = "kernel";
                        arch = "arm64";
                        os = "linux";
                        compression = "gzip";
                        load = <0x80000>;
                        entry = <0x80000>;
                        hash-1 {
                                algo = "sha256";
                        };
                };
                fdt-system-top.dtb {
                        description = "Flattened Device Tree blob";
                        
                        /* data = /incbin/("/proj/hankf/v211/zcu106-bsp-peta/build/tmp/work/zynqmp_generic-xilinx-linux/linux-xlnx/5.10+gitAUTOINC+c830a552a6-r0/recipe-sysroot/boot/devicetree/system-top.dtb"); */
                        
                        data = /incbin/("/proj/hankf/v211/zcu106-bsp-peta/images/linux/system.dtb");
                        
                        type = "flat_dt";
                        arch = "arm64";
                        compression = "none";
                        
                        hash-1 {
                                algo = "sha256";
                        };
                };
                ramdisk-1 {
                        description = "petalinux-initramfs-image";
                        
                        /* data = /incbin/("/proj/hankf/v211/zcu106-bsp-peta/build/tmp/deploy/images/zynqmp-generic/petalinux-initramfs-image-zynqmp-generic.cpio.gz"); */
                        
                        data = /incbin/("/proj/hankf/v211/zcu106-bsp-peta/images/linux/rootfs.cpio.gz");
                        type = "ramdisk";
                        arch = "arm64";
                        os = "linux";
                        compression = "none";
                        
                        
                        hash-1 {
                                algo = "sha256";
                        };
                };
    };

        configurations {
                default = "conf-system-top.dtb";
                conf-system-top.dtb {
            description = "1 Linux kernel, FDT blob, ramdisk";
            kernel = "kernel-1";
            fdt = "fdt-system-top.dtb";
            ramdisk = "ramdisk-1";
            
                        hash-1 {
                                algo = "sha256";
                        };
                };
    };
};

在PetalLinux工程目录中执行下列脚本,能以Open Source流程编译Linux,并将Image、Image.ub文件复制到PetalLinux 工程目录中的目录“images/linux/”。

代码语言:javascript
代码运行次数:0
运行
AI代码解释
复制
#!/bin/bash
# Author: Hank FU, hankf@amd.com
# osl-make-linux.sh
# Execute osl-make-linux.sh in PetaLinux project directory. 
# Usage: osl-make-linux.sh linux_source_dir [ Default: components/yocto/workspace/sources/linux-xlnx]

if [ ! -d ./project-spec/meta-user/recipes-bsp/ ]; then 
    echo "Not PetaLinux project directory."
    echo "No directory: ./project-spec/meta-user/recipes-bsp "
    echo "Exit."
    exit 1
fi 

peta_dir=`pwd`
echo "Current directory: $peta_dir"

petalinux_tool=`which petalinux-build` 
if [ "$petalinux_tool" = "" ]; then
    echo "Error: petalinux-build is invalid"
    exit 1
fi

# Check PetaLinux building environment variable settings.
if [ "$ARCH" != "arm" ]; then
    if [ "$ARCH" != "arm64" ]; then
        echo "ARCH is not set correctly.";
        exit 1
    fi
fi

if [ "$CROSS_COMPILE" = "" ]; then
    echo "CROSS_COMPILE is not set.";
    exit 1
fi
echo "PetaLinux building environment variable is set.";
echo "ARCH: $ARCH"
echo -e "CROSS_COMPILE: $CROSS_COMPILE\n"

linux_dir=$1
if [ "$linux_dir" = "" ]; then

    if [ -d ./components/yocto/workspace/sources/linux-xlnx/arch/arm/ ]; then
            linux_dir=./components/yocto/workspace/sources/linux-xlnx
    else
            linux_dir=
    fi
fi

if [ ! -d  $linux_dir ]; then 
    echo "No Linux kernel directory: $linux_dir"
    echo "Usage: $0 linux_source_dir [ Default: components/yocto/workspace/sources/linux-xlnx]"
    exit 1
fi 

cd $linux_dir
echo "Linux kernel directory: "
pwd
echo ""

if [ ! -f  .config ]; then 
    echo "Has no config file: .config."
    echo "Linux kernel source code not configured."
    exit 1
fi 

make -j 
ls -l -h ./arch/arm64/boot/Image
ls -l -h vmlinux
if [ ! -f ./arch/arm64/boot/Image ]; then 
    echo "Failed to build Linux in directory: $peta_dir/$linux_dir"
    exit 1
fi 

# Build image.ub
if [ -f vmlinux ]; then
    
    echo "Linux vmlinux in directory: $peta_dir/$linux_dir:: "
    ls -l vmlinux

    linux_kernel_its_file=` find -name "fit-image-petalinux*.its" `
    if [ ! "$linux_kernel_its_file" = "" ]; then

        echo "Create image.ub by using its file: $linux_kernel_its_file."
        rm -f linux_objcopy.bin
        rm -f linux.bin
        rm -f image.ub
        aarch64-linux-gnu-objcopy -O binary -R .note -R .comment -S vmlinux linux_objcopy.bin
        gzip -9 linux_objcopy.bin
        mv -f linux_objcopy.bin.gz linux.bin
        mkimage -f $linux_kernel_its_file image.ub 
    else        
        echo "No image.ub its file in directory: $peta_dir/$linux_dir"    
    fi
else        
    echo "Failed to build Linux vmlinux in directory: $peta_dir/$linux_dir"    
fi

# Copy Image and image.ub to PetaLinux project's directory: images/linux/
cd  $peta_dir
rm -f images/linux/Image
rm -f images/linux/image.ub
cp  $linux_dir/arch/arm64/boot/Image ./images/linux/
cp  $linux_dir/image.ub ./images/linux/
ls -l -h images/linux/Image
ls -l -h images/linux/image.ub

已知问题

错误"The source tree is not clean"

在使用OpenSource Linux编译流程后,再回到Petalinux的编译,执行petalinux-build会得到下列错误。需要在Linux的源代码目录,执行命令“make mrproper”,清理Linux的源代码目录。

代码语言:javascript
代码运行次数:0
运行
AI代码解释
复制
NOTE: Executing Tasks
NOTE: linux-xlnx: compiling from external source tree /proj/hankf/v211/zcu106-bsp-peta/components/yocto/workspace/sources/linux-xlnx
ERROR: linux-xlnx-5.10+git999-r0 do_compile: oe_runmake failed
ERROR: linux-xlnx-5.10+git999-r0 do_compile: Execution of '/proj/hankf/v211/zcu106-bsp-peta/build/tmp/work/zynqmp_generic-xilinx-linux/linux-xlnx/5.10+git999-r0/temp/run.do_compile.49655' failed with exit code 1:
***
*** The source tree is not clean, please run 'make mrproper'
*** in /proj/hankf/v211/zcu106-bsp-peta/components/yocto/workspace/sources/linux-xlnx
***
make[1]: *** [/proj/hankf/v211/zcu106-bsp-peta/components/yocto/workspace/sources/linux-xlnx/Makefile:547: outputmakefile] Error 1
make: *** [/proj/hankf/v211/zcu106-bsp-peta/components/yocto/workspace/sources/linux-xlnx/Makefile:185: __sub-make] Error 2
WARNING: /proj/hankf/v211/zcu106-bsp-peta/build/tmp/work/zynqmp_generic-xilinx-linux/linux-xlnx/5.10+git999-r0/temp/run.do_compile.49655:306 exit 1 from 'exit 1'
WARNING: Backtrace (BB generated script): 
	#1: bbfatal_log, /proj/hankf/v211/zcu106-bsp-peta/build/tmp/work/zynqmp_generic-xilinx-linux/linux-xlnx/5.10+git999-r0/temp/run.do_compile.49655, line 306
	#2: die, /proj/hankf/v211/zcu106-bsp-peta/build/tmp/work/zynqmp_generic-xilinx-linux/linux-xlnx/5.10+git999-r0/temp/run.do_compile.49655, line 286
	#3: oe_runmake, /proj/hankf/v211/zcu106-bsp-peta/build/tmp/work/zynqmp_generic-xilinx-linux/linux-xlnx/5.10+git999-r0/temp/run.do_compile.49655, line 161
	#4: kernel_do_compile, /proj/hankf/v211/zcu106-bsp-peta/build/tmp/work/zynqmp_generic-xilinx-linux/linux-xlnx/5.10+git999-r0/temp/run.do_compile.49655, line 197
	#5: do_compile, /proj/hankf/v211/zcu106-bsp-peta/build/tmp/work/zynqmp_generic-xilinx-linux/linux-xlnx/5.10+git999-r0/temp/run.do_compile.49655, line 152
	#6: main, /proj/hankf/v211/zcu106-bsp-peta/build/tmp/work/zynqmp_generic-xilinx-linux/linux-xlnx/5.10+git999-r0/temp/run.do_compile.49655, line 310

Backtrace (metadata-relative locations):
	#1: bbfatal_log, /proj/hankf/v211/zcu106-bsp-peta/components/yocto/layers/core/meta/classes/logging.bbclass, line 72
	#2: die, /proj/hankf/v211/zcu106-bsp-peta/components/yocto/layers/core/meta/classes/base.bbclass, line 56
	#3: oe_runmake, /proj/hankf/v211/zcu106-bsp-peta/components/yocto/layers/core/meta/classes/base.bbclass, line 65
	#4: kernel_do_compile, /proj/hankf/v211/zcu106-bsp-peta/components/yocto/layers/meta-petalinux/oe-core/meta/classes/kernel.bbclass, line 349
	#5: do_compile, autogenerated, line 2

错误devtool_post_patch

在执行命令“petalinux-devtool reset”,停止使用外部源代码后,再通过命令“petalinux-devtool modify”获取源代码,可能得到下列错误。请删除Petalinux工程的build目录下的所有文件,再重新编译Petalinux工程,再通过命令“petalinux-devtool modify”获取源代码。

代码语言:javascript
代码运行次数:0
运行
AI代码解释
复制
NOTE: Executing Tasks
ERROR: Error executing a python function in exec_python_func() autogenerated:

The stack trace of python calls that resulted in this exception/failure was:
File: 'exec_python_func() autogenerated', lineno: 2, function: <module>
     0001:
 *** 0002:devtool_post_patch(d)
     0003:
File: '/proj/hankf/v211/zcu106-bsp-peta/components/yocto/layers/core/meta/classes/devtool-source.bbclass', lineno: 226, function: devtool_post_patch
     0222:                bb.build.exec_func('do_patch', localdata)
     0223:                rm_patches()
     0224:                # Now we need to reconcile the new branch with the no-overrides one
     0225:                # (otherwise we'd likely be left with identical commits that have different hashes)
 *** 0226:                bb.process.run('git rebase devtool-no-overrides', cwd=srcsubdir)
     0227:        bb.process.run('git checkout %s' % devbranch, cwd=srcsubdir)
     0228:    bb.process.run('git tag -f devtool-patched', cwd=srcsubdir)
     0229:}
     0230:
File: '/proj/hankf/v211/zcu106-bsp-peta/components/yocto/layers/core/bitbake/lib/bb/process.py', lineno: 184, function: run
     0180:        if not stderr is None:
     0181:            stderr = stderr.decode("utf-8")
     0182:
     0183:    if pipe.returncode != 0:
 *** 0184:        raise ExecutionError(cmd, pipe.returncode, stdout, stderr)
     0185:    return stdout, stderr
Exception: bb.process.ExecutionError: Execution of 'git rebase devtool-no-overrides' failed with exit code 128:
fatal: It seems that there is already a rebase-apply directory, and
I wonder if you are in the middle of another rebase.  If that is the
case, please try
	git rebase (--continue | --abort | --skip)
If that is not the case, please
	rm -fr ".git/rebase-apply"
and run me again.  I am stopping in case you still have something
valuable there.

测试环境

  1. Ubuntu 18.04
  2. PetaLinux 2021.1/2022.1
  3. PetaLinux 2021.1/2022.1 ZCU106 BSP
  4. PetaLinux 2021.1/2022.1 KR260 BSP
  5. ZCU106
  6. KR260
本文参与 腾讯云自媒体同步曝光计划,分享自作者个人站点/博客。
原始发表:2022-11-16,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体同步曝光计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
暂无评论
推荐阅读
复旦大学提出《Meta-FDMixup》解决"跨域小样本学习"中的域偏移问题
这篇文章『Meta-FDMixup: Cross-Domain Few-Shot Learning Guided by Labeled Target Data』是 ACM Multimedia 2021 上的工作,主要是做 cross-domain few-shot learning,文章主要提出使用极少一部分 target 带标注数据来帮助模型的学习。
CV君
2021/12/13
3.3K0
复旦大学提出《Meta-FDMixup》解决"跨域小样本学习"中的域偏移问题
小样本学习只是一场学术界自嗨吗?
这两年看见很多人,都在批评few-shot learning,觉得是学术界在自high,思考良久,感觉有必要给这个领域正个名~(注意,本文仅关注few-shot image classification)
Color Space
2022/05/26
8580
小样本学习只是一场学术界自嗨吗?
小样本学习只是一场学术界自嗨吗
每天给你送来NLP技术干货! ---- 文 | ALme@知乎 排版 | 夕小瑶的卖萌屋 这两年看见很多人,包括我实习的mentor在内,都在批评few-shot learning,觉得是学术界在自high,思考良久,感觉有必要给这个领域正个名~(注意,此答案仅关注few-shot image classification) 首先,要讨论few-shot learning的价值,咱得先把few-shot learning(FSL)这个问题的定位搞清楚。而要搞清楚few-shot learning的定
zenRRan
2022/05/09
1.3K0
小样本学习只是一场学术界自嗨吗
ICLR 2021 | 基于自监督学习的小样本分类,代码已开源
深度神经网络往往要求为每个新任务收集大量标记训练数据,实用性也因此受到限制。给定来自一组源任务的数据,有两种迁移学习方法可以克服这种限制:小样本学习 (FSL) 和自监督学习 (SSL)。前者通过在源任务中设计元集(episode),模拟使用少量标记样本解决新任务的挑战,从而学习“如何学习”。相比之下,后者在所有源任务中利用无标注的代理任务来学习可泛化的特征表示。
AI科技评论
2021/07/03
1.6K0
ICLR 2021 | 基于自监督学习的小样本分类,代码已开源
小样本学习(Few-shot Learning)综述
笔者所在的阿里巴巴小蜜北京团队就面临这个挑战。我们打造了一个智能对话开发平台——Dialog Studio,以赋能第三方开发者来开发各自业务场景中的任务型对话,其中一个重要功能就是对意图进行分类。大量平台用户在创建一个新对话任务时,并没有大量标注数据,每个意图往往只有几个或十几个样本。
机器之心
2019/04/29
5.9K0
小样本学习(Few-shot Learning)综述
ImageNet的top-1终于上了90%,网友质疑:用额外数据集还不公开,让人怎么信服?
近日,谷歌大脑研究科学家、AutoML 鼻祖 Quoc Le 发文表示,他们提出了一种新的半监督学习方法,可以将模型在 ImageNet 上的 top-1 准确率提升到 90.2%,与之前的 SOTA 相比实现了 1.6% 的性能提升。
机器之心
2021/01/26
8840
ImageNet的top-1终于上了90%,网友质疑:用额外数据集还不公开,让人怎么信服?
【知识蒸馏】Deep Mutual Learning
引言 首先感谢:https://github.com/AberHu/Knowledge-Distillation-Zoo
BBuf
2021/11/19
9060
【知识蒸馏】Deep Mutual Learning
CVPR 2022 Oral | 大连理工提出小样本识别DeepBDC,6项基准性能最好
机器之心专栏 作者:谢江涛、龙飞、吕佳铭、王旗龙、李培华 在本文中,来自大连理工大学等机构的研究者提出了 DeepBDC 用于小样本分类任务,DeepBDC 通过度量样本对之间的联合分布从而获得更准确的相似度,极大的提升了小样本分类的性能。论文已被 CVPR 2022 接收为 Oral Presentation。 本文首次将布朗距离协方差这一基于概率和统计的相似性度量引入到深度学习中,提出了一种端到端的小样本识别方法 DeepBDC。所提出的方法在包括一般目标识别、细粒度分类和跨域分类等任务的 6 个标准数
机器之心
2022/04/24
9260
CVPR 2022 Oral | 大连理工提出小样本识别DeepBDC,6项基准性能最好
从少数示例中泛化:介绍小样本学习(Few-shot Learning,FSL)
论文题目:Generalizing from a Few Examples: A Survey on Few-shot Learning(ACM Computing Surveys,中科院 1 区)
叶庭云
2024/05/25
1.3K0
从少数示例中泛化:介绍小样本学习(Few-shot Learning,FSL)
CVPR2022:局部和全局知识蒸馏用于目标检测(源代码开源)
关注并星标 从此不迷路 计算机视觉研究院 公众号ID|ComputerVisionGzq 学习群|扫码在主页获取加入方式 论文地址:https://arxiv.org/pdf/2111.11837.pdf 源代码: https://github.com/yzd-v/FGD 计算机视觉研究院专栏 作者:Edison_G 知识蒸馏已成功应用于图像分类。然而目标检测要复杂得多,大多数知识蒸馏方法都失败了。 01 前言 在目标检测中,教师和学生的特征在不同的区域有很大的差异,尤其是在前景和背景中。如
计算机视觉研究院
2022/04/06
8920
CVPR2022:局部和全局知识蒸馏用于目标检测(源代码开源)
提升精度 | 新的小样本学习算法提升物体识别精度(附论文地址)
事实证明,深度学习在大量标记数据的学习中是非常有效的。很少有shot learning,相反,试图学习只有少数标签数据。
计算机视觉研究院
2020/09/02
1.5K0
「知识蒸馏」最新2022研究综述
每天给你送来NLP技术干货! ---- 来自:专知 华南师范大学等《知识蒸馏》最新综述论文 高性能的深度学习网络通常是计算型和参数密集型的,难以应用于资源受限的边缘设备. 为了能够在低 资源设备上运行深度学习模型,需要研发高效的小规模网络. 知识蒸馏是获取高效小规模网络的一种新兴方法, 其主要思想是将学习能力强的复杂教师模型中的“知识”迁移到简单的学生模型中. 同时,它通过神经网络的互 学习、自学习等优化策略和无标签、跨模态等数据资源对模型的性能增强也具有显著的效果. 基于在模型压缩和 模型增强上的优越特
zenRRan
2022/03/24
3K0
当小样本遇上机器学习 fewshot learning
深度学习(deep learning)已经广泛应用于各个领域,解决各类问题,例如在图像分类问题下,如图1,区分这10类目标的准确率目前可以轻松做到94%。然而,deep learning是一种data hungry的技术,需要大量的标注样本才能发挥作用。
全栈程序员站长
2022/08/11
9270
当小样本遇上机器学习 fewshot learning
知识蒸馏(Knowledge Distillation)
本文主要罗列与知识蒸馏相关的一些算法与应用。但首先需要明确的是,教师网络或给定的预训练模型中包含哪些可迁移的知识?基于常见的深度学习任务,可迁移知识列举为:
全栈程序员站长
2022/07/01
2.9K0
知识蒸馏(Knowledge Distillation)
CVPR 2022 | 提高小数据集利用效率,复旦等提出分层级联ViT网络
机器之心专栏 戈维峰 复旦大学 来自复旦大学、上海市智能信息处理重点实验室和香港大学的研究者提出了一种基于 DINO 知识蒸馏架构的分层级联 Transformer (HCTransformer) 网络。 小样本学习是指从非常少量的标记数据中进行学习的问题,它有望降低标记成本,实现低成本、快速的模型部署,缩小人类智能与机器模型之间的差距。小样本学习的关键问题是如何高效地利用隐藏在标注数据中的丰富信息中进行学习。近年来,视觉 Transformer (ViT [1]) 作为计算机视觉领域的新兴架构,因其在很多
机器之心
2022/07/18
4740
CVPR 2022 | 提高小数据集利用效率,复旦等提出分层级联ViT网络
​田渊栋:ReLU神经网络的可证明理论性质
在本文中,Facebook人工智能研究院研究员、卡耐基梅隆大学机器人系博士田渊栋以ReLU网络为例,分享了深度学习理论和可解释性方面的研究进展。田渊栋博士提到,在学生-教师设置下的ReLU神经网络中,存在学生网络和教师网络的节点对应关系,通过对这种关系的分析,可以帮助我们理解神经网络的学习机制,以及剪枝、优化、数据增强等技术的理论基础。
AI科技评论
2020/08/10
6650
​田渊栋:ReLU神经网络的可证明理论性质
CVPR2020最佳检测 | 带有注意力RPN和多关系检测器的小样本目标检测网络
传统的目标检测方法通常需要大量的训练数据,并且准备这样高质量的训练数据是劳动密集型的(工作)。在本文中,我们提出了少量样本的目标检测网络,目的是检测只有几个训练实例的未见过的类别对象。我们的方法的核心是注意力RPN和多关系模块,充分利用少量训练样本和测试集之间的相似度来检测新对象,同时抑制背景中的错误检测。为了训练我们的网络,我们已经准备了一个新的数据集,它包含1000类具有高质量注释的不同对象。据我们所知,这也是第一个数据集专门设计用于少样本目标检测。一旦我们的网络被训练,我们可以应用对象检测为未见过的类,而无需进一步的训练或微调。我们的方法是通用的,并且具有广泛的应用范围。我们证明了我们的方法在不同的数据集上的定性和定量的有效性。
计算机视觉研究院
2020/04/14
1.6K0
位置蒸馏:针对目标检测提高定位精度的知识蒸馏
今日分享一篇最近新出的目标检测论文『Localization Distillation for Object Detection』
CV君
2021/05/07
1.2K0
位置蒸馏:针对目标检测提高定位精度的知识蒸馏
SEMI-SUPERVISED OBJECT DETECTION FRAMEWORK WITH OBJECT FIRST MIXUPFOR REMOTE SENSING IMAGES
本文提出了一个用于遥感图像的简单半监督目标检测框架,该框架被命名为SSOD-RS。SSOD-RS包含两个部分,即改进的自我训练和基于强数据增强的一致性正则化,以及改进的混合。首先,作为一种增强算法,提出了Object First mixup(OF-mixup)来调整物体和背景的权重,扩大了训练样本的分布,同时减少了遥感复杂背景对物体特征的干扰。其次,在自训练中引入了集合损失和微调的训练策略,使模型在学习了伪标签的特征后,适应真实标签的特征分布。实验结果表明,利用无标签图像的SSOD-RS可以极大地提高模型的准确性。
狼啸风云
2023/10/07
2740
SEMI-SUPERVISED OBJECT DETECTION FRAMEWORK WITH OBJECT FIRST MIXUPFOR REMOTE SENSING IMAGES
知识蒸馏综述:网络结构搜索应用
知识蒸馏可以看做教师网络通过提供soft label的方式将知识传递到学生网络中,可以被视为一种更高级的label smooth方法。soft label与hard label相比具有以下优点:
BBuf
2021/12/15
1.2K0
知识蒸馏综述:网络结构搜索应用
推荐阅读
相关推荐
复旦大学提出《Meta-FDMixup》解决"跨域小样本学习"中的域偏移问题
更多 >
LV.0
这个人很懒,什么都没有留下~
目录
  • 提高PetaLinux/Yocto的编译速度,暨整合Open Source U-Boot/Linux编译 -- PetaLinux 2021/2022版本
  • 总结
  • 概述
  • PetaLinux的安装
  • 提高PetaLinux的编译速度
    • 使用本地SState cache
    • 使用本地Downloads文件包
    • 重用下载文件
    • 离线编译
  • PetaLinux编译Linux和U-Boot
  • devtool取得Linux和UBoot源代码
  • Open Source流程编译Linux和UBoot
    • 获取源代码和配置文件
    • Open Source流程编译UBoot
    • Open Source流程编译Linux
  • 已知问题
    • 错误"The source tree is not clean"
    • 错误devtool_post_patch
  • 测试环境
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档