Preparing a toolchain for building ARM binaries on x86 hosts

本文详细介绍了如何在x86主机上为32位和64位ARM目标设备准备Linaro工具链,包括下载、安装及环境变量配置,适用于如NXP i.MX6、i.MX7和i.MX8M等嵌入式硬件。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

https://www.technexion.com/support/knowledgebase/preparing-a-toolchain-for-building-arm-binaries-on-x86-hosts/

 

Difficulty Levels: Intermediate
Date added: November 8, 2018
Affected Products: EDM1-CF-IMX6 , EDM2-IMX6PLUS , PICO-IMX6 , PICO-IMX6UL , PICO-IMX7 , PICO-IMX8M , TEK3-IMX6 , TEK3-IMX6UL , TEP-0500-IMX6UL , TEP-0500-IMX7 , TEP-0700-IMX6UL , TEP-0700-IMX7 , TEP-1010-IMX6 , TEP-1560-IMX6 , TWP-1010-IMX6 , TWP-1560-IMX6

If you are building from source with Yocto, Yocto automatically builds a native toolchain from source. In many cases, you will also want to build binaries for 32-bit or 64-bit ARM targets without using Yocto to build a toolchain for you. The following steps will show you how to download and prepare your host with a Linaro toolchain.

Download the toolchain from Linaro:

For 32-bit targets such as NXP i.MX6, i.MX6UL, and i.MX7, the toolchain you use depends on the version of kernel and bootloader, as well as the target processor architecture:

ToolchainU-bootLinux Kernel
GCC-4.6.2_201112U-boot 2013.10
U-boot 2014.10
3.0.35
3.10.53
GCC-5.1_201508U-boot 2015.04
U-boot 2017.03
3.14.52
4.1.15
4.9.88

Currently, for 64-bit ARM targets such as PICO-IMX8M, we are using the following Linaro GCC toolchain, which can be downloaded from here:

gcc-linaro-6.4.1-2017.11-x86_64_aarch64-linux-gnu.tar.xz

Install the toolchain

We normally install the toolchain into the /opt directory on our Linux host:

tar xvf [toolchain-file.tar.xz] -C /opt/

Export the environment

When you are building a binary for target CPU architectures other than that of your host, you are cross-compiling. To do that with GCC, you should set up certain environment variables that are used by the other tools to ensure that you are calling the correct toolchain executables when building. For kernel and u-boot, you should also set the ARCH variable to the appropriate processor architecture.

export PATH=$PATH:/opt/[toolchain directory]/bin

For ARM64 (64-bit ARM) targets such as i.MX8M:

export ARCH=arm64
export CROSS_COMPILE=/opt/[toolchain directory]/bin/aarch64-linux-gnu-

For 32-bit ARM targets such as i.MX6 and i.MX7:

export ARCH=arm
export CROSS_COMPILE=/opt/[toolchain directory]/bin/arm-linux-gnueabihf-

Note that you will need to do this in every Linux terminal in which you intend to build for your target.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值