-
Notifications
You must be signed in to change notification settings - Fork 19
Toolchain Setup Guide
This page explains how to set up ARM GCC and other tools on your computer so that you can compile Mbed CE projects.
- Get CMake by downloading the installer from here. If you already have CMake installed, make sure it's at least version 3.16. Make sure to select "Add CMake to the system PATH for all users" in the installer!
- Download the latest Ninja Build binary from here (grab ninja-win.zip). Then, you need to extract the exe file to somewhere on your PATH. Note: It might be convenient to put it into the CMake bin folder (C:\Program Files\CMake\bin) since the CMake installer has already added that to your PATH.
- Go to ARM's toolchain download page and download the exe installer under "Windows (mingw-w64-i686) hosted cross toolchains" > "AArch32 bare-metal target (arm-none-eabi)". Then, execute it and go through the installer, making sure to check the "Add path to environment variable" box!
- If you don't already have it, install Python 3 so that you can run python from the command line. Note: Windows Store version not recommended. To make sure Python gets installed correctly, follow the install process below:
On the first screen, select the "Add Python 3.x to PATH" checkbox, then click "Customize installation"
Click Next on the second screen.
On the third screen, check "Install for all users". Also, make sure "Add Python to environment variables" is checked.
- Reboot your machine so that the changes to your PATH are applied.
The toolchain should now be set up!
- If you don't already have Homebrew, install it according to its instructions here.
- Install cmake and ninja with
brew install cmake ninja
in the terminal. - Add a Brew remote for the ARM toolchain:
brew tap osx-cross/arm
- Install the toolchain:
brew install arm-gcc-bin
- Lastly, make sure Pip is installed to your system python. In a terminal, run
sudo -H python3 -m easy_install pip
The toolchain should now be set up!
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 packages from ARM do not have this bug.
- Install CMake >= 3.19.
- For recent distros, e.g. Ubuntu 22.04 and newer, you can just use the package manager CMake package.
- For Ubuntu 16.04, 18.04, and 20.04, use this APT repo.
- 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.
- Install Ninja Build. On Ubuntu you can install it with
sudo apt-get install ninja-build
, though other distros may vary. - Install some dependency packages for the arm toolchain:
sudo apt-get install libncurses5 libncursesw5
- Go to ARM's toolchain download page and download the tar.xz toolchain under "x86_64 Linux hosted cross toolchains" > "AArch32 bare-metal target (arm-none-eabi)".
- Note: If using an ARM64 machine like a Raspberry Pi, get the "AArch64 Linux hosted" build instead.
- Open a terminal in the folder where you downloaded the tar.xz file, and extract it with
tar xf arm-gnuXXXX.tar.xz
(replace "arm-gnuXXXX" with the full name of the toolchain file) - Using the terminal, copy the entire folder to /usr/local on your machine by running:
sudo mv arm-gnuXXXX /usr/local/gcc-arm
. - Navigate to your home directory by typing cd ~. Then, create a bash profile if you don't already have one by typing
nano .bash_profile
- If you use zsh, use .zshrc instead of .bash_profile in these steps
- Add the following line to the end of your .bash_profile file:
export PATH=/usr/local/gcc-arm/bin:$PATH
- Save the file and exit by hitting Ctrl-O, then Enter, then Ctrl-X
- Restart all terminal windows or run
source ~/.bash_profile
in all open terminal windows. - Lastly, 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
.
The toolchain should now be set up!
If you want to debug your code, you will also need to install one of the upload methods that supports debugging. Which one to use depends on your specific setup -- generally openocd and pyocd can be used on all processors, but others such as STM32Cube only work with specific ones. See the Upload Methods page for details about the methods and how to install them.