arm交叉编译 扫盲贴 ARM交叉编译工具链

 

为什么要用交叉编译器?

交叉编译通俗地讲就是在一种平台上编译出能运行在体系结构不同的另一种平台上的程序,
比如在PC平台(X86 CPU)上编译出能运行在以ARM为内核的CPU平台上的程序,编译得到的程序在X86 CPU平台上是不能运行的,必须放到ARM CPU平台上才能运行,虽然两个平台用的都是Linux系统。

arm交叉编译器

交叉编译工具链是一个由编译器、连接器和解释器组成的综合开发环境,交叉编译工具链主要由binutils、gcc和glibc三个部分组成。
有时出于减小 libc 库大小的考虑,也可以用别的 c 库来代替 glibc,例如 uClibc、dietlibc 和 newlib。
建立交叉编译工具链是一个相当复杂的过程,如果不想自己经历复杂繁琐的编译过程,
网上有一些编译好的可用的交叉编译工具链可以下载,但就以学习为目的来说读者有必要学习自己制作一个交叉编译工具链(目前来看,对于初学者没有太大必要自己交叉编译一个工具链)。

分类和说明: 从授权上,分为免费授权版和付费授权版。

免费版目前有三大主流工具商提供,

  1. GNU(提供源码,自行编译制作)
  2. Codesourcery
  3. Linora (提供源码,和已经编译好的release binrary)

收费版有ARM原厂提供的armcc、IAR提供的编译器等等,因为这些价格都比较昂贵,不适合学习用户使用,所以不做讲述。

arm-linux-gnueabihf-gcc(32-bit Armv7 Cortex-A, hard-float, little-endian )

是由 Linaro 公司基于GCC推出的的ARM交叉编译工具。  
可用于交叉编译ARMv7(32位)系统中所有环节的代码,包括裸机程序、u-boot、Linux kernel、filesystem和App应用程序。

armv8l-linux-gnueabihf(32-bit Armv8 Cortex-A, hard-float, little-endian )

是由 Linaro 公司基于GCC推出的的ARM交叉编译工具。 
可用于交叉编译ARMv8(32位)系统中所有环节的代码,包括裸机程序、u-boot、Linux kernel、filesystem和App应用程序。

aarch64-linux-gnu-gcc(64-bit Armv8 Cortex-A, little-endian )

是由 Linaro 公司基于GCC推出的的ARM交叉编译工具。
可用于交叉编译ARMv8 64位目标中的裸机程序、u-boot、Linux kernel、filesystem和App应用程序。

名称描述详情
ABI二进制应用程序接口(Application Binary Interface (ABI) for the ARM Architecture)在计算机中, 应用二进制接口描述了应用程序(或者其他类型)和操作系统之间或其他应用程序的低级接口
EABI嵌入式ABI (Embedded Application Binary Interface)嵌入式应用二进制接口指定了文件格式、数据类型、寄存器使用、堆积组织优化和在一个嵌入式软件中的参数的标准约定. 开发者使用自己的汇编语言也可以使用 EABI 作为与兼容的编译器生成的汇编语言的接口

ABI的定义
ABI描述应用程序与操作系统、应用程序与库、应用程序的组成部分之间的低层接口。ABI允许编译好的目标代码在使用兼容ABI的系统中无需改动就能运行。

两者主要区别是,ABI是运行在x86,x64平台, EABI是嵌入式平台上(如ARM,MIPS,android, iOS等)。


linaro

Linaro,一间非营利性质的开放源代码软件工程公司,主要的目标在于开发不同半导体公司系统单芯片(SoC)平台的共通软件,以促进消费者及厂商的福祉。针对于各个成员推出的 ARM系统单芯片(SoC),它开发了ARM开发工具、Linux内核以及Linux发行版(包括 Android 及 Ubuntu)的主要自动建构系统。

由ARM、飞思卡尔、IBM、Samsung、ST-Ericsson 及德州仪器 (TI)等半导体厂商联合,在2010年3月成立。2010年6月在台北对外宣布这个消息。预计在2010年11月,推出第一版以ARM Cortex-A 为核心的 SoC 进行效能优化的软件工具

除了推出交叉编译器还推出修改的linux和安卓内核等包

