Ubuntu - 20.04 system installation Espressif ESP-IDF toolchain (2) --- Install IDF

Espressif ESP-IDF Toolchain

ESP-IDF is Espressif's official IoT development framework for ESP32, ESP32-S and ESP32-C series SoCs. It provides a self-sufficient SDK based on the C/C++ language to facilitate users to develop general-purpose applications on these platforms.

Judging from the current feedback on our side, most of the first-time ESP32users are ESP-IDFstill not friendly enough to install, difficult to install, and situations such as installation to abandonment.

Therefore, we are here to write this article based on the construction tutorial on Espressif's official website to help more users, and also record the various problems and solutions I have encountered during multiple installations.

ESP-IDF Getting Started Guide: https://docs.espressif.com/projects/esp-idf/en_US/stable/esp32/get-started/index.html

install idf

In our last article, we installed the Ubuntu 20.04 operating system in the virtual machine, here we will not introduce the installation and settings of ubuntu

Open the IDF Getting Started Guide: https://docs.espressif.com/projects/esp-idf/en_US/stable/esp32/get-started/index.html

After opening, click to open to the 详细安装步骤section, Espressif's official installation guide provides us with a detailed installation process, which is divided into the following two parts

insert image description here

Step 1: Preparation for installation

We follow the steps of Espressif documentation 第一步:安装准备, we are using linux system, click linux to start our configuration process

insert image description here
The following introduces the software packages needed to compile ESP-IDF. We click on the menu bar in the lower left corner, find Terminal/中文(终端)and open

insert image description here
Copy the installation command under linux and enter it into the window opened by ubuntu

insert image description here

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

A password is required, after entering the password, Ypress Enter and wait patiently for the download

insert image description here
Download completed

insert image description here

If the interface that finally appears is not processing triggers for install - info...but other failures such as fail, then re-enter the command and repeat the download several times, and there will be success

If the language is set to Chinese, it is easy to understand whether it is successful (forgot to set it to Chinese, set it later)

Step 2: Get ESP-IDF

Espressif official documentation provides the following three commands

mkdir -p ~/esp
cd ~/esp
git clone -b v4.4.1 --recursive https://github.com/espressif/esp-idf.git

Here we execute one by one

insert image description here

Problems encountered:

Error:fatal: unable to access 'https://github.com/espressif/esp-idf.git/': Failed to connect to github.com port 443: Connection refused

We saw that when the last command is executed, some students will refuse to connect and fail like me below. It is worth mentioning whether this happens to everyone. network environment

solution:

Method 1:
The above command fails, then our solution is to divide the command executed above git clone -b v4.4.1 --recursive https://github.com/espressif/esp-idf.git into the following four commands to achieve a higher success rate

cd ~/esp
git clone https://github.com/espressif/esp-idf.git
cd esp-idf
git submodule update --init

When I installed it for the first time, it was successful to replace these four commands. I don't know why it didn't work when I wrote the article. I was really bald.

Method Two:

The article was the first time I went through the process and re-written it, but I encountered new problems.

github refuses to connect

It is still recommended to surf the Internet scientifically, remember to set the proxy under ubuntu, otherwise it will be invalid in the terminal

Some people on the Internet also said to clone Espressif on github

In short, most of the failures in this step are 网络问题, it is recommended to solve the problem of scientific Internet

insert image description here

Step 3: Setup Tools

Espressif's introductory documentation also provides corresponding instructions, with more detailed instructions

Linux and macOS operating systems

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

or use Fish shell

cd ~/esp/esp-idf
./install.fish esp32

Note: By specifying multiple targets at one time, you can install tools for multiple target chips at the same time, such as running ./install.sh esp32, esp32c3, esp32s3. The tools can be installed for all supported target chips at once by running ./install.sh or ./install.sh all.

method one:

We execute the command: ./install.sh all, and then we will download the compilation tools for ESP32

./install.sh all

If the download cannot be downloaded or the download is slow, you can execute the command first export IDF_GITHUB_ASSETS="dl.espressif.com/github_assets"and then execute./install.sh all

IDF_GITHUB_ASSETS="dl.espressif.com/github_assets"
./install.sh all

The above commands are to be executed under esp/esp-idfthe file path of

According to the above method, there is generally no problem, the downloaded files are all under .espressif/toolsthe folder (there is a point in front of it is that hidden files need to be checked to show hidden files to see)

Method 2: If you still can't download using method 1, you can download it manually and then unzip it and add it to the corresponding folder. There are 7 files in total, corresponding to the following 7 download links.

https://dl.espressif.com/github_assets/espressif/crosstool-NG/releases/download/esp-2021r2-patch3/xtensa-esp32-elf-gcc8_4_0-esp-2021r2-patch3-linux-amd64.tar.gz

