How to install a functional ARM cross-GCC toolchain on Ubuntu 18.04 (Bionic Beaver)
You can download a functional toolchain from developer.arm.com and install it manually after removing your existing gcc-arm-none-eabi package.
Go to that website, click the "Download" button and get:
gcc-arm-none-eabi-7-2018-q2-update-linux.tar.bz2
. Save it in your home directory.
Make sure you've uninstalled the old Ubuntu packages.
sudo apt remove binutils-arm-none-eabi gcc-arm-none-eabi libnewlib-arm-none-eabi
Untar the new package in your home directory:
tar -xjvf gcc-arm-none-eabi-7-2018-q2-update-linux.tar.bz2
Add the new toolchain to your path:
export PATH=$PATH:/home/(your user)/gcc-arm-none-eabi-7-2018-q2-update/bin/
At this point you should have a working ARM compiler and toolchain. (For the Unix newbies: if you close the terminal and open a new one, you'll have to re-run the export PATH
statement so the compiler will get picked up again.)
To check if the compiler is installed:
gcc --version
Related videos on Youtube
Tim
Updated on September 18, 2022Comments
-
Tim over 1 year
Context
I recently installed
Ubuntu 18.04, Linux foobar-VirtualBox 4.15.0-23-generic #25-Ubuntu SMP Wed May 23 18:02:16 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux
on a VM. I want to cross-compile applications for Cortex-M4F CPUs with hard floating points, and therefore I have installed the packagegcc-arm-none-eabi
version15:6.3.1+svn253039-1build1
as well aslibnewlib-arme-none-eabi
at version2.4.0.20160527-3
.Problem
There is a linker error due to a conflict between my object files using hard floats and the libraries using soft floats. Some research indicates that this is a known Ubuntu 18.04 (Bionic Beaver) issue:
Note that I do provide the correct compiler and linker flags, and this project correctly builds with the Windows cross-toolchain from GNU ARM Embedded. I think it'd be pointless to paste the complete error here. If someone thinks it'd be required I'd be glad to edit this question.
What I already tried
From my basic understanding, I have two solutions to get a functional GCC ARM toolchain:
- Downgrade
gcc-arm-none-eabi
to return to a working version - Remove
gcc-arm-none-eabi
and install insteadgcc-arm-embedded
from the team GCC ARM embedded's PPA (Install gcc-arm-embedded from the PPA)
Downgrading gcc-arm-none-eabi, but to what?
In order to downgrade
gcc-arm-none-eabi
I have to find a previous version in my package manager. I first updated the package list withsudo apt update
, then I typed:sudo apt show gcc-arm-none-eabi
Package: gcc-arm-none-eabi
Version: 15:6.3.1+svn253039-1build1
Priority: extra
Section: universe/devel
Origin: Ubuntu
Maintainer: Ubuntu Developers
Original-Maintainer: Agustin Henze
Bugs: https://bugs.launchpad.net/ubuntu/+filebug
Installed-Size: 307 MB
Depends: libc6 (>= 2.15), libgcc1 (>= 1:3.0), libgmp10, libisl15 (>= 0.15), libmpc3, libmpfr6 (>= 3.1.3), libstdc++6 (>= 5), zlib1g (>= 1:1.1.4), binutils-arm-none-eabi
Recommends: libnewlib-arm-none-eabi
Homepage: http://gcc.gnu.org/
Download-Size: 24.3 MB
APT-Sources: http://ch.archive.ubuntu.com/ubuntu bionic/universe amd64 Packages
Description: GCC cross compiler for ARM Cortex-A/R/M processors
Bare metal compiler for embedded ARM chips using Cortex-M, Cortex-R and
Cortex-A processors.
This package is based on the GNU ARM toolchain provided by ARM.There, I don't see any previous version. I think they should be listed here, but I don't see it. I can't downgrade if I can't provide the exact previous version I want to downgrade to.
Using gcc-arm-embedded instead of gcc-arm-none-eabi
I followed the instructions given in the link above, which led me to these commands:
sudo apt remove gcc-arm-none-eabi sudo apt-add-repository ppa:team-gcc-arm-embedded/ppa sudo apt update
[...] Ign:4 http://ppa.launchpad.net/team-gcc-arm-embedded/ppa/ubuntu bionic InRelease
Get:5 http://security.ubuntu.com/ubuntu bionic-security InRelease [83.2 kB]
Err:6 http://ppa.launchpad.net/team-gcc-arm-embedded/ppa/ubuntu bionic Release
404 Not Found [IP: 91.189.95.83 80]
Reading package lists... Done
E: The repository 'http://ppa.launchpad.net/team-gcc-arm-embedded/ppa/ubuntu bionic Release' does not have a Release file.
N: Updating from such a repository can't be done securely, and is therefore disabled by default.
N: See apt-secure(8) manpage for repository creation and user configuration details.sudo apt-install gcc-arm-embedded
Reading package lists... Done
Building dependency tree
Reading state information... Done
E: Unable to locate package gcc-arm-embeddedBasically it seems I have issues accessing the PPA. I tried the
apt
switch--allow-unauthenticated
, but it didn't change the commands output.Question
Is there a way to make one of those two solutions work, or is there another way to get a functional GCC toolchain on Ubuntu 18.04 to build hard-float application for the Cortex-M4F CPU?
(I've recently posted a Stack Overflow question on this issue, as at this time I thought it was a toolchain issue not so related with the Unix world. If I get an answer here I'll close it and redirect to this Q/A)
-
Andrew Kohlsmith over 4 yearsThis issue (newlib doesn't understand M4F should use hardfloat) in 19.04. It's a little disappointing that this hasn't been addressed correctly and we have to do an end-run around the official packages.
- Downgrade
-
MikeB over 4 yearsAfter doing these steps, how can I quickly test that my ARM tool chain is working?