Ubuntu源中的交叉编译器即使用linaro下载编译的交叉编译器

下载 https://releases.linaro.org/components/toolchain/binaries/latest/

ELDK的下载

http://www.denx.de/en/News/WebHome

-> ftp://ftp.denx.de/pub/eldk/5.3/

-> ftp://ftp.denx.de/pub/eldk/5.3/iso/

中有各种的,基于arm的eldk,比如:

eldk-5.3-armv4t.iso
eldk-5.3-armv5te.iso
eldk-5.3-armv6.iso
eldk-5.3-armv6.iso
eldk-5.3-armv7a-hf.iso
eldk-5.3-armv7a.iso

下载下来,解压后,去运行安装脚本后,就可以使用了

Codesourcery

Codesourcery 推出的产品叫 Sourcery G++ Lite Edition, 其中基于 command-line 的编译器是免费的, 在官网上可以下载, 而其中包含的 IDE 和 debug 工具是收费的, 当然也有30天试用版本的.

目前 CodeSourcery 已经由明导国际(Mentor Graphics)收购, 所以原本的网站风格已经全部变为 Mentor 样式, 但是 Sourcery G++ Lite Edition 同样可以注册后免费下载.

Codesourcery一直是在做 ARM 目标 GCC 的开发和优化, 它的 ARM GCC 在目前在市场上非常优秀, 很多 patch 可能还没被 gcc 接受, 所以还是应该直接用它的(而且他提供 Windows 下[mingw交叉编译的]和Linux下的二进制版本, 比较方便; 如果不是很有时间和兴趣, 不建议下载 src 源码包自己编译, 很麻烦, Codesourcery给的 shell 脚本很多时候根本没办法直接用, 得自行提取关键的部分手工执行, 又费精力又费时间, 如果想知道细节, 其实不用自己编译一遍, 看看他是用什么步骤构建的即可, 如果你对交叉编译器感兴趣的话.

FriednlyARM友善之臂

arm9之家 http://www.arm9home.net/
论坛 http://www.friendlyarm.net/forum/topic/5203

命名规则

对应分别是 :

arch [-vendor] [-os] [-(gnu)eabi]

规则 描述
arch 体系架构, 如ARM, MIPS
vendor 工具链提供商
os 目标操作系统
eabi 嵌入式应用二进制接口(Embedded Application Binary Interface)


https://developer.arm.com/embedded

Getting started

Starting with the basics, find all of the resources you will need here.

Keil Application Notes

Keil MDK Device List

Keil Discussion Forum

Keil Knowledge Base

Keil MDK User's Guides

Latest Mbed news and releases

Learning Platform for Cortex-M

Migrating from 8051 to Cortex Microcontrollers

User Guides: Cortex-M4, Cortex-M3, Cortex-M0+ and Cortex-M0

Choosing a Board

Find the right development platform for your project and minimize project setup time.

Keil board list for Arm Cortex-M

Arm Cortex-M7

Arm Cortex-M4

Arm Cortex-M3

Arm Cortex-M0

Arm V2M-MPS2

Developing with Mbed

snapdragon boards

Latest Linux Targeted Binary Toolchain Releases

linaro toolchain binaries

linaro downloads

arm版本硬件型号   
arm-linux-gnueabihf32-bit Armv7 Cortex-A, hard-float, little-endianRelease-NotesBinariesSource
armv8l-linux-gnueabihf32-bit Armv8 Cortex-A, hard-float, little-endianRelease-NotesBinariesSource
aarch64-linux-gnu64-bit Armv8 Cortex-A, little-endianRelease-NotesBinariesSource

Latest Bare-Metal Targeted Binary Toolchain Releases (也可以认为是MCU,不跑操作系统)

arm版本硬件型号   
arm-eabi32-bit Armv7 Cortex-A, soft-float, little-endianRelease-NotesBinariesSource
aarch64-elf64-bit Armv8 Cortex-A, little-endianRelease-NotesBinariesSource

GNU Toolchain for Arm processors

Open source GNU tools for Arm processors: GNU compiler (GCC), binutils, GNU debugger (GDB) and newlib

1> ## GNU toolchain for the A-profile architecture

- Application and Linux kernel development
- Support for Arm Cortex-A family
- Monthly updates to QEMU, GDB, and various versions of GCC
- Freely available from Linaro
- Community support

Download GNU Toolchain for the A-profile architecture

GNU Toolchain for the A-profile architecture

The GNU Toolchain for the Cortex-A Family are integrated and validated packages featuring the GCC compiler, libraries and other GNU tools necessary for software development on devices based on the Arm Cortex-A processors or the Arm A-profile architecture. The toolchains are available for cross-compilation on Microsoft Windows and Linux host operating systems.

These toolchains are based on Free Software Foundation's (FSF) GNU Open source tools.

2> ## GNU toolchain for embedded processors

- Bare-metal development
- Support for Arm Cortex-R and Cortex-M families
- GCC, binutils, GDB and newlib
- Freely available from Arm
- Community support

GNU Arm Embedded Toolchain

Pre-built GNU toolchain for Arm Cortex-M and Cortex-R processors

The GNU Arm Embedded toolchains are integrated and validated packages featuring the Arm Embedded GCC compiler, libraries and other GNU tools necessary for bare-metal software development on devices based on the Arm Cortex-M and Cortex-R processors. The toolchains are available for cross-compilation on Microsoft Windows, Linux and Mac OS X host operating systems.

These toolchains are based on Free Software Foundation's (FSF) GNU Open source tools and newlib.

These toolchains support Arm Cortex-M0, Cortex-M0+, Cortex-M3, Cortex-M4, Cortex-M7, Cortex-M23, Cortex-M33, Cortex-R4, Cortex-R5, Cortex-R7, Cortex-R8 and Cortex-R52 processors.

The toolchains support code generation for non-OS or 'bare-metal' environments. These toolchains are based on Free Software Foundation's (FSF) GNU Open source tools and newlib.

GNU C/C++ Compiler

You can find the sources to Arm Embedded GCC under  svn://gcc.gnu.org/svn/gcc/branches/ARM/. All contributions are made to trunk and patches are cherry-picked on a need basis to the Arm embedded branches.

Binutils

You can find the sources to Arm Embedded Binutils under git://sourceware.org/git/binutils-gdb.git. All embedded branches are under users/ARM/embedded-binutils-[version]-branch. Contribution is similar to GCC.

GDB

You can find the sources to Arm Embedded Binutils under git://sourceware.org/git/binutils-gdb.git. All embedded branches are under users/ARM/embedded-gdb-[version]-branch. Contribution is similar to GCC.

Newlib

You can find the sources under git://sourceware.org/git/newlib-cygwin.git. We contribute to master and the toolchain is based on master branch as well.

https://launchpad.net/gcc-linaro

https://launchpad.net/gcc-linaro/+packages

qemu WIKi

中文
https://github.com/gatieme/AderXCoding/tree/master/system/tools/cross_compile


介绍区别

https://www.crifan.com/files/doc/docbook/cross_compile/release/html/cross_compile.html#crosscompiler_name_examples

Linux

    表示:有OS(此处主要指的是Linux)操作系统的环境
    比如,我用交叉编译器,编译一个helloworld程序,然后下载到嵌入式开发中的嵌入式Linux中运行,
    就属于,用此交叉编译器,编译出来的程序,是要运行于,带OS,即嵌入式Linux系统,环境中的
    此处,简称为,有OS的目标系统:Linux


bare-metal 直译为:裸金属

    表示:无(此处主要指的是Linux)操作系统的环境,
    比如,用此交叉编译器,去编译一个Uboot,或者是其他一个小程序,是运行在,无嵌入式Linux的时候,单独运行的一个程序。
    比如,你购买的嵌入式系统开发版,常常附带一些小程序,比如点亮LED,跑马灯等程序,就是这种,运行在无OS的环境的
    此处,简称为:无OS系统的:bare-metal
   


关于,运行在有OS的Linux下,和,无OS的bare-metal,区别 是 一个运行OS,库会有很多,依赖也会有很多。

而类似STM32F1系列(MCU ) 既可以 跑RTOS,也可以当单片机来用, 在初始化中 设置GPIO,时钟晶振频率,然后 就可以利用GPIO 输出想要的东西。
  • 4
    点赞
  • 13
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值