Setting up ESP-IDF Development Environment on Linux

The GNU development and debugging tools required for the ESP-IDF development environment are native to the Linux system. Additionally, the command-line terminal in Linux is powerful and user-friendly, making it an ideal choice for ESP32-C3 development. You can select your preferred Linux distribution, but we recommend using Ubuntu or other Debian-based systems. This section provides guidance on setting up the ESP-IDF development environment on Ubuntu 20.04.

1. Install required packages

Open a new terminal and execute the following command to install all necessary packages. The command will automatically skip packages that are already installed.

$ sudo apt-get install git wget flex bison gperf python3 python3-pip python3- setuptools cmake ninja-build ccache libffi-dev libssl-dev dfu-util libusb-1.0-0

💡 Tip

You need to use the administrator account and password for the command above. By default, no information will be displayed when entering the password. Simply press the "Enter" key to continue the procedure.

Git is a key code management tool in ESP-IDF. After successfully setting up the development environment, you can use the git log command to view all code changes made since the creation of ESP-IDF. In addition, Git is also used in ESP-IDF to confirm version information, which is necessary for installing the correct tool chain corresponding to specific versions. Along with Git, other important system tools include Python. ESP-IDF incorporates numerous automation scripts written in Python. Tools such as CMake, Ninja-build, and Ccache are widely used in C/C++ projects and serve as the default code compilation and building tools in ESP-IDF. libusb-1.0-0 and dfu-util are the main drivers used for USB serial communication and firmware burning.

Once the software packages are installed, you can use the apt show <package_name> command to obtain detailed descriptions of each package. For example, use apt show git to print the description information for the Git tool.

Q: What to do if the Python version is not supported?

A: ESP-IDF v4.3 requires a Python version that is not lower than v3.6. For older versions of Ubuntu, please manually download and install a higher version of Python and set Python3 as the default Python environment. You can find detailed instructions by searching for the keyword update-alternatives python.

2. Download ESP-IDF repository code

Open a terminal and create a folder named esp in your home directory using the mkdir command. You can choose a different name for the folder if you prefer. Use the cd command to enter the folder.

$ mkdir -p ~/esp
$ cd ~/esp

Use the git clone command to download the ESP-IDF repository code, as shown below:

$ git clone -b v4.3.2 --recursive https://github.com/espressif/esp-idf.git

In the command above, the parameter -b v4.3.2 specifies the version to download (in this case, version 4.3.2). The parameter --recursive ensures that all sub-repositories of ESP-IDF are downloaded recursively. Information about sub-repositories can be found in the .gitmodulesfile.

3. Install the ESP-IDF development tool chain

Espressif provides an automated script install.sh to download and install the tool chain. This script checks the current ESP-IDF version and operating system environment, and then downloads and installs appropriate version of Python tool packages and compilation tool chains. The default installation path for the tool chain is ~/.espressif. All you need to do is to navigate to the esp-idf directory and run install.sh.

$ cd ~/esp/esp-idf
$ ./install.sh

If you install the the tool chain successfully, the terminal will display:

All done!

At this point, you have successfully set up the ESP-IDF development environment.