Skip to content

Toolchain Setup

Jamie Smith edited this page Jun 1, 2020 · 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. Download the GNU ARM toolchain from ARM's website (get the Mac OS 64 Bit version), 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. Now we need to add the toolchain to your PATH. 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 the end of your .bash_profile file: export PATH=/usr/local/gcc-arm/bin:$PATH
  6. Save the file by hitting the escape key 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. In a terminal, run sudo -H python3 -m easy_install pip
  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!

On Linux:

  1. Install CMake >= 3.9.
    • 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. In a terminal, run sudo -H python3 -m easy_install pip
  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