https://dl.espressif.com/github_assets/espressif/crosstool-NG/releases/download/esp-2021r2-patch3/xtensa-esp32s2-elf-gcc8_4_0-esp-2021r2-patch3-linux-amd64.tar.gz

https://dl.espressif.com/github_assets/espressif/crosstool-NG/releases/download/esp-2021r2-patch3/xtensa-esp32s3-elf-gcc8_4_0-esp-2021r2-patch3-linux-amd64.tar.gz

https://dl.espressif.com/github_assets/espressif/crosstool-NG/releases/download/esp-2021r2-patch3/riscv32-esp-elf-gcc8_4_0-esp-2021r2-patch3-linux-amd64.tar.gz

https://dl.espressif.com/github_assets/espressif/binutils-esp32ulp/releases/download/v2.28.51-esp-20191205/binutils-esp32ulp-linux-amd64-2.28.51-esp-20191205.tar.gz

https://dl.espressif.com/github_assets/espressif/binutils-esp32ulp/releases/download/v2.28.51-esp-20191205/binutils-esp32s2ulp-linux-amd64-2.28.51-esp-20191205.tar.gz

https://dl.espressif.com/github_assets/espressif/openocd-esp32/releases/download/v0.11.0-esp32-20220411/openocd-esp32-linux-amd64-0.11.0-esp32-20220411.tar.gz

After downloading the corresponding files, .espressif/toolsput them in the folder. The esp32s2ulp-elfand esp32ulp-elfthese two folders can be downloaded by themselves. Compare the seven files in the figure below.

insert image description here

Then execute the command to ./install.sh allinstall the rest of the files

It is only recommended to do this operation in the above seven files that cannot be downloaded. Of course, it is generally not necessary to do this special operation.

Step 4: Set environment variables

The following are the configuration instructions provided by Espressif's introductory documentation, with detailed instructions

Linux and macOS operating systems
Please run the following command in the terminal window where ESP-IDF needs to be run:

. $HOME/esp/esp-idf/export.sh

For fish shell (only fish 3.0.0 and above is supported), run the following command:

. $HOME/esp/esp-idf/export.fish

Note that there should be a space between the start of the command “.”and path!

If you need to run it frequently ESP-IDF, you can export.shcreate as follows:

1. Copy and paste the following commands into the shell configuration file (.profile, .bashrc, .zprofile, etc.)

alias get_idf='. $HOME/esp/esp-idf/export.sh'

2. Refresh the configuration file by restarting the terminal window or running ,source [path to profile] eg .source ~/.bashrc

Now you can run in any terminal window get_idfto set or refresh esp-idf 环境.

It is not recommended that you export.shadd to the shell's configuration file. Because this would cause the IDF virtual environment to be activated in every terminal session (including when IDF is not needed), defeating the purpose of using the virtual environment and possibly affecting the use of other software.

We . $HOME/esp/esp-idf/export.shcan , a relatively simple process

. $HOME/esp/esp-idf/export.sh

insert image description here

Step 5: Start creating the project

We can find the example of Espressif in the ~/esp/esp-idf/examplespath , open theexamples/get-started example in it below to compilehello_world

We copy the example under the ~/esp/esp-idf/examples hello_world/get-startedpath to the followinghello_world~/esp

insert image description here
Then this is our example project, and we can also copy a large number of other examples to the location of our own project.

Step 6: Configuration

Execute the following command to open the folder where the aforementioned hello_worldproject is located

cd ~/esp/hello_world

The following select the corresponding model or series of chips to set, this operation will clear and initialize the previously configured settings

idf.py set-target esp32

Next we execute the command to configure

idf.py menuconfig

insert image description here

When we enter the command idf.py menuconfig, the following interface will pop up, and we can study and configure it by ourselves.

insert image description here

Press ESCExit

Step 7: Compile the project

We execute the following command to compile our just hello_worldproject

idf.py build

The first compilation time is slightly longer, and the compilation is completed after waiting patiently

insert image description here
At this point, we have completed the construction of the IDF tool under the ubuntu system. After burning to the device, please refer to the ninth step of the Espressif Getting Started Guide. The virtual machine here is a little more troublesome, so I won't do a screenshot demonstration.

Burn instruction

idf.py -p PORT [-b BAUD] flash

The middle parameter is the baud rate, the default 460800, refer to the getting started guide

Summarize

There was no scientific Internet access when building it. The process was particularly difficult when it was cloned ESP-IDF. I encountered a lot of problems along the way. I analyzed and solved it bit by bit and checked a lot of information!
If there is no scientific Internet access, the environment construction of Espressif is quite unfriendly. The two constructions encountered different errors and problems, but they were basically caused by network environment problems!
In addition, I believe that there are also many people who have encountered other problems. You can leave a message below to discuss and solve them. You can also propose a simpler and more stable construction method. Thank you for your one-click three-link!

Guess you like

Origin blog.csdn.net/qq_42250136/article/details/124338110