第 2 節

ESP32 environment setup

0瀏覽次數0訪問次數--跳出率--平均停留

Linux

Open the following website: https://docs.espressif.com/projects/esp-idf/zh_CN/stable/esp32/get-started/linux-macos-setup.html

Install dependencies

alt text

First, follow the instructions shown on this website. If you are using Ubuntu,

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

If you are Fedora

sudo dnf -y makecache && sudo dnf install git wget flex bison gperf python3 python3-setuptools cmake ninja-build ccache dfu-util libusbx

alt text

Get ESP-IDF

alt text

Check which version is the latest stable release.

alt text

As shown in the image above, this is version 5.5.2. Next, choose a folder to store the firmware. For example, I want to place it under the /home/tungchiahui/UserFolder/Applications/ folder (where /home/tungchiahui can be replaced by ~/). So

cd ~/UserFolder/Applications
mkdir -p ./esp
cd ./esp
# 记得版本号要改成最新稳定版(网络环境一定要好)
git clone -b v5.5.2 --recursive https://github.com/espressif/esp-idf.git

alt text

As shown in the image is a success; anything not like the one below means it was not downloaded successfully. alt text

Set up the tool

alt text

cd ./esp-idf
# 选择国内服务器
export IDF_GITHUB_ASSETS="dl.espressif.cn/github_assets"
./install.sh all

alt text

alt text

The image above shows what success looks like. Here, you need to copy what I've circled in red (the path to export.sh), as it will be used in the next environment configuration. For example, the path I copied here is ~/UserFolder/Applications/esp/esp-idf/export.sh

Set environment variables

At this point, the newly installed tools have not yet been added to the PATH environment variable, so they cannot be used from the command window. Therefore, some environment variables must be set. This can be done using another script provided by ESP-IDF.

vim ~/.bashrc

Add the following line (fill in the specific path where you actually store it, which is the path you just copied. Remember to change ~ to $HOME to improve robustness).

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

alt text

source ~/.bashrc

alt text

Configure VScode

https://docs.espressif.com/projects/vscode-esp-idf-extension/zh_CN/latest/index.html

  1. Install the ESP-IDF plugin

alt text

  1. Click Express and select the download server:

As shown in the figure below, since we have already configured the environment, do not select a version here. Instead, directly choose to locate ESP-IDF from my computer.

alt text

It will automatically help you complete the entire toolchain.

alt text

If it displays like this in the bottom-right corner, it means success.

alt text

alt text

Next, configure OpenOCD: alt text Copy the line above, open a terminal (any terminal will do, no need to worry about the path), and run it.

sudo cp --update=none /home/tungchiahui/.espressif/tools/openocd-esp32/v0.12.0-esp32-20250707/openocd-esp32/share/openocd/contrib/60-openocd.rules /etc/udev/rules.d

alt text

End!

Windows

Open the following website: https://docs.espressif.com/projects/esp-idf/zh_CN/stable/esp32/get-started/windows-setup.html

Download and install the program.

Check the latest version; for example, the latest version here is v5.5.2. alt text

Click to download the tool. alt text

And click to install the latest version. For example, the latest version here is v5.5.2.

alt text

Install ESP-IDF

Click on the downloaded esp-idf. alt text

alt text

alt text

Select the hard drive partition where you want to install. For example, if I want to install it on C:\Espressif, it would look like the image below. alt text If you want to install it on the D drive, change the first C to D. alt text

Check all the unchecked boxes, then click Install. alt text

Then click Finish. alt text

If the pop-up windows all display like this, then the installation was successful. alt text

Set up the environment

Just open any folder, right-click This PC(此电脑), and click 属性. alt text

Here is an advanced system setting. alt text

Click on Environment Variables alt text

Click New. alt text

alt text

Find the directory mentioned in the path where you just installed IDF, then click OK.

alt text

alt text

Configure VScode

Install the plugin below.

alt text

Once installed, click to open the Getting Started wizard.

alt text

Click on the first one. alt text

Do it my way, then click Install. alt text

This interface indicates a successful installation. alt text

Download the serial port driver.

Open the website below. https://docs.espressif.com/projects/esp-idf/zh_CN/stable/esp32/get-started/establish-serial-connection.html

  1. CP210x driver

alt text

alt text

Extract the compressed archive you just downloaded. alt text

Right-click silabser.inf and click 安装. alt text Installation complete. alt text

  1. FTDI driver

alt text

alt text

Similarly, extract the downloaded archive.

alt text

Right-click each of the two below, then click Install.

alt text

alt text

  1. CH340 driver Open the website below. https://www.wch.cn/products/ch340.html

alt text

alt text

alt text

alt text

音乐页