Yocto下如何安装交叉编译工具生成SDK包,并使用SDK

1、先进入Yocto的BSP包的根目录下,输入如下命令:

xxx@xxx-virtual-machine:~/BSP-Yocto-AM335x-PD17.1.1$ . sources/poky/oe-init-build-env

2、有两种方法来生成交叉编译工具链:

a、bitbake meta-toolchain 

此命令生成的交叉编译工具链只适用于编译bootlaoder和内核,不包含外部库。

b、bitbake -c populate_sdk [image名称]

其中image名称一般是 

phytec-headless-image 没有QT支持

phytec-qt5demo-image 有QT

也可以自己定义image的名称。

这样生成的sdk就可以用于如QT程序开发这样的工作。

生成的SDK位于 build/deploy/sdk/

xxx@xxx-virtual-machine:~/BSP-Yocto-AM335x-PD17.1.1/build$ bitbake -c populate_sdk phytec-headless-image
Loading cache: 100% |############################################| Time: 0:00:03
Loaded 2743 entries from dependency cache.
NOTE: Resolving any missing task queue dependencies


Build Configuration:
BB_VERSION        = "1.32.0"
BUILD_SYS         = "x86_64-linux"
NATIVELSBSTRING   = "Ubuntu-16.04"
TARGET_SYS        = "arm-phytec-linux-gnueabi"
MACHINE           = "phycore-r2-am335x-2"
DISTRO            = "yogurt"
DISTRO_VERSION    = "BSP-Yocto-AM335x-PD17.1.1"
TUNE_FEATURES     = "arm armv7a vfp thumb neon       callconvention-hard       cortexa8"
TARGET_FPU        = "hard"
meta              
meta-poky         = "HEAD:e2fcc721c2af8e2785a91eaceea1d81f503ea2ec"
meta-oe           
meta-networking   
meta-python       
meta-multimedia   = "HEAD:b40116cf457b88a2db14b86fda9627fb34d56ae6"
meta-gstreamer1.0 = "HEAD:2c74a61e11c46d8bd5ebe4642292bc145e33d6d1"
meta-nodejs       = "HEAD:eec531e97a17bfd406f3bf76dee4057dcf5286a4"
meta-phytec       = "HEAD:72bd4d8b3f08fb51d591a4be4f63f21d53c1d71c"
meta-qt5          = "HEAD:2c9f0e4eb0e9097f6f872ec1e1d81768a8ab5f1b"
meta-yogurt       = "HEAD:cb43dd6f3bb1e149af67006feabc980121f2c995"


NOTE: Fetching uninative binary shim from http://downloads.yoctoproject.org/releases/uninative/1.7/x86_64-nativesdk-libc.tar.bz2;sha256sum=ed033c868b87852b07957a4400f3b744c00aef5d6470346ea1a59b6d3e03075e
WARNING: Disabling uninative as unable to fetch uninative tarball: Network access disabled through BB_NO_NETWORK (or set indirectly due to use of BB_FETCH_PREMIRRORONLY) but access requested with command /usr/bin/env wget -t 2 -T 30 -nv --passive-ftp --no-check-certificate -P /home/scw/BSP-Yocto-AM335x-PD17.1.1/build/downloads/uninative/ed033c868b87852b07957a4400f3b744c00aef5d6470346ea1a59b6d3e03075e 'http://downloads.yoctoproject.org/releases/uninative/1.7/x86_64-nativesdk-libc.tar.bz2' (for url None)
WARNING: To build your own uninative loader, please bitbake uninative-tarball and set UNINATIVE_TARBALL appropriately.
WARNING: /home/scw/BSP-Yocto-AM335x-PD17.1.1/sources/poky/../meta-phytec/recipes-kernel/linux/linux-ti_4.4.52-phy5.bb.do_compile is tainted from a forced run
Initialising tasks: 100% |#######################################| Time: 0:00:15
NOTE: Executing SetScene Tasks
NOTE: Executing RunQueue Tasks

Currently  1 running tasks (1188 of 3154)  37% |###########                    |

第一次编译的时间可能会很长,耐心等待。而且很可能出错(提示:关于BB_NO_NETWORK的错误),这时需要修改配置文件site.conf,该文件路径:/BSP-Yocto-AM335x-PD17.1.1/build/conf/ 下。  

打开site.conf文件,显示如下内容:

SOURCE_MIRROR_URL = "file://${TOPDIR}/../src_mirror"
INHERIT += "own-mirrors"
BB_GENERATE_MIRROR_TARBALLS = "1"
SCONF_VERSION = "1"

BB_NO_NETWORK = "1"

只需将最后一行 BB_NO_NETWORK = "1" 中的"1"改为"0"即可。然后重新执行第二步的命令。

3、生成的SDK位于 build/deploy/sdk/,进入此文件夹下,直接运行对应的 .sh文件就可以安装,执行安装文件:

xxx@xxx-virtual-machine:~/BSP-Yocto-AM335x-PD17.1.1/build/deploy/sdk$./phytec-yogurt-glibc-x86_64-meta-toolchain-cortexa8hf-neon-toolchain-AM335x-PD16.2.0.sh

安装后的的文件路径一般为:opt/yogurt/BSP-Yocto-AM335x-PD17.1.1/下。

4、激活交叉编译工具:交叉编译工具需要激活后方可使用

激活使用如下命令:source /opt/yogurt/BSP-Yocto-AM335x-PD17.1.1/environment-setup-cortexa8hf-neon-phytec-linux-gnueabi

然后使用:$CC 命令来编译目标文件即可。eg: $CC main.c -o main

5、下载编译后的可执行文件main到目标板运行。

你可能感兴趣的:(Yocto下如何安装交叉编译工具生成SDK包,并使用SDK)