Skip to content

Instantly share code, notes, and snippets.

@carloscn
Last active March 29, 2022 03:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save carloscn/7774739514033fa7a9b5407f6fb880d8 to your computer and use it in GitHub Desktop.
Save carloscn/7774739514033fa7a9b5407f6fb880d8 to your computer and use it in GitHub Desktop.
在MACBOOK上搭建ARMv8架构的ARM开发环境

在MACBOOK上搭建ARMv8架构的ARM开发环境

本文适用针对于ARMv8-A64指令集的编译器环境搭建。 关于arm的交叉编译环境可以总结以下几点:

  • aarch64-linux-gnu: ARMv8的64位架构编译,指令集A64,Linux应用编译。
  • aarch64-linux-gnu_ilp32: ARMv8的32位架构编译,指令集A32/T32,Linux应用编译。
  • aarch64-none-elf: ARMv8, 64位的裸机编译,指令集A64。
  • arm-linux-gnueabi: ARMv7全指令集, ARMv8 aarch32(A32/T32)指令集,Linux应用。
  • arm-none-eabi: ARMv7全指令集, ARMv8 aarch32(A32/T32)指令集,裸机应用。
multiarch name syscall ABI instruction set endian­ness word size description spec documents
aarch64-linux-gnu linux ARMv8 little 64 aarch64 Linux Platform AAPCS64 (ARM IHI 005A)1 ELF for the ARM 64-bit Architecture2
aarch64_be-linux-gnu linux ARMv8 big 64 aarch64 Linux Platform AAPCS64 (ARM IHI 005A)1 ELF for the ARM 64-bit Architecture2
aarch64-linux-gnu_ilp32 linux ARMv8 little 32 aarch64 Linux Platform
aarch64_be-linux-gnu_ilp32 linux ARMv8 big 32 aarch64 Linux Platform
arm-linux-gnu linux ARMv7/ARMv8 little 32 Old ARM ABI APCS (ARM DUI 0041 chapter 9)4
arm-linux-gnueabi linux ARMv7/ARMv8 little 32 ARM EABI, soft-float AAPCS (ARM IHI 0042D)5 ARM GNU/Linux ABI Supplement6
arm-linux-gnueabihf linux ARMv7/ARMv8 little 32 ARM EABI, hard-float AAPCS (ARM IHI 0042D)5 and XXXXX (TBD)
armeb-linux-gnueabi linux ARMv7/ARMv8 big 32 ARM EABI, soft-float AAPCS (ARM IHI 0042D)5 ARM GNU/Linux ABI Supplement6
armeb-linux-gnueabihf linux ARMv7/ARMv8 big 32 ARM EABI, hard-float AAPCS (ARM IHI 0042D)5 and XXXXX (TBD)
armv8l-linux-gnueabihf linux ARMv8 little 32 ARMv8 EABI, hard-float
arm-eabi Bare-Metal ARMv7/ARMv8 little 32 ARM EABI, soft-float
armeb-eabi Bare-Metal ARMv7/ARMv8 big 32 ARM EABI, soft-float
aarch64-elf Bare-Metal ARMv8 little 64 ARMv8 EABI, hard-float
aarch64_be-elf Bare-Metal ARMv8 big 64 ARMv8 EABI, hard-float
  • test.o使用 aarch64-none开头编译的文件,运行在armv8架构上面
  • test.elf使用 arm-none开头编译的文件,运行在armv7架构的
test file test.o
test.o: ELF 64-bit LSB executable, ARM aarch64, version 1 (SYSV), dynamically linked, interpreter /lib/ld-linux-aarch64.so.1, for GNU/Linux 3.7.0, with debug_info, not stripped
➜  test file test.elf
test.elf: 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, with debug_info, not stripped

1.1 交叉编译环境

1.1.1 A32/T32

$ brew tap PX4/homebrew-px4
$ brew update
$ brew install gcc-arm-none-eabi-83`
$ arm-none-eabi-gcc --version
arm-none-eabi-gcc (GNU  Tools for Arm Embedded Processors 8-2019-q3-update) 8.3.1 20190703 (release) [gcc-8-branch revision 273027]
Copyright (C) 2018 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.

1.1.2 A64

下载地址: https://developer.arm.com/tools-and-software/open-source-software/developer-tools/gnu-toolchain/downloads 中国下载太慢可以使用清华镜像:https://mirror.tuna.tsinghua.edu.cn/armbian-releases/_toolchain/

1.2 jlink

brew install openocd

1.3 qemu

自己编译带树莓派4b的qemu

$ git clone git@github.com:0xMirasio/qemu-patch-raspberry4.git --depth=1

$ ./configure --target-list=aarch64-softmmu

$ make -j8

$ make install

$ qemu-system-aarch64 -machine raspi3b -nographic -kernel xxxx.bin -S -s

不需要树莓派4b支持的可以直接:

$ brew install qemu

1.4 gdb

$ aarch64-none-elf-gdb --tui xxxx.elf -x xxxx.sh

REF

https://developer.arm.com/tools-and-software/open-source-software/developer-tools/gnu-toolchain/gnu-a/downloads

https://www.cnblogs.com/arnoldlu/p/14243491.html

https://mynewt.apache.org/v1_5_0/get_started/native_install/cross_tools.html#installing-the-arm-toolchain-for-mac-os-x

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment