1
Installing Ubuntu
2
Installing the ESP-IDF Environment
2.1 Installing Common Software
We need to install several commonly used software:
sudo apt-get install vim
sudo apt install git
If you have installed another version of Ubuntu, first check your python version
python -V
If it is not python3, please install python3 first
sudo apt-get update
sudo apt-get install python3.6
sudo apt-get install python3-pip
sudo update-alternatives --install /usr/bin/python python /usr/bin/python2 100
sudo update-alternatives --install /usr/bin/python python /usr/bin/python3 150
// Use the following command to switch python versions
sudo update-alternatives --config python
(Swipe left to view all content)
If you are installing Ubuntu 18 or above, it defaults to python3, run the following command
sudo update-alternatives --install /usr/bin/python python /usr/bin/python3 150
(Swipe left to view all content)
2.2 Start Installing Dependencies
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
(Swipe left to view all content)
What is the ESP IDF framework? I won’t elaborate here! Use the git command to pull it down, and this will sync the latest framework version! Do not download directly, as there may be errors, remember!
2.2.1 Getting the Source Code
1. Download the redirect script esp-gitee-tools, run the following command:
git clone https://gitee.com/EspressifSystems/esp-gitee-tools.git
(Swipe left to view all content)
2. Download the SDK:
git clone https://gitee.com/EspressifSystems/esp-idf.git -b release/v4.4
(Swipe left to view all content)
3. Use esp-gitee-tools to pull submodules
cd esp-gitee-tools
export EGT_PATH=$(pwd)
cd ..
cd esp-idf
$EGT_PATH/submodule-update.sh
4. Install the compilation toolchain
$EGT_PATH/install.sh
If this appears, it indicates installation was successful!
2.3 Setting the IDF_PATH
This is much simpler, just set the variable! First, get the SDK path above, which is the IDF path!
For example, in my environment:
export IDF_PATH=/home/xuhongv/ESPRESSIF/ESP32/esp-idf
(Swipe left to view all content)
1. Then press i to embed the code:vim ~/.bashrc
2. Add the above code at any location!
3. Press esc and then :wq to save:source ~/.bashrc
4. Test if the IDF_PATH is set successfully:echo $IDF_PATH
2.4 Setting the Compilation Environment Variables
At this point, the tools you just installed have not been added to the PATH environment variable, so you cannot use these tools through the “command window”. Therefore, you must set some environment variables, which can be done using another script provided by ESP-IDF.
Note that there is a space between the two dots in the command below!
. ./export.sh
After success, it will prompt like this:
2.5 Introduction to SDK Directory Structure
There are many examples in esp-idf, all examples are placed in the example folder
Each example has a README file, which provides a detailed introduction to the functions and usage methods of that example, a must-read!
2.6 Starting to Compile the Project.
Here, we take compiling the hello_world example under examples/get-started as an example;
-
Configure the compilation chip:
ESP32 series modules: idf.py set-target esp32
ESP32-S2 series modules: idf.py set-target esp32s2
ESP32-C3 series modules: idf.py set-target esp32c3
ESP32-S3 series modules: idf.py set-target esp32s3
-
idf.py menuconfig : Configuration panel
-
idf.py build : Compile the code;
-
idf.py flash : Flash the program into the device;
Note:
When flashing firmware using certain Linux versions, you may encounter the error message Failed to open port /dev/ttyUSB0. In this case, you can add the current user to the :ref:Linux Dialout group. By default, only the root user and users belonging to the dialout group have read and write permissions, so just add your user to the dialout group. After running the command, restart to make it permanent.
sudo usermod -a -G dialout $USER //$USER is your username
(Swipe left to view all content)
idf.py erase_flash : Erase the program in the device;
Source: Anxin Technology

Old Yu Brother takes you to play with ESP32: 05 Using ADC is too easy

Old Yu Brother takes you to play with ESP32: 04 Serial Port is really convenient

Old Yu Brother takes you to play with ESP32: 02 Using VSCode + PlatformIO to set up the development environment
Welcome to share, bookmark, like, and watch.