ESP32 – building the toolchain for Linux (Ubuntu)

This quick tutorial shows how to build a complete development environment for the ESP32 processors on Linux (Ubuntu).  These instructions have been tested successfully on Ubuntu 16.04  (32 and 64 bit).

Building Toolchain with Bash One-Liner

I recommend to use this handy bash one-liner command to build ESP32 Tolchain. To override ESP32 Toolchain base directory change the value of option -d.

curl | bash -s -- -d ~/esp

Building Toolchain Step-by-Step

1. Collect and install tools

At first, we need to get few packages.

sudo apt-get install git wget make libncurses-dev flex bison gperf python python-serial

2. Create base directory

mkdir -p $HOME/esp

3. Download binary Toolchain for the ESP32

ESP32 toolchain (32 and 64-bit) for Linux is available for download from Espressif website. Download this file, then extract it to the $HOME/esp.

cd $HOME/esp
tar -xzf xtensa-esp32-elf-linux64-1.22.0-61-gab8375a-5.2.0.tar.gz
export PATH=$PATH:$HOME/esp/xtensa-esp32-elf/bin
echo "export PATH=\$PATH:$HOME/esp/xtensa-esp32-elf/bin" >> ~/.bashrc

4. Get ESP-IDF from GitHub

Clone ESP-IDF using git clone command. Framework will be downloaded into $HOME/esp/esp-idf. I strongly recommend cloning the repository to local computer because it’s frequently updated and It’s good to keep it up to date.

cd $HOME/esp
git clone --recursive
export IDF_PATH=$HOME/esp/esp-idf
echo "export IDF_PATH=$HOME/esp/esp-idf" >> ~/.bashrc

5. Update framework ESP-IDF

It’s a easy to keep framework ESP-IDF up-to-date with the following commands.

cd $HOME/esp/esp-idf
git pull
git submodule update

Compile “blinky” example

Now you can test the toolchain. Compile one of the examples from directory $HOME/esp-idf/examples.

cd $HOME/esp-idf/examples/02_blink


Leave a Comment