简体   繁体   中英

How to install the aarch64 toolchain for armv8 cortex-a53 on Debian?

I'm wanting to start low level programming on ARM chips. I've installed qemu and followed a few example programs for hello world type stuff, but now I want to target the latest Raspberry Pi, which has the ARMv8 cortex-a53 and neon-fp-armv8 FPU. I'm currently running Debian:

$ lsb_release -a
    No LSB modules are available.
    Distributor ID: BunsenLabs
    Description:    BunsenLabs GNU/Linux 8.5 (Hydrogen)
    Release:    8.5
    Codename:   bunsen-hydrogen

$ cat /etc/debian_version
    8.5

I've currently installed the following toolchain:

binutils-arm-none-eabi
gcc-arm-none-eabi
gdb-arm-none-eabi

However, when I try to compile with -mcpu=cortex-a53 , I receive the following error:

arm-none-eabi-gcc: error: unrecognized argument in option '-mcpu=cortex-a53'

$ arm-none-eabi-gcc --version
    arm-none-eabi-gcc (4.8.4-1+11-1) 4.8.4 20141219 (release)

I assumed I had an older GCC that did not contain that target CPU, so I tried to download the source for binutils, gcc, and gdb but I am unable to build binutils. It always fails when trying to make all .

binutils configuration:

$../../src/binutils-2.26.51/configure \
 --target=arm-none-eabi \
 --disable-nls

Build error:

$make -j4
    checking for bison... /home/nathan/development/tools/arm/src/binutils-2.26.51/missing bison -y
    checking for flex... /home/nathan/development/tools/arm/src/binutils-2.26.51/missing flex
    checking lex output file root... configure: error: cannot find output from /home/nathan/development/tools/arm/src/binutils-2.26.51/missing flex; giving up
    Makefile:3545: recipe for target 'configure-binutils' failed
    make[1]: *** [configure-binutils] Error 1
    no
    checking for bison... /home/nathan/development/tools/arm/src/binutils-2.26.51/missing bison -y
    checking for flex... /home/nathan/development/tools/arm/src/binutils-2.26.51/missing flex
    checking lex output file root... configure: error: cannot find output from /home/nathan/development/tools/arm/src/binutils-2.26.51/missing flex; giving up
    Makefile:4834: recipe for target 'configure-gas' failed
    make[1]: *** [configure-gas] Error 1
    make[1]: Leaving directory '/home/nathan/development/tools/arm/build/binutils-2.26.51'
    Makefile:844: recipe for target 'all' failed
    make: *** [all] Error 2

What are the proper steps I need to take in order to get a toolchain setup to compile for an aarch64 cortex-a53 architecture?

Edit 1

Discovered through the comments, I need to install the aarch64 toolchain, not the arm toolchain. Still clueless.

As of Ubuntu 18.04 you can do:

sudo apt-get install gcc-aarch64-linux-gnu
aarch64-linux-gnu-gcc -mcpu=cortex-a53 hello_world.c

The package gcc-aarch64-linux-gnu is at version 4:7.3.0-3ubuntu2

However, for Raspberry Pi, you should just download the official binaries from https://github.com/raspberrypi/tools which is the more reliable way to do it as explained at: https://raspberrypi.stackexchange.com/questions/64273/installing-raspberry-pi-cross-compiler/83215#83215

Finally, for bare metal, I was not able to find the analogue of arm-none-eabi-gcc , I wonder why: https://github.com/cirosantilli/cirosantilli.github.io/issues/68

You can try my Latest Pre-Built Open-Sourced GCC Toolchains for Raspberry Pi from this Github Project :

This Project Summary: This project contains the UpToDate set of Precompiled/Pre-Built Raspberry pi GCC Cross & Native Compilers Binaries, saving your tons of time(No compiling or Error Handling needed whatsoever). Just Extract, Link & Enjoy complete GCC(Raspberry Pi) functionality in your Machine. You can use its native compilers for Raspberry Pi(Can be used along with old & slow 6.3.0 GCC), Or use the Cross-Compiler in any Linux Machine(Tested on Latest Ubuntu/bionic x64) to compile programs for your Raspberry Pi. All these compilers binaries are Raspberry Pi hardware optimized for enhanced overall performance.

The Supported GCC Versions are:

  • GCC 6.3.0
  • GCC 7.4.0
  • GCC 8.2.0
  • GCC 8.3.0

Supported Environments:

  • Cross-Compiler: All Linux Distros (x32/x64) are currently supported.
  • Native-Compiler: All Raspberry Pi version/model with Raspbian OS is supported. Other OS may/may-not work.

Hope that helps! :)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM