怎样使用sdk来编译的文档请参考以下文档:

另外在QT和Eclipse中使用SDK请阅读QT和Eclipse的文档。

我们在大多数BSP的下载页面中有SDK的文件夹,如 http://ftp.phytec.cn/AM335x/BSP-Yocto-AM335x-PD17.2.2/sdk/ 下载已经编译好的SDK就不需要使用yocto生成。

注意我们提供的SDK只能运行在64位的ubuntu 14/16上。如果有其他需求需要按照本文的步骤重新生成。

下载以后按照本文的使用说明来使用。

SDK生成方法

首先,如果你还没有进入yocto环境的话,需要

$ source sources/poky/oe-init-build-env

此时就可以继续执行yocto的指令。

我们有两种可选的开发包可以通过yocto来生成。

指令解释
bitbake -c populate_sdk phytec-qt5demo-image

包含交叉工具链,以及文件系统中各个软件的头文件,库等,如QT。

其中phytec-qt5demo-image也可以换为其他img对象。image对象和生成的sdk内容对应。

bitbake meta-toolchain
只包含交叉工具链。

生成SDK需要一段时间,对于离线编译的BSP,需要修改 conf/site.conf 去掉 BB_NO_NETWORK,编译过程中需要下载一些文件。

OURCE_MIRROR_URL = "file://${TOPDIR}/../src_mirror"
INHERIT += "own-mirrors"
BB_GENERATE_MIRROR_TARBALLS = "1"
SCONF_VERSION = "1"
BB_NO_NETWORK = "1"				<-- 去掉这一行

生成的SDK安装文件位于build/deploy/sdk。

xxx@debian8:~/bsp/build/deploy/sdk$ ls -alh
total 283M
drwxr-xr-x 2 bob bob 4.0K Aug 15 14:09 .
drwxr-xr-x 6 bob bob 4.0K Aug 15 13:05 ..
-rw-r--r-- 1 bob bob 9.8K Aug 15 14:08 phytec-yogurt-glibc-x86_64-meta-toolchain-cortexa8hf-neon-toolchain-AM335x-PD16.2.0.host.manifest
-rwxr-xr-x 1 bob bob  73M Aug 15 14:09 phytec-yogurt-glibc-x86_64-meta-toolchain-cortexa8hf-neon-toolchain-AM335x-PD16.2.0.sh				<-- 交叉编译工具链
-rw-r--r-- 1 bob bob 1.7K Aug 15 14:07 phytec-yogurt-glibc-x86_64-meta-toolchain-cortexa8hf-neon-toolchain-AM335x-PD16.2.0.target.manifest
-rw-r--r-- 1 bob bob 9.8K Aug 15 13:05 phytec-yogurt-glibc-x86_64-phytec-headless-image-cortexa8hf-neon-toolchain-AM335x-PD16.2.0.host.manifest
-rwxr-xr-x 1 bob bob 211M Aug 15 13:10 phytec-yogurt-glibc-x86_64-phytec-headless-image-cortexa8hf-neon-toolchain-AM335x-PD16.2.0.sh	    <-- 交叉工具链+链接库
-rw-r--r-- 1 bob bob  36K Aug 15 13:05 phytec-yogurt-glibc-x86_64-phytec-headless-image-cortexa8hf-neon-toolchain-AM335x-PD16.2.0.target.manifest
xxx@debian8:~/bsp/build/deploy/sdk$

SDK的使用方法

直接运行对应的 .sh文件就可以安装

root@debian8:/home/bob/bsp/am335x/BSP-Yocto-AM335x-PD16.2.0/build/deploy/sdk# ./phytec-yogurt-glibc-x86_64-meta-toolchain-cortexa8hf-neon-toolchain-AM335x-PD16.2.0.sh 
Yogurt (Phytec Example Distribution) SDK installer version AM335x-PD16.2.0
==========================================================================
Enter target directory for SDK (default: /opt/phytec-yogurt/AM335x-PD16.2.0): 
You are about to install the SDK to "/opt/phytec-yogurt/AM335x-PD16.2.0". Proceed[Y/n]? Y
Extracting SDK.................done
Setting it up...done
SDK has been successfully set up and is ready to be used.
Each time you wish to use the SDK in a new shell session, you need to source the environment setup script e.g.
 $ . /opt/phytec-yogurt/AM335x-PD16.2.0/environment-setup-cortexa8hf-neon-phytec-linux-gnueabi
root@debian8:/home/bob/bsp/am335x/BSP-Yocto-AM335x-PD16.2.0/build/deploy/sdk# 

安装好后,在使用前,需要先运行初始化脚本,如先初始化环境:

bob@debian8:~/test$ . /opt/phytec-yogurt/AM335x-PD16.2.0/environment-setup-cortexa8hf-neon-phytec-linux-gnueabi 

c源码:

bob@debian8:~/test$ cat gst.c
#include <stdio.h>
#include <gst/gst.h>

