Esp32 Linux development environment to build

Now I’m playing esp32, so I must first set up the environment. I originally wanted to use the Windows environment to make it more convenient, but I couldn’t use Espressif’s tools to create it. The download speed was very slow and slow, so I dispelled this idea. , Just think about it or use the Linux development environment.

The system I use is Ubuntu20.04. I want to emphasize it here, because I tried to build with 16.04 and there was a problem. I actually forgot the specific problems. . .

First install the required packages:

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

Then this is more important, you need to uninstall python2, otherwise there will be many weird errors in the subsequent compilation, remember!

//1.卸载python2.7
sudo apt-get remove python2.7

//2.卸载python2.7及其依赖
sudo apt-get remove --auto-remove python2.7

//3.消除python2.7
sudo apt-get purge python2.7 or sudo apt-get purge --auto-remove python2.7

Get the source code:

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

But I don't recommend to get it this way. After all, github, you know, you can use Code Cloud to download it.

installation:

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

The installation process is actually going to github to find something to install, but compared to getting the source code, the things here will be smaller and the success rate will be higher. You need to find a place where the network environment is relatively better for installation.

After the installation is complete, set the environment variables:

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

Take helloworld to test the water, copy the project to the ~/esp directory, and set the project:

cd ~/esp/hello_world
idf.py set-target esp32
idf.py menuconfig

Compile the project:

idf.py build

At this point, the project is even compiled.

Burn to esp32:

sudo chmod 0777 /dev/ttyUSB0
idf.py -p /dev/ttyUSB0 flash

Note here that unless you are a root user, ordinary users need to modify the permissions of /dev/ttyUSB0, otherwise there will be cases where the programming fails without permission. For my development board, you need to press the en key and then the downloaded log will appear. For different development boards, see the instructions for different situations.

You can use the built-in information to view the print information, or you can use minicom to view it. It depends on everyone's usage habits. After printing out helloworld, it will run.

In fact, I came from a virtual machine, and it’s already packaged. If you need it, you can click to pay attention, and then tell me in a private message that I will send the compressed package of the virtual machine. If the demand is relatively large, I will also be here. Write a link below the article for everyone to download.

Reference document: https://docs.espressif.com/projects/esp-idf/zh_CN/latest/esp32/get-started/index.html#get-started-get-esp-idf

Guess you like

Origin blog.csdn.net/smile_5me/article/details/115346099