Skip to content

Toolchain Setup

Jamie Smith edited this page Feb 6, 2021 · 18 revisions

This page explains how to set up ARM GCC on your computer so that you can compile mbed-cmake projects. Note: If you are setting up an mbed-cmake project for the first time, then you will need to follow the Project Configuration instructions after this guide to set up mbed-cmake for your processor target.

On Windows:

  1. Get CMake by downloading the installer from here. If you already have CMake installed, make sure it's at least version 3.9. Make sure to select "Add CMake to the system PATH for all users"!
  2. Download the GNU ARM toolchain from ARM's website (get the Windows 32-bit Installer), and install it. Make sure to check "Add path to environment variable" in the installer!
  3. Install Python 3 so that you can run python from the command line. Don't forget to click the "add to path" checkbox when installing Python!
  4. Reboot your machine so that the changes to your PATH are applied.
  5. Install the Python packages "intelhex" and "prettytable": python -m pip install intelhex prettytable.

The toolchain should now be set up!

You will of course need a make tool to use with CMake, and unlike other OSs Windows doesn't come with one out of the box. I tend to use mingw32-make, with the CMake argument "-GMinGW Makefiles". mingw32-make is included with MinGW and MSYS2, or if you don't have those installed you can download a standalone version of it here. You can also use Ninja (with -GNinja) for faster builds with better parallization and decreased scanning time.

On Mac:

  1. Install cmake with brew install cmake in the terminal.
  2. Add a Brew remote for the ARM toolchain: brew tap osx-cross/arm
  3. Install the toolchain: brew install arm-gcc-bin
  4. Next, make sure Pip is installed to your system python. In a terminal, run sudo -H python3 -m easy_install pip
  5. Now, install the needed packages for the build system: sudo -H python3 -m pip install intelhex prettytable

The toolchain should now be set up!

On Ubuntu Linux:

  1. Install CMake >= 3.12.
    • For Ubuntu 14.04 and 16.04, use this PPA.
    • For newer Ubuntu, sudo apt-get install cmake should work
  2. Install the GNU Arm toolchain: sudo apt-get install gcc-arm-none-eabi
  3. Next, make sure Pip is installed to your system python. You should be able to run sudo apt-get install python3-pip python3-setuptools python3-wheel.
  4. Now, install the needed packages for the build system: sudo -H python3 -m pip install intelhex prettytable

On Linux (other distros):

  1. Install CMake >= 3.12.
    • If your distro doesn't have a version this recent, you may have to build it from source.
    • For Ubuntu 14.04 and 16.04, use this PPA.
    • Many distros can also utilize the CMake snap package.
  2. Download the GNU ARM toolchain from ARM's website (get the Linux x86_64 Tarball) and extract it to your downloads folder.
  3. Using the terminal, copy the entire folder to /usr/local on your machine by running this command: sudo cp -r ~/Downloads/gcc-armXXXX /usr/local/gcc-arm (replace "gcc-armXXXX" with the full name of the folder you extracted).
  4. Navigate to your home directory by typing cd ~. Then, create a bash profile if you don't already have one by typing vim .bash_profile
    • If you use zsh, use .zshrc instead of .bash_profile in these steps
  5. Add the following line to your .bash_profile file: export PATH=/usr/local/gcc-arm/bin:$PATH
  6. Save the file by hitting escape followed by ":wq"
  7. Restart all terminal windows or run source ~/.bash_profile in all open terminal windows.
  8. Next, make sure Pip is installed to your system python. This depends on your specific distro, but on Ubuntu you should be able to run sudo apt-get install python3-pip python3-setuptools python3-wheel.
  9. Now, install the needed packages for the build system: sudo -H python3 -m pip install intelhex prettytable

The toolchain should now be set up!

Clone this wiki locally