ESP32 compile micropython firmware

Development environment
Hardware: ESP32-WROOM-32 development board
Software: Ubuntu 18.04 virtual machine

1. Install the environment that the cross-compilation tool chain depends on **
sudo apt-get install git make gcc libncurses5-dev flex bison gperf python-serial
If it has already been installed, it will not be installed again.
2. Create the working directory level and set the compilation chain
1. Create the working directory
mkdir ~/esp32
cd ~/esp32
2. Download the latest cross compilation chain
wget  on the official website https://dl.espressif.com/dl/xtensa-esp32- elf-linux64-1.22.0-61-gab8375a-5.2.0.tar.gz  (64-bit)
3. Unzip the file to the current directory and set the environment variable
tar -zxvf xtensa-esp32-elf-linux32-1.22.0- 61-gab8375a-5.2.0.tar.gz
Open nano ~/.profile
and enter export PATH=$PATH:~/esp32/xtensa-esp32-elf/bin in the last line, exit and save
to make it effective source ~/.profile
test whether Success xtensa-esp32-elf-gcc -v

3. Install esp-idf development kit
1. Download esp-idf
cd ~/esp32
git clone --recursive  https://github.com/espressif/esp-idf.git
cd ~/esp32/esp-idf
git submodule update - init
set the environment variable
vi ~/.profile
and enter export IDF_PATH=~/esp32/esp-idf in the last line to save and exit
to make it effective source ~/.profile

4. Install microPython esp32
download the source code
cd ~/esp32
git clone  https://github.com/micropython/micropython.git
cd micropython/ports/esp32
Open the Makefile and find the following line
ESPIDF_SUPHASH := xxxx Copy the string
into esp- idf directory cd ~/esp32/esp-idf
switch to this branch git checkout xxxx

It is best to update the submodule after switching the branch: git submodule update --init


Configure
cd ~/esp32/micropython/ports/esp32
to create a new makefile in this directory and add the following content:
ESPIDF = /home/xxx/esp32/esp-idf
#PORT = /dev/ttyUSB0
#FLASH_MODE = qio
#FLASH_SIZE = 4MB
#CROSS_COMPILE = xtensa-esp32-elf-
include Makefile

Compile the firmware
cd ~/esp32/micropython
make -C mpy-cross
//You need to add the following command, otherwise the following error will be reported
//make: *** No rule to make target'lib/berkeley-db-1.xx/ btree/bt_close.c', needed by //'build/genhdr/qstr.i.last'. stop.

git submodule init lib/berkeley-db-1.xx
git submodule update

cd esp32
make
5 烧写
esptool.py --port COM5 erase_flash
esptool.py --port COM5 --baud 460800 write_flash --flash_size=detect 0x1000 pathToYourFile/firmware.bin

0x1000 pathToYourFile/bootloader.bin
0x8000 pathToYourFile/partitions.bin
0x10000 pathToYourFile/application.bin

Slow git download problem
1. Use gitee code cloud to download resources instead

espidf link: https://gitee.com/EspressifSystems/esp-idf.git

Update submodule method: refer to https://gitee.com/EspressifSystems/esp-gitee-tools/blob/master/docs/README-submodule-update.md

micropython link: https://gitee.com/mirrors/micropython.git

 

 

reference:

https://blog.csdn.net/ztx01001/article/details/97532918

Guess you like

Origin blog.csdn.net/qq_34440409/article/details/108850057