GW201网关提供了可以开发应用的SDK工具包,名称为i2SOM-yocto-glibc-x86_64-i2som-image-gateway-cortexa7t2hf-neon-toolchain-2.2-r0.sh。
本节以安装i2SOM-yocto-glibc-x86_64-i2som-image-gateway-cortexa7t2hf-neon-toolchain-2.2-r0.sh工具包为例。
在“资源下载”页面下载工具包后,确认有执行权限,然后安装即可。这里将安装路径设置为“/opt/i2SOM-yocto-adk-core/2.2-r0”。
$ chmod a+x i2SOM-yocto-glibc-x86_64-i2som-image-gateway-cortexa7t2hf-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
$ $CC --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.
这里使用的是$CC变量,这个变量是指向gcc工具链的,但使用时请直接使用$CC,而不是arm-i2som-linux-gnueabi-gcc,直接使用会缺失部分参数配置,导致应用无法编译的情况。每次编译应用前,再加载环境变量文件即可。
测试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 14:56
最后编辑:SteveChen 更新时间:2024-09-17 15:25
最后编辑:SteveChen 更新时间:2024-09-17 15:25