int main (int   argc,char *argv[]) {
        const gchar *nano_str;
        guint major, minor, micro, nano;
        gst_init (&argc, &argv);
        gst_version (&major, &minor, &micro, &nano);
        if (nano == 1)
                nano_str = "(CVS)";
        else if (nano == 2)
                nano_str = "(Prerelease)";
        else
                nano_str = "";
        printf ("This program is linked against GStreamer %d.%d.%d %s\n",
                        major, minor, micro, nano_str);
        return 0;
}

编译:

bob@Z220:~/test$ $CC $CFLAGS -I=/usr/include/gstreamer-1.0 -I=/usr/include/glib-2.0 -I=/usr/lib/glib-2.0/include -L=/usr/lib -lgstreamer-1.0 -lgobject-2.0 -lglib-2.0 gst.c -o gst

关于SDK的更多内容请阅读yocto的文档 Chapter 3. Using the Standard SDK

这里大概介绍一下,在source enviroment-setup文件后,脚本会在当前的shell中设置很多环境变量:

 % export
AR=arm-phytec-linux-gnueabi-ar
ARCH=arm
AS='arm-phytec-linux-gnueabi-as '
CC='arm-phytec-linux-gnueabi-gcc  -march=armv7-a -mfpu=neon  -mfloat-abi=hard -mcpu=cortex-a9 --sysroot=/mnt/work/home/bob/sdk/imx6-pd16.1.0/sysroots/c
ortexa9hf-neon-phytec-linux-gnueabi'
CCACHE_PATH=/mnt/work/home/bob/sdk/imx6-pd16.1.0/sysroots/x86_64-yogurtsdk-linux/usr/bin:/mnt/work/home/bob/sdk/imx6-pd16.1.0/sysroots/x86_64-yogurtsdk
-linux/usr/bin/../x86_64-yogurtsdk-linux/bin:/mnt/work/home/bob/sdk/imx6-pd16.1.0/sysroots/x86_64-yogurtsdk-linux/usr/bin/arm-phytec-linux-gnueabi:/mnt
/work/home/bob/sdk/imx6-pd16.1.0/sysroots/x86_64-yogurtsdk-linux/usr/bin/arm-phytec-linux-uclibc:/mnt/work/home/bob/sdk/imx6-pd16.1.0/sysroots/x86_64-y
ogurtsdk-linux/usr/bin/arm-phytec-linux-musl:
CFLAGS=' -O2 -pipe -g -feliminate-unused-debug-types '
CONFIGURE_FLAGS='--target=arm-phytec-linux-gnueabi --host=arm-phytec-linux-gnueabi --build=x86_64-linux --with-libtool-sysroot=/mnt/work/home/bob/sdk/i
mx6-pd16.1.0/sysroots/cortexa9hf-neon-phytec-linux-gnueabi'
CONFIG_SITE=/mnt/work/home/bob/sdk/imx6-pd16.1.0/site-config-cortexa9hf-neon-phytec-linux-gnueabi
CPP='arm-phytec-linux-gnueabi-gcc -E  -march=armv7-a -mfpu=neon  -mfloat-abi=hard -mcpu=cortex-a9 --sysroot=/mnt/work/home/bob/sdk/imx6-pd16.1.0/sysroots/cortexa9hf-neon-phytec-linux-gnueabi'
CPPFLAGS=''
CROSS_COMPILE=arm-phytec-linux-gnueabi-
CXX='arm-phytec-linux-gnueabi-g++  -march=armv7-a -mfpu=neon  -mfloat-abi=hard -mcpu=cortex-a9 --sysroot=/mnt/work/home/bob/sdk/imx6-pd16.1.0/sysroots/
cortexa9hf-neon-phytec-linux-gnueabi'
CXXFLAGS=' -O2 -pipe -g -feliminate-unused-debug-types '
GDB=arm-phytec-linux-gnueabi-gdb
KCFLAGS='--sysroot=/mnt/work/home/bob/sdk/imx6-pd16.1.0/sysroots/cortexa9hf-neon-phytec-linux-gnueabi'
LD='arm-phytec-linux-gnueabi-ld  --sysroot=/mnt/work/home/bob/sdk/imx6-pd16.1.0/sysroots/cortexa9hf-neon-phytec-linux-gnueabi'
LDFLAGS='-Wl,-O1 -Wl,--hash-style=gnu -Wl,--as-needed'
NM=arm-phytec-linux-gnueabi-nm
OBJCOPY=arm-phytec-linux-gnueabi-objcopy
OBJDUMP=arm-phytec-linux-gnueabi-objdump
...

此时,在编译kernel或者其他软件时,软件的makefile会使用$(CC),$(CFLAGS)等变量来编译。

一般厂商中提供的Makefile文件中如果定义了这些交叉工具链的变量, 可把这些变量对应的值修改为$(CC),$(CFLAGS) , $(CROSS_COMPILE)来引用phytec的交叉工具链.

如: CROSS_COMPILE=$(CROSS_COMPILE).

如果要编译自己写的程序,也是直接调用上面的变量来编译即可, 如: $(CC) helloworld.c -o helloworld.

  • No labels