imx交叉编译环境搭建
资源下载
https://atk-imx6ull.coding.net/public/imx6ull/05_Tools/git/files/master/01%E3%80%81%E4%BA%A4%E5%8F%89%E7%BC%96%E8%AF%91%E5%99%A8
正点原子提供两种交叉编译工具链。这两种交叉编译工具链解释如下图。
第一种 Poky 编译器是Yocto 项目编译出的,常用于编译Uboot和Linux出厂源码, 及快速编译Qt应用程序到开发板上运行。
第二种通用的交叉编译器用于ARM linux驱动,应用开发
安装
直接执行脚本安装交叉编译工具完成安装
大概看一下脚本文件,近200M的大小,其实里面把poky sdk的压缩包放到文件里面了,
payload_offset=$(($(grep -na -m1 "^MARKER:$" $0|cut -d':' -f1) + 1))
printf "Extracting SDK..."
tail -n +$payload_offset $0| $SUDO_EXEC tar xJ -C $target_sdk_dir --checkpoint=.2500 $EXTRA_TAR_OPTIONS || exit 1
echo "done"
把这部分直接另存为.tar.bz2文件,解压,内容如下
再大概看一下nxp提供的原版的安装环境步骤,参看手册, i.MX Yocto Project User’s Guide
https://www.nxp.com.cn/docs/en/user-guide/IMX_YOCTO_PROJECT_USERS_GUIDE.pdf
Build configurations
i.MX provides a script, imx-setup-release.sh, that simplifies the setup for i.MX
machines. To use the script, the name of the specific machine to be built for needs to be
specified as well as the desired graphical backend. The script sets up a directory and the
configuration files for the specified machine and backend.
In the meta-imx layer, i.MX provides new or updated machine configurations that
overlay the meta-freescale machine configurations. These files are copied into the
meta-freescale/conf/machine directory by the imx-setup-release.sh script.
https://github.com/nxp-imx/imx-manifest/blob/imx-linux-kirkstone/imx-5.15.52-2.1.0.xml
https://github.com/Freescale/fsl-community-bsp-base/blob/master/setup-environment
使用 arm-poky-linux-gnueabi-gcc -v 指令可以查看 gcc 版本,表明环境变量已经生效。
编译测试
编译一个简单的 c 文件, main.c
#include <stdio.h>
int main(void)
{
printf("hello world!\n");
return 0;
}
编译
fei@ubuntu:~/zhengyuandianzi$ mkdir test
fei@ubuntu:~/zhengyuandianzi$ cd test/
fei@ubuntu:~/zhengyuandianzi/test$ ls
fei@ubuntu:~/zhengyuandianzi/test$ touch main.c
fei@ubuntu:~/zhengyuandianzi/test$ vi main.c
fei@ubuntu:~/zhengyuandianzi/test$ echo $CC
arm-poky-linux-gnueabi-gcc -march=armv7ve -mfpu=neon -mfloat-abi=hard -mcpu=cortex-a7 --sysroot=/opt/fsl-imx-x11/4.1.15-2.1.0/sysroots/cortexa7hf-neon-poky-linux-gnueabi
fei@ubuntu:~/zhengyuandianzi/test$ $CC main.c -o main
fei@ubuntu:~/zhengyuandianzi/test$ ls
main main.c
fei@ubuntu:~/zhengyuandianzi/test$
复制main到开发板运行
- 打开串口
- 打开sftp, meraXterm打开ssh之后,sftp在左边窗口就直接打开了。 或者用winscp工具。 用户名root, 无密码
- 上传文件
- 执行