How to install the aarch64 toolchain for armv8 cortex-a53 on Debian?
Solution 1
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
Solution 2
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! :)
nathansizemore
Software Engineer at Real Art. I enjoy beer, bourbon, climbing rocks, and Linux.
Updated on June 14, 2022Comments
-
nathansizemore almost 2 years
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
andneon-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.
-
Jasonw almost 5 yearscan you produce gcc 7.3.0 ?
-
abhiTronix almost 5 yearsMaybe not, since it is now obsoleted and replaced by newer binaries. You can rather use my GCC 7.4.0 toolchains.
-
Jasonw almost 5 yearsokay, that's really a pity.. unfortunately the app cannot be compile using gcc740 (tried it) and i dont have knowledge to fix that. it will absolutely do wonder if you can release for 730 even though it is obsolete..
-
Ciro Santilli OurBigBook.com over 3 years@TheExcitedEngineer thanks, it's due to Stack Exchange's idiotic post deletion algorithms regardless of how many million rep asker has, reposted at: github.com/cirosantilli/cirosantilli.github.io/issues/68