ESP32CAM micropython固件制作 win10 Ubuntu18.04

ESP32CAM micropython固件制作

  • 系统
    • 编译
    • 部分错误信息
    • camera部分参数

系统

win10 Ubuntu18.04子系统
修改源

 sudo cp /etc/apt/sources.list /etc/apt/sources.list.bak #备份
sudo vim /etc/apt/sources.list #修改
##中科大源
deb https://mirrors.ustc.edu.cn/ubuntu/ bionic main restricted universe multiverse
deb-src https://mirrors.ustc.edu.cn/ubuntu/ bionic main restricted universe multiverse
deb https://mirrors.ustc.edu.cn/ubuntu/ bionic-updates main restricted universe multiverse
deb-src https://mirrors.ustc.edu.cn/ubuntu/ bionic-updates main restricted universe multiverse
deb https://mirrors.ustc.edu.cn/ubuntu/ bionic-backports main restricted universe multiverse
deb-src https://mirrors.ustc.edu.cn/ubuntu/ bionic-backports main restricted universe multiverse
deb https://mirrors.ustc.edu.cn/ubuntu/ bionic-security main restricted universe multiverse
deb-src https://mirrors.ustc.edu.cn/ubuntu/ bionic-security main restricted universe multiverse
deb https://mirrors.ustc.edu.cn/ubuntu/ bionic-proposed main restricted universe multiverse
deb-src https://mirrors.ustc.edu.cn/ubuntu/ bionic-proposed main restricted universe multiverse

安装一堆新包,包括gcc,g ++和make。

sudo apt update
sudo apt upgrade
sudo apt install build-essential

编译

操作步骤 sudo -s用root模式

cd
mkdir Esp32Cam
cd Esp32Cam

下载micropython和esp-idf

git clone https://github.com/micropython/micropython.git
git clone https://github.com/espressif/esp-idf.git

查看esp32所对应的espidf版本(重要)

cat micropython/ports/esp32/Makefile | grep ESPIDF_SUPHASH | head -1

显示:ESPIDF_SUPHASH :=???????

cd esp-idf

下载espidf(粘贴ESPIDF_SUPHASH结果)

git checkout ??????
git submodule update --init --recursive

进入components文件夹,下载camera

cd components
git clone https://github.com/espressif/esp32-camera.git

下载micropython文件

cd ~/Esp32Cam/micropython
git submodule update --init --recursive

加入环境变量

export PATH="/home/dul/micropython/xtensa-esp32-elf/bin:/home/st/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
export ESPIDF=/home/dul/Esp32Cam/esp-idf

mpy_cross是micorpython的python脚本编译工具,可以将python文件编译成micropython的byte code直接运行,这样做的好处如下:
1.减小flash占用
2.让别人看不到源代码

make -C mpy-cross

进入ports文件夹

cd ports

将esp32文件夹复制到esp32-cam文件夹

cp -r esp32 esp32-cam

准备好编译需要的相关文件

cd esp32-cam

在 Ubuntu中复制win10 C盘文件到这里(

cp /mnt/c/esp/mpconfigport.h mpconfigport.h
cp /mnt/c/esp/modcamera.c modcamera.c
cp /mnt/c/esp/main.c main.c
cp /mnt/c/esp/Makefile Makefile
cp /mnt/c/esp/boards/sdkconfig.base boards/sdkconfig.base

这里可以提前下64位xetensa-esp32-elf ,5.2.0

cd ~/Downloads
wget https://dl.espressif.com/dl/xtensa-esp32-elf-linux64-1.22.0-80-g6c4433a-5.2.0.tar.gz

解压到esp32-cam文件夹

cd ~/Esp32Cam/micropython/esp32-cam
tar -xzf ~/Downloads/xtensa-esp32-elf-linux64-1.22.0-80-g6c4433a-5.2.0.tar.gz

编译 V=1显示所有信息

make V=1

查看固件是否成功

strings build-GENERIC/firmware.bin | grep MicroPython | tail -1

查看camera是否存在

strings build-GENERIC/firmware.bin | grep camera

显示结果:

camera
[0;31mE (%d) %s: Detected camera not supported.
/home/dul/Esp32Cam/esp-idf/components/esp32-camera/driver/camera.c
camera_xclk

将build-GENERIC/firmware.bin拷出到 /mnt/c/esp/

cp build-GENERIC/firmware.bin /mnt/c/esp/firmware.bin

部分错误信息

发生错误:No module named pyparsing

pip install pyparsing
make PYTHON=python2

参考这个可以直接看

camera部分参数

import camera
camera.init()

camera.framesize(1) # 1~11分辨率
1=160x120 2=160x128 3=176 x 144 4=240 x 176 5=320 x 240 6=400x296
7=640x480 8=800x600 9=1024x768 10=1280x1024 11 =1600x1200
camera.quality(10) # 10~63质量 高~低
camera.contrast(0) # -2~2 对比度
camera.saturation(0) #-2~2 饱和度
camera.brightness(0) #-2~2 亮度
camera.aelevels(0)#-2~2
camera.aecvalue(0) #-2~2
camera.agcgain(0)# 0~30
camera.speffect(0) #0~6
camera.whitebalance(0) #0~4 白平衡
camera.flip(0) #0正、1翻转

你可能感兴趣的:(ESP32CAM micropython固件制作 win10 Ubuntu18.04)