Building ESP32 development environment with ubuntu

This article refers to official documents

1. Installation preparation

Install the relevant software packages according to the software required to compile ESP-IDF. The ubuntu system is installed according to the following instructions. From the instructions, we can see that git, python 3 and other software need to be 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

2. Get ESP-IDF

Create a folder esp32 in your own file directory to store the SDK. Enter this folder from the command line

cd /home/study/wifi/esp/esp32

2.1. Official method for obtaining ESP IDF (not recommended)

git clone -b v4.3.1 --recursive

After testing, the above method is very, very slow to obtain the code, and finally indicates failure. I have no choice but to find another method

2.2. Method of obtaining ESP IDF from domestic code cloud

Download gitee tools

git clone

Download SDK (only clone ESP IDF, not including sub modules)

git clone

Here, there are two folders in this directory

Enter the tool directory and execute the command to update the sub module

cd esp-gitee-tools
./ ../esp-idf

After the download is successful, you can delete the ESP gitee tools folder and leave only ESP IDF

rm -rf esp-gitee-tools

3. Set the tools used to compile the code

Tools that need to be used, such as compiler, debugger, Python package, etc.

After the command line enters the ESP IDF directory, execute the following command


Execute the above script, wait for the script to complete, no error is reported, and the tool download setting is completed

4. Setting environment variables

Execute the command vim ~/.bashrc

Add at the end of the file

alias get_esp32='. /home/study/wifi/esp/esp32/esp-idf/'

Save and exit, execute the command source ~/.bashrc to make the environment variable take effect

5. Configuration Engineering

5.1. Enter hello_world routine directory

cd /home/study/wifi/esp/esp32/esp-idf/examples/get-started/hello_world

5.2. Execute command get_esp32

5.3. Set the currently used chip, and use esp32 here set-target esp32

Setting methods corresponding to different types of chips


5.4. Use the menu to configure various parameters menuconfig

You can set specific variables of the item through this menu, including Wi Fi network name, password, processor speed, etc

6. Compile project

Enter hello_world routine directory

cd /home/study/wifi/esp/esp32/esp-idf/examples/get-started/hello_world

Execute command get_esp32

Execute the command build to start compiling the program and wait for the compilation results

Run this command to compile the application and all ESP-IDF components, and then generate bootloader, partition table and application binary files.

7. Burn to device

Please use the following command to burn the binaries just generated (bootloader.bin, partition-table.bin and hello_world.bin) to your ESP32 development board: -p PORT [-b BAUD] flash

Please replace PORT with the serial PORT name of ESP32 development board

You can also replace BAUD with the burning BAUD rate you want. The default BAUD rate is 460800

After the burning is successful, you can use the command -p PORT monitor to monitor the operation of the "hello_world" project. Note that do not forget to replace PORT with your serial PORT name

You can see the printed "Hello world!" after starting the log and diagnostic log.


Hello world!

Restarting in 10 seconds...

This is esp32 chip with 2 CPU core(s), WiFi/BT/BLE, silicon revision 1, 2MB external flash

Minimum free heap size: 298968 bytes

Restarting in 9 seconds...

Restarting in 8 seconds...

Restarting in 7 seconds...

You can exit the IDF monitor using the shortcut Ctrl +]

Tags: ESP8266 ESP32

Posted on Tue, 23 Nov 2021 04:34:47 -0500 by senyo