Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

gcc

arm

toolchain

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.

like image 323
nathansizemore Avatar asked Jun 25 '16 05:06

nathansizemore


People also ask

How install toolchain Linux?

You should download it from https://developer.arm.com/open-source/gnu-toolchain/gnu-rm/downloads or you can grab an older version from launchpad.net. This will create a directory named gcc-arm-none-eabi-9-2020-q2-update in your current working dir.

What is aarch64 Linux GNU?

GNU C compiler for the arm64 architecture This is the GNU C compiler, a fairly portable optimizing compiler for C. This is a dependency package providing the default GNU C cross-compiler for the arm64 architecture.


1 Answers

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