i2X-6UB开发套件上的应用开发,需要先安装应用开发工具包(ADK)。i2X-6UB提供了两种ADK工具包:i2SOM-yocto-glibc-x86_64-core-image-base-cortexa7hf-neon-toolchain-2.2-r0.sh和i2SOM-yocto-glibc-x86_64-i2som-image-qt-fb-cortexa7hf-neon-toolchain-2.2-r0.sh。

本节以安装i2SOM-yocto-glibc-x86_64-core-image-base-cortexa7hf-neon-toolchain-2.2-r0.sh工具包为例。

在“资源下载”页面下载工具包后,确认有执行权限,然后安装即可。这里将安装路径设置为“/opt/i2SOM-yocto-adk-core/2.2-r0”。

$ chmod a+x i2SOM-yocto-glibc-x86_64-core-image-base-cortexa7hf-neon-toolchain-2.2-r0.sh
$ ls -lh
-rwxr-xr-x 1 i2somdev i2somdev 199M Nov 29 10:20 i2SOM-yocto-glibc-x86_64-core-image-base-cortexa7hf-neon-toolchain-2.2-r0.sh
$ ./i2SOM-yocto-glibc-x86_64-core-image-base-cortexa7hf-neon-toolchain-2.2-r0.sh 
i2SOM Yocto SDK installer version 2.2-r0
========================================
Enter target directory for SDK (default: /opt/i2SOM-yocto/2.2-r0): /opt/i2SOM-yocto-adk-core/2.2-r0
You are about to install the SDK to "/opt/i2SOM-yocto-adk-core/2.2-r0". Proceed[Y/n]? y
[sudo] password for i2somdev: 
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/i2SOM-yocto-adk-core/2.2-r0/environment-setup-cortexa7hf-neon-i2som-linux-gnueabi

验证开发工具是否安装正确,显示版本信息就表示工具链安装和加载正确。

$ source /opt/i2SOM-yocto-adk-core/2.2-r0/environment-setup-cortexa7hf-neon-i2som-linux-gnueabi
$ arm-i2som-linux-gnueabi-gcc --version
arm-i2som-linux-gnueabi-gcc (GCC) 6.2.0
Copyright (C) 2016 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.

然后就可以编译应用程序了。

测试Helloworld应用
编写hello.c文件,内容如下:

#include <stdio.h>
int main(int argc, char* argv)
{
    printf("Hello, world!");
}

编译hello应用

$CC hello.c -o hello
file hello
hello: ELF 32-bit LSB executable, ARM, EABI5 version 1 (SYSV), dynamically linked, interpreter /lib/ld-linux-armhf.so.3, for GNU/Linux 3.2.0, BuildID[sha1]=b6a98060e4d0423c65a477d0a0d74cb183441648, not stripped

这里必须要用$CC变量来编译,不能直接用gcc名称。然后复制在i2C-6ULX开发板后,直接运行就可以了。

编译应用例程
例程包里有很多应用程序,使用cmake管理,编译方式如下,编译前需要先加载sdk工具链。

cd linux-example
mkdir build
cd build
cmake ../
make
作者:SteveChen  创建时间:2024-09-17 16:27
最后编辑:SteveChen  更新时间:2024-09-17 16:27
上一篇:
下一篇: