一、编译环境
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.4.2
cd /
mkdir -p /data/espidf/v5.4.2
cd /data/espidf/v5.4.2
git clone -b v5.4.2 --recursive https://github.com/espressif/esp-idf.git
cd esp-idf
git checkout v5.4.2
git submodule update --init --recursive
./install.sh <板卡类型>
source export.sh板卡类型说明
为空则是安装全部类型
也可以安装指定类型, 英文逗号分隔. 例如: ./install.sh esp32,esp32s2
四、编译Micropython
cd /data
mkdir -p /data/mpy/v1.26.1
cd /data/mpy/v1.26.1
git clone https://github.com/micropython/micropython.git
cd micropython
git checkout v1.26.1
git submodule update --init --recursive
make -C mpy-cross
cd ports/esp32/
make submodules
make上述为编译 Micro python 的默认版本
五、编译指定主板芯片的Micropython固件
进入 boards 下查看支持的芯片类型
下面以 ESP32_GENERIC_S2 为例
make BOARD=ESP32_GENERIC_S2 submodules
make BOARD=ESP32_GENERIC_S2六、编译注意事项:
每次编译,进入 /data/mpy/v1.26.1/micropython/ports/esp32/ 后先执行下面命令
export IDF_PATH=/data/espidf/v5.4.2/esp-idf
export IDF_PATH=/data/espidf/v5.4.2/esp-idf/tools
source /data/espidf/v5.4.2/esp-idf/export.sh