The M5Stack development board uses an ESP32 chip, so if you want to establish a corresponding development environment, you can build an ESP32 development environment on ubuntu. Next, sort out how M5Stack develops and compiles on ubuntu.
For the development of esp32, you need to rely on some libraries.
sudo apt-get install git make gcc libncurses5-dev flex bison gperf python-serial
First create the project directory
mkdir esp32
Then create the project subdirectory
mkdir crossTools demos sources
Catalog description
crossTools: Cross compilation environment
demos: example
sources: SDK source code
You can download the xtensa-esp32-elf-linux64-
cross-compilation environment on the official website, or download it on the console with wget.
wget https://dl.espressif.com/dl/xtensa-esp32-elf-linux64-1.22.0-75-gbaf03c2-5.2.0.tar.gz
After the download is complete, unzip it.
tar -zxvf xtensa-esp32-elf-linux64-1.22.0-75-gbaf03c2-5.2.0.tar.gz
The function of this step is to perform global compilation
Modify the /etc/profile file
sudo vim /etc/profile
Add the directory of the cross-compilation environment that you decompressed at the end
E.g:
export PATH=$PATH:/home/bigmagic/work/esp32/crossTools/xtensa-esp32-elf/bin
Among them, /home/bigmagic/work/esp32/
is the directory on my computer, which can be modified according to my actual needs
After the configuration is complete, source the environment
source /etc/profile
Check if it is successful
xtensa-esp32-elf-gcc -v
The following screen comes out, indicating success
Since Espressif's toolchain is used, SDK needs to be downloaded, first download esp-idf.
git clone --recursive https://github.com/espressif/esp-idf.git
Also set environment variables
export IDF_PATH=/home/bigmagic/work/esp32/sources/esp-idf
Note that this also requires its own working directory and needs to be modified accordingly.
Finally update the environment
source /etc/profile
With the above cross-compilation tools and the corresponding SDK, then you can compile the project
Add the project file hello_world in the demo directory, the specific directory is in the following file
/XXX/esp32/sources/esp-idf/examples/get-started/hello_world
Transfer all the folders to the demo directory
Enter the hello_world folder and directly make menuconfig
There are three main points that need to be configured
(1) Cross compilation tool
(2) Set the print level of bootload
(3) Configure programming mode
After configuration, you can compile the firmware
make all -j8
Can be burned after compilation
make flash
The following error may be prompted
This is caused by insufficient access permissions for /dev/ttyUSB0
Increase the permission to burn
Analyze the serial port programming process, there are actually three parts
0 x1000 build/bootloader/bootloader.bin
0 x10000 hello-world.bin
0 x8000 partition_singleapp.bin
Start minicon to see
At this time, it means that the system has started and verified successfully.
The advantage of using the ESP32 development environment on ubuntu is that the compilation is fast, and at the same time, it is more convenient to burn, but the editing code and downloading and debugging are not as good as windows. I personally think that it is more convenient to use the development and compilation environment of vscode+platform IO on the window.
Recommended Posts