环境是Ubuntu 18.04 WSL

0x01 配置必要环境

sudo apt install gcc make git wget curl flex bison gperf python-serial libncurses5-dev python3-pip python-pip python python3

0x02 下载代码及相关工具

mkdir micropython
cd micropython
git clone --depth=50 --branch=master https://github.com/micropython/micropython.git 
curl -L https://dl.espressif.com/dl/xtensa-esp32-elf-gcc8_2_0-esp-2019r2-linux-amd64.tar.gz | tar zxf 
wget https://cdn.jsdelivr.net/gh/ITJoker233/Blog/esp32-cam.tar.gz
tar -xzvf esp32-cam.tar.gz
sudo pip3 install 'pyparsing<2.4' pyserial

0x03 linux 环境变量里添加路径

export PATH="~/micropython/xtensa-esp32-elf/bin:~/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
export ESPIDF="~/micropython/esp-idf"
export MPTD="~/micropython/esp32-cam"

0x04 编译mpy-cross

cd micropython
make -C mpy-cross

0x05 esp-idf切换到v4.0,并更新子模块

cd ..
git -C esp-idf checkout $(grep "ESPIDF_SUPHASH_V4 :=" micropython/ports/esp32/Makefile | cut -d " " -f 3)
git -C esp-idf submodule update --init

0x06 编译esp32-cam

make -C micropyhon/ports/esp32 submodules -j 4
cp -r micropyhon/ports/esp32 micropyhon/ports/esp32-cam
cd micropyhon/ports/esp32-cam
cp $MPTD/Makefile .
cp $MPTD/modcamera.c .
cp $MPTD/mpconfigport.h .
cp $MPTD/boards/manifest.py ./boards/manifest.py
cp $MPTD/boards/sdkconfig.base ./boards/sdkconfig.base
make clean
make V=1 -j 4

如果没有报错应该大功告成了 XD....