ESP32 Tutorial 3: Setting up a Linux development environment (using docker to completely solve all problems)

1. Summary

In fact, no matter whether the ESP32 development environment is built on Linux or Windows, there are dependency problems, resulting in a lot of time wasting in the environment construction, and even failure in the end. This is a pain point and makes us very irritable. We have been working on the research of ESP32 development, this article First completely solve all the problems of the Linux development environment (using docker technology), and then completely solve the problems of the Windows development environment.

2. What is docker?

Docker is a kind of virtualization technology. On the surface, it is a virtual system like a virtual machine. In fact, it consumes far less resources than an operating system, because docker is just a service process of a Linux system.

3. Why can it solve all the problems of Linux development environment?

docker is a kind of virtual machine technology, so just do a good ESP32 Linux environment, and this environment to make a docker mirror, so whether you what kind of Linux systems, as long as you install the software, a docker , then used Okay, this image , start the docker service, then you have a perfect development environment.

Fourth, install docker.

Take ubuntu as an example, install docker:

step 1: 安装必要的一些系统工具
sudo apt-get update
sudo apt-get -y install apt-transport-https ca-certificates curl software-properties-common
step 2: 安装GPG证书
curl -fsSL http://mirrors.aliyun.com/docker-ce/linux/ubuntu/gpg | sudo apt-key add -
Step 3: 写入软件源信息
sudo add-apt-repository "deb [arch=amd64] http://mirrors.aliyun.com/docker-ce/linux/ubuntu $(lsb_release -cs) stable"
Step 4: 更新并安装 Docker-CE
sudo apt-get -y update
sudo apt-get -y install docker-ce

Other Linux systems can be quickly installed by searching on Baidu .
Note: If the installation is slow, you can modify the installation source or Baidu.

5. Obtain the esp-idf environment image.

We provide a docker image of esp32-idf that has been made, named idf_v4x_full_v3.tar.
Baidu network disk address:

链接:https://pan.baidu.com/s/1u-5FiTGH51SuhrL0eOs_4g 
提取码:z8e9 

6. Create a container and use docker for development.

Note: Reference article for accelerated pull of code packages: How to accelerate pull of github code packages (take ESP-IDF as an example) .
(1) Load the image and create the container.
Load image command: sudo docker load -i idf_v4x_full_v3.tar
Insert picture description here
view image: sudo docker image ls
Insert picture description here
use image to create container:, sudo docker run -it -d d2098b4ed96cwhere d2098b4ed96cis the ID of the docker image just loaded.
Insert picture description here
View the container:sudo docker ps
Insert picture description here

Note: The container needs to use the network port number, so the docker command needs super authority to run. If you feel troublesome, you can use the Linux alias command alias sdocker="sudo docker", and then use sdocker directly.
Insert picture description here

(2) Use container environment for esp-idf development.
(2.1) Use the internal esp-idf code package directly.
Inside the container, we have provided the code package developed by esp32-idf (it is v4.3 version), under the directory, you can use it git pullto synchronize with github.
Use the command sudo docker exec -it dccbce0f4778 /bin/bash, where is the ID number of the container just created.
Insert picture description here
The following terminal appears, indicating that you have successfully entered the container.
Insert picture description here
Enter under a routine of esp32-idf idf.py menuconfig, and the following configuration interface will pop up.
Insert picture description here
Insert picture description here

(2.2) The esp-idf code package hung on the outside.
If you have the esp-idf software package in the host, you can overwrite this path to a directory of the container when you create the container, and use the command: sudo docker run -it -v 宿主机路径:容器目录 -d d2098b4ed96c
Go to the directory of the container to see the code package of the host. Then you can continue to develop.
Insert picture description here
Insert picture description here
You can see that we have successfully mounted the host's directory into the container.
Insert picture description here
Note:
(1) You can also overwrite multiple host's directories into the container, just add the -v option, for example, you can add the host's / dev covers the /dev of the container. At this point, you can use idf.py flashcommands in the container to directly burn the code.
Since /dev/ are all device files, when covering /dev, you also need to add parameters --privileged:

sudo docker run -it --privileged -v /dev:/dev -d d2098b4ed96c

(2) Docker can use one image to create countless multiple containers, and there are many other operations for container use, just Baidu.
Stop container command: docker kill container ID
delete container command: docker rm container ID

Seven, summary.

(1) Install docker software.
(2) Download the mirroring environment package.
(3) Load the docker image.
(4) Create a container.
(5) Enter the container.
(6) Development.

QQ exchange group: 454308668

Guess you like

Origin blog.csdn.net/agony_isolate/article/details/114955021