一、编译环境
Windows 11 专业版
WSL Ubuntu 22.04
二、更新环境和安装依赖项
apt update
apt install -y git wget flex bison gperf python3 python3-pip python3-venv cmake ninja-build ccache libffi-dev libssl-dev dfu-util libusb-1.0-0三、安装ESP-IDF V5.5.1
cd /
mkdir -p /data/espidf/v5.5.1
cd /data/espidf/v5.5.1
git clone -b v5.5.1 --recursive https://github.com/espressif/esp-idf.git
cd esp-idf
git checkout v5.5.1
git submodule update --init --recursive
./install.sh <板卡类型>
source export.sh板卡类型说明
为空则是安装全部类型
也可以安装指定类型, 英文逗号分隔. 例如: ./install.sh esp32,esp32s2
四、编译Micropython
cd /data
mkdir -p /data/mpy/v1.27.0
cd /data/mpy/v1.27.0
git clone -b v1.27.0 --recursive https://github.com/micropython/micropython.git
cd micropython
#git checkout v1.27.0 不用
#git submodule update --init --recursive 不用
make -C mpy-cross
cd ports/esp32/
source /data/espidf/v5.5.1/esp-idf/export.sh
make submodules #CMake可能会出现警告,不用管
make上述为编译 Micro python 的默认版本
五、编译指定主板芯片的Micropython固件
进入 boards 下查看支持的芯片类型
下面以 ESP32_GENERIC_S3 为例
cd /data/mpy/v1.27.0/micropython/ports/esp32/
source /data/espidf/v5.5.1/esp-idf/export.sh
make BOARD=ESP32_GENERIC_S3 submodules
make BOARD=ESP32_GENERIC_S3
或者
make BOARD=ESP32_GENERIC_S3 BOARD_VARIANT=SPIRAM_OCT六、编译注意事项:
每次编译,进入 /data/mpy/v1.27.0/micropython/ports/esp32/ 后先执行下面命令
export IDF_PATH=/data/espidf/v5.5.1/esp-idf
export IDF_PATH=/data/espidf/v5.5.1/esp-idf/tools
source /data/espidf/v5.5.1/esp-idf/export.sh