Skip to content

Toolchain Setup

Jamie Smith edited this page Nov 7, 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", "prettytable", and "future": python -m pip install intelhex prettytable future.

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 future

The toolchain should now be set up!

On Linux:

  1. Install CMake >= 3.12.
    • For most recent distros, e.g. Ubuntu 18.04 and newer, you can just use the package manager CMake package.
    • For Ubuntu 14.04 and 16.04, use this PPA.
    • Many distros can also utilize the CMake snap package.
    • Otherwise, if your distro doesn't have a version recent enough, you may have to build it from source.
  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 future

note: We do not recommend using the official Debian/Ubuntu gcc-arm-none-eabi package due to an as-yet-unfixed bug that prevents proper compilation of Mbed OS. As far as we can tell, the zip files downloaded from ARM do not have this bug.

The toolchain should now be set up!