Day2: 正点原子 imx交叉编译环境搭建

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到开发板运行

  1. 打开串口
  2. 打开sftp, meraXterm打开ssh之后,sftp在左边窗口就直接打开了。 或者用winscp工具。 用户名root, 无密码
  3. 上传文件
  4. 执行
    请添加图片描述
    请添加图片描述
    请添加图片描述
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值