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).

Update: 18-05-2017.

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 https://raw.githubusercontent.com/lpodkalicki/blog/master/esp32/tools/build_esp32_toolchain.sh | bash -s -- -d ~/esp32

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/esp32

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/esp32
wget https://dl.espressif.com/dl/xtensa-esp32-elf-linux64-1.22.0-61-gab8375a-5.2.0.tar.gz
tar -xzf xtensa-esp32-elf-linux64-1.22.0-61-gab8375a-5.2.0.tar.gz
export PATH=$PATH:$HOME/esp32/xtensa-esp32-elf/bin
echo "export PATH=\$PATH:$HOME/esp32/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/esp32
git clone --recursive https://github.com/espressif/esp-idf.git
export IDF_PATH=$HOME/esp32/esp-idf
echo "export IDF_PATH=$HOME/esp32/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/esp32/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/esp32/esp-idf/examples/get-started/blink
make

Resources

One thought on “ESP32 – building the toolchain for Linux (Ubuntu)

  1. Please add “/usr/bin/python -m pip install –user -r /root/esp32/esp-idf/requirements.txt” to your oneliner script.

    Thank you for your great work!

Leave a